problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02700
s622050833
Wrong Answer
[A, B, C, D] = list(map(int, input().split())) X = A / D Y = C / B if X < Y or (X < 0 and Y < 0): print('No') else: print('Yes')
p02723
s491575744
Wrong Answer
S = input() flag = True if (S[2] != S[3]): flag = False if (S[4] != S[4]): flag = False if flag: print('Yes') else: print('No')
p02784
s314323704
Wrong Answer
hp, atk = input().split() hp = int(hp) atk = int(atk) value = 0 numlist = list((input().split())) numlist = list(map(int, numlist)) numlist = sorted(numlist, reverse=True) for i in range(atk): value = value + numlist[i] if value > hp: print("Yes") else: if i+1 == atk: print...
p03437
s106502214
Wrong Answer
x,y=map(int,input().split()) a=0 for i in range(min(x,y),max(x,y)): if x%y==0 or y%x==0: print(-1) a=1 break if i%x==0 and i%y!=0: print(i) a=1 break if a==0: print(-1)
p03721
s486540372
Accepted
N, K = map(int, input().split()) D = {} for _ in range(N): a, b = map(int, input().split()) if a not in D: D[a] = 0 D[a] += b D = sorted(list(D.items())) k = 0 for a, b in D: k += b if k>=K: print(a) exit()
p02773
s991219025
Accepted
import math import sys n = int(input()) li=[input()] for i in range(n-1): li.append(input()) li.sort() cnt = 0 tmp = 1 li.append('') for i in range(n): if (li[i] == li[i + 1]): tmp += 1 else: if(cnt<tmp): cnt=tmp tmp = 1 tmp=1 for i in range(n): if (li[i] == li[i + 1]...
p02661
s767474173
Accepted
N = int(input()) AB = [list(map(int, input().split())) for _ in range(N)] A, B = map(list, zip(*AB)) A.sort() B.sort() def median(a): n = N return a[(n+1)//2-1] if n%2 else (a[n//2-1]+a[n//2])/2 A_mid = median(A) B_mid = median(B) r = int((B_mid-A_mid) * [2, 1][N%2]) + 1 print(r)
p02730
s388135124
Accepted
S = input() index1 = (len(S)-1)//2 index2 = (len(S)+3)//2 S_sub1 = S[:index1] S_sub2 = S[index2-1:] if S == S[::-1] and S_sub1 == S_sub1[::-1] and S_sub2 == S_sub2[::-1]: print('Yes') else: print('No')
p03252
s521647527
Accepted
S = input().strip() T = input().strip() F = {} flag = 0 for i in range(len(S)): a = S[i] b = T[i] if a not in F: F[a] = b if F[a] != b: flag = 1 break for c in F: if c!=a and F[c]==b: flag = 1 break if flag==1: print("No") else: print("...
p03037
s679880095
Accepted
n, m = map(int, input().split()) lmax, rmin = map(int, input().split()) for i in range(1, m): l, r = map(int, input().split()) lmax = max(lmax, l) rmin = min(rmin, r) print(max(0, rmin-lmax+1))
p03779
s451620746
Accepted
x = int(input()) s = 0 i = 1 while True: s += i if s >= x: print(i) break i += 1
p03219
s668143525
Wrong Answer
x, y = map(int, input().split()) print(x + y/2)
p02789
s961172565
Accepted
def main(test_case,clear_case): if test_case <= clear_case: return "Yes" else: return "No" if __name__ == "__main__": input_num = input() num1 = int(input_num.split()[0]) num2 = int(input_num.split()[1]) print(main(num1,num2))
p03251
s765995873
Accepted
n, m, X, Y = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) x.sort() y.sort() x_max = x[-1] y_min = y[0] if max(X, x_max) < min(Y, y_min): print('No War') else: print('War')
p02699
s012409563
Accepted
def main(): S, W = map(int, input().split()) if S <= W: print("unsafe") else: print("safe") return 0 if __name__ == '__main__': main()
p03220
s542347263
Accepted
n=int(input()) t,a=map(int,input().split()) H=list(map(int,input().split())) newH=[(t-x*0.006,i) for i,x in enumerate(H)] newH=sorted(newH) from bisect import bisect_left, bisect_right Ht=[newH[i][0] for i in range(n)] Hi=[newH[i][1] for i in range(n)] i=bisect_left(Ht, a) if i==0: ans=Hi[0]+1 elif i==n: ans=Hi...
p03487
s652244357
Accepted
import collections N = int(input()) A = list(map(int, input().split())) c = collections.Counter(A) ans = 0 for i in set(A): if i > c[i]: ans += c[i] if i < c[i]: ans += (c[i] -i) print(ans)
p02922
s499099898
Accepted
A,B = map(int,input().split()) x = 1 ans = 0 while x < B: x += A-1 ans += 1 print(ans)
p03252
s677361003
Wrong Answer
def checkTrans(s, t): m = {} for sc, tc in zip(s, t): if tc in m: if m[tc] != sc: return False else: m[tc] = sc return True s = input() t = input() if checkTrans(s, t): print('Yes') else: print('No')
p02897
s593138262
Accepted
a = int(input()) dum = a//2 dum = a - dum print(dum/a)
p02555
s624079285
Accepted
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy INF = 10**9 if __name__ == "__main__": s = int(input()) MOD = 10**9 + 7 dp = [0]*(s + 1) if s>=3: dp[3] = 1 for i in range(4,s+1):...
p04034
s788342584
Accepted
int1 = lambda x: int(x) - 1 N, M = map(int, input().split()) red = [True] + [False] * (N-1) n_ball = [1] * N for _ in range(M): x,y = map(int1, input().split()) if red[x]: red[y] = True n_ball[x] -= 1 n_ball[y] += 1 if n_ball[x] == 0: red[x] = False else: ...
p02994
s151487253
Wrong Answer
n,l = map(int,input().split()) lst = 0 if l>=0: for i in range(1,n+1): lst+=l+(i-1) a = lst - l if l < 0 and l+n-1 >=0: for i in range(1,n+1): if l+i-1 == 0: lst+=l+(i-1) a = lst if l+n-1 <0: for i in range(1,n+1): lst+=l+(i-1) a = ...
p02693
s252761469
Accepted
import math if __name__ == "__main__": K = int(input()) A, B = map(int, input().split()) for i in range(A, B+1): if i % K == 0: ret = "OK" break else: ret = "NG" print(ret)
p03910
s343372364
Wrong Answer
N=int(input()) a=1 cnt=1 while cnt<=N: a+=1 cnt+=a A=[] S=N for i in range(a): if S==3: A.append(2) A.append(1) break if S>=(a-i): A.append(a-i) S-=(a-i) for i in (A[::-1]): print(i)
p03407
s694891340
Accepted
a, b, c = map(int, input().split()) print("Yes" if (a + b) >= c else "No")
p02911
s001468717
Accepted
N,K,Q=map(int,input().split()) pts = [K-Q]*N for _ in range(Q): A = int(input()) pts[A-1] += 1 for i in range(N): if pts[i] > 0: print('Yes') else: print('No')
p02861
s200381957
Accepted
import numpy as np import math n=int(input()) a=[] for i in range(n): a.append(list(map(int,input().split()))) a=np.array(a, dtype=object) ans=0 for i in range(n): for j in range(n): if i==j: continue else: x= (a[i]-a[j])**2 hei=math.sqrt(sum(x)) ans+= hei/n print(ans)
p02628
s188422810
Accepted
#https://atcoder.jp/contests/abc171/tasks/abc171_b [n, k]=[int(i) for i in input().split()] p=[int(i) for i in input().split()] p.sort() sum=0 for i in range(k): sum+=p[i] print(sum)
p02639
s260093981
Wrong Answer
a = list(map(int, input().split())) cnt = 1 for i in a: if a == 0: print(cnt) cnt += 1
p02994
s541457395
Accepted
def main(): N, L = (int(i) for i in input().split()) s = sum(L + i for i in range(N)) mi = 10**9 ans = -1 for i in range(N): eat = L + i if abs(eat) < mi: mi = abs(eat) ans = s - eat print(ans) if __name__ == '__main__': main()
p02732
s136122017
Accepted
import collections N = int(input()) A = list(map(int, input().split())) all_comb = 0 def combinations_count_two(n): if n < 2: return 0 else: return (n * (n - 1)) // 2 counter = collections.Counter(A) for val in counter.values(): all_comb += combinations_count_two(val) for i in A: an...
p02554
s940571300
Wrong Answer
N = int(input()) s = N * (N-1) p = 10 ** (N-2) d = s * p ans = d % (10 ** 9 + 7) print(ans)
p02768
s261213531
Accepted
import math import sys import collections import bisect readline = sys.stdin.readline def main(): n, a, b = map(int, readline().rstrip().split()) mod = 10 ** 9 + 7 ans = pow(2, n, mod) - 1 nca, ncb = 1, 1 for i in range(b): ncb = ncb * (n - i) % mod ncb *= pow(i + 1, mod - 2, mo...
p02880
s413386568
Wrong Answer
n = int(input()) ans = 0 for i in range(1,10): for j in range(1,10): if n == (i*j): ans = 1 break if ans == 1: print('YES') else: print('NO')
p03944
s916266017
Wrong Answer
import numpy as np W, H, N = map(int, input().split()) ze = np.ones((W, H)) for i in range(N): x, y, a = map(int, input().split()) if a == 1: ze[:x, :] = 0 elif a == 2: ze[x+1:, :] = 0 elif a == 3: ze[:, :y] = 0 elif a == 4: ze[:, y+1:] = 0 print(np.sum(ze))
p03327
s763713200
Accepted
n = int(input()) if 1 <= n and n <= 999: print("ABC") else: print("ABD")
p02554
s882941011
Wrong Answer
if __name__ == "__main__": N=int(input()) a = N * (N-1) * 10 ** (N-2) a = a % (10 ** 9 + 7) print(a)
p02900
s940433996
Wrong Answer
A, B = map(int, input().split()) M = max(A, B) m = min(A, B) ans = 0 tmp = m l = [] for i in range(2, int(-(-m**0.5//1))+1): if tmp % i == 0 and M % i == 0: ans += 1 l.append(i) while tmp % i == 0: tmp //= i if m != 1: ans += 1 if ans == 0 and M % m == 0: ans += 1 pr...
p02707
s218436308
Wrong Answer
n = int(input()) A =[int(x) for x in input().split()] ans = [0] * n for i in range(n-1): ans[A[i]-1] +=1 for i in ans: print(ans[i])
p02795
s252624722
Accepted
H=int(input()) W=int(input()) N=int(input()) K=H if K<W: K=W sum = 0 ans= 0 for i in range(1,K+1): if sum < N: sum += K ans = i #print(ans, K) print(ans)
p02608
s086709095
Wrong Answer
import itertools n = int(input()) ans_d = {i: 0 for i in range(1,10001)} p = itertools.product(range(1, 100), range(1, 100), range(1, 100)) for x, y, z in p: cnt = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (x * z) if cnt <= 10000: ans_d[cnt] += 1 for i, j in ans_d.items(): print(i,j) ...
p03160
s186192350
Accepted
N = int(input()) H = [int(x) for x in input().split()] dp = [0]*N dp[0] = 0 dp[1] = abs(H[1]-H[0]) for i in range(2,N): dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2])) print(dp[N-1])
p04034
s597373317
Wrong Answer
n,m = map(int,input().split()) x_y = [list(map(int,input().split())) for _ in range(m)] start = 1 aka_list = [1] for i in range(m): if x_y[i][0] == start: if start == 1: aka_list.remove(1) aka_list.append(x_y[i][1]) start = x_y[i][1] balls = [1]*n for i in range(m): balls[x_...
p03469
s671297858
Wrong Answer
n = input() n.replace("2017","2018") print(n)
p03261
s752424579
Accepted
n=int(input()) w=[input() for i in range(n)] m=w[0][-1] for i in range(1,n): if w.count(w[i])==1 and m==w[i][0]: m=w[i][-1] else: print('No') exit() print('Yes')
p03838
s024167439
Accepted
a, b = map(int, input().split()) if b > a >= 0 or a < b <= 0: print(abs(a-b)) elif a > b > 0 or 0 > a > b: print(abs(a-b)+2) else: print(abs(abs(a)-abs(b))+1)
p02922
s406139761
Wrong Answer
import math A,B = list(map(int,input().split())) ans = 1 c = 0 if B <= A: print("1") else: while ans < B: ans += A-1 c += 1 print(c)
p02660
s450499851
Wrong Answer
n = int(input()) if n > 1: ans = 1 else: ans = 0 i = 2 while i<=10**6: if n % i == 0: ans+=1 n //= i i += 1 print(ans)
p02732
s326804849
Accepted
import math N = int(input()) A = list(map(int, input().split())) count = [0]*N for i in range(N): count[A[i] - 1] += 1 sum = 0 for i in range(N): t = count[i] if t >= 2: sum += math.factorial(t) // (math.factorial(t - 2) * 2) for i in range(N): t = count[A[i] - 1] if t > 1: print...
p02602
s215322485
Wrong Answer
import numpy as np N, K = map(int, input().split()) A = list(map(int, input().split())) ep = K fp = 0 bs = np.prod(A[fp:ep]) for i in range(1, N - K + 1): s = np.prod(A[fp + i: ep + i]) if s > bs: print('Yes') else: print('No') bs = s
p03377
s303453360
Accepted
A, B, X = map(int, input().split()) print("YNEOS"[not (A<=X<=A+B)::2])
p03309
s674630796
Accepted
N = int(input()) A = list(map(int,input().split())) def cal(A,b): a = 0 for i in range(len(A)): a += abs(A[i] - b) return a #cal(A,b)の値の最小値 A_2 = A for i in range(N): A_2[i] = A[i] - (i+1) A_2.sort() if N%2 == 0: cnum = N//2 - 1 chu = A_2[cnum] else: cnum = (N-1)//2 chu = A_2[cn...
p02661
s394184098
Wrong Answer
from statistics import median t=int(input()) n=t low=list() high=list() while t!=0: t-=1 L,H=list(map(int,input().split())) low.append(L) high.append(H) diff=int(median(high)-median(low)) if n%2 == 0: ans=(diff*2)+1 print(ans) else: ans=diff+1 print(ans)
p03250
s144976015
Wrong Answer
A,B,C=map(int,input().split()) ichi=10*A+B+C two=A+10*B+C print(max(ichi,two))
p02963
s803606008
Accepted
s = int(input()) x1 = 0 y1 = 0 x2 = 10 ** 9 y2 = 1 if s < 10 ** 9: y3 = 0 x3 = s else: mod = s % 10 ** 9 if mod == 0: y3 = s // 10 ** 9 x3 = 0 else: y3 = s // 10 ** 9 + 1 x3 = 10 ** 9 - mod print(x1, y1, x2, y2, x3, y3)
p02618
s194205454
Accepted
d = int(input()) C = list(map(int, input().split())) T = [] for i in range(d): S = list(map(int, input().split())) index = S.index(max(S)) T.append(index+1) for t in T: print(t)
p02993
s947304094
Wrong Answer
S=input() l=set(S) if len(l)==4: print('Good') else: print('Bad')
p03067
s642906111
Wrong Answer
a,b,c = map(int, input().split()) if a <= c <= b: print('Yes') else: print('No')
p03543
s243295141
Wrong Answer
n = input() if len(set(n))<= 2: print('Yes') else: print('No')
p02687
s580976233
Wrong Answer
s = input() if s == "ABC": print("ARC") else: print("ARC")
p02594
s831839023
Accepted
X = int(input()) print('Yes' if X >= 30 else 'No')
p03486
s667399623
Accepted
s = sorted(list(input())) t = sorted(list(input()), reverse = True) if s < t: print("Yes") else: print("No")
p03605
s600136324
Wrong Answer
N=input() N=int(N[0])*int(N[1]) print("Yes" if N%9==0 else "No")
p03309
s796830051
Wrong Answer
n = int(input()) lst = list(map(int, input().split())) m = [] for i, l in enumerate(lst,start=1): m.append(l-i) ave = int(sum(m)/n) cand = [] for b in range(ave-3, ave+3): tmp = sum([abs(val-i-b) for i, val in enumerate(lst, start=1)]) cand.append(tmp) print(min(cand))
p02923
s131218653
Accepted
import math import copy neko = 0 nuko = 0 inu = 0 n = int(input()) h = [int(x) for x in input().split()] nya = h[0] h = h[1:] for i in h: if nya >= i: neko += 1 else: neko = 0 if neko > inu: inu = neko nya = i print(inu)
p03548
s871312843
Accepted
x, y, z = map(int, input().split()) c = (x - z)//(y+z) print(c)
p03617
s551722783
Accepted
q,h,s,d = map(int,input().split()) n = int(input()) a = 0 if n%2 == 1: n -= 1 a += 1 ans = n//2*min(8*q,4*h,2*s,d)+a*min(4*q,2*h,s) print(ans)
p03264
s759553514
Wrong Answer
K=int(input()) print((K/2)**2 if K%2==0 else (K//2)*(K//2+1))
p03624
s728796405
Accepted
s = input() for i in range(97,123): if not chr(i) in s: print(chr(i)) exit() print("None")
p03387
s731652179
Accepted
abc = sorted(list(map(int, input().split()))) ans = 0 if (abc[1]-abc[0])%2 == 1: ans += 1 abc[1] += 1 abc[2] += 1 ans += (abc[1]-abc[0])//2 abc[0] += abc[1]-abc[0] ans += abc[2]-abc[1] print(ans)
p02836
s513949347
Wrong Answer
N = input() count = 0 X = len(N) -1 for i in range(int(X/2)): if N[i] != N[-1]: count += 1 print(count)
p02646
s305661765
Accepted
a,asp=map(int, input().split(" ")) b,bsp=map(int, input().split(" ")) t=(int)(input()) if asp > bsp: print("YES") if abs(b-a)/(asp-bsp) <= t else print("NO") else: print("NO")
p03481
s106497061
Wrong Answer
import math x,y = map(int,input().split()) if x == 1: print(y-x+1) else: print(int(math.log2(y/x))+1)
p03548
s693606541
Accepted
x,y ,z= map(int,input().split()) print((x-z)//(y+z))
p02730
s037842042
Wrong Answer
S=input() N=len(S) M=N//2 def kaibun(x): n=len(x) m=n//2 if x[:m]==x[m+1:][::-1]: return True else: return False if all([kaibun(S),kaibun(S[:M])]): print("Yes") else: print("No")
p03324
s891720907
Accepted
D, N = map(int,input().split()) if D == 0: if N < 100: print(N) else: print(101) elif D == 1: if N < 100: print(N*100) else: print(10100) else: if N < 100: print(N*10000) else: print(1010000)
p03699
s720192905
Wrong Answer
N = int(input()) s = [int(input()) for _ in range(N)] s.sort() while sum(s) % 10 == 0 and len(s) != 0: s = s[1:] print(sum(s))
p03469
s902834947
Accepted
N = list(input()) print("2018/01/"+N[-2]+N[-1])
p03241
s566933236
Accepted
# AGC112 D - Partition from math import floor def divisor(n): i = 1 table = [] while i * i <= n: if n%i == 0: table.append(i) table.append(n//i) i += 1 table = list(set(table)) return table n,m=map(int,input().split()) n_max=floor(m/n) div_m=divisor(m) div...
p03723
s634973286
Accepted
A, B, C = map(int, input().split()) cnt = 0 while A % 2 == B % 2 == C % 2 == 0: # print(A, B, C) if A == B == C: print(-1) break A, B, C = (B+C)//2, (C+A)//2, (A+B)//2 cnt += 1 else: print(cnt)
p03071
s819278676
Accepted
#A a,b = map(int,input().split()) cnt = 0 if a > b: cnt += a a -= 1 else: cnt += b b -= 1 if a > b: cnt += a a -= 1 else: cnt += b b -= 1 print(cnt)
p03657
s851521356
Accepted
a, b = map(int, input().split()) if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0: print("Possible") else: print("Impossible")
p02916
s054236937
Accepted
N = int(input()) A, B, C = [list(map(int, input().split())) for i in range(3)] S = 0 for i in range(N): S += B[i] try: if A[i+1] == A[i]+1: S += C[A[i]-1] except IndexError as e: continue print(S)
p03481
s113668024
Accepted
import sys def solve(): input = sys.stdin.readline X, Y = map(int, input().split()) length = 0 now = X while now <= Y: now *= 2 length += 1 print(length) return 0 if __name__ == "__main__": solve()
p03075
s009164762
Wrong Answer
# coding: utf-8 #Author:Code a = input() b = input() c = input() d = input() e = input() k = input() if k > e - a: print "Yay!" else: print ":("
p03623
s016204487
Wrong Answer
import sys s = list(set(input())) s.sort() alp = list('abcdefghijklmnopqrstuvwxyz') count = 0 for s_,alp_ in zip(s,alp): if s_ != alp_ : print(alp_) sys.exit() count += 1 print('None' if count == 24 else alp[count])
p02918
s916047129
Accepted
def resolve(): N, K = list(map(int, input().split())) S = list(input()) base = 0 prev = S[0] for i in range(1, N): if prev == S[i]: base += 1 prev = S[i] print(min(base+2*K, N-1)) if '__main__' == __name__: resolve()
p03665
s067189458
Accepted
n,p = map(int, input().split()) a = list(map(int,input().split())) if all(i%2==0 for i in a): print(0 if p==1 else 2**n) else: print(2**(n-1))
p02910
s643779408
Wrong Answer
s = input() oddStep = ['R','U','D'] evenStep = ['L','U','D'] CNST_NO = 'No' CNST_YES = 'Yes' good_step = CNST_YES for i in range( len( s )): if i % 2 == 0: if not ( s[ i ] in evenStep ): good_step = CNST_NO else: if not( s[ i ] in oddStep ): good_step = CNST_NO if good_step == CNST_NO: ...
p02995
s986182852
Accepted
import fractions A,B,C,D=map(int,input().split()) A-=1 E=C*D//fractions.gcd(C,D) print(B-B//C-B//D+B//E-A+A//C+A//D-A//E)
p03220
s719024061
Wrong Answer
n = int(input()) t, a = [int(i) for i in input().split()] h = [int(i) for i in input().split()] l = [abs(a-(12-i*0.006)) for i in h] print(l.index(min(l))+1)
p03455
s813655025
Accepted
a, b = map(int,input().split()) if a*b % 2 != 0: print('Odd') else: print('Even')
p03360
s731136734
Accepted
a,b,c = map(int,input().split()) k = int(input()) ans = a+b+c-max(a,b,c) ans += max(a,b,c)*2**k print(ans)
p02682
s259181316
Accepted
import sys input = sys.stdin.readline input = sys.stdin.buffer.readline def RD(): return sys.stdin.read() def II(): return int(input()) def MI(): return map(int,input().split()) def LI(): return list(map(int,input().split())) def TI(): return tuple(map(int,input().split())) def RN(N): return [input().strip() for i in ...
p03475
s253085287
Accepted
n=int(input()) l=[0]*n for i in range(1,n): c,s,f=map(int,input().split()) for j in range(i): l[j]=max(-(-l[j]//f)*f,s)+c print(*l,sep='\n')
p03698
s093801038
Wrong Answer
S = list(input()) s = set(S) if len(s) == len(S): print("yes") else: print("No")
p03639
s854716530
Accepted
n = int(input()) a = list(map(int, input().split())) cnt4,cnt2=0,0 for i in a: if i % 4 == 0: cnt4 += 1 elif i % 2 == 0: cnt2 += 1 cnt2 = max(1,cnt2) print('Yes' if 2 * cnt4 + cnt2 >= n else 'No')
p02618
s998155471
Accepted
for i in range(365): print(i%26+1)
p03986
s559599811
Accepted
import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): X = str(input()) stack = 0 pop = 0 for i in range(len(X)): if X[i] == 'S': stack += 1 elif X[i] == 'T' and stack > 0: pop += 1 stack -= ...