problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02823
s973828945
Wrong Answer
N, A, B = map( int, input().split() ) if ( A + B ) % 2 == 0: print( (abs( A - B ) + 1) // 2 ) else: print( min( max( A, B ) - 1, max( N - A, N - B ) - 1 ))
p02702
s691135538
Wrong Answer
s = str(input()) count = 0 for i in range(len(s)+1): for j in range(len(s)+1): if i < j: if int(s[i:j]) % 2019 == 0: print(s[i:j]) count += 1 print(count)
p03387
s469425935
Accepted
ABC = list(map(int, input().split())) ABC.sort(reverse=True) max_val = ABC[0] second_max_val = ABC[1] ans = max_val - second_max_val min_val = ABC[2] + ans diff = max_val - min_val if diff % 2 == 0: ans += diff // 2 else: ans += diff // 2 + 2 print(ans)
p03380
s210782616
Wrong Answer
n = int(input()) a = sorted(map(int, input().split())) p = a[-1] b =10000000 c = 0 for i in range(n-1): if abs(a[i]-p/2) < b: b = abs(a[i]-p/2) c = a[i] else: break print(p,c)
p02553
s846759016
Accepted
a,b,c,d=map(int,input().split()) print(max(a*c,a*d,b*c,b*d))
p02693
s137279411
Accepted
K = int(input()) A,B = map(int,input().split()) for i in range(1,1000): x = K * i if A <= x <= B: print('OK') exit() else: continue print('NG')
p02700
s068331818
Accepted
A, B, C, D =map( int, input().split() ) takahashi_win = False while (A > 0) and ( C > 0 ): C -= B if C <= 0: takahashi_win = True A -= D if takahashi_win: print('Yes') else: print('No')
p02784
s174544980
Accepted
H,N = map(int, input().split()) A = list(map(int, input().split())) if sum(A)>=H: print('Yes') else: print('No')
p03617
s854584367
Wrong Answer
*l, n = map(int, open(0).read().split()) c = 0 for i, j in sorted([j*2**(2-i), 2**(i-2)] for i, j in enumerate(l)): t = n//j*j c += i*t n -= t if not n: print(int(c)) exit()
p02633
s428669316
Accepted
import math n = int(input()) print(360*n//math.gcd(360,n)//n)
p03380
s172840126
Accepted
n = int(input()) a = list(map(int, input().split())) # n_C_rの最大化 # nは出来るだけ大きい方が良く、rは出来るだけn/2に近い方が良い # n>rという条件があるので、サンプル2では(100,100)は許されない # x = max(a) y = float("inf") for ai in a: if abs(x / 2 - ai) < abs(x / 2 - y) and ai < x: y = ai print(x, y)
p03408
s663848275
Accepted
from collections import Counter n = int(input()) s = [None] * n for i in range(n): s[i] = input().rstrip() m = int(input()) t = [None] * m for i in range(m): t[i] = input().rstrip() ctr = Counter(s) - Counter(t) if ctr: print(ctr.most_common(1)[0][1]) else: print(0)
p03997
s685955640
Accepted
#!/usr/bin/env python3 import sys INF = float("inf") def solve(a: int, b: int, h: int): print(h*(a+b)//2) return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() a = int(next(tokens)) # t...
p03221
s534428694
Accepted
N,M=map(int,input().split()) A=[[] for i in range(N)] for i in range(M): a,b=map(int,input().split()) A[a-1].append((b,i)) ans=[0]*M for i in range(N): d=sorted(A[i]) n=len(d) for j in range(n): a,b=d[j] D=str(i+1) E=str(j+1) r=D.zfill(6)+E.zfill(6) ans[b]=r for i in ans: print(i)
p03821
s310856048
Accepted
N = int(input()) lisAB = [list(map(int,input().split())) for _ in range(N)] ans = 0 for A,B in lisAB[::-1]: if (A+ans)%B == 0: continue else: num = B - (A+ans)%B ans += num print(ans)
p03075
s031254023
Wrong Answer
line2 = [] for i in range(5): line = int(input()) line2.append(line) long = int(input()) if line2[4] - line2[0] <= long: print("Yey!") else: print(": (")
p03077
s096702378
Accepted
import math N = int(input()) listA = [] for i in range(5): listA.append(int(input())) print(math.ceil(N / min(listA)) + 4)
p02832
s974364505
Wrong Answer
A = int(input()) B = list(map(int,input().split(" "))) memory = 1 for i in range(A): if B[i] == memory: memory += 1 else: continue print(A-(memory-1))
p02572
s745112238
Accepted
def solve(): N = int(input()) A = list(map(int, input().split())) sum_a = 0 tmp = 0 for i in range(N-1): tmp += A[i] sum_a += tmp * A[i+1] # print(sum_a) ans = sum_a % 1000000007 print(ans) if __name__ == "__main__": solve()
p03479
s010109529
Accepted
X,Y = map(int, input().split()) ans = 0 while X <= Y: ans += 1 X <<= 1 print(ans)
p02693
s837319447
Wrong Answer
import sys k = int(input()) a,b = map(int,input().split()) #if k==1: # print('Ok') # sys.exit() wk = (a//k) while wk*k <=b: print('Ok') sys.exit() wk+=1 print('NG')
p03252
s395071929
Accepted
s = input() t = input() cs = [] ct = [] for i in range(97,97+26): cs.append(s.count(chr(i))) ct.append(t.count(chr(i))) if sorted(cs) == sorted(ct): print("Yes") else: print("No")
p03815
s894373177
Accepted
x=int(input()) a,b=divmod(x,11) ans=0+a*2 if b==0: pass elif b>6: ans+=2 else: ans+=1 print(ans)
p03680
s735006876
Accepted
n = int(input()) a = [int(input()) for _ in range(n)] flag = [True]*n t = a[0] ans = 1 while t != 2: if flag[t-1]: flag[t-1] = False t = a[t-1] ans += 1 else: print(-1) exit() print(ans)
p02615
s421859001
Wrong Answer
N = int(input()) A = list(map(int,input().split())) A.sort(reverse = True) ans = A[0]+A[1] for i in range(2,N-1): ans += max(A[i],A[i-1]) print(max(ans,sum(A[:-1])))
p02730
s053371674
Accepted
S = input() N = len(S) def func(S,ans,N): for i in range(N): if S[i] != S[N - i-1]: ans ='No' return (ans) ans = func(S, 'Yes',(len(S)-1//2)) S1 = S[(N+3)//2-1:N] ans = func(S1, ans,len(S1)) print(ans)
p03437
s481402059
Accepted
X,Y = map(int,input().split()) if X%Y == 0: print(-1) else: print(X*(Y-1))
p03001
s877929628
Accepted
mi = lambda : map(int, input().split()) w, h, x, y = mi() s = w*h if 2*x == w and 2*y == h: hantei = 1 else: hantei = 0 print(*[s/2, hantei])
p02766
s142716317
Accepted
N, K = map(int, input().split()) count = 0 while N >= K ** count: count += 1 print(count)
p03469
s268881945
Accepted
def main(): date = list(str(input())) date[3] = '8' ans = '' for i in date: ans = ans + i print(ans) main()
p03351
s129427906
Wrong Answer
a,b,c,d=map(int, input().split()) print("Yes" if abs(a-c)<d or abs(a-b)<d and abs(b-c)<d else "No")
p03254
s283495585
Accepted
n,x=map(int,input().split()) l=list(map(int,input().split())) l=sorted(l) ans=0 for i in l: x-=i ans+=1 if x<0: break if x!=0 and ans>0: print(ans-1) else: print(ans)
p02705
s453840867
Accepted
R=int(input()) print(R*2*3.141592)
p02838
s517987776
Accepted
import sys input = sys.stdin.readline import numpy as np def main(): MOD = 10**9+7 n = int(input()) A = np.array(input().split(), dtype=np.int64) ans = 0 for j in range(61): X = A>>j & 1 t = np.count_nonzero(X) ans += pow(2, j, MOD) * t * (n-t) % MOD print(ans%MOD) if __name__ == "__main__"...
p04034
s601708703
Accepted
N,M = map(int, input().split()) balls = [1]*(N+1) reds = [False]*(N+1) reds[0] = True for i in range(M): x,y = map(int, input().split()) x -= 1 y -= 1 balls[x] -= 1 balls[y] += 1 if reds[x]: reds[y] = True if balls[x] == 0: reds[x] = False print(sum(reds))
p02880
s575754095
Wrong Answer
def notprime(n): for i in range(2,int(n**0.5)): if n%i==0: return True return False n = int(input()) if 1<=n<=81: if n%10==0: print('Yes' if n==10 else 'No') else: print('Yes' if notprime(n) else 'No') else: print('No')
p03761
s397467653
Wrong Answer
n=int(input()) ans=[] mins=55 a=[list(input()) for _ in range(n)] for i in range(n): if mins > len(a[i]): mins=min(mins,len(a[i])) m=i for i in a[m]: flg=0 for j in a: if i not in j: flg=1 if flg==0: ans.append(i) ans.sort() print(*ans,sep='')
p02691
s489753788
Wrong Answer
from collections import Counter N,*A = map(int,open(0).read().split()) #j - i = Aj + Ai #j - Aj = Ai + i #L = i + Ai, R = j - Aj とおく L = [] R = [] for i in range(N): L.append(i+1 + A[i]) R.append(i+1 - A[i]) l = Counter(L) r = Counter(R) cnt = 0 a=[] for i in range(1,N+1): if i in l and i in r: c...
p02924
s139040546
Wrong Answer
N = int(input()) count =0.01 count = int(N*(N-1)/2) print(int(count))
p03779
s805600630
Wrong Answer
x=int(input()) i=1 if x==0: print(0) else: while True: if (i-2)*(i-1)/2+1<=x+1<=i*(i-1)/2: break i+=1 print(i-1)
p02701
s674519908
Wrong Answer
from collections import Counter import sys s = sys.stdin.readlines() n = int(s[0][:-1]) dct={} cnt = 0 for i in range(1, n): if s[i][:-1] not in dct.keys(): dct[s[i][:-1]] = 1 cnt += 1 if n > 1: if s[n] not in dct.keys(): dct[s[n]] = 1 cnt += 1 print(cnt)
p02859
s961378317
Accepted
print(int(input())**2)
p02779
s984421024
Wrong Answer
N = int(input()) A = list(input()) SET_A = set(A) if len(A)==len(SET_A): print("YES") else: print("NO")
p03698
s456733447
Accepted
from collections import defaultdict S = input() d = defaultdict(int) for i in range(len(S)): d[S[i]] += 1 for val in d.values(): if val != 1: print("no") exit() print("yes")
p02629
s454560156
Wrong Answer
ans = "" N = int(input()) for i in range(10000): tmp = N%26 ans += chr(96+tmp) N //= 26 if N <= 0: break print(ans[::-1])
p03469
s933934315
Accepted
print('2018' + input()[4:])
p03309
s136358080
Accepted
# -*- coding: utf-8 -*- import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) A = list(map(int,readline().split())) for i in range(N): A[i] -= (i+1) A = sorted(A) k = N // 2 b = A[k] ans = 0 for i in range(N): ans += abs(A[i]-b)...
p02795
s459594404
Wrong Answer
H = int(input()) W = int(input()) N = int(input()) ans = 0 num_bk = 0 for i in range(0,min(H,W)+1): num_bk += max(H,W) ans +=1 if num_bk>N: print(ans) break
p03324
s547196661
Wrong Answer
d, n = map(int, input().split()) print(n * (100 ** d))
p03449
s799880326
Accepted
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline n = int(input()) a = [list(map(int, input().split())) for _ in range(2)] max = 0 for i in range(n): tmp = 0 for j in range(i + 1): tmp += a[0][j] for j in range(i, n): ...
p02755
s233185731
Accepted
import math a,b=map(int,input().split()) ans=-1 tmp=b*10 for x in range(tmp-20,tmp+20): if math.floor(x*0.08)==a and math.floor(x*0.10)==b: ans=x break print(ans)
p03827
s855946267
Wrong Answer
if __name__ == '__main__': a = int(input()) s = input() count =0 for i in s: if i == "I": count +=1 else: count -=1 print(count)
p02553
s482915102
Accepted
import sys def solve(): A, B, C, D = [int(i) for i in input().split()] ans = sys.maxsize * -1 X = [0, A, B] if A <= 0 <= B else [A, B] Y = [0, C, D] if A <= 0 <= B else [C, D] for x in X: for y in Y: ans = max(ans, x * y) print(ans) if __name__ == "__main__": solve()
p02570
s978170955
Wrong Answer
D, T, S = map(int, input().split()) if(T*S>D): print('YES') if(T*S<=D): print('NO')
p02676
s695200977
Accepted
max_len = int(input()) s = input() if len(s) > max_len: print(f"{s[:max_len]}...") else: print(s)
p02596
s972825162
Wrong Answer
b = int(input()) list = [7] for i in range(b): list.append(list[-1]*10 +7) for l in range(b%10, len(list)): if list[l] % b == 0: print(b%10 + l) exit()
p03861
s762976090
Accepted
# from decimal import Decimal a, b, c = map(int, input().split()) print(b//c - a//c if a%c != 0 else b//c - a//c +1)
p02842
s446578494
Accepted
import math N = int(input()) count = 0 ans = 0 for i in range(N+1): money = 0 money = math.floor(i*1.08) if money == N: count += 1 ans = i break if count == 0: print(":(") else: print(ans)
p02552
s987115842
Wrong Answer
x= input() if x==0: print(1) elif x==1: print(0)
p02811
s496657264
Accepted
K,X = map(int,input().split()) print('Yes' if X <= K*500 else 'No')
p03408
s838054671
Accepted
n=[input() for _ in range(int(input()))] m=[input() for _ in range(int(input()))] l=list(set(n)) print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))
p02642
s763823716
Accepted
n=int(input()) b=list(map(int,input().split())) ans=0 w=max(b) a=[0]*(w+1) for i in b: x=i while x<=w: a[x]+=1 x+=i for i in b: if a[i]==1: ans+=1 print(ans)
p03435
s935249621
Accepted
import sys C = [list(map(int,input().split())) for _ in range(3)] for j in range(2): for i in range(2): if C[i+1][j+1]-C[i+1][j]!=C[i][1+j]-C[i][j]: print('No') sys.exit() print('Yes')
p02723
s904672523
Wrong Answer
S=input() if S[2]==S[3] and S[4]==S[5]: print("yes") else: print("No")
p02756
s195837738
Accepted
import sys from collections import deque def input(): return sys.stdin.readline().strip() S = input() Q = int(input()) q = deque(S) flipped = False for _ in range(Q): q_t, *q_d = input().split() if q_t == "1": flipped = not flipped else: F, C = q_d if (not flipped and F == "2...
p02861
s326097956
Accepted
import itertools n = int(input()) p = [[0 for i in range(2)] for j in range(n)] for i in range(n): p[i][0],p[i][1] = map(int,input().split()) #print(p) def dis(a,b): dis = (a[0]-b[0]) ** 2 + (a[1]-b[1]) **2 return dis ** (1/2) perm = [i for i in range(n)] total = 0 num = 0 for v in itertools.permutations(pe...
p02836
s152328392
Wrong Answer
S = list(input()) cnt = 0 if len(S)%2 == 0: for i in range(0,int(len(S)/2+1)): if S[i] != S[-1-i]: cnt +=1 else: for i in range(0,int(len(S)/2)): if S[i] != S[-1-i]: cnt +=1 print(cnt)
p03696
s790987955
Wrong Answer
n = int(input()) s = str(input()) ans = "" index = 0 left = 0 right = 0 for i in range(n): if s[-i-1] == ")": index = n - i break lis = s[:index] left = lis.count("(") right = lis.count(")") if right >= left: ans += "(" * (right-left) + s + ")" * (n-index) else: ans += s + ")" * (le...
p04020
s468103107
Wrong Answer
import sys stdin = sys.stdin import itertools mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) N = ni() A = list() for _ in range(N): A.append(ni()) cnt = 0 for i in range(N-1): ccnt = (A[i] + A[i+1]) //2 A[i+1] -= max(0, ...
p02624
s990618202
Accepted
n = int(input()) ans = 0 for i in range(1,n+1): ans += (i + (n//i)*i) * (n//i) // 2 print(ans)
p03035
s987230758
Accepted
a, b = map(int, input().split()) if a > 12: print(b) elif 6 <= a <= 12: print(b//2) elif 0 <= a <= 5: print(0)
p03778
s025716457
Wrong Answer
w, a, b = list(map(int, input().split())) diff = b - a - w print(max([diff, 0]))
p03077
s956788808
Wrong Answer
N = int(input()) lst = [int(input()) for _ in range(5)] #print(lst) #print(min(lst),N//min(lst)) if min(lst) > N: print(5) else: print(N//min(lst)+5)
p03672
s056946866
Accepted
S = list(input()) # i = 2 while S != []: S.pop() S.pop() l = len(S) half = int(l / 2) # print(S) # print(S[0:half]) # print(S[half:]) if S[0:half] == S[half:]: print(l) exit()
p02820
s377977004
Wrong Answer
n, k = map(int,input().split()) r, s, p = map(int,input().split()) l = list(input()) ans = 0 def jan(a): if a == "r": return p elif a == "s": return r return s for i in range(len(l)): if i<k: ans += jan(l[i]) elif l[i] != l[i-k]: ans += jan(l[i]) print(ans)
p03815
s363355169
Accepted
N=int(input()) a=N//11 ans=2*a b=N-11*a if 0<b<=6: ans+=1 elif 6<b<=10: ans+=2 print(ans)
p03043
s857101207
Wrong Answer
import math ans = 0 N, K = map(int, input().split()) dp = [[0] * (2*K + 1) for _ in range(int(math.log2(K)) + 2)] for i in range(1, N + 1): if i < 2*K + 1: dp[0][i] = 1 / N else: ans += 1 / N for cnt in range(1, int(math.log2(K)) + 2): for now in range(1, 2*K + 1): if now % 2 == 0:...
p02577
s793762515
Accepted
#!/usr/bin/python from sys import stdin from keyword import iskeyword if __name__ == "__main__": n = int(input()) if n % 9 == 0: ret = "Yes" else: ret = "No" print(ret)
p02701
s778473328
Wrong Answer
def solve(): number=int(input()) items=[] for i in range(number): item=input() items.append(item) count=1 for i in range(1,number): if items[i]!=items[i-1]: count+=1 print(count) return solve()
p03417
s619137750
Wrong Answer
N,M = map(int,input().split()) if N == 1 and M == 1: print(0) elif N == 1 or M == 1: print(max(N,M)-2) else: print((N-2)*(M-2))
p02628
s841410351
Wrong Answer
a, b = [int(x) for x in input().split()] cs = [int(x) for x in input().split()] print(a, b) print(cs) cs.sort() print(sum(cs[:b]))
p03285
s436484698
Accepted
n = int(input()) dp = [False]*110 dp[4] = dp[7] = True for i in range(101): if dp[i]: dp[i+4] = True dp[i+7] = True if dp[n]: print("Yes") else: print("No")
p02882
s621711286
Accepted
import math a,b,x = map(int,input().split()) if x>=a*a*b*0.5: theta = math.degrees(math.atan(2*(a*a*b-x)/a**3)) else: theta = math.degrees(math.atan(0.5*a*b*b/x)) print(theta)
p03623
s466145620
Accepted
x, a, b = map(int, input().split()) if abs(x - a) < abs(x - b): print('A') else: print('B')
p02838
s596938962
Accepted
N = int(input()) M = list(map(int, input().split())) M = [bin(m)[2:] for m in M] max_len = max([len(m) for m in M]) M = ["0"*(max_len-len(m))+m for m in M] MOD = 10**9+7 result = 0 for i in range(1, max_len+1): zero = len([m[-i] for m in M if m[-i]=="0"]) one = len(M) - zero #print(one, zero, i) result += (((on...
p02700
s882830078
Accepted
import collections import sys import numpy as np sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop MOD = 10**9+7 import itertools import math a,b,c,d = map(int,input().split()) i = 0 cnt1 = 0 while True: if a<=0: break cnt1+=1 a -= d cnt2 = 0 while True: i...
p03150
s478752898
Wrong Answer
S = input() key = 'keyence' if 'keyence' in S: print('YES') else: ans = 'NO' for i in range(1,6): f = key[:i] if S[:i] == f: if key[i:][::-1] == S[::-1][:7-i]: ans = 'YES' break print(ans)
p02664
s771535648
Wrong Answer
t = input() t = t.replace('?', 'P') t = list(t) for i in range(1, len(t)): if t[i-1] == 'P' and t[i] == 'P': t[i] = 'D' print(''.join(t))
p02701
s424868970
Accepted
n=int(input()) lst=set() for i in range(n): lst.add(input()) print(len(lst))
p02729
s020033754
Wrong Answer
from scipy.special import comb n, m = map(int, input().split()) print(n * m + comb(n, 1, exact=True) + comb(m, 1, exact=True))
p02578
s074189866
Accepted
N = int(input()) A = list(map(int,input().split())) now_max = A[0] ans = 0 for i in range(N): if A[i] > now_max: now_max = A[i] else: ans += now_max - A[i] print(ans)
p02607
s528472895
Wrong Answer
# coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read #from heapq import heappop, heappush #from collections import defaultdict sys.setrecursionlimit(10**7) #import math #from itertools import product, accumulate, combinations, product #import bisec...
p02600
s546460689
Accepted
from sys import stdin input = stdin.buffer.readline x = int(input()) print(8 - (x - 400) // 200)
p03076
s039417098
Accepted
import itertools import math antena = [] antena.append(int(input())) antena.append(int(input())) antena.append(int(input())) antena.append(int(input())) antena.append(int(input())) mod = [] idx = 0 for i in range(len(antena)): mod.append(antena[i] % 10) if(mod[i] == 0): mod[i]=10 idx = mod.index(min(...
p02718
s359121332
Accepted
n, m = map(int, input().split()) a = list(map(int, input().split())) num = sum(a) cnt = 0 for i in range(n): if a[i] < num/(4*m): continue else: cnt += 1 if cnt >= m: print("Yes") else: print("No")
p02576
s927629249
Wrong Answer
import math N, X, T = map(int, input().split()) print(math.ceil((N/X))+T)
p03385
s769224022
Accepted
S = list(input()) S.sort() if S == ['a', 'b', 'c']: print("Yes") else: print("No")
p02641
s563141255
Wrong Answer
import math X, N = map(int, input().split()) if N == 0: print(X) else: p = list(map(int, input().split())) q = [int(i)+1 for i in range(100)] #print(q) for i in p: q.remove(i) ans = 0 r0 = 101 for j in q: r = abs(j-X) if r0 > r: r0 = r ans = j print(ans)
p02899
s001494549
Wrong Answer
n = int(input()) toko = [int(i) for i in input().split()] ans = [int(0) for i in range(n)] for j in range(n): ##01234 ans[toko[j]-1] = j + 1 print(ans)
p03339
s020826213
Accepted
N = int(input()) S = input() oder = N l = [0 for i in range(N)] r = [0 for i in range(N)] for i in range(1, N): l[i] = l[i-1] + (S[i-1] == 'W') r[-i-1] = r[-i] + (S[-i] == 'E') for i in range(N): oder = min(oder, l[i]+r[i]) print(oder)