problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02795
s287257377
Wrong Answer
H = int(input()) W = int(input()) N = int(input()) print(N // max(H,W))
p02596
s325233731
Accepted
def main(): K = int(input()) v = 7 % K for i in range(K+5): if v == 0: print(i+1) return v = v * 10 + 7 v %= K print(-1) if __name__ == '__main__': main()
p02899
s380885005
Accepted
n = int(input()) a = list(map(int,input().split())) b = [0 for j in range(n)] for i in range(n): b[a[i]-1] = i+1 print(*b)
p03062
s469503764
Wrong Answer
N = int(input()) A = list(map(int, input().split())) neg = sum([1 for i in range(N) if A[i] < 0]) s = [abs(A[i]) for i in range(N)] ans = sum(s) if neg % 2 == 0: print(ans) else: print(ans - min(s))
p03329
s791497541
Accepted
N = int(input()) dp = [N] * (N + 1) dp[0] = 0 for i in range(N): j = 1 while i + j <= N: dp[i + j] = min(dp[i + j], dp[i] + 1) j *= 6 j = 9 while i + j <= N: dp[i + j] = min(dp[i + j], dp[i] + 1) j *= 9 print(dp[-1])
p03627
s408327742
Wrong Answer
n = int(input()) a = [int(i) for i in input().split()] a.sort(reverse=True) b = list(set(a)) b.sort(reverse=True) l = len(b) c = [0 for _ in range(l)] prei = b[0] j = 0 for i in a: if i != prei: j += 1 c[j] += 1 prei = i x = [] for i in range(l): if c[i] >= 2: x.append(b[i]) if len(x) >=...
p02842
s974865176
Accepted
n=int(input()) a=int(n/1.08) aa=a-1 aaa=a+1 b=int(a*1.08) bb=int(aa*1.08) bbb=int(aaa*1.08) A=[a,aa,aaa] B=[b,bb,bbb] f=0 for i in range(3): if B[i]==n: f=1 ans=A[i] break if f==0: print(":(") else: print(ans)
p02664
s368152020
Wrong Answer
n=input() ans="" for i in n: if i=="?": ans=ans+"D" else: ans=ans+i print(i)
p02786
s745558849
Accepted
from math import floor H = int(input()) def f(a): if a == 1: return 1 else: return 1 + 2 * f(floor(a / 2)) print(f(H))
p03073
s553835588
Accepted
from fractions import gcd S = input() odd = [0,0] even = [0,0] for i,s in enumerate(S): if i % 2 == 0: even[int(s)]+=1 else: odd[int(s)]+=1 o0e1 = odd[1]+even[0] o1e0 = odd[0]+even[1] print(min(o0e1,o1e0))
p03261
s038967660
Wrong Answer
n = int(input()) check = True ss = '' str_set = set() for i in range(n): s = input() str_set.add(s) if ss != '': if ss[-1] != s[0]: break ss = s if len(str_set)!=n: print('No') elif i != n-1: print('No') else: print('Yes')
p02623
s126147278
Accepted
# Begin Header {{{ from math import gcd from collections import Counter, deque, defaultdict from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort from itertools import accumulate, product, permutations, combi...
p02606
s585787063
Wrong Answer
a, b, c = map(int, input().split()) print(len(list(range(a,b+1,c))))
p03469
s758227510
Accepted
s = input() a = int(s[0])*1000+int(s[1])*100+int(s[2])*10+int(s[3])+1 b = s[4]+s[5]+s[6]+s[7]+s[8]+s[9] print(str(a)+b)
p02811
s355375517
Accepted
processedIp = input().split(" ") k = int(processedIp[0]) x = int(processedIp[1]) totalValue = k*500 if (totalValue >= x): print("Yes") else: print("No")
p02630
s015367021
Accepted
from collections import Counter import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) dic = Counter(a) q = int(input()) bs = [] cs = [] for _ in range(q): b, c = map(int, input().split()) bs.append(b) cs.append(c) ans = 0 for k, v in dic.items(): ans += k * v for i...
p02718
s385110449
Accepted
n, m = map(int, input().split()) a_list = [int(i) for i in input().split()] a_sum = sum(a_list) a_sorted = sorted(a_list)[::-1] if a_sorted[m-1] >= a_sum/m/4: print('Yes') else: print('No')
p02659
s578097595
Wrong Answer
import numpy as np A,B = input().split() B = float(B) A = int(A) B = int(B*100) ans = str(np.dot(A,B)) if len(ans) <=2: print(0) else: print(ans[:-2])
p02712
s932944953
Wrong Answer
N = int(input()) re = 0 for i in range(N): if i % 3 == 0 or i % 5 == 0: re = re + 0 else: re = re + i print(re)
p02848
s927772410
Accepted
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' n = int(input()) s = input() def searchIndex(c): return alphabet.index(c) s_rot_n = '' for i in range(len(s)): index = (searchIndex(s[i]) + n) % 26 s_rot_n += alphabet[index] print(s_rot_n)
p03994
s558178485
Wrong Answer
s = list(input()) k = int(input()) n = len(s) c = ord("z") + 1 for i in range(n): tmp = c - ord(s[i]) if k >= tmp: s[i] = "a" k -= tmp if k > 0: s[n-1] = chr(ord(s[n-1])+k%26) print("".join(s))
p02577
s659639383
Wrong Answer
N = input() ans = 0 for n in N: ans = (ans + int(n)) % 9 if ans == 0: print("YES") else: print("NO")
p03456
s699402092
Wrong Answer
def resolve(): N = int(input().replace(" ", "")) for i in range(100): if N == i * i: print("Yes") break else: print("No") resolve()
p03328
s756847161
Wrong Answer
a, b = map(int, input().split()) ans = (b-a)*(b-a-1)/2-a print(ans)
p02693
s288038180
Accepted
def main(): k = int(input()) a, b = map(int, input().split()) ans = "NG" for i in range(a, b + 1): if i % k == 0: ans = "OK" break print(ans) if __name__ == '__main__': main()
p03543
s186911294
Wrong Answer
N = str(input()) for i in range(1,9+1): if N.count(str(i)*3): print('Yes') else: exit() print('No')
p02602
s711557887
Accepted
n, k = map(int, input().split()) A = list(map(int, input().split())) for i in range(k, n): if A[i-k] < A[i]: print('Yes') else: print('No')
p03435
s477592050
Accepted
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): C = [list(map(int, input().split())) for _ in range(3)] b2_1 = C[0][1] - C[0][0] b3_1 = C[0][2] - C[0][0] if (any([b2_1 != C[x][1] - C[x][0] for x in [1, 2]]) or any([b3_1 != C[x][2] - C[x][0] for x in [1, 2]])): print("N...
p02814
s561374618
Accepted
import math N, M = map(int, input().split()) nums = list(map(int, input().split())) lcm = 1 b_cnt = -1 for num in nums: lcm = lcm*(num//2)//math.gcd(lcm, num//2) count = 0 while num%2 == 0: count += 1 num //= 2 if b_cnt < 0: b_cnt = count elif count != b_cnt: print(0) exit() print((M+lcm)/...
p02695
s714862980
Wrong Answer
from itertools import combinations_with_replacement N,M,Q = map(int,input().split()) A = [] for i in range(Q): b = list(map(int,input().split())) A.append(b) T = range(M+1) K = list(combinations_with_replacement(T,N)) ans = 0 for line in K: total = 0 for combi in A: if line[combi[1]-1] - line[...
p02612
s257238593
Accepted
n = int(input()) % 1000 print(1000 - n if n else 0)
p03071
s492690484
Wrong Answer
A, B = map(int, input().split()) if A > B : print(2 * A - 1) elif B < A : print(2 * B - 1) else : print(A + B)
p03943
s316549112
Accepted
candy_list = list(map(int, input().split(' '))) if max(candy_list) == (sum(candy_list) - max(candy_list)): print('Yes') else: print('No')
p02917
s312898057
Wrong Answer
N = int(input()) b = [10**9] + list(map(int,input().split())) + [10**9] a = [] a.append(b[1]) for i in range(1,N-1): a.append(min(b[i-1],b[i])) a.append(b[N-1]) print(sum(a))
p02959
s572771334
Accepted
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) fii=min(a[0],b[0]) fij=min(a[1],b[0]-fii) icnt=fii+fij for i in range(1,n): fii=min(a[i]-fij,b[i]) fij=min(a[i+1],b[i]-fii) icnt+=fij+fii print(icnt)
p04033
s598085906
Accepted
a,b = map(int, input().split()) if a>0: print('Positive') elif a<0: if b<0 and (b-a+1)%2==0: print('Positive') elif b<0 and (b-a+1)%2==1: print('Negative') elif b>0: print('Zero')
p02813
s599738183
Accepted
from itertools import permutations def main(): n = int(input()) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) for i, per in enumerate(permutations(range(1, n + 1), n)): if per == P: a = i if per == Q: b = i print(abs(a - b)) i...
p02838
s369258105
Wrong Answer
def main(): N = int(input()) li = [-1] + list(map(int, input().split())) S = 0 for i in range(1, N): for j in range(i + 1, N + 1): S += (li[i] ^ li[j]) % (10 ** 9 + 7) print(S) if __name__ == "__main__": main()
p04019
s742898869
Accepted
S = input() res = "Yes" if S.count('N') and not S.count('S'): res = "No" if not S.count('N') and S.count('S'): res = "No" if S.count('E') and not S.count('W'): res = "No" if not S.count('E') and S.count('W'): res = "No" print(res)
p02786
s235461716
Wrong Answer
n = int(input()) flag = True ans = 1 now = n count = 1 for i in range(10000): if n > 2**i: pass elif n == 2**i: print(4*(2**(i)//2)-1) break else: print(4*(2**(i-1)//2)-1) break
p02970
s495942410
Accepted
import math N, D = map(int, input().split()) print(math.ceil(N/(2*D+1)))
p03433
s715886648
Accepted
N = int(input()) A = int(input()) if N%500<=A: print("Yes") else: print("No")
p03804
s446610830
Accepted
n,m=map(int,input().split()) a=[input() for i in range(n)] b=[input() for j in range(m)] count=0 for k in range(n-m+1): for j in range(n-m+1): for i in range(m): if a[i+k][j:j+m]==b[i]: count+=1 if count==m: print("Yes") exit() count=0 pr...
p02689
s746934195
Wrong Answer
n,m = map(int,input().split()) hlist = list(map(int,input().split())) rank_hlist = sorted(hlist) rank_dict = dict() for i in range(n): rank_dict[rank_hlist[i]] = i ab_list = [] for i in range(m): a, b = map(int,input().split()) if rank_dict[hlist[a-1]] < rank_dict[hlist[b-1]]: a,b = b,a a...
p04030
s129418602
Wrong Answer
s = input() a = "" for i in a: if i == "1" or i == "0": a += i else: if a: a = a[:-1] print(a)
p04033
s149796785
Accepted
# coding: utf-8 def main(): a, b = map(int, input().split()) ans = 'Positive' if a <= 0 and b >= 0: ans = 'Zero' elif b < 0: if (b - a) % 2 == 0: ans = 'Negative' print(ans) if __name__ == "__main__": main()
p02817
s153596005
Accepted
S, T = input().split() print(T + S)
p03073
s427281397
Wrong Answer
cnt=0 cnt_2=0 s = str(input()) for i in range(len(s)): if s[i]=='0' and i%2==0: cnt+=1 else: cnt_2+=1 if s[i]=='1' and i%2!=0: cnt+=1 else: cnt_2+=1 print(min(cnt,cnt_2))
p04029
s293601785
Accepted
n = int(input()) print(sum([i for i in range(1,n+1)]))
p03681
s375506398
Wrong Answer
from functools import reduce n, m = map(int, input().split()) mod = 10 ** 9 + 7 if abs(n - m) >= 2: print(0) elif n - m == 1: a = reduce(lambda x, y: (x * y) % mod, range(1, n + 1)) b = reduce(lambda x, y: (x * y) % mod, range(1, m + 1)) ans = (a * b) % mod print(ans) elif n == m: a = reduce(l...
p02754
s260669136
Accepted
n, a, b = map(int, input().split()) q = n // (a + b) r = n % (a + b) print(q*a + min(r, a))
p03103
s898733250
Accepted
import numpy as np n,m = map(int, input().split()) A = np.array([list(map(int, input().split())) for _ in range(n)], dtype='int64') ind = np.argsort(A[:,0]) A = A[ind] num = 0 money = 0 for a,b in A: num += b if num < m: money += a * b else: money += a * (b - (num - m)) break print(m...
p03289
s244659841
Accepted
s = input() if s[0] == 'A' and s.count('A') == 1 and s.count('C') == 1 and s[2:-1].count('C') == 1: s = s.replace('A', '').replace('C', '') for c in s: if ord(c) < ord('a'): print('WA') exit(0) print('AC') else: print('WA')
p02879
s295643339
Wrong Answer
a, b = (int(x) for x in input().split()) c = a * b if c > 1 and c < 400: print(c) else: print("-1")
p02801
s653364408
Accepted
n=input() print(chr(ord(n)+1))
p04029
s373903474
Accepted
n=int(input()) sum=0 for i in range(1,n+1): sum=sum+i print(sum)
p03371
s239957095
Wrong Answer
a,b,c,x,y = map(int,input().split()) ans = 0 if a + b >= c * 2: ans = c * 2 * min(x,y) if min(a,b) >= c * 2: ans += (max(x,y) - min(x,y)) * (c * 2) else: if x >= y: ans += min((max(x,y) - min(x,y)) * a,(max(x,y) - min(x,y)) * b) else: ans = a * x + b * y print(ans)
p04011
s525004886
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) print(min(k, n)*x + max((n-k)*y, 0))
p02786
s197028279
Accepted
print(2**len(bin(int(input())))//4-1)
p02729
s509732784
Accepted
n,m=map(int,input().split()) print(((n-1)*n)//2+((m-1)*m)//2)
p02935
s390992636
Accepted
N = int(input()) v = list(map(int,input().split())) v.sort() L = [] for i in range(N-1): a = (v[i]+v[i+1])/2 L.append(a) v[i+1] = a print(max(L))
p02676
s481044172
Accepted
k=int(input()) s=[i for i in input()] ans=0 if len(s)<=k: ans="".join(s) else: ans="".join(s[:k])+"..." print(ans)
p03219
s609541551
Wrong Answer
x,y = map(int,input().split()) print(x+y/2)
p02555
s455960171
Wrong Answer
import math S = int(input()) m = (10**9)+7 def combinations_count(n, r): return (math.factorial(n) // (math.factorial((n - r)) * math.factorial((r)))) result = 0 for i in range((S-1)//9+1,S//3+1): result += combinations_count((S-i*3+(i-1)), (i-1)) print(result%m)
p03815
s598154386
Accepted
x = int(input()) s = x//11 if 11*s == x: print(s*2) elif x <= 11*s + 6: print(s*2+1) else: print(s*2+2)
p03285
s480662470
Wrong Answer
x = int(input()) flag = 0 for i in range((x//7)+1): x = x - 7 if x < 0: break if x%4 == 0: flag = 1 if flag == 1: print("Yes") else : print("No")
p02787
s665834899
Wrong Answer
h,n=map(int,input().split()) H=[] A=[] for i in range(n): a,b=map(int,input().split()) H.append([a,b]) A.append(a) a_max=max(A) dp=[10**5]*(h+a_max+1) dp[0]=0 for i in range(1,h+a_max+1): for j in range(n): if i-H[j][0]<0: dp[i]=min(dp[i],H[j][1]) else: dp[i]=min(...
p03351
s863141073
Accepted
a, b, c, d = map(int, input().split()) if (abs(b-a) <= d and abs(c-b) <= d) or abs(c-a) <= d: print("Yes") else: print("No")
p02773
s730300949
Accepted
n = int(input()) dd = {} for i in range(n): s = input() if s in dd.keys(): dd[s] += 1 else: dd[s] = 1 ma = max(dd.values()) lst = [] for k, v in dd.items(): if v == ma: lst.append(k) for l in sorted(lst): print(l)
p02957
s475662302
Wrong Answer
a, b = map(int, input().split()) n = abs(a-b) print(n if n&1 else "IMPOSSIBLE")
p02888
s603611908
Accepted
import bisect n = int(input()) L = list(map(int,input().split())) L.sort() ans = 0 for i in range(n-2): for j in range(i+1,n-1): k = L[i]+L[j] x = bisect.bisect_left(L,k) ans += x-j-1 print(ans)
p02660
s685082625
Accepted
from math import sqrt n = int(input()) ans = 0 for i in range(2, 1 + int(sqrt(n))): c = 0 while n % i == 0: n //= i c += 1 ans += int((-1 + sqrt(1 + 8 * c)) / 2) if n != 1: ans += 1 print(ans)
p04045
s265472300
Accepted
n,k = map(int,input().split()) D = list(map(str,input().split())) for i in range(n,10**7): for j in str(i): if j in D: break else: print(i) break
p03105
s896101596
Accepted
A,B,C = map(int,input().split()) print(min(B//A,C))
p02706
s884178730
Accepted
n,m = input().split() N = int(n) L1 = list(map(int,input().split())) ans=-1 if sum(L1)<=N: ans = N-sum(L1) print(ans)
p02768
s508962243
Accepted
n,a,b = map(int,input().split()) mod = 10**9+7 sum_comb = pow(2,n,mod) - 1 def comb(n, r, mod): x=y=1 for i in range(r): x *= n; y *= r x %= mod; y %= mod n -= 1; r -= 1 return x * pow(y, mod - 2, mod) % mod comb_a = comb(n,a,mod) comb_b = comb(n,b,mod) print((sum_comb - comb_a -...
p03624
s294073286
Accepted
alphabet = "abcdefghijklmnopqrstuvwxyz" S = input() result = "" found = True for i in alphabet: if i not in S: result = i found = False break if not found: print(result) else: print("None")
p03380
s893104183
Accepted
import sys sys.setrecursionlimit(2147483647) n=int(input()) aa=list(map(int,input().split())) if n==2: print(aa[0],aa[1]) exit() aa.sort() nn=max(aa) c=0 tmp=10**9 for a in aa: if abs(nn/2.0-a)<tmp: tmp=abs(nn/2.0-a) c=a print(nn,c)
p03261
s847160086
Accepted
N = int(input()) w = [input() for _ in range(N)] jdg = True s_last = w[0][-1] ss = [w[0]] for s in w[1:]: if s in ss: jdg = False break if s[0] != s_last: jdg = False break s_last = s[-1] ss.append(s) print('Yes' if jdg else 'No')
p02963
s129211297
Accepted
S=int(input()) if S<10**18: x1,y1,x2,y2,x3,y3=0,0,(S//10**9+1),10**9-S%10**9,1,10**9 else: x1,y1,x2,y2,x3,y3=(0,0,10**9,1,0,10**9) print(x1,y1,x2,y2,x3,y3)
p03136
s510665789
Accepted
N = int(input()) L = list(map(int, input().split())) maxlength = max(L) total = sum(L) if total > maxlength * 2: print('Yes') else: print('No')
p02897
s081658722
Accepted
import math N = int(input()) print((math.ceil(N/2))/N)
p03317
s901820705
Accepted
import math n,k = map(int,input().split()) a = list(map(int,input().split())) print(math.ceil((n-1)/(k-1)))
p02601
s036276347
Accepted
a, b, c = map(int, input().split()) K = int(input()) k = 0 while a >= b: b *= 2 k += 1 while b >= c: c *= 2 k += 1 if k<=K: print("Yes") else: print("No")
p03017
s492234700
Accepted
n,a,b,c,d = map(int,input().split()) s = input() if '##' in s[a:c] or '##' in s[b:d]: print('No') else: if c < d: print('Yes') else: if '...' in s[b - 2:d + 1]: print('Yes') else: print('No')
p02677
s015867143
Wrong Answer
import numpy as np print('a')
p03077
s627196319
Wrong Answer
import math def main(): N=int(input()) A=int(input()) B=int(input()) C=int(input()) D=int(input()) E=int(input()) min_num=N+1 for i in (A,B,C,D,E): min_num=min(i,min_num) print(math.ceil(N/min_num)+1+4) if __name__=="__main__": main()
p03380
s808079725
Wrong Answer
n = int(input()) a = list(map(int,input().split())) max_n = max(a) tmp = max_n//2 check = 10**9+7 for i in range(n): res = a[i] - tmp if check > tmp: check = tmp ans_r = a[i] print(max_n,ans_r)
p02646
s075381415
Accepted
a,v=[int(x) for x in input().rstrip().split()] b,w=[int(x) for x in input().rstrip().split()] t=int(input()) if b+w*t<=a+v*t and a-v*t<=b-w*t: print("YES") else: print("NO")
p02813
s564501766
Wrong Answer
import itertools N = list(range(1, int(input()) + 1)) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) a = 0 b = 0 for i, n in enumerate(itertools.permutations(N)): if n == P: a = i elif n == Q: b = i print(abs(a - b))
p02597
s339793648
Accepted
import sys input = sys.stdin.readline n = int(input()) s = list(input()) c = 0 for e in s: if e == 'R': c += 1 res = min(c,n-c) tmp = 0 for i in range(c): if s[i] != 'R': tmp += 1 res = min(res,tmp) print(res)
p03220
s298583232
Accepted
N = int(input()) T, A = map(int, input().split()) H = list(map(int, input().split())) for i in range(N): H[i] = T - H[i]*0.006 t = 10**5 p = 0 for i in range(N): if abs(H[i]-A) < t: t = abs(H[i]-A) p = i+1 print(p)
p03827
s839150598
Accepted
n = int(input()) s = input() a = [] a.append(0) for i in range(n): if s[i] == 'I': a.append(a[i]+1) else: a.append(a[i]-1) print(max(a))
p03042
s805160800
Wrong Answer
S = input() f, r = int(S[:2]), int(S[2:]) #print(f) #print(r) if f == 0 or r == 0 or (f > 12 and r > 12): ans = "NA" elif f > 12 and r <= 12: ans = "YYMM" elif f <= 12 and r > 12: ans = "MMYY" elif r <= 12 and f <= 12: ans = "AMBIGUOUS" print(ans)
p02987
s182549205
Wrong Answer
s = input() if s[0] == s[1] and s[2] == s[3]: print('Yes') elif s[0] == s[2] and s[1] == s[3]: print('Yes') elif s[0] == s[3] and s[1] == s[2]: print('Yes') else: print('No')
p04031
s624422581
Wrong Answer
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N ans = 0 for k in range(N): ans = ans + (list[k] - A) ** 2 for i in range(-100,100): sum = 0 sum_new = 0 for j in range(N): sum_new = sum_new + (list[j] - i) ** 2 if(sum > sum_new): ans = sum_new print(ans...
p03281
s588482846
Wrong Answer
import math import sys n = int(sys.stdin.readline()) ans = 0 for i in range(3, n + 1, 2): # print(f'{i=}', end=' ') count = 0 for j in range(1, int(math.sqrt(i))): if i % j == 0: # print(f'{i} % {j} is 0.') count += 2 if count == 8: # print(f'{i} have just 8 divis...
p02723
s045771044
Accepted
S = input() if(S[2]==S[3] and S[4]==S[5]): print('Yes') else: print('No')
p03043
s210210028
Accepted
# 2020/07/23 # AtCoder Beginner Contest 126 - C import math # Input n, k = map(int,input().split()) ans = 0 # Calc for i in range(1, n+1): idx = 1 wval = i while(wval < k): wval = wval * 2 idx = idx + 1 ans = ans + (1/n) * (1/2) ** idx # Output print(ans*2)
p03759
s920835560
Accepted
a,b,c = map(int,input().split()) if b-a == c-b: print('YES') else: print('NO')