problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03339
s809340926
Wrong Answer
N = int(input()) A = list(input()) res = N num = [0] * (N+1) for i in range(0, N): num[i + 1] = num[i] if A[i] == 'W': num[i + 1] += 1 for i in range(1, N + 1): res = min(res, num[i] + (N - i) - (num[N] - num[i])) print(res)
p02576
s960537178
Wrong Answer
N,X,T=map(int,input().split()) print((N//X+1)*T)
p02603
s705600145
Accepted
n = int(input()) A = list(map(int, input().split())) money = 1000 stack = 0 for i in range(n-1): if A[i] < A[i+1]: stack = int(money/A[i]) money = stack*A[i+1] - stack*A[i] + money print(money)
p02795
s389419737
Accepted
H = int(input()) W = int(input()) N = int(input()) p = -1 if H > W: p = H else: p = W count = 1 result = 1 while True: result = count * p if result >= N: print(count) break else: count += 1
p02576
s915159793
Wrong Answer
n, x, t = input().split() n = int(n) x = int(x) t = int(t) if n % x == 0: print((n//x)*t) else: print(int((n//x)*t))
p03061
s234782765
Accepted
N = int(input()) A = list(map(int,input().split())) L = [0] R = [0] import fractions def GCD(a,b): if a*b != 0: return fractions.gcd(a,b) else: return max(a,b) for i in range(N-1): x = A[i] y = A[-i-1] L.append(GCD(L[i],x)) R.append(GCD(R[i],y)) ans = 0 for i in range(N): x = L[i] y = R[-i-1] ans = max(GCD(x,y),ans) print(ans)
p02732
s846108756
Accepted
N = int(input()) A = [int(k) for k in input().split(' ')] from collections import Counter import math res = [] # solution for each key in A res_list = {} # solution for each value in A # counter ver A_c = Counter(A) l = len(A_c) def ncr(j): return int(j * (j-1) / 2) if j >= 2 else 0 # store ncr for each value combs = {k: ncr(v) for k, v in A_c.items()} s = sum(combs.values()) for m in A_c.keys(): res_list[m] = s - combs[m] + ncr(A_c[m] - 1) for k in range(N): res.append(res_list[A[k]]) print('\n'.join([str(s) for s in res]))
p03495
s559063936
Wrong Answer
import heapq n,k = map(int,input().split()) a = list(map(int,input().split())) r = [0 for _ in range(max(a)+1)] if len(set(a)) <= 2: print(0) exit() for i in range(n): r[a[i]] += 1 t = [] for i in range(len(r)): if r[i]: t.append(r[i]) t = list(map(lambda x:-x,t)) heapq.heapify(t) print(n+sum(t[:k]))
p03705
s983332035
Wrong Answer
n,a,b=map(int,input().split()) x=0 if a>b: x=0 elif n==1 and a==b: x=1 else: x=(b-a)*(n-2)+1 print(x)
p03494
s869637511
Wrong Answer
n=int(input()) l=[int(n) for n in input().split()] sum=0 oc=1 for i in l: if i%2!=0: oc=0 sum+=i if(oc==0): print(0) else: c=0 while(sum%2==0 and sum>=2): c+=1 sum=sum//2 print(c)
p02780
s089283142
Accepted
N, K = map(int, input().split()) S = list((num+1)/2 for num in map(int, input().split())) temp = 0 ans = 0 for i in range(K): temp += S[i] ans = temp for i in range(K, N): temp = temp + S[i] - S[i-K] ans = max(ans, temp) print(ans)
p03779
s426812128
Wrong Answer
x = int(input()) t = int(x ** 0.5) min_d = t * 0.5 * (t + 1) if min_d == x: print(t) elif (min_d + 2) <= x: print(t + 2) else: print(t + 1)
p03069
s615797896
Accepted
N=int(input()) S=input() if S=='#'*N or S=='.'*N: print(0) exit() rightB=0 for i in S: if i=='#': rightB+=1 rightW=N-rightB leftB=0 leftW=0 ans=min(rightB,rightW) for i in range(N): if S[i]=='.': leftW+=1 rightW-=1 d=rightW+leftB ans=min(ans,d) else: leftB+=1 rightB-=1 d=rightW+leftB ans=min(ans,d) print(ans)
p03986
s887196826
Accepted
X = input() N = len(X) right = 1 cnt = 0 for left in range(N - 1): if X[left] == 'S': right = max(right, left + 1) while right < N and X[right] != 'T': right += 1 if right >= N: break if X[right] == 'T': # print(left, right) right += 1 cnt += 1 print(N - cnt * 2)
p03681
s089992888
Accepted
import math n, m = map(int, input().split()) n_f = math.factorial(n) m_f = math.factorial(m) mod = 1000000007 if abs(n-m) > 1: print(0) exit() if n == m: print((n_f * m_f * 2) % mod) else: print((n_f * m_f) % mod)
p02624
s942137070
Accepted
def main(): # これはなに?笑 N = int(input()) ans = 0 for i in range(1, N+1): for j in range(i, N+1, i): ans += j print(ans) if __name__ == '__main__': main()
p02780
s912960447
Wrong Answer
M,N = list(map(int,input().split())) s = list(map(int,input().split())) count = 0 kiroku = 0 t = [0 for i in range(M+1)] for i in range(M): t[i+1] = t[i] + (1+s[i])/2 for i in range(N,M-N+1): if t[i] -t[i-N] > count: count = t[i] -t[i-N] print(count)
p02613
s110026164
Accepted
N=int(input()) li=[input() for i in range(N)] a=li.count("AC") b=li.count("WA") c=li.count("TLE") d=li.count("RE") print("AC x "+str(a)) print("WA x "+str(b)) print("TLE x "+str(c)) print("RE x "+str(d))
p03557
s008622370
Accepted
#!/usr/bin/env python3 def main(): from bisect import bisect, bisect_left N = int(input()) A = sorted([int(x) for x in input().split()]) B = [int(x) for x in input().split()] C = sorted([int(x) for x in input().split()]) print(sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])) if __name__ == '__main__': main()
p02713
s635576728
Accepted
import math import itertools K = int(input()) a = list(range(1, K + 1)) it = itertools.product(a, repeat=2) c = 0 for i, j in it: g = math.gcd(i, j) for j in a: c += math.gcd(g, j) print(c)
p03137
s417686222
Accepted
n, m = map(int, input().split()) x = list(map(int, input().split())) if n >= m: print(0) exit() x.sort() d = [x[i+1] - x[i] for i in range(m-1)] d.sort() print(sum(d[:m-n]))
p03774
s587014218
Accepted
N,M = map(int,input().split()) ls1 = [] ls2 = [] for i in range(N): ls1.append(list(map(int,input().split()))) for i in range(M): ls2.append(list(map(int,input().split()))) for i in range(N): minimum = 10**18 check = 0 for j in range(M): K = abs(ls1[i][0]-ls2[j][0])+abs(ls1[i][1]-ls2[j][1]) if K < minimum: minimum = K check = j print(check+1)
p02860
s146396700
Accepted
n = int(input()) s = input() sh = s[0:n//2] if s == sh + sh: print('Yes') else: print('No')
p03377
s845850170
Accepted
a,b,x=map(int,input().split()) if a>x: print("NO") else: if x<=a+b: print("YES") else: print("NO")
p02973
s291214538
Accepted
from bisect import bisect_right N = int(input()) A = [int(input()) for _ in range(N)] t = [-A[0]] for a in A[1:]: if a <= -t[-1]: t.append(-a) else: t[bisect_right(t, -a)] = -a print(len(t))
p03557
s373709801
Accepted
import bisect N = int(input()) A= list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() B.sort() C.sort() ans = 0 for b in B: a = bisect.bisect_left(A,b) c = bisect.bisect_right(C,b) ans += a * (len(C)-c) print(ans)
p03644
s997813809
Accepted
N=int(input()); a=1; while(2*a<=N): a*=2 print(a)
p03163
s899754230
Wrong Answer
N, W = map(int, input().split()) dp_pv = [0]*(W+1) for i in range(N): w, v = map(int, input().split()) #print(w,v) dp = [0]+[dp_pv[j+1] if w > j else max(dp_pv[j+1], dp_pv[j+2-w]+v) for j in range(W)] dp_pv = dp #print(dp) print(dp[-1])
p03721
s426544130
Accepted
n,k = map(int, input().split()) a = [] for i in range(n): a.append(list(map(int, input().split()))) a = sorted(a, key = lambda x:x[0]) x = 0 for i in a: x += i[1] if x >= k: break print(i[0])
p03761
s578923599
Accepted
n = int(input()) out = "" s1 = input() s = [list(input()) for _ in range(n-1)] for i in s1: if all([i in x for x in s]): out += i for j in s: j.remove(i) print("".join(sorted(out)))
p03385
s238012582
Accepted
S=input() l=list(S) l.sort() if(l[0]=="a")and(l[1]=="b")and(l[2]=="c"): print("Yes") else: print("No")
p02784
s235252728
Wrong Answer
L1 = input().split() L2 = input().split() H, N = int(L1[0]), int(L1[1]) d = 0 for i in L2: d += int(i) if d < H: print("NO") else: print("YES")
p03779
s407461948
Accepted
X=int(input()) for i in range(1,X+1): tmp=(1+i)*i/2 if(tmp>=X): ans=i break print(ans)
p03145
s341195320
Accepted
a,b,c = map(int,input().split()) print(a*b//2)
p03071
s451734121
Wrong Answer
a,b = map(int,input().split()) if abs(a-b) < 2: print(a+b) else: print(2*max(a,b) + 1)
p03778
s293611783
Accepted
w, a, b = map(int, input().split()) ans = max(a, b) - min(a, b) - w print(max(ans, 0))
p03262
s199075971
Wrong Answer
n, x = map(int, input().split()) lis = list(map(int, input().split())) if n == 1: print(abs(lis[0] - x)) exit() lis.append(x) lis = sorted(lis) ans = 10**9 + 7 for i in range(n-1): ans = min(ans, abs(lis[i+1] - lis[i])) print(ans)
p03087
s145481086
Accepted
n, q = list(map(int, input().split())) s = list(input()) a = [0] * (n+1) for i in range(1, n): if s[i-1] == "A" and s[i] == "C": a[i+1] = a[i] + 1 else: a[i+1] = a[i] for j in range(q): l, r = list(map(int, input().split())) print(a[r] - a[l])
p02696
s947812852
Wrong Answer
#import matplotlib.pyplot as plt def main(): a,b,n = map(int,input().split()) mx = 0 for x in range(0,min(a+1,n+1)): left = int(a*x/b) right = a * int(x/b) print("x=",x,"floor(Ax/B)=",int(a*x//b),"A*floor(x/B)=",a * int(x // b),"answer=",left-right) #right.append(a * int(x/b)) mx = max(left-right,mx) print(mx) #plt.plot(list(range(len(right))),right,label="test") if __name__ == '__main__': main()
p03799
s454850843
Accepted
n,m = map(int,input().split()) ans = 0 if 2*n >= m: ans = m//2 else: ans = n m = m - 2 * n ans += m//4 print(ans)
p02957
s033487570
Accepted
a,b=map(int,input().split()) c=(a+b)/2 if c==int(c): print(int(c)) else: print("IMPOSSIBLE")
p03761
s887947800
Accepted
from collections import Counter n=int(input()) s=Counter(input()) for i in range(n-1): s&=Counter(input()) print(''.join(sorted(s.elements())))
p03623
s045970544
Wrong Answer
x,a,b=map(int,raw_input().split()) if a-x < b-x: print "A" elif a-x > b-x: print "B"
p03836
s353856001
Accepted
sx, sy, tx, ty = map(int, input().split()) ans = "U"*(ty-sy) ans += "R"*(tx-sx) ans += "D"*(ty-sy) ans += "L"*(tx-sx) ans += "L" ans += "U"*(ty-sy+1) ans += "R"*(tx-sx+1) ans += "DR" ans += "D"*(ty-sy+1) ans += "L"*(tx-sx+1) ans += "U" print(ans)
p03545
s680229087
Accepted
ABCD = input() n = len(ABCD) for i in range(1<<(n-1)): s = int(ABCD[0]) for j in range(n-1): if i>>j & 1: # T: +, F: - s += int(ABCD[j+1]) else: s -= int(ABCD[j+1]) if s == 7: break r = [ABCD[0]] for k in range(n-1): if i>>k & 1: r.append('+') else: r.append('-') r.append(ABCD[k+1]) print('{}=7'.format(''.join(r)))
p02621
s636555702
Accepted
a = int(input()) print(a + a ** 2 + a ** 3)
p02838
s611308865
Accepted
n = int(input()) a = list(map(int, input().split())) ans = 0 mod = 10**9+7 for i in range(60): j = 1<<i cnt = sum((k & j) >> i for k in a) ans += (cnt*(n-cnt))<<i ans%= mod print(ans)
p02664
s378937935
Accepted
t = str(input()) t_bara = list(t) for i in range(len(t_bara)): if t_bara[i] == "?": t_bara[i]= t_bara[i].replace("?","D") print(''.join(t_bara))
p03721
s592482280
Accepted
n, k = map(int, input().split()) ab = [] for i in range(n): a, b = map(int, input().split()) ab.append([a, b]) ab.sort() for a, b in ab: k -= b if k <= 0: break print(a)
p02661
s707456170
Accepted
N = int(input()) A = [] B = [] for i in range(N): a, b = map(int, input().split()) A.append(a) B.append(b) A.sort() B.sort() if N % 2 == 0: n = N // 2 print(B[n] + B[n - 1] - A[n] - A[n - 1] + 1) else: n = N // 2 print((B[n] - A[n] + 1))
p02645
s535395168
Accepted
s = str(input()) print(s[0:3])
p03611
s479462296
Wrong Answer
n = int(input()) A = list(map(int, input().split())) A = sorted(A) from bisect import bisect_left ans = 0 for i in range(1, A[-1]+1): cnt = bisect_left(A, i+2) - bisect_left(A, i-1) ans = max(ans, cnt) #print(i, cnt) print(ans)
p03127
s166642480
Wrong Answer
#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input= lambda: sys.stdin.readline().rstrip() def pin(type=int):return map(type,input().split()) def tupin(t=int):return tuple(pin(t)) #%%code def resolve(): N,=pin() A=tupin() from fractions import gcd temp=A[0] for i in range(N-1): temp=gcd(temp,A[i]) print(temp) #%%submit! resolve()
p02823
s142703968
Accepted
#!/usr/bin/env python3 n, a, b = map(int, input().split()) ans = 0 if (b-a)%2 == 0: ans = (b-a)//2 else: if a-1 >= n-b: ans = n + (1-a-b)//2 else: ans = (a+b)//2 print(int(ans))
p02848
s417909440
Accepted
""" author : halo2halo date : 9, Jan, 2020 """ import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) N = int(readline()) S = [int(x) - ord('A') for x in readline().rstrip()] S = [(x + N)%26 for x in S] ans = ''.join(chr(x+ord('A')) for x in S) print(ans)
p02768
s323397460
Wrong Answer
from operator import mul from functools import reduce def combinations_count(n, r): r = min(r, n - r) numer = reduce(mul, range(n, n - r, -1), 1) denom = reduce(mul, range(1, r + 1), 1) return numer // denom n,a,b = map(int,input().split()) c=0 for i in range(0,n): if i!=a and i!=b: c+=combinations_count(n, i) print(c%((10**9)+7))
p03723
s538064027
Wrong Answer
a, b, c = map(int, input().split()) cnt = 0 if a == b and b == c: print(-1) exit() while cnt >= 0: if a % 2 != 0 or b % 2 != 0 or c % 2 != 0: print(cnt) exit() else: a1 = (b + c) // 2 b1 = (a + c) // 2 c1 = (a + b) // 2 a = a1 b = b1 c = c1 cnt += 1 print(cnt)
p02829
s160329489
Accepted
A = int(input()) B = int(input()) l = [1, 2, 3] l.remove(A) l.remove(B) print(int(l[0]))
p02658
s056102917
Accepted
n=int(input()) A=list(map(int,input().split())) ans=1 if 0 in A: print(0);exit() for i in range(n): ans*=A[i] if ans>10**18: print(-1);exit() print(ans)
p03250
s372767989
Wrong Answer
#k = int(input()) #s = input() #a, b = map(int, input().split()) #s, t = map(str, input().split()) #l = list(map(int, input().split())) #l = [list(map(int,input().split())) for i in range(n)] #a = [list(input()) for _ in range(n)] #a = [input() for _ in range(n)] l = list(map(int, input().split())) l.sort() print(l[2]*10+l[1]-l[0])
p03779
s609879680
Accepted
#!/usr/bin/env python3 x = int(input()) a = int((x * 2)**0.5) while a * (a + 1) // 2 > x: a -= 1 print(a + (a * (a + 1) // 2 != x))
p02909
s021232582
Wrong Answer
a=input() n=['Sunny','Cloudy','Rainy'] if a==n[2]: print(n[0]) else: print(n[2-n.index(a)])
p02577
s945305126
Accepted
import sys readline = sys.stdin.readline N = readline().strip() l = len(N) d = 0 for i in range(l): d += int(N[i]) if d%9 == 0: print("Yes") else: print("No")
p02873
s700035499
Accepted
s = input() n = len(s) a = [0] * (n + 1) for i in range(n): if s[i] == '<': a[i + 1] = max(a[i + 1], a[i] + 1) for i in range(n - 1, -1, -1): if s[i] == '>': a[i] = max(a[i], a[i + 1] + 1) print(sum(a))
p02760
s719103795
Accepted
A = [] for i in range(0, 3): a = input().split(' ') for j in a: A.append(int(j)) # print(A) N = int(input()) for i in range(0, N): data = int(input()) if data in A: A[A.index(data)] = 0 if sum(A[0:3]) == 0 \ or sum(A[3:6]) == 0 \ or sum(A[6:9]) == 0 \ or A[0] + A[4] + A[8] == 0 \ or A[2] + A[4] + A[6] == 0 \ or A[0] + A[3] + A[6] == 0 \ or A[1] + A[4] + A[7] == 0 \ or A[2] + A[5] + A[8] == 0: print("Yes") else: print("No")
p02748
s383594195
Wrong Answer
A,B,M = [int(i) for i in input().split()] A = [int(i) for i in input().split()] B = [int(i) for i in input().split()] min = A[0]+B[0] for i in range(M): x,y,c = [int(i) for i in input().split()] buf = A[x-1]+B[y-1]-c print(A[x-1],B[y-1],c) if buf<min: min = buf print(min)
p03639
s896350507
Accepted
N = int(input()) A = map(int, input().split()) ni = 0 yon = 0 hoka = 0 for a in A: if a % 4 == 0: yon += 1 elif a % 2 == 0: ni += 1 else: hoka += 1 if ni > 0: if yon >= hoka: print("Yes") else: print("No") else: if yon >= hoka-1: print("Yes") else: print("No")
p02572
s306994438
Accepted
from itertools import accumulate N = int(input()) A = list(map(int, input().split())) B = list(accumulate(A)) mod = 10**9+7 ans = 0 sumA = sum(A) for i in range(N-1): ans += A[i] * (sumA-B[i]) % mod ans = ans%mod print(ans)
p02613
s490329196
Accepted
N = int(input()) Cac = 0 Cwa = 0 Ctle = 0 Cre = 0 for cnt in range(N): Si = input() if Si == 'AC': Cac = Cac + 1 elif Si == 'WA': Cwa = Cwa + 1 elif Si == 'TLE': Ctle = Ctle + 1 elif Si == 'RE': Cre = Cre + 1 print('AC', 'x', Cac) print('WA', 'x', Cwa) print('TLE', 'x', Ctle) print('RE', 'x', Cre)
p03555
s275762478
Accepted
a=input() b=input() if(a[0]==b[2] and a[1]==b[1] and a[2]==b[0]): print("YES") else: print("NO")
p02818
s741048834
Accepted
A,B,K=map(int,input().split()) x=A-K if x<0: y=B+x A=0 if y<0: B=0 else: B=B+x else: A=A-K print('{} {}'.format(A,B))
p03778
s121069838
Accepted
W, a, b = map(int, input().split()) if b < a: print(a - (b + W)) elif a + W < b: print(b - (a + W)) else: print(0)
p03695
s586401372
Accepted
N = int(input()) A = list(map(int, input().split())) color = [False for _ in range(8)] x = 0 for a in A: if a >= 3200: x += 1 else: tmp = a // 400 color[tmp] = True ans = color.count(True) if ans == 0: print(1, ans + x) else: print(ans, ans + x)
p03433
s155110195
Wrong Answer
N = int(input()) S = int(input()) L = N % 500 if L < S: print("Yes") else: print("No")
p03804
s873318451
Accepted
n,m=map(int,input().split()) a=[list(input())for i in range(n)] b=[list(input()) for i in range(m)] def judge(i,j): for k in range(m): for l in range(m): if b[k][l]!=a[i+k][j+l]: return False return True for i in range(n-m+1): for j in range(n-m+1): if judge(i,j): print('Yes') exit() print('No')
p03408
s625493852
Wrong Answer
import collections n = int(input()) s = [str(input()) for _ in range(n)] m = int(input()) t = [str(input()) for _ in range(m)] s = collections.Counter(s) t = collections.Counter(t) for k, j in t.items(): if k in s: s[k] -= j values, counts = zip(*s.most_common()) print(counts[0])
p02861
s912599584
Accepted
import math N=int(input()) L=[] tmp=[] t=1 for i in range (N): t=t*(i+1) x,y=map(int,input().split()) L.append([x,y]) for i in range(N-1): for j in range(i+1,N): z=math.sqrt((L[i][0]-L[j][0])**2+(L[i][1]-L[j][1])**2) tmp.append(z) print((sum(tmp))*2/N)
p02797
s350327529
Wrong Answer
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): """ sum[Al,,,Ar] = Sの部分和がちょうどK個。 """ n, k, s = map(int, input().split()) if n == k: r = [s] * k else: if s != 1: r = [s] * (k - 1) + [s - 1] * 1 + [1] * 1 + [1000000000] * (n - k) else: r = [1] * k + [1000000000] * (n - k) print(*r, sep=' ') if __name__ == '__main__': main()
p03385
s927939570
Wrong Answer
print ("yes" if len(set(input()))==3 else "No")
p03814
s243572256
Accepted
s=input() ia=None iz=None for i,c in enumerate(s): if ia==None and c=="A": ia=i if c=="Z": iz=i print(iz-ia+1)
p03698
s497388321
Accepted
S = input() print('yes' if len(S) == len(set(S)) else 'no')
p02642
s577645304
Accepted
N = int(input()) A = list(map(int,input().split())) ma = max(A) Er = [0 for _ in range(ma + 5)] for i in range(N): temp = A[i] if Er[temp] != 2: a = 0 while(1): a += 1 tt = a * temp if tt >= ma + 5: break Er[tt] += 1 ans = 0 for i in range(N): temp = A[i] if Er[temp] == 1: ans += 1 print(ans)
p03827
s930228428
Accepted
n = int(input()) s = str(input()) x = 0 lst = [0] for i in range(len(s)): if s[i]=='I': x += 1 else: x -= 1 lst.append(x) print(max(lst))
p03481
s079716440
Wrong Answer
X,Y = list(map(int,input().split())) if X == 1 and Y ==1: print(1) exit() if X == 1: X = 2 A = Y//X B = A//2 num = 0 ans = 0 for i in range(1,10000000): num += 2**i if num > B: ans = i+1 break if X*(2**ans) <= Y: ans += 1 print(ans)
p02691
s392386645
Accepted
n = int(input()) a = list(map(int,input().split())) l = [i+a[i] for i in range(n)] r = [j-a[j] for j in range(n)] import collections cl = collections.Counter(l) cr = collections.Counter(r) ans = 0 for i in cl.keys(): if i in cr.keys(): ans += cl[i]*cr[i] print(ans)
p02598
s850153032
Wrong Answer
import math N, K = map(int, input().split()) A = list(map(float, input().split())) if K == 0: print(int(max(A))) exit() if N == 1: print(math.ceil(A[0]/K)) exit() min_A = 0 max_A = max(A) while( max_A - min_A > 1): now = (min_A + max_A) / 2 temp = 0 for i in A: temp += (i // now) if temp > K: min_A = now else: max_A = now print(math.ceil((min_A + max_A)/2))
p02787
s708419838
Accepted
H, N = map(int, input().split()) magic = [list(map(int, input().split())) for _ in range(N)] max_magic = 0 for a, _ in magic: max_magic = max(max_magic, a) amount = H + 1 dp = [0] * (amount + max_magic) dp[0] = 0 ret = float('inf') for amt in range(1, amount + max_magic): t = [dp[amt - a] + b if amt - a >= 0 else float('inf') for a, b in magic] dp[amt] = min(t) if amt >= H: ret = min(dp[amt], ret) print(ret)
p03455
s192078598
Accepted
a, b = map(int,input().split()) if a % 2 !=0 and b % 2!=0: print('Odd') else: print('Even')
p02923
s768470292
Accepted
import sys readline = sys.stdin.buffer.readline N = int(readline()) H = list(map(int, readline().split())) if N == 1: print(0) exit() dp = [0] * N for i in range(N-2, -1, -1): if H[i] >= H[i+1]: dp[i] = 1 + dp[i+1] print(max(dp))
p02718
s115146508
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) total_vote = 0 result = True for a in A: total_vote += a for m in range(M): if A[m] < (total_vote/(4*M)): result = False if result: print("Yes") else: print("No")
p03852
s078203327
Accepted
boin=["a","i","u","e","o"] if input() in boin: print("vowel") else: print("consonant")
p03962
s056863405
Accepted
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections MOD = 10**9+7 a,b,c = map(int,input().split()) s = set([a,b,c]) print(len(s))
p02813
s011390299
Wrong Answer
n = int(input()) def dfs(nn): if n == nn: print("".join(ans)) return for i in ["a", "b", "c"]: ans[nn] = i dfs(nn+1) ans = ["0" for i in range(n)] dfs(0)
p02688
s348981802
Accepted
n, k = map(int, input().split()) a = [] for i in range(k): d = int(input()) temp = [k for k in map(int, input().split())] for j in range(d): a.append(temp[j]) a = set(a) print(len(set(range(1,n+1)) - a))
p02594
s710814540
Accepted
X = int(input()) if X >= 30: print("Yes") else: print("No")
p03241
s236678083
Accepted
n,m=map(int,input().split()) yakusuu=[] import math for i in range(1,int(math.sqrt(m)+1)): if m%i==0: yakusuu.append(i) yakusuu.append(m//i) yakusuu.sort() for num in yakusuu: if num>=n: print(m//num) exit()
p03221
s876887675
Wrong Answer
from operator import itemgetter N,M=map(int,input().split()) py=[list(map(int,input().split())) for _ in range(M)] py.sort(key=itemgetter(1)) pre={} #print(dp) for i in range(M): if py[i][0] not in pre.keys(): pre[py[i][0]]=1 else: pre[py[i][0]]+=1 print(str(py[i][0]).rjust(6,"0")+str(pre[py[i][0]]).rjust(6,"0")) #print(p) #print(y) #print(dp)
p04034
s976188735
Accepted
n,m=map(int,input().split()) l=[list(map(int,input().split())) for i in range(m)] num_l=[1 for i in range(n)] bit_l=[1]+[0 for i in range(n-1)] for x,y in l: x-=1 y-=1 if bit_l[x]==1 and num_l[x]==1: bit_l[x]=0 bit_l[y]=1 num_l[x]-=1 num_l[y]+=1 elif bit_l[x]==1 and num_l[x]>=2: bit_l[y]=1 num_l[x]-=1 num_l[y]+=1 else: num_l[x]-=1 num_l[y]+=1 print(bit_l.count(1))
p03286
s679206237
Accepted
n = int(input()) ans = [] now = n cou = 1 if n == 0: print(0) exit() while True: if now == 0: break if now % (2**cou) == 2**(cou-1): ans.append(1) now -= (-2)**(cou-1) elif now % (2**cou) == 0: ans.append(0) cou += 1 for i in reversed(range(len(ans))): print(ans[i],end="") print()
p02783
s410071164
Accepted
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline h,a = map(int, input().split()) # 切り上げ print((h+a-1)//a)