problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02725
s094819943
Accepted
import sys read = sys.stdin.buffer.read k, n, *A = read().split() far = int(k) + int(A[0]) - int(A[-1]) for x, y in zip(A[1:], A): if far < int(x) - int(y): far = int(x) - int(y) print(int(k)-far)
p03136
s210257587
Wrong Answer
a = input() num = map(int, input().split()) num_max = max(num) num_sum = sum(num) - num_max if(num_sum > num_max): print("Yes") else: print("No")
p03711
s290383717
Accepted
x, y = map(int, input().split()) A = [1, 3, 5, 7, 8, 10, 12] B = [4, 6, 9, 11] if x in A and y in A: print("Yes") elif x in B and y in B: print("Yes") else: print("No")
p02697
s138246490
Accepted
#!/usr/bin/env python3 n, m = map(int, input().split()) d = m r = d + 1 for i in range(m): if d <= 0: break a = i + 1 b = a + d print(a, b) d -= 2 d = m - 1 for i in range(m): if d <= 0: break a = r + i + 1 b = a + d print(a, b) d -= 2
p02732
s192632916
Accepted
from collections import Counter import numpy as np N = int(input()) A = np.array(list(map(int, input().split()))) A_set = np.unique(A) count_dict= Counter(A) count_sum = np.sum([count_dict[i]*(count_dict[i]-1)/2 for i in A_set]) out = [int(count_sum-count_dict[i]+1) for i in A] for i in out: print(i)
p03617
s327991902
Wrong Answer
q, h, s, d = map(int, input().split()) q *= 4 h *= 2 d //= 2 n = int(input()) if n % 2 == 0: print(n * min(q, h, s, d)) else: tmp = min(q, h, s) if n > 1 and d < tmp: print((n - 1) * d + tmp) else: print(n * tmp)
p03943
s272695003
Accepted
x = sorted(list(map(int, input().split()))) if x[0]+x[1] == x[2]: print("Yes") else: print("No")
p03011
s370511015
Wrong Answer
p, q, r = map(int, input().split()) print(min(p+q, q+r, r+q))
p03767
s171018588
Wrong Answer
N = int(input()) a = list(map(int, input().split())) cnt = 0 a.sort(reverse=True) print(a) for i in range(1, 2*N, 2): cnt += a[i] print(cnt)
p02691
s889339070
Wrong Answer
import collections n=int(input()) a=list(map(int,input().split())) ans=0 b=[] for i in range(n): b.append(abs(a[i]-i+1)) #print(b) ans=0 b=collections.Counter(b) for i in b.values(): ans+=i*(i-1)//2 print(ans) #print(ans)
p02813
s648977918
Accepted
import itertools N = int(input()) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) permutations = list(itertools.permutations(range(1, N+1))) p = permutations.index(P) q = permutations.index(Q) print(abs(p-q))
p02743
s791672136
Wrong Answer
import decimal import numpy [a, b, c] = list(map(int, input().split())) flg = 'No' if decimal.Decimal(numpy.sqrt(a)) + decimal.Decimal(numpy.sqrt(b)) < decimal.Decimal(numpy.sqrt(c)): flg = 'Yes' print(flg)
p02766
s010988021
Accepted
a,b=list(map(int, input().split())) from math import log if True: print(int(log(a,b)+1))
p03286
s088788002
Wrong Answer
N = int(input()) ans = "" while N: if N % 2: ans += "1" N = -((N - 1) // 2) else: ans += "0" N = -(N // 2) print(ans[::-1])
p03860
s764797303
Accepted
a = input().split() print(*[h[0] for h in a], sep='')
p02843
s951397562
Wrong Answer
X = int(input()) def hoge(X): if 1+ ((X%100)//5) <= X//100: return 1 else: return 0 print(hoge(X))
p02726
s070224012
Accepted
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy import bisect if __name__ == "__main__": n,x,y = map(int,input().split()) x-=1 y-=1 ans = [0]*(n) for i in range(n): for j in range...
p03131
s121757600
Accepted
K,A,B=map(int,input().split()) if (B-A)/2>1 and K>=A+1: print(A+(B-A)*((K-A+1)//2)+(K-A+1)%2) else: print(K+1)
p02760
s954875625
Accepted
# B - Bingo A = [] for _ in range(3): tmp = list(map(int,input().split())) A.extend(tmp) B = [0]*9 N = int(input()) for _ in range(N): tmp = int(input()) for i in range(9): if tmp==A[i]: B[i] = 1 ans = 'No' for i,j,k in [(0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6)...
p02881
s780947251
Accepted
n=int(input()) ans=float('inf') for a in range(1,int(n**0.5+1)): if n%a==0: ans=min(ans,a+n//a-2) print(ans)
p03659
s978392472
Accepted
import numpy as np n = int(input()) a = list(map(int, input().split())) total = sum(a) Min = np.inf s = 0 for i in range(len(a)-1): s += a[i] Min = min(Min, abs(2 * s- total)) print(Min)
p02813
s694158183
Accepted
import itertools import sys N = int(input()) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) if P == Q: print(0) else: M = [0]*N for i in range(N): M[i] = i+1 ans = [] for i, v in enumerate(itertools.permutations(M, N)): if v in [P, Q]: ans.ap...
p02675
s288243260
Accepted
N = input() if N[-1:] == "2" or N[-1:] == "4" or N[-1:] == "5" or N[-1:] == "7" or N[-1:] == "9": print('hon') elif N[-1:] == "0" or N[-1:] == "1" or N[-1:] == "6" or N[-1:] == "8": print('pon') else: print("bon")
p02731
s537109008
Accepted
l = int(input()) v = 0 r = l/3 vr = r ** (3) for i in range(0,l+1): for j in range(0,l-i+1): if v < i*j*(l-i-j): v = i*j*(l-i-j) if vr >= v: print(vr) else: print(v)
p02995
s913261920
Accepted
import fractions A, B, C, D = map(int, input().split(" ")) W = (B-A+1) x = C*D//fractions.gcd(C,D) c = (B//C) - ((A-1)//C) d = (B//D) - ((A-1)//D) j = (B//x) - ((A-1)//x) div = (c+d-j) print(W-div)
p02661
s840284725
Accepted
n=int(input()) a,b=[],[] for _ in range(n): i,j=map(int,input().split()) a+=[i] b+=[j] a.sort() b.sort() c=n//2 if n%2==1: print(b[c]-a[c]+1) else: print(b[c]-a[c]+b[c-1]-a[c-1]+1)
p02546
s184551552
Accepted
l = input() if l[-1] == 's': print(l+'es') else: print(l+'s')
p02847
s844052650
Accepted
week =input() if week=="SUN": print("7") elif week=="MON": print("6") elif week=="TUE": print("5") elif week=="WED": print("4") elif week=="THU": print("3") elif week=="FRI": print("2") else: print("1")
p02615
s909826979
Wrong Answer
N=int(input()) A=list(map(int,input().split())) A=sorted(A) i=len(A) i//=2 print(sum(A[-i-2:-2])*2+A[-1])
p02646
s312403433
Wrong Answer
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) d = abs(A - B) v = V - W ans = 'YES' if v <= 0: ans = 'NO' else: if d / v > T: ans = 'NO' if (A % 2 != B % 2 and V % 2 == W % 2) or (A % 2 == B % 2 and V % 2 != W % 2): ans = 'NO' print(ans)
p02659
s053929731
Accepted
a,b=input().split() a=int(a) b=int(b.replace(".","")) print(a*b//100)
p03327
s768115193
Accepted
n = int(input()) if (n < 1000): print('ABC') else: print('ABD')
p02623
s113274148
Accepted
import itertools n, m, k = map(int, input().split()) A = [0] + list(map(int, input().split())) B = [0] + list(map(int, input().split())) A = list(itertools.accumulate(A)) B = list(itertools.accumulate(B)) count = 0 j = m for i in range(n+1): if A[i] > k: break while A[i]+B[j] > k: j -= 1...
p02953
s610975914
Accepted
n = int(input()) H = list(map(int,input().split())) if n==1: print('Yes');exit() H[0]-=1 for i in range(n-1): if H[i]>H[i+1]: print('No');exit() elif H[i]==H[i+1]: continue else: H[i+1]-=1 print('Yes')
p02957
s624362246
Accepted
A, B = [int(s) for s in input().split()] if (A - B) % 2 == 0: print((A+B)//2) else: print("IMPOSSIBLE")
p03759
s014111267
Accepted
def resolve(): a,b,c = map(int,input().split()) print("YES" if b-a==c-b else "NO") resolve()
p02814
s677654549
Accepted
n,m=map(int,input().split()) A=[int(i)//2 for i in input().split()] def gcd(a,b): while b: a,b=b,a%b return a def div2(x): ret=0 while x%2==0: ret+=1 x//=2 return ret s=div2(A[0]) chk=True mul=A[0] for i in range(1,n): if s!=div2(A[i]) or mul>m: chk=False else: mul=mul*A[i]//gcd(mu...
p03062
s916439387
Accepted
n = int(input()) a = list(map(int,input().split())) i = 10**9 s = 0 z = 0 c = 0 for b in a: if b < 0: s += 1 elif b == 0: z += 1 if abs(b) < i: i = abs(b) c += abs(b) if z > 0 or s%2 == 0: print(c) else: print(c-2*i)
p03095
s023293521
Wrong Answer
N = int(input()) S = input() from collections import Counter c = Counter(S) ans = 1 for v in c.values(): # print(v) ans *= v+1 print(ans-1)
p02602
s891200795
Wrong Answer
def main(): n, k = map(int, input().split()) A = [int(a) for a in input().split()] score = 1 # for i in range(k): # score *= A[i] for i in range(n - k): tmp = ((score // A[i]) * A[k + i]) if tmp > score: print("Yes") else: print("No") ...
p03457
s843908774
Accepted
import sys n=int(input()) l=[list(map(int,input().split())) for i in range(n)] t=0 x=0 y=0 for i in range(n): t1=l[i][0] x1=l[i][1] y1=l[i][2] dt=t1-t md=abs(x-x1)+abs(y-y1) if dt >= md and (dt - md) % 2 == 0: t=t1 x=x1 y=y1 else: print("No") sy...
p02696
s221266404
Wrong Answer
def solve(): if n > b: print((b-1)*a//b) else: print((a*n)//b- a*(n//b)) return # n = int(input()) a, b, n = [int(s) for s in input().split(" ")] solve()
p02578
s481893997
Wrong Answer
n=input() l=list(map(int,input().split())) ma=max(l) mi=min(l) print(int(ma-mi))
p03998
s585111124
Accepted
a=list(input()) b=list(input()) c=list(input()) order='a' while True: if order=='a': if len(a)==0: print('A') break else: order=a[0] a=a[1:] elif order=='b': if len(b)==0: print('B') break else: order=b[0] b=b[1:] elif order=='c': if len(c)==0: ...
p02748
s747342356
Wrong Answer
A, B, M = map(int, input().split()) price_A = list(map(int, input().split())) price_B = list(map(int, input().split())) ans = 10**6 for m in range(M): x, y, c = map(int, input().split()) p1 = price_A[x-1] + price_B[y-1] - c p2 = price_A[x-1] + price_B[y-1] if p1 <= p2 and p1 <= ans: ans=p1 elif p2 <= p1 an...
p03672
s738206475
Accepted
s = input() t = len(s)//2 for i in range(1,t): u = s[:-2*i] if u[:len(u)//2] == u[len(u)//2:]: print(len(u)) exit()
p02603
s722938152
Accepted
n = int(input()) a = list(map(int, input().split())) kabu = 0 money = 1000 for i in range(n): if i == n-1: money += kabu*a[i] kabu = 0 elif a[i] < a[i+1]: if money >= a[i]: kabu = money // a[i] money = money - a[i]*kabu else: money += kabu*a[i] ...
p02779
s275150313
Wrong Answer
def has_duplicates(seq): if len(seq) == len(set(seq)): print("Yes") else: print("No") #return len(seq) != len(set(seq)) N = int(input()) A = list(map(int,input().split())) has_duplicates(A)
p03043
s030030532
Accepted
N,K = map(int,input().split()) result = 0 for i in range(1,N+1): prob = 1 count = i while count < K: prob *= 0.5 count *= 2 result += prob /N print(result)
p03699
s531118576
Accepted
N=int(input()) List=[int(input()) for i in range(N)] List.sort() LIst=[] total=sum(List) for i in List: if i % 10 != 0: LIst.append(i) if total % 10 != 0: print(total) elif LIst == []: print(0) else: print(total-LIst[0])
p03962
s402703079
Wrong Answer
color=input() iro=color.split(" ") i=0 if int(iro[0])==int(iro[1]): i=i+0 else: i=i+1 if int(iro[0])==int(iro[2]): i=i+0 else: i=i+1 if int(iro[1])==int(iro[2]): i=i+0 else: i=i+1 print(str(i)) print(str(i))
p02755
s921221040
Accepted
A, B = map(int, input().split()) for i in range(500000): a = i * 8 // 100 b = i // 10 if (a, b) == (A, B): print(i) exit() print(-1)
p03785
s158995919
Wrong Answer
N, C, K = map(int, input().split()) bus_count = 0 waiting_count = 0 time_limit = 0 for _ in range(N): T = int(input()) waiting_count += 1 if waiting_count == 1: time_limit = T + K else: if T > time_limit: time_limit = T + K bus_count += 1 waiting_count...
p02600
s519811660
Wrong Answer
a=int(input()) if 400 <= a < 600: print(8) elif 600 <= a < 799: print(7) elif 800 <= a < 999: print(6) elif 1000 <= a < 1199: print(5) elif 1200 <= a < 1399: print(4) elif 1400 <= a < 1599: print(3) elif 1600 <= a < 1799: print(2) elif 1800 <= a < 2000: print(1)
p03471
s193689688
Accepted
n, y = map(int, input().split()) count = 5000*n work = [0, n, 0] for i in range(n): if y > count: count += 5000 work[0] += 1 work[1] -= 1 elif y < count: work[2] += 1 work[1] -= 1 count -= 4000 else: break if y == count: print(" ".join(map(str, wor...
p03479
s282426940
Accepted
x, y = map(int, input().split()) cnt = 0 while x <= y: cnt += 1 x *= 2 print(cnt)
p03035
s050907775
Accepted
A, B = map(int, input().split()) if A >= 13: print(B) elif 6 <= A <= 12: print(B//2) else: print(0)
p02595
s896939726
Wrong Answer
n,d = map(int,input().split(" ")) d *= d c = 0 for i in range(n): a,b =map(int,input().split(" ")) if(a**2 + b**2 == d): c += 1 print(c)
p03435
s764146867
Wrong Answer
c1 = list(map(int,input().split())) c2 = list(map(int,input().split())) c3 = list(map(int,input().split())) if (sum(c1)+sum(c2)+sum(c3))%3 == 0: print("Yes") else: print("No")
p03778
s862610990
Wrong Answer
w, a, b = map(int, input().split()) if a <= b and b <= a+w: print(0) elif b <= a+w and a <= b: print(0) elif b + w < a: print(min(a-b-w, b-a-w))
p03000
s696594659
Accepted
N,X = map(int,input().split()) list = list(map(int, input().split())) cnt = 1 sum = 0 for i in list: sum += i if sum <= X: cnt += 1 print(cnt)
p02848
s097662253
Accepted
n=int(input()) s=input() ans="" for i in range(len(s)): num=ord(s[i])+n if num>90: num-=26 ans+=chr(num) print(ans)
p03289
s229423636
Wrong Answer
s = input() if s[0]==s[0].upper()and s[2]==s[2].upper() and s[3:-1]==s[3:-1].lower()and s[1]==s[1].lower()and s[-1]==s[-1].lower(): print("AC") else: print("WA")
p02767
s734690093
Wrong Answer
import numpy as np import math n = int(input()) lst = list(map(int, input().split())) avg = np.mean(lst) avg= math.ceil(avg) ans = 0 for _ in lst: ans += (_ - avg) ** 2 print(ans)
p03673
s757637666
Wrong Answer
n = int(input()) s = list(input().split()) res = "" for i in range(n): if i%2 == 0: res+=str(i) else: res = str(i)+res ans = "" if n%2: res =res[::-1] for x in res: ans += s[int(x)] p = list(ans) print(*p)
p02582
s497839180
Accepted
s = input() if s == "RRR": print(3) elif "RR" in s: print(2) elif "R" in s: print(1) else: print(0)
p04034
s157588382
Wrong Answer
n,m=map(int,input().split()) check=[False]*n check[0]=True for i in range(m): x,y=map(int,input().split()) x-=1 y-=1 if check[x]: check[y]=True else: continue ans=0 for i in range(n): if check[i]: ans+=1 print(ans-1)
p02719
s743242596
Accepted
# AtCoder Beginner Contest 161: C (2020/04/04) N, K = map(int, input().split()) A = abs(N-K*(N//K)) B = abs(N-K*(N//K+1)) if A < B: print(A) else: print(B)
p04034
s392468574
Accepted
def main(): n, m = list(map(int, input().split())) ans = set([1, ]) balls = [1] * n for _ in range(m): x, y = list(map(int, input().split())) if x in ans: ans.add(y) if balls[x - 1] == 1 and x in ans: ans.remove(x) balls[x - 1] -= 1 balls[y...
p03817
s274944561
Wrong Answer
x = int(input()) if x%11<=6: print(2*(x//11)+1) else: print(2*(-(-x//11)))
p02702
s153473073
Accepted
S = input() res = [0] * 2019 res[0] = 1 d = 1 a = 0 for c in reversed(S): a += int(c) * d a %= 2019 res[a] += 1 d *= 10 d %= 2019 ans = 0 for r in res: ans += r*(r-1) // 2 print(ans)
p02707
s554449984
Wrong Answer
import numpy as np import math as mt N=int(input()) #R=map(int, input().split()) A=list(map(int,input().split())) count=1 p_count=0 for i in range(0,N-1): if i==N-2: print(count) for i in range(0,N-p_count-1): print(0) elif A[i]!=A[i+1]: print(count) count=1 p...
p02663
s800086173
Wrong Answer
hmk = input('') h1 = int(hmk.split(' ')[0]) m1 = int(hmk.split(' ')[1]) h2 = int(hmk.split(' ')[2]) m2 = int(hmk.split(' ')[3]) k = int(hmk.split(' ')[4]) h = h2 - h1 m = m2 - m1 if m < 0: m = m1 - m2 h-=1 a = h*60 + m - k print(a)
p02753
s863146358
Wrong Answer
s = input() if s == 'AAA' and 'BBB': print('No') else: print('Yes')
p02687
s464197863
Accepted
s = input() if s == 'ABC': print('ARC') else: print('ABC')
p03433
s137310169
Wrong Answer
a = int(input()) b = int(input()) if a % 500 <= b: print("Yes") else: print("NO")
p02959
s103744145
Accepted
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) kill = 0 for i in range(N): if A[i] < B[i] : kill += A[i] B[i] = B[i] - A[i] kill += min(B[i] , A[i+1]) A[i+1] =max(0, A[i+1] - B[i]) else : kill += B[i] print(kill)
p03475
s350733464
Accepted
import sys input = sys.stdin.readline def main(): n=int(input()) l=tuple(tuple(map(int,input().split())) for i in range(n-1)) for i in range(n): now=0 for a,s,d in l[i:]: if now<=s:now=s+a else:now=(now+d-1)//d*d+a print(now) if __name__=="__main__": main()
p02719
s544779839
Accepted
N, K = map(int, input().split()) print(min(N%K, K-N%K))
p02577
s835493092
Accepted
n = input() ans = 0 for i in range(len(n)): ans += int(n[i]) if ans % 9 == 0: print('Yes') else: print('No')
p04012
s385743446
Wrong Answer
from sys import exit w = list(input()) w_set = list(set(w)) for i in range(len(w_set)): if w.count(w_set[i]) % 2 != 0: print("No") exit() else: print("Yes") exit()
p02791
s421467663
Accepted
N = int(input()) P = list(map(int, input().split())) mn = N+1 c = 0 for pi in P: if pi <= mn: c += 1 mn = pi print(c)
p03827
s757391007
Wrong Answer
n = int(input()) s = "" current_num = 0 max_num = 0 for c in s: current_num += 1 if c == 'I' else -1 max_num = max(max_num, current_num) print(max_num)
p03417
s937659530
Wrong Answer
n,m=map(int,input().split()) if n==1 or m==1: print(n*m-2) else: print((n-2)*(m-2))
p02642
s706767412
Wrong Answer
import math N = int(input()) A = list(map(int, input().split())) A.sort() se = set(A) if len(se) == 1 and N > 1: print(0) exit() for i in range(N): tmp = set() for s in se: if s == A[i] or s % A[i] != 0: tmp.add(s) se = tmp print(len(se))
p03329
s831156721
Accepted
N = int(input()) dp = [0] * (N+1) for i in range(1,N+1): dp[i] = float('inf') power = 1 while power <= i: dp[i] = min(dp[i], dp[i-power] +1) power *= 6 power = 9 while power <= i: dp[i] = min(dp[i], dp[i-power] + 1) power *= 9 print(dp[N])
p02600
s031804532
Accepted
x = int(input()) print(10 - x//200)
p02713
s183630756
Accepted
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline def gcd(a, b): """ return gcd of a,b ユークリッド """ a,b =max(a,b),min(a,b) while b: a, b = b, a % b return a K = int(input()) ans=0 for i in range(1,K+1): for j in range(1,K+1): i_j = gcd(i,j) fo...
p02916
s111932653
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) def main(): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(N - 1): ans += B[A[i] - 1] if A[i] + 1 == A[i+1]...
p03779
s748833756
Accepted
X=int(input()) acc=0 cnt=0 t=0 while True: if acc>=X: break t+=1 acc+=t cnt+=1 print(cnt)
p02882
s153537473
Wrong Answer
import math a,b,x = map(int,input().split()) if 2*(a**2)*b <= 2*(a**2)*x: print(math.degrees(math.atan(2*((a**2)*b-x)/a**3))) else: print(math.degrees(math.atan(a*(b**2)/2*x)))
p03076
s504676206
Accepted
A = int(input()) B = int(input()) C = int(input()) D = int(input()) E = int(input()) dishes = [A, B, C, D, E] tens = 0 ones = 10 muda = 10 for d in dishes: if d % 10 == 0: tens += d // 10 else: tens += d // 10 + 1 if d % 10 < ones: muda = d ones = d % 10 #%% if...
p02705
s081785926
Accepted
import math r = float(input()) s = r * 2 * math.pi print (s)
p03494
s922104332
Accepted
N = int(input()) A = list(map(int, input().split())) B = [] for a in A: i = 0 while a % 2 ** i == 0: i += 1 B.append(i - 1) B.sort() print(B[0])
p02797
s351246126
Wrong Answer
n, k, s = map(int, input().split()) a = [s] * k + [s + 1] * (n - k) print(*a)
p02631
s298979731
Accepted
n = input() a = list(map(int, input().split())) sum = 0 for i in a: sum ^= i for i in a: print(sum^i)
p03997
s185653002
Accepted
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
p02971
s928449494
Accepted
N = int(input()) A = [int(input()) for i in range(N)] A_sorted = list(sorted(A, reverse=True)) for i in range(N): if A[i] == A_sorted[0]: print(A_sorted[1]) else: print(A_sorted[0])
p02952
s060504420
Accepted
N=int(input()) cnt=0 for i in range(1,N+1): if(len(str(i))%2==1): cnt+=1 print(cnt)
p02988
s693607386
Accepted
n=int(input()) L=list(map(int,input().split())) M=[] ans=0 for i in range(1,n-1): M.append(L[i-1]) M.append(L[i]) M.append(L[i+1]) M.sort() if M[1]==L[i]: ans+=1 M=[] print(ans)