problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03485
s092710767
Accepted
a, b = map(int, input().split()) if (a+b) % 2 == 0: print((a+b)//2) else: print(((a+b)//2)+1)
p03592
s259117794
Wrong Answer
n,m,k = map(int,input().split()) for i in range(1,n+1): for j in range(1,m+1): #print(n*j+m*i-i*j*2) if n*j+m*i-i*j*2==k: print('Yes');exit() print('No')
p03107
s410347603
Accepted
S=input() print(min(S.count("0"),S.count("1"))*2)
p02729
s238525893
Accepted
n,m=map(int,input().split()) def fac(n): if n == 0: return 1 else: return n * fac(n-1) def binom(n,k): if n==0 or n==1: return 0 else: return fac(n) // (fac(n-k) * fac(k)) print(binom(n,2) + binom(m,2))
p02819
s561782101
Accepted
import math def is_prime(n): if n == 1: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True x = int(input()) if x == 2: print(x) exit() if x % 2 == 0: x += 1 while not is_prime(x): x += 2 print(x)
p02935
s042723685
Accepted
# easy for C!!! n = int(input()) l = [int(x) for x in input().split()] i =0 while len(l) >= 2: l.sort() a = l.pop(i) b = l.pop(i) c = (a + b) / 2 l.append (c) print(*l)
p02624
s956900926
Wrong Answer
N=int(input()) print( sum(j*(N//j)*(N//j+1)//2 for j in range(1,N)) )
p02971
s422913442
Wrong Answer
n=int(input()) a=[int(input()) for _ in range(n)] m1=max(a) m2=max(a[a.index(max(a)):]+a[:a.index(max(a))+1]) for i in range(n): if a[i]==m1: print(m2) else: print(m1)
p03012
s217247875
Accepted
N = int(input()) numbers = [int(i) for i in input().split()] min_diff = sum(numbers) for i in range(N-1): diff = abs(sum(numbers[:i+1]) - sum(numbers[i+1:])) if diff < min_diff: min_diff = diff print(min_diff)
p04044
s727100909
Accepted
N,L = (int(x) for x in input().split()) S = [input() for i in range(N)] S.sort() ans = ''.join(S) print(ans)
p03862
s230987874
Wrong Answer
N, x = map(int, input().split()) A = list(map(int, input().split())) A.append(0) CA = [a for a in A] for i in range(N): total = CA[i] + CA[i+1] if x < total: if CA[i + 1] <= (total - x): rest = total - x - CA[i + 1] CA[i + 1] = 0 CA[i] = CA[i] - rest if CA[i] - rest >...
p02664
s951925127
Accepted
S = input() print(S.replace("?", "D"))
p03328
s607080031
Accepted
import math def main(): a,b = list(map(int,input().split())) number=b-a ans=0 for i in range(1,number): ans+=i print(ans-a) main()
p02786
s998885063
Accepted
import math H = int(input()) count = 1 while H > 1: H = math.floor(H/2) count += 1 print(2**count -1)
p03719
s332700537
Accepted
a, b, c = map(int, input().split()) if a <= c and c <= b: print('Yes') else: print('No')
p02899
s359386925
Wrong Answer
n = int(input()) order = input().split() a = sorted(order) print(a) for i in a: print(order.index(i)+1, end=" ")
p03624
s490199722
Wrong Answer
s = list(input()) s.sort() for i in range(97,123): if s.count(chr(i)) == 0: print(chr(i)) break
p03645
s902081054
Accepted
N,M = map(int,input().split()) a=[0]*M b=[0]*M c=set() #最初の候補地 for i in range(M): a[i],b[i]=map(int,input().split()) if a[i]==1: if b[i] not in c: c.add(b[i]) for j in range(M): if a[j]!=1: if a[j] in c: if b[j]==N: print("POSSIBLE") break else: print("IMPOSSIBLE")
p02952
s567890827
Accepted
n = int(input()) ans = 0 for i in range(1, n+1): if len(str(i))%2 == 1: ans += 1 print(ans)
p03548
s562506053
Wrong Answer
X,Y,Z=map(int,input().split()) print(X//(Y+Z))
p02784
s788312914
Accepted
h, n = list(map(int, input().split())) a = list(map(int, input().split())) if h-sum(a) <= 0: print("Yes") else: print("No")
p02835
s732640668
Accepted
a=list(map(int, input().split())) b=sum(a) print("bust" if b>=22 else "win")
p02993
s894934284
Accepted
import sys code = input() for i in range(len(code) - 1): if code[i] == code[i + 1]: print("Bad") sys.exit() print("Good")
p02767
s636796261
Wrong Answer
n=int(input()) xlis = list(map(int,input().split())) def tai(p,x): return pow(x-p,2) ans=999999999999 for i in range(min(xlis),max(xlis)-min(xlis)+1): sum=0 for j in xlis: sum+=tai(i,j) if ans>sum: ans=sum print(ans)
p02963
s984717200
Accepted
S = int(input()) x1,y1 = 0,0 x2 = 10**9 y2 =1 y3,x3 = divmod(-S,x2) y3 *= -1 for a in [x1,y1,x2,y2,x3,y3]: if a == y3: print(a) else: print(a,end=" ")
p03293
s413576473
Accepted
S = list(input().strip()) T = list(input().strip()) f = False for _ in range(len(T)+1): if S == T: f = True break t = T.pop(0) T.append(t) print("Yes" if f else "No")
p02748
s877365340
Wrong Answer
A, B, M = map(int, input().split()) aList = list(map(int, input().split())) bList = list(map(int, input().split())) mList = [list(map(int, input().split())) for i in range(M)] Min = 20001 for i in range(A): for j in range(B): for k in range(M): if i+1 == mList[k][0] and j+1 == mList[k][1]: ...
p02935
s327061794
Accepted
n = int(input()) v = [int(x.strip()) for x in input().split()] vs = sorted(v) ans = 0 for i in range(n): a = (vs[i]/(2**(n-max(i,1)))) ans += a print(ans)
p03557
s989070928
Accepted
import bisect n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] a.sort() b.sort() c.sort() total = 0 for i in b: a_number = bisect.bisect_left(a, i) c_number = n - bisect.bisect_right(c, i) total = total + a_number * c_numb...
p03289
s599153351
Accepted
""" 1. The initial character of S is an uppercase A. 2. There is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive). 3. All letters except the A and C mentioned above are lowercase. """ import collections def a(r): return r[0] == 'A' def b(r): return ...
p02690
s210362874
Accepted
''' A = 500 とする。 このとき、X = 10^9 となるのは、 B = 499.9968... のとき。 → AまたはB (の絶対値) が大きすぎると、Xが10^9に収まらない。 A, Bの探索範囲は -120~120で十分。 ''' from itertools import product def main(): X = int(input()) for A, B in product(range(-150, 150), range(-150, 150)): if A**5 - B**5 == X: print(A, B) retu...
p03385
s330949389
Wrong Answer
s=input() s=sorted(s) if s[0]=='a' and s[1]=='b' and s[2]=='c': print('YES') else: print('NO')
p02702
s877951732
Wrong Answer
S = input() # S = '201879812018798120187981' baisu = [str(2019 * m) for m in range(1, 10000)] # print(baisu) cnt = 0 for b in baisu: # 開始位置 s = 0 while True: # 見つけた位置 pos = S.find(b, s) if pos > -1: # 次の開始位置を1文字後にする s = pos + 1 cnt += 1 ...
p03274
s786311075
Accepted
N, K = map(int, input().split()) X = list(map(int, input().split())) ans = 10**20 for i in range(N-K+1): l = X[i] r = X[i+K-1] if l*r >= 0: ans = min(ans, max(abs(l), abs(r))) else: ans = min(ans, r-l + min(abs(l), abs(r))) print(ans)
p03455
s740783461
Accepted
a,b=map(int,input().split()) print("Even" if a*b%2==0 else "Odd")
p03910
s706262163
Wrong Answer
n = int(input()) k = 1 while True: if k*(k+1)//2 >= n: ans = k break k += 1 if n == ans*(ans+1)//2: i = 1 while i <= ans: print(i) i += 1 else: i = 1 l = [] cnt = 0 while i < ans: if cnt <= (ans-1)*(ans+2)//2 - n: print(i) cnt += 1 else: print(i+1) i += 1 ...
p03309
s906345679
Accepted
n=int(input()) a=list(map(int,input().split())) for i in range(n): a[i]-=i+1 a=sorted(a) def f(x): ans=0 for i in range(n): ans+=abs(x-a[i]) return ans if n%2==0: m=n//2 else: m=(n+1)//2 print(f(a[m-1]))
p03095
s671342340
Wrong Answer
from collections import Counter n = input() mod = 10**9+7 s = list(Counter(list(input())).values()) an = 1 for i in s: an *= i print(an-1)
p03160
s373867052
Accepted
def solve(): n = int(input()) cost = list(map(int, input().split(' '))) dp = [-1 for _ in range(n)] dp[0] = 0 dp[1] = abs(cost[1] - cost[0]) for i in range(2, n): dp[i] = min(dp[i-2] + abs(cost[i] - cost[i-2]), dp[i-1] + abs(cost[i] - cost[i-1])) print(dp[-1]) solve()
p02910
s879807422
Accepted
S = input() print("Yes" if all(s in ["R","U","D"] for s in S[::2]) \ and all(s in ["L","U","D"] for s in S[1::2]) else "No")
p03838
s887490773
Accepted
x, y = map(int, input().split()) diff_abs = abs(abs(x) - abs(y)) ans = diff_abs if x * y > 0: if x > y: ans += 2 elif x * y == 0: if x > y: ans += 1 else: ans += 1 print(ans)
p03795
s749343898
Wrong Answer
N = int(input()) x = N * 800 y = (N / 15) * 200 print(x-y)
p02607
s745207813
Wrong Answer
N = int(input()) a = list(map(int, input().split())) count = 0 for i in range(0,N): if i % 2 == 1: if a[i] % 2 == 1: count = count+ 1 print(count)
p02795
s953910979
Accepted
# import numpy as np # import math # import copy # from collections import deque import sys input = sys.stdin.readline # sys.setrecursionlimit(10000) def main(): H = int(input()) W = int(input()) N = int(input()) res = 0 black = 0 if H >= W: D = W E = H else: D = ...
p03161
s316688899
Wrong Answer
import math N, K = map(int, input().split()) h = list(map(int, input().split())) S = [0] * N S[0] = 0 for i in range(1, N): value = math.inf for step in range(1, N): value = min(value, S[i - step] + abs(h[i] - h[i - step])) S[i] = value print(S[N - 1])
p03773
s151049520
Wrong Answer
a, b = map(int, input().split()) time = a + b if time > 24: print(time - 24) else: print(time)
p03994
s068361841
Accepted
s = list(input()) K = int(input()) for i in range(len(s)): need = (123-ord(s[i]))%26 if need <= K: s[i] = "a" K -= need if 0 < K: tmp = ord(s[-1]) + K%26 tmp -= 26 if 123 <= tmp else 0 s[-1] = chr(tmp) print("".join(s))
p03481
s974572811
Accepted
X,Y=map(int,input().split()) cnt=1 tmp=[X] while True: if tmp[-1]*2<=Y: tmp.append(tmp[-1]*2) cnt+=1 else: break print(cnt)
p02922
s356399537
Wrong Answer
a,b=map(int,input().split()) if b%(a-1)==0:print(b//(a-1)) elif b%(a-1)==1:print(b//(a-1)) else:print(b//(a-1)+1)
p03328
s731979612
Wrong Answer
a,b = map(int,input().split()) c = abs(b - a) x = 0 for i in range(1,c+1): x += 1 print(x-b)
p02911
s735226830
Wrong Answer
n,k,q = map(int, input().split()) a = [k] * n for i in range(q): A = int(input()) a[A-1] -= 1 for i in a: if i > 0: print('Yes') else: print('No')
p02645
s098979268
Wrong Answer
import random S = input() ans = random.sample(S, 3) print(str("".join(ans)))
p03030
s930875011
Wrong Answer
N = int(input()) list=[] for i in range(N): s, p = input().split() list.append([s, int(p)]) A=list list.sort(key=lambda list:(list[0], -list[1])) for i in A: print(int(list.index(i))+1)
p02911
s880247525
Accepted
N, K, Q = map(int, input().split()) S = [K - Q for i in range(N)] for i in range(Q): A = int(input()) S[A - 1] += 1 for i in S: if i > 0: print('Yes') else: print('No')
p03163
s166804867
Wrong Answer
def inpl(): return list(map(int,input().split())) N, W = inpl() dp = [[0]*W for _ in range(N+1)] for n in range(1,N+1): w, v = inpl() for x in range(W): if x < w: dp[n][x] = dp[n-1][x] else: dp[n][x] = max(dp[n-1][x], dp[n-1][x-w] + v) print(dp[-1][-1])
p02847
s376089538
Accepted
#146 S = input() if S == 'MON': print("6") elif S == 'TUE': print("5") elif S == 'WED': print("4") elif S == 'THU': print("3") elif S == 'FRI': print("2") elif S == 'SAT': print("1") elif S == 'SUN': print("7")
p03479
s300194883
Accepted
X, Y = map(int, input().split()) ans = 1 nextX = X for i in range(0, 10 ** 8): t = nextX * 2 if t <= Y: ans += 1 nextX = t else: break print(ans)
p02596
s628824983
Wrong Answer
k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) elif k == (1 or 7): print(1) else: t = 2 ex = 77 for i in range(10 ** 8): if ex % k == 0: break ex = (ex % k) * 10 + 7 t += 1 print(t)
p02755
s977106918
Accepted
a,b = map(int,input().split()) i = 0 x = int(a/0.08) while True: if int((x+i)*0.1) == b and int((x+i)*0.08) == a: ans = int(x+i) break elif int((x+i)*0.1) > b: ans = '-1' break else: i += 1 print(ans)
p02639
s048560145
Accepted
x = input().split() print(x.index('0') + 1)
p04020
s373455461
Accepted
n = int(input()) a = [int(input()) for _ in range(n)] ans = 0 for i in range(n - 1): pair1 = a[i] // 2 a[i] -= pair1 * 2 pair2 = min(a[i], a[i+1]) ans += pair1 + pair2 a[i+1] -= pair2 ans += a[-1] // 2 print(ans)
p02612
s673552927
Wrong Answer
n = input() print(n[-3:])
p03545
s219729069
Accepted
import itertools,sys def S(): return sys.stdin.readline().rstrip() A,B,C,D = [x for x in S()] for op1,op2,op3 in itertools.product(['+','-'],repeat=3): ans = A+op1+B+op2+C+op3+D if eval(ans)==7: print(ans+'=7') break
p03012
s583088008
Wrong Answer
import math a=math.ceil(int(input())/2) b=list(map(int,input().split()))[::-1] t=min(abs(sum(b[::2])-sum(b[1::2])),abs(sum(b[:-a])-sum(b[-a:]))) print(t)
p03456
s363997600
Accepted
import math a, b = list(map(int, input().split())) c = str(a) + str(b) c = int(c) d = math.floor(c/4 + 1) square = [i * i for i in range(c) if i * i == c ] if len(square) != 0 : print('Yes') else: print('No')
p03059
s426449865
Accepted
a,b,t = map(int,input().split()) print(int(((t+0.5)//a)*b))
p03419
s643587115
Accepted
N,M = map(int,input().split()) if N == M == 1: print(1) elif N == 1 or M == 1: print(max(M-2,N-2)) else: print(N*M-(2*N+2*M-4))
p03150
s531422135
Wrong Answer
s = input() ans = 'NO' pattern = 'keyence' for i in range(len(pattern) - 1): x = pattern[:i] y = pattern[i:] p = 0 while s.find(x, p) >= 0: p += 1 if s.find(y, p + len(x) - 1) >= 0: ans = 'YES' break print(ans)
p02795
s546840978
Accepted
H=int(input()) W=int(input()) N=int(input()) if W<H: H,W=W,H #Wが大きい if N%W==0: print(N//W) else: print(N//W+1)
p02708
s841649058
Accepted
N, K = map(int, input().split()) sm = 0 for i in range(K, N+2): sm += (N+N-i+1)*i//2 -(i-1)*i//2 + 1 print(sm%(10**9+7))
p02600
s012423783
Accepted
x = int(input()) if 400 <= x <= 599: print(8) elif 600 <= x <= 799: print(7) elif 800 <= x <= 999: print(6) elif 1000 <= x <= 1199: print(5) elif 1200 <= x <= 1399: print(4) elif 1400 <= x <= 1599: print(3) elif 1600 <= x <= 1799: print(2) elif 1800 <= x <= 1999: print(1)
p02693
s780234994
Accepted
K = int(input()) A, B = map(int, input().split()) if B - (B % K) >= A: print('OK') else: print('NG')
p02693
s319539190
Accepted
K = int(input()) A,B = map(int,input().split()) mes = 0 for num in range (A,B+1): if num % K == 0 : mes = 1 else : pass if mes == 1 : print("OK") else : print("NG")
p03862
s731868156
Wrong Answer
n,x=[int(i) for i in input().split()] a=[int(i) for i in input().split()] add_a=[] for i in range(n-1): add_a.append(max(a[i]+a[i+1]-x,0)) ans=0 for i in range(n-1): ans+=min(add_a[i],a[i+1]) if i!=n-2: add_a[i+1]=max(0,add_a[i+1]-min(add_a[i],a[i+1])) add_a[i]=0 print(ans)
p02935
s772129335
Accepted
N = int(input()) v = list(map(int, input().split())) v.sort() res = v[0] for i in range(1, N): res = (res+v[i])/2 print(res)
p02933
s829709883
Accepted
A = int(input()) S = input() if A < 3200: print("red") else: print(S)
p02989
s255506967
Accepted
n = int(input())//2 d = sorted(list(map(int,input().split()))) print(d[n]-d[n-1])
p03681
s472226063
Accepted
from math import factorial N, M = map(int, input().split()) diff = abs(N-M) ans = -1 mod = 10**9+7 if diff >= 2: ans = 0 elif diff == 1: # oxoxo ans = factorial(N) * factorial(M) elif diff == 0: # oxox / xoxo ans = 2 * factorial(N) * factorial(M) print(ans%mod)
p02935
s626523960
Accepted
N=int(input()) L=list(map(int,input().split())) l=sorted(L) for i in range(N-1): n=(l[0]+l[i+1])/2 l[0]=n print(l[0])
p02755
s046442232
Accepted
import math A, B = map(int, input().split()) min = B * 10 max = B * 10 + 9 flag = False for i in range(min, max + 1): temp = math.floor(i * 0.08) if (temp == A): flag = True ans = i break if flag: print(ans) else: print('-1')
p02861
s444779234
Accepted
from itertools import permutations n = int(input()) box = [] for _ in range(n): x,y = map(int,input().split()) box.append([x,y]) ans = 0 ans_box = list(permutations(range(n))) cnt = len(ans_box) for i in range(cnt): for j in range(n-1): ans += (((box[ans_box[i][j+1]][0] - box[ans_box[i][j]][0]) ** ...
p02756
s609751912
Accepted
from collections import deque S = input() q = deque() for s in list(S): q.append(s) Q = int(input()) direction = True for _ in range(Q): line = input() if line[0] == '1': direction = not direction else: if (direction and line[2] == '1') or (not direction and line[2] == '2'): ...
p02693
s849477983
Accepted
K = int(input()) A, B = map(int, input().split()) for i in range(A, B+1): if i % K == 0: print("OK") exit() print("NG")
p03472
s969252689
Wrong Answer
N,H = map(int,input().split()) A = [] B = [] for i in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) B.append(0) A.sort() B.sort() ans = 0 while A[-1] < B[-1]: b = B.pop() H -= b ans += 1 ans += (H+A[-1]-1)//A[-1] print(ans)
p02598
s077149438
Accepted
N, K = map(int, input().split()) A = list(map(int, input().split())) # [ok, ng) - Maximum # (ng, ok] - Minimum # ok が 最終的な答え ok = max(A) ng = 0 while abs(ok - ng) > 1: mid = (ok + ng) // 2 cnt = 0 for a in A: l = (a + mid - 1) // mid cnt += l - 1 if cnt <= K: ok = mid else:...
p02657
s642918013
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(2 * 10**6) def inpl(): return list(map(int, input().split())) def main(): A, B = inpl() print(A * B) return if __name__ == '__main__': main()
p03208
s848143413
Accepted
# -*- coding: utf-8 -*- """ Created on Sun Sep 13 03:08:56 2020 @author: liang """ N, K = map(int, input().split()) h = [int(input()) for _ in range(N)] ans = 10**10 h.sort() for i in range(0,N-K+1): tmp = h[i+K-1] - h[i] ans = min(ans,tmp) print(ans)
p03252
s010070461
Accepted
from collections import defaultdict S = list(input()) T = list(input()) Ms = defaultdict(int) Mt = defaultdict(int) for i in range(len(S)): Ms[S[i]] += 1 Mt[T[i]] += 1 ans = "Yes" A = list(Ms.values()) A.sort() B = list(Mt.values()) B.sort() for i in range(len(A)): if A[i] != B[i]: ans = "No" ...
p02924
s865120893
Wrong Answer
N = int(input()) print("{:}".format(int((N-1)*N/2)))
p04034
s686283329
Wrong Answer
N,M = map(int,input().split()) a = [1] b = [1]*N for i in range(M): x,y = map(int,input().split()) b[x-1]-=1 b[y-1]+=1 if x ==1 and a == [1]: a.remove(1) a.append(int(y)) elif (x in a) and (y not in a): a.append(int(y)) ans=0 for j in range(len(a)): if b[a[j]-1]!=0: ans+=1 print(ans)
p02972
s398635268
Accepted
n = int(input()) a = list(map(int,input().split())) ans = [] b = [0] * n for i in range(1,n+1)[::-1]: sum_i = sum(b[(i-1)::i]) if sum_i%2 != a[i-1]: ans.append(i) b[i-1] = 1 print(len(ans)) if len(ans) != 0: print(*ans)
p03293
s269147063
Accepted
S = str(input()) T = str(input()) n = len(S) for i in range(n): S_ = S S_ = S_[i:]+S_[0:i] if S_ == T: print('Yes') break else: print('No')
p03696
s803333699
Accepted
N = int(input()) motoS = input() S = list(motoS) start = 0 end = 0 for i in range(N): if S[i] == '(': end += 1 else: end -= 1 if end < 0: start += 1 end = 0 print('('*start+motoS+')'*end)
p02916
s875325351
Wrong Answer
n = input() line1 = input() line2 = input() line3 = input() a_list = line1.split(" ") a_list = [int(a) for a in a_list] b_list = line2.split(" ") b_list = [int(b) for b in b_list] c_list = line3.split(" ") c_list = [int(c) for c in c_list] temp = a_list[0] ans = 0 for a in a_list: if a == temp + 1: ans = ...
p02772
s129218259
Accepted
N=int(input()) A=list(map(int,input().split())) b=0 for x in A: if x%2==0: if x%3==0 or x%5==0: pass else: b=1 break if b==0: print("APPROVED") else: print("DENIED")
p03241
s259902248
Wrong Answer
def main(): N, M = map(int, input().split(" ")) i = M // N + 1 while True: if M % i == 0: break elif i == 2: break else: i -= 1 print(i) if __name__ == '__main__': main()
p02747
s455227415
Accepted
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': s = input() s = s.replace("hi","") if s =="": print("Yes...
p03637
s810137994
Accepted
n=int(input()) a=list(map(int, input().split())) cnt_4=0 cnt_2=0 for i in range(n): if a[i]%4==0: cnt_4+=1 elif a[i]%2==0: cnt_2+=1 print('Yes' if cnt_4*2+1>=n or (cnt_4*2+cnt_2>=n) else 'No')
p02859
s993364200
Accepted
print(int(input())**2)
p02957
s233497863
Accepted
a,b = map(int, input().split()) x = a +b print(int(x/2) if x%2 == 0 else "IMPOSSIBLE")