problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02814
s375122731
Wrong Answer
import itertools import fractions from functools import reduce N,M=map(int,input().split()) A=list(map(int,input().split())) def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) tmp=lcm_list(A) if M>tmp: print((M-tmp//2)//tmp+1) else: print(0...
p02866
s662526358
Wrong Answer
import sys read = lambda: sys.stdin.readline().rstrip() def counting_tree(N, D): tot = 1 cnt = [0]*N # cnt = collections.Counter(D) for i in D: cnt[i]+=1 print(cnt) for i in D[1:]: tot = tot * cnt[i-1]%998244353 print(tot) return tot if D[0]==0 else 0 def main...
p02577
s723160440
Wrong Answer
num = input() sum = 0 for x in num: sum = sum + (int(x) - 48) if (sum % 9 == 0): if (sum != 0): print("YES") else: print("NO") else: print("NO")
p03162
s606421343
Accepted
n = int(input()) A = [list(map(int, input().split())) for _ in range(n)] dp = [[ 0 for _ in range(3)]for _ in range(n+10)] for i in range(3): dp[0][i] = A[0][i] for i in range(1, n): for j in range(3): for k in range(3): if j != k: dp[i][k] = max(dp[i][k], dp[i-1][j]+A[i][...
p02861
s595334105
Wrong Answer
import itertools N = int(input()) X = [list(map(int, input().split())) for i in range(N)] x = list(itertools.permutations(range(N), N)) res = 0 for a in x: for i in range(N - 1): print(res) res += ((X[a[i]][0] - X[a[i + 1]][0]) ** 2 + (X[a[i]][1] - X[a[i + 1]][1]) ** 2) ** 0.5 print(res / len(x))
p02701
s171186288
Accepted
n=int(input()) s=[] for i in range(n): s.append(input()) s.sort() ans=n for i in range(n-1): if s[i]==s[i+1]: ans-=1 print(ans)
p03698
s708772029
Accepted
s = input() for i in range(len(s) - 1): if s[i] in s[i+1:]: print('no') exit() print('yes')
p02797
s845994566
Accepted
n,k,s = map(int,input().split()) ans = [] for i in range(k): ans.append(str(s)) for j in range(n-k): if s != 1: ans.append(str(s-1)) else: ans.append(str(s+1)) print(' '.join(ans))
p03611
s289935828
Wrong Answer
N = int(input()) a = list(map(int, input().split())) n = sum(a) // N - 1 ans = 0 for i in range(N): if a[i] == n or a[i] - 1 == n or a[i] + 1 == n: ans += 1 print(ans)
p03359
s342769549
Accepted
a,b = map(int,input().split()) if a <= b: print(a) else: print(a-1)
p03719
s514490800
Accepted
a, b, c = map(int, input().split()) if c >= a and c <= b: print('Yes') else: print('No')
p04043
s893593198
Accepted
ABC = input().split() print("YES" if ABC.count("5") == 2 and ABC.count("7") == 1 else "NO")
p03796
s867393968
Accepted
n = int(input()) l = 10**9 + 7 power = 1 for i in range(1,n+1): power = (power * i)%l print(power)
p02646
s602932091
Wrong Answer
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if a+v*t >= b+w*t >= 0: print('YES') else: print('NO')
p02601
s700099262
Accepted
def main(): a, b, c = map(int, input().split()) k = int(input()) count = 0 while True: if a < b: if b < c: break else: c *= 2 count += 1 else: b *= 2 count += 1 print('Yes' if count <= k ...
p03433
s969487789
Wrong Answer
n=int(input()) a=int(input()) if n//500<=a: print("Yes") else: print("No")
p03494
s714356590
Accepted
N = int(input()) A = list(map(int, input().split())) min_div = 10 ** 9 for a in A: div_count = 0 while a % 2 == 0: a /= 2 div_count += 1 min_div = min(min_div, div_count) print(min_div)
p02947
s257531343
Accepted
from collections import defaultdict N = int(input()) d = defaultdict(int) for _ in range(N): d[''.join(sorted(input()))] += 1 def tousa(n): return n*(n-1)//2 ans = 0 for i in d.values(): ans += tousa(i) print(ans)
p02695
s827099385
Accepted
import itertools N,M,Q = map(int,input().split()) x = [list(map(int,input().split())) for _ in range(Q)] d=0 ans=0 B=[] #Aの場合の数を全列挙 ele = [k for k in range(1,M+1)] for i in itertools.combinations_with_replacement(ele,N): A = list(i) d=0 for j in range(Q): if A[x[j][1]-1] - A[x[j][0]-1] == x[j][2]: d ...
p03289
s893076966
Accepted
S = input() if S[0]=="A" and S[2:-1].count("C") == 1 and S[1:].replace("C","c").islower(): print("AC") else: print("WA")
p02779
s944080171
Accepted
N=int(input()) A=list(map(int,input().split())) B=set(A) if N==len(B): print('YES') else: print('NO')
p03282
s314553687
Wrong Answer
import sys S = input() K = int(input()) for i in S: if i != 1: print(i) sys.exit() print(1)
p02676
s772509402
Wrong Answer
k=int(input()) s=input() l=len(s) if(l<=k): print(s) else: s=s[k:] print(s)
p02576
s577226999
Wrong Answer
n, x, t = map(int, input().split()) times = (n + x - 1) / x ans = times * t print(ans)
p03457
s973565977
Wrong Answer
n = int(input()) txy = [list(map(int, input().split())) for i in range(n)] t = 0 dx = 0 dy = 0 z = 'Yes' for i,h,j in txy: if (dx != h or dy != j) and abs(dx-h)+abs(dy-j) <= i-t: dx = h dy = j t = i else: z = 'No' print(z)
p03351
s573733623
Accepted
a,b,c,d = map(int,input().split()) if abs(a-b)<=d and abs(b-c)<=d: print("Yes") elif abs(a-c)<=d: print("Yes") else: print("No")
p02780
s648649910
Accepted
import itertools n, k = map(int, input().split()) dices = map(int, input().split()) dices_EV = list(map(lambda x:(x+1)/2, dices)) dices_EV_accumulate = list(itertools.accumulate(dices_EV)) dices_EV_sums = [dices_EV_accumulate[i+k] - dices_EV_accumulate[i] for i in range(n-k)] dices_EV_sums.append(dices_EV_accumulate[k...
p02723
s551464519
Accepted
s = input() if s[2]==s[3] and s[4]==s[5]: print("Yes") else: print("No")
p02688
s143969777
Accepted
n, k = map(int, input().split()) d = [] a = [] for i in range(k): d.append(int(input())) a.append(list(map(int,input().split()))) okashi = [0] * n for i in a: for j in i: okashi[j-1] = 1 ans = n - sum(okashi) print(ans)
p02787
s742193785
Wrong Answer
h,n=map(int,input().split()) A=[list(map(int,input().split())) for i in range(n)] ma=max(a for a,b in A) dp=[0]*(h+ma) for i in range(h+ma): dp[i]=min(dp[i-a]+b for a,b in A) print(min(dp[h:]))
p03545
s583638382
Accepted
a = input() for i in range(1 << 3): ans = int(a[0]) f = a[0] for j in range(3): if i & (1 << j): ans += int(a[j+1]) f += '+' else: ans -= int(a[j+1]) f += '-' f += a[j+1] if ans == 7: print(f + '=7') exit()
p03607
s869349992
Accepted
from collections import Counter n = int(input()) A = Counter([int(input()) for _ in range(n)]) cnt = 0 for k in A.values(): if k%2 != 0: cnt +=1 print(cnt)
p02866
s817587250
Accepted
from collections import Counter n = int(input()) D = list(map(int,input().split())) Dc = Counter(D) mod = 998244353 ans = 1 if Dc[0]!=1 or D[0]!=0: print(0) else: for i in range(max(D)): ans = ans*pow(Dc[i],Dc[i+1])%mod print(ans%mod)
p03161
s467628949
Accepted
n, k = map(int, input().split()) h = list(map(int, input().split())) dp = [float('inf')] * n dp[0] = 0 for i in range(1, n): for j in range(1, k+1): if(i-j < 0): break dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i])) print(dp[-1])
p02838
s400854568
Wrong Answer
MOD = 1000000007 n = int(input()) a = list(map(int,input().split())) ans = 0 for k in range(60): mask = 1<<k cnt1 = sum(1 for x in a if x&mask != 0) ans += cnt1*(n-cnt1)*(1<<k) print(ans)
p03352
s059209305
Wrong Answer
#ABC097 import math x = int(input()) l = [1] for i in range(int(math.sqrt(x))+1): j = 1 for j in range(100): if i ** j > x: l.append(i ** (j-1)) break print(l[-1])
p02718
s434667937
Accepted
n,m=map(int, input().split()) a_list=[int(i) for i in input().split()] a_list.sort(reverse=True) #print(a_list) standard=sum(a_list)/(4*m) #print(a_list[m-1]) #print(standard) if a_list[m-1]<standard: print("No") else: print("Yes")
p02924
s851014965
Accepted
N = int(input()) ans = N*(N-1)//2 print(ans)
p03607
s426173788
Accepted
n =int(input()) a =list(int(input()) for i in range(n)) dict = {} for i in range(n): if str(a[i]) in dict: dict.pop(str(a[i])) continue if not(str(a[i]) in dict): dict[str(a[i])] =1 continue print(len(dict))
p03720
s936530195
Accepted
n, m = map(int, input().split()) cnt = [0] * n for i in range(m): a, b = map(int, input().split()) cnt[a - 1] += 1 cnt[b - 1] += 1 for i in range(n): print(cnt[i])
p03632
s949859364
Wrong Answer
A,B,C,D=list(map(int, input().split())) ma=min(B,D) mi=max(A,C) print(ma-mi)
p03817
s668870870
Accepted
x = int(input()) ans = x // 11 m = x % 11 ans *= 2 if m > 6: ans += 2 elif m != 0: ans += 1 print(ans)
p02663
s690699148
Accepted
H1, M1, H2, M2, K = map(int, input().split()) h = H2 - H1 m = M2 - M1 T = h * 60 + m print(T-K)
p04033
s694167342
Accepted
a,b=map(int,input().split()) if a<=0 and b>=0: print("Zero") elif a>0: print("Positive") else: if (abs(a-b)+1)%2==0: print("Positive") else: print("Negative")
p04043
s751267612
Accepted
n_5 = 0 n_7 = 0 a = map(int, input().split()) for i in a: if i == 5: n_5 += 1 elif i == 7: n_7 += 1 if n_5 == 2 and n_7 == 1: print("YES") else: print("NO")
p02556
s864747663
Wrong Answer
n = int(input()) l = [list(map(int,input().split())) for i in range(n)] x = list(sorted(l,key=lambda x: x[0])) y = list(sorted(l,key=lambda x: x[1])) ax = abs(x[0][0]-x[-1][0])+abs(x[0][1]-x[-1][1]) ay = abs(y[0][0]-y[-1][0])+abs(y[0][1]-y[-1][1]) print(max(ax,ay))
p03327
s551726827
Accepted
N=int(input()) if N>=1000: print('ABD') else: print('ABC')
p02729
s536326078
Accepted
n, m = map(int, input().split()) print(n * (n - 1) // 2 + m * (m - 1) // 2)
p02811
s524091740
Wrong Answer
k,x = map(int,input().split()) print("No") if x // k > 500 else print("Yes")
p03407
s671573310
Accepted
A,B,C = map(int,input().split()) D=A+B if D>=C: print("Yes") else: print("No")
p03472
s116013112
Wrong Answer
import math n,k = map(int,input().split()) lst1 = [list(map(int,input().split())) for i in range(n)] ans = 0 x = 0 for i in range(n): x = max(x,lst1[i][0]) sum1 = 0 for i in range(n): if lst1[i][1] > x: k -= lst1[i][1] ans += 1 if k <= 0: print(ans) exit() print(ans + ma...
p03759
s318452961
Accepted
a,b,c=list(map(int,input().split())) if b - a == c - b: print("YES") else: print("NO")
p02860
s452298830
Wrong Answer
n = int(input()) s = input() if len(s)%2 == 1: print('No') else: m = len(s) s1, s2 = s[:m], s[m:] if s1 == s2: print('Yes') else: print('No')
p02663
s396828075
Accepted
#!/usr/bin/env python3 import sys input = sys.stdin.readline def IS(cb): return cb(input().strip()) def IL(cb): return [cb(s) for s in input().strip().split()] def IR(cb, rows): return [IS(cb) for _ in range(rows)] def ILL(cb, rows): return [IL(cb) for _ in range(rows)] def solve(): h1, m1, h2, m2, k = IL(int) ...
p02731
s310563314
Wrong Answer
l=int(input()) print(int(l**3/27))
p02628
s288792687
Accepted
n, k = map(int, input().split()) p = sorted(map(int, input().split())) print(sum(p[:k]))
p03000
s737161696
Accepted
N,X = map(int,input().split()) L_li = input().split() for i in range(len(L_li)): L_li[i] = int(L_li[i]) D = [0]*(N+1) for i in range(1,N+1,1): D[i] = D[i-1] + L_li[i-1] print(len([i for i in D if i <= X]))
p02719
s868350038
Accepted
n,k=map(int, input().split()) n=n%k n1=abs(n-k) n2=abs(n1-k) print(min(n1,n2))
p03137
s569260715
Accepted
N, M = map(int, input().split()) X = list(map(int, input().split())) if N >= M: print(0) exit() X.sort() Y = [] for i in range(1, M): Y.append(X[i] - X[i - 1]) Y.sort() ans = sum(Y[:M-N]) print(ans)
p03494
s340169042
Accepted
N=int(input()) A=list(map(int,input().split())) MIN=10**9 for i in range(N): count=0 while 1: if A[i] % 2 == 0: A[i] //= 2 else: break count += 1 MIN = min(MIN,count) if MIN==0: print(0) exit() print(MIN)
p03836
s520947514
Accepted
a,b,c,d = map(int,input().split()) th1 = "R"*(c-a) th2 = "U"*(d-b) th3 = "L"*(c-a) th4 = "D"*(d-b) th5 = "D"+"R"*(c-a+1)+"U"*(d-b+1)+"L" th6 = "U"+"L"*(c-a+1)+"D"*(d-b+1)+"R" ans=th1+th2+th3+th4+th5+th6 print(ans)
p02759
s740416071
Accepted
x = input() if int(x) % 2: print(int(int(x)/2+0.5)) else: print(int(int(x)/2))
p02578
s560289556
Wrong Answer
N = int(input()) A = list(map(int, input().split())) s = 0 if N==1: print(0) exit() for i,a in enumerate(A): if i==0: continue s+=(a<A[i-1])*a print(s)
p04012
s706956037
Accepted
def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 w=input() from collections import defaultdict dd = defaultdict(int) for i in range(len(w)): dd[w[i]]+=1 f=1 for k,...
p03407
s324638466
Accepted
A,B,C=map(int,input().split()) print("Yes" if A+B>=C else "No")
p02584
s229856791
Accepted
x, k, d = map(int, input().split()) x = abs(x) # x > 0のとき left = abs(x - d * (x // d + 1)) right = abs(x - d * (x // d)) if k < x // d: print(x - d * k) exit() if (k - (x // d)) % 2 == 0: print(right) else: print(left)
p03435
s585440083
Wrong Answer
a, b, c = map(int, input().split()) d, e, f = map(int, input().split()) g, h, i = map(int, input().split()) if a-d==b-e==c-f and a-g==b-h==c-i and a-b--d-e==g-h and a-c==d-f==g-i: print("Yes") else: print("No")
p03469
s057963412
Accepted
a = input() print(a[:3]+'8'+a[4:])
p04045
s413100509
Accepted
N, K = map(int, input().split()) D = set(input().split()) for n in range(N, 100001): for s in str(n): if s in D: break else: print(n) exit()
p04043
s779024163
Accepted
ABC = list(map(int, input().split())) if ABC.count(5) == 2 and ABC.count(7): print('YES') else: print('NO')
p03073
s028106189
Wrong Answer
s=input() ans=len(s) for i in range(2): cnt=0 for j in s: if int(j) % 2 == 0 and j!=i: cnt+=1 if int(j) % 2 == 1 and j==i: cnt+=1 ans=min(cnt,ans) print(ans)
p02720
s687680068
Wrong Answer
k = int(input()) lunlun = list(range(1, 10)) for i in range(k - 1): a = lunlun[i] b = a * 10 + a % 10 if a % 10 != 0: lunlun.append(b - 1) lunlun.append(b) if a % 10 != 9: lunlun.append(b + 1) print(lunlun) print(lunlun[k - 1])
p03971
s069227008
Accepted
n,a,b=map(int,input().split()) s=list(input()) ac=0 fc=0 for i in range (n): if s[i]=='a' and ac<a+b: ac+=1 print ('Yes') elif s[i]=='b' and ac<a+b and fc<b: ac+=1 fc+=1 print ('Yes') else: print ('No')
p03339
s771963669
Accepted
n = int(input()) s = list(input()) counter = [0] * n counter[0] = s[1:].count('E') for i in range(1, n): n = 0 if s[i - 1] == 'W': n += 1 if s[i] == 'E': n -= 1 counter[i] = counter[i - 1] + n print(min(counter))
p02773
s558660728
Wrong Answer
N = input() S=[] for i in range(int(N)): S.append(input()) ls=[] for i in S: if i not in ls: ls.append(i) str_ls =[] num_ls = [] flag = 0 for i in ls: num_ls.append(S.count(i)) str_ls.append(i) for i in range(len(str_ls)): if num_ls[i] == max(num_ls): print(str_ls[i])
p03524
s809457963
Accepted
s=input() a,b,c=0,0,0 for i in range(len(s)): if s[i]=='a': a+=1 elif s[i]=='b': b+=1 else : c+=1 ans = (abs(a-b) <2) and (abs(c-b)<2) and (abs(c-a)<2) print( "YES" if ans else "NO")
p04033
s153792182
Wrong Answer
a,b=map(int,input().split()) ab=[i for i in range(a,b+1)] if 0 in ab: print('Zero') elif a>0 : print('Positive') else: print('Negative')
p02843
s691888832
Accepted
X = int(input()) l = [1,2,3,4,5] a = X // 100 b = X % 100 ans = 0 for i in l: if b % i == 0: if b // i <= a: ans = 1 break print(ans)
p02630
s259805567
Accepted
from collections import defaultdict N = int(raw_input()) A = map(int, raw_input().split()) lookup = defaultdict(int) for a in A: lookup[a] += 1 cur_sum = 0 for k in lookup: cur_sum += k*lookup[k] Q = int(raw_input()) for q in xrange(Q): b, c = map(int, raw_input().split()) cur_sum -= b*lookup[b] cur_s...
p02548
s591830913
Accepted
n = int(input()) count = 0 for a in range(1,n): count += (n-1)//a print(count)
p02784
s347776811
Wrong Answer
a,b=map(int,input().split()) l=list(map(int,input().split())) l=l+l e=sum(l) if e>=a: print("YES") else: print("NO")
p03220
s132742648
Wrong Answer
n = int(input()) t,a = map(int, input().split()) h = list(map(int, input().split())) ave = [float(a)-float(t-i*0.006) for i in h] print(ave.index(min(ave))+1)
p02756
s573976582
Accepted
S = list(input()) q = int(input()) procedure = [list(input().split()) for i in range(q)] cnt = 0 S2 = [] for i in range(q): if procedure[i][0] == '1': cnt += 1 if procedure[i][0] == '2': if (procedure[i][1] == '1' and cnt%2 == 0) or (procedure[i][1] == '2' and cnt%2 == 1): S2.appen...
p03285
s528586679
Accepted
N = int(input()) four = 0 while 4*four <= N: X = N - 4*four if X % 7 == 0: print("Yes") exit() four += 1 print("No")
p02743
s495768461
Accepted
a, b, c = map(int, input().split()) left = 4 * a * b right = c - (a + b) if (right < 0): print('No') exit() right = right ** 2 if (left < right): print('Yes') else: print('No')
p03408
s614270932
Wrong Answer
N = int(input()) S = [] for i in range(N): S.append(input()) T = [] M = int(input()) for j in range(M): T.append(input()) S = list(set(S)) T = list(set(T)) count = 0 for i in range(len(S)): for j in range(len(T)): if S[i] != T[j]: count = count + 1 print(count)
p02633
s068680277
Accepted
x = int(input()) for i in range(1, 1000): if x * i % 360 == 0: print(i) exit()
p03109
s345479969
Accepted
import time from datetime import date S = list(map(int, input().split("/"))) day = date(S[0], S[1], S[2]) border = date(2019, 4, 30) if day <= border: print("Heisei") else: print("TBD")
p02717
s667523857
Accepted
# coding: utf-8 # Your code here! a = list(map(int, input().split())) for i in range(3): print(a[-1+i], end=" ")
p03387
s579922514
Accepted
a=[0,0,0] a[0],a[1],a[2]=map(int,input().split()) a=sorted(a) sa1=a[2]-a[0] sa2=a[2]-a[1] if (a[0]%2==a[1]%2==a[2]%2): print(sa1//2 + sa2//2) else: if (sa1%2==0 and sa2%2==1): print((sa1//2)+1 + (sa2+1)//2) elif (sa1%2==1 and sa2%2==0): print(((sa1+1)//2)+(sa2//2)+1) else: print((sa2-sa1)//2+sa1)
p03836
s370787740
Accepted
sx,sy,tx,ty = map(int,input().split()) ans = '' for i in range(tx-sx): ans += 'R' for i in range(ty-sy): ans += 'U' ans += 'R' for i in range(ty-sy+1): ans += 'D' for i in range(tx-sx+1): ans += 'L' ans += 'U' for i in range(ty-sy): ans += 'U' for i in range(tx-sx): ans += 'R' ans += 'U' for i i...
p02702
s972877702
Wrong Answer
S = input() list1 = [] divisor = 2019 while (divisor <= 200000) and (divisor > 1): divisor += 2019 to_string = str(divisor) if to_string in S: list2 = [x for x in range(len(S)) if S.startswith(to_string, x)] for num in list2: list1.append(num) print(len(list1))
p03146
s507451409
Wrong Answer
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline s = int(input()) arr = [0] * 1000000 cnt = 0 while True: if s % 2 == 0: s //= 2 else: s = 3 * s + 1 cnt += 1 arr[s] += 1 if arr[s] > 1: print(cnt + 1) exit()
p02760
s526316843
Wrong Answer
a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) N = int(input()) s = [int(input()) for i in range(N)] if len(list(set(a) & set(s))) or len(list(set(b) & set(s))) or len(list(set(c) & set(s))) == 3: print('Yes') elif len(list(set([a[0],b[1],c[2]]) & se...
p03220
s081307525
Wrong Answer
N=int(input()) T,A=map(int,input().split()) mylist=list(map(int,input().split())) min=T index=0 for i in range(N): if(min>abs(T-0.006*mylist[i])): min=mylist[i] index=i print(index)
p03951
s439427780
Accepted
n=int(input()) s=input() t=input() while True: if s==t: break s=s[1:] t=t[:-1] n+=1 print(n)
p02659
s707206442
Wrong Answer
a,b=input().split() a=int(a) b=int(float(b)*100) print(int(a*b/100))
p02606
s443182496
Accepted
l, r, d = map(int, input().split()) a = 0 for i in range(l, r+1): if i % d == 0: a += 1 print(a)
p02606
s916922218
Wrong Answer
l,r,d = map(int,input().split()) print((r-l+1)//d)
p03695
s658554655
Wrong Answer
n = int(input()) a = list(map(int, input().split())) c = [0] * 9 for i in a: if i < 3200: c[i // 400] += 1 else: c[8] += 1 ans = 0 for i in range(8): if c[i] != 0: ans += 1 print(ans, ans + c[8])