problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03262
s383215826
Wrong Answer
N,X = map(int,input().split()) W = list(map(int,input().split())) + [X] W = sorted(W) dist = 10**18 if len(W) == 2: print(W[1]-W[0]) exit() for i in range(1,N+1): dist = min(dist, W[i]-W[i-1]) while (W[i]-W[i-1])%dist != 0: dist //= 2 if dist == 1: break print(dist)
p02613
s009556478
Accepted
n = int(input()) c0 = c1 = c2 = c3 = 0 for i in range(n): s = input() if s == 'AC': c0 += 1 elif s == 'WA': c1 += 1 elif s == 'TLE': c2 += 1 elif s == 'RE': c3 += 1 print('AC x {}\nWA x {}\nTLE x {}\nRE x {}'.format(c0, c1, c2, c3))
p04005
s010270898
Accepted
A,B,C=map(int,input().split())#どれか1つでも偶数ならばans=0 l=[A,B,C] for i in range(3): if l[i]%2==0: print(0) exit() #以下すべて奇数の場合) x=(A//2 +1)*B*C-(A//2)*B*C y=A*(B//2 +1)*C-A*(B//2)*C z=A*B*(C//2 +1)-A*B*(C//2) print(min(x,y,z))
p02708
s191466204
Wrong Answer
import math n,k = map(int,input().split()) if(k>n): print("1") else: ans=(pow(n+1,2,1000000007)) ans2=-(pow(k,2,1000000007))-1 print(ans2) for i in range(k+1,n+1): ans -= math.floor((i-1)/2) print(ans)
p02719
s119560684
Accepted
# coding: utf-8 N,K=map(int,input().split()) print(min(N%K,K-N%K))
p02910
s889091276
Accepted
s = input() odd = ["R","U","D"] even = ["L","U","D"] ret = "Yes" for i,v in enumerate(s): l = even if i % 2==0: l = odd if v not in l: ret ="No" break print(ret)
p02658
s545747892
Accepted
# abc169_b.py N = int(input()) A = list(map(int,input().split())) ans =1 A.sort() for i in A: if i == 0 : ans = 0 break ans *= i if ans >10**18: print(-1) exit() print(ans)
p02684
s552648814
Accepted
N, K = map(int, input().split()) A = [int(a) - 1 for a in input().split()] if K <= N: p = 0 for i in range(K): p = A[p] print(p + 1) exit() p = 0 t = [-1] * N t[0] = 0 for i in range(1, N): p = A[p] if t[p] != -1: break t[p] = i d = i - t[p] K -= i K %= d for i in range(K...
p02912
s679879630
Accepted
import heapq from math import ceil n, m = [int(x) for x in input().split()] a_list = [-int(x) for x in input().split()] heapq.heapify(a_list) for _ in range(m): temp = ceil(heapq.heappop(a_list) / 2) heapq.heappush(a_list, temp) print(-sum(a_list))
p03481
s106649661
Wrong Answer
def resolve(): x, y = map(int, input().split()) ans = 0 if x == 1: ans += 1 while x<=y: x *= 2 ans += 1 print(ans) resolve()
p02742
s311185035
Accepted
import math def main(): H,K = map(int, input().split()) if H==1 or K ==1: print(1) return elif H%2==0 or K%2==0: print(int(H*K/2)) return else: print(int(math.ceil(H*K/2))) return main()
p03720
s347988017
Accepted
n,m = list(map(int, input().split())) ans=[0]*n for i in range(m): a,b=list(map(int, input().split())) a,b=a-1,b-1 ans[a],ans[b]=ans[a]+1,ans[b]+1 for i in range(n): print(ans[i])
p02660
s381648393
Accepted
import collections n = int(input()) numbers = [] while n%2 == 0: numbers.append(2) n //= 2 i = 3 while i*i <= n: if n%i == 0: numbers.append(i) n //= i else: i += 2 if n != 1: numbers.append(n) factors = collections.Counter(numbers) ans = 0 for num in factors.values()...
p02789
s295672023
Accepted
h,a=map(int, input().split()) if h==a: print('Yes') else : print('No')
p02939
s644448151
Accepted
s=input() n=len(s) k=0 l=1 r=2 j=s[0] cnt=1 ans=[] while r<=n: if s[l:r]==j: r+=1 else: j=s[l:r] ans+=[j] l=r r+=1 cnt+=1 print(cnt)
p03150
s436782516
Accepted
s = str(input()); n = len(s) kn = 7 if n < kn: print("NO") exit() for i in range(kn): temp = s[:i] + s[n-kn+i:] if temp == "keyence": print("YES") exit() print("NO")
p03146
s618748167
Accepted
s = int(input()) def fx(s): if s % 2 == 1: return 3*s + 1 else: return s//2 a = [s] b0 = a[0] ans = 1 while fx(b0) not in a: a.append(fx(b0)) b0 = a[-1] ans += 1 print(ans+1)
p03095
s457160648
Wrong Answer
import math import collections import fractions import itertools import functools import operator import bisect def lowmod(a, b, mod): a -= b if a >= mod: a -= mod return a def solve(): n = int(input()) s = input() c = collections.Counter(s) mod = 10*9+7 ans = 1 for i in c:...
p02742
s988672972
Accepted
#スペース区切りの整数の入力 H, W = map(int, input().split()) ans = 0 if((H==1)or(W==1)): print("1") elif(((H*W)%2 == 0)): ans = H*W/2 print(int(ans)) else: ans = int(H*W/2) ans = ans + 1 print(ans)
p02897
s413991707
Accepted
n = int(input()) if n % 2 == 0: print(0.5) else: print((n + 1) / 2 / n)
p03351
s147353897
Accepted
#!/usr/bin/env python3 a, b, c, d = list(map(int, input().split())) if abs(a-b) <= d and abs(b-c) <= d or abs(a-c) <= d: print("Yes") else: print("No")
p02659
s631088498
Accepted
a, b = input().split() a = int(a) b = int(b[0] + b[2] + b[3]) ans = int(a * b // 100) print(ans)
p03387
s475546282
Accepted
alist = list(map(int,input().split())) alist.sort() a = alist[2] b = alist[1] c = alist[0] ans = 0 if b%2 == c%2: while c < b: c += 2 ans += 1 ans += a-b print(ans) else: ans += 1 a += 1 b += 1 while c < b: c += 2 ans += 1 ans += a-b print(...
p02675
s940475362
Accepted
N=input() one=int(N[-1]) if(one==2 or one==4 or one==5 or one==7 or one==9): print("hon") elif(one==0 or one==1 or one==6 or one==8): print("pon") else: print("bon")
p03161
s558677474
Accepted
import numpy as np # 入力 N, K = map(int, input().split()) H = np.array([int(i) for i in input().split()]) # ndarray型のDPテーブルを生成 dp = np.zeros(N, dtype=int) # 初期値をセット dp[0] = 0 # 各足場へたどり着く最小コストを調べる for i in range(1, N): s = max(0, i-K) dp[i] = min(dp[s:i] + np.abs(H[i] - H[s:i])) # iより前の足場のコストに足す print(dp[N-1]...
p03352
s341486615
Accepted
# -*- coding: utf-8 -*- X = int(input()) ans = 1 b = 1 p = 2 while b ** 2 <= X: p = 2 while b ** p <= X and p <= X: ans = max(ans, b ** p) p += 1 b += 1 print(ans)
p02996
s767347230
Accepted
n = int(input()) ab = [list(map(int,input().split())) for _ in range(n)] ab = sorted(ab, key=lambda x: x[1]) a_sum = 0 ans = 'Yes' for i in range(n): a_sum += ab[i][0] if a_sum>ab[i][1]: ans = 'No' break print(ans)
p03997
s849877834
Accepted
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
p03745
s672979950
Accepted
n = int(input()) a = list(map(int,input().split())) c = 1 d = 0 for i in range(n-1): if a[i] == a[i+1]: pass elif a[i] < a[i+1]: if d < 0: d = 0 c += 1 else: d += 1 else: if d > 0: d = 0 c += 1 else: d -= 1 print(c)
p03264
s742646966
Accepted
k=int(input()) if k%2==0: print((k//2)**2) else: print(((k+1)//2)*((k-1)//2))
p03761
s886747795
Wrong Answer
from collections import defaultdict def solve(): N = int(input()) dics = [0]*N for i in range(N): S = input() dics[i] = defaultdict(lambda:0) for s in S: dics[i][s] += 1 ans = '' for k,v in sorted(dics[0].items()): mincnt = v for i in range(1,N): ...
p02818
s771677672
Accepted
# ABC149B - Greedy Takahashi def main(): A, B, K = map(int, input().split()) if K <= A: print(A - K, B) else: print(0, max(0, B - (K - A))) if __name__ == "__main__": main()
p03672
s569026932
Accepted
s=list(input()) n=len(s) s1=s[:n//2] s2=s[n//2:] for i in range(n//2): s2=[s1[-1]]+s2[:-2] s1=s1[:-1] if s2==s1: break print(len(s1+s2))
p03069
s034650522
Wrong Answer
N = int(input()) S2 = list(str(input())) S1 = S2.copy() count1,count2 = 0,0 j = 0 for i in range(N-1,0,-1): if S1[i-1] == "#" and S1[i] == ".": count1 += 1 S1[i-1] = "." for i in range(1,N): if S2[i-1] == "#" and S2[i] == ".": count2 += 1 S2[i] = "#" print(min(count1,count2))
p03261
s828868859
Accepted
n = int(input()) a = [] for i in range(n): a.append(input()) if i > 0 and (a[i - 1][-1] != a[i][0] or a.count(a[i]) == 2): print("No") break else: print("Yes")
p03633
s308490442
Accepted
n=int(input()) ''' if n==1: print(input()) quit() ''' def gcd(a,b): if b==0:return a return gcd(b,a%b) def lcm(a,b): return a*b//gcd(a,b) ans = int(input()) for i in range(n-1): tmp = int(input()) ans = lcm(tmp,ans) print(ans)
p03455
s644375076
Accepted
A, B = list(map(int,input().split())) if A*B % 2 == 0: print('Even') else: print('Odd')
p03779
s578608709
Wrong Answer
x = int(input()) tmp = 0 t = 0 while tmp <= x-tmp: t += 1 tmp += t print(max(x-tmp, t))
p03137
s037585903
Wrong Answer
n,m = map(int, input().split()) x = sorted(list(map(int, input().split()))) if n>=m:print(0) else:print(sum(sorted([abs(x[i+1]-x[i]) for i in range(m-1)])[:-(n-1)]))
p03323
s321419810
Accepted
a,b=map(int,input().split()) if a<=8 and b<=8:print("Yay!") else:print(":(")
p03103
s387428276
Wrong Answer
n,m=map(int, input().split()) l=[] for i in range(n): a=list(map(int, input().split())) l.append(a) l=sorted(l) p=0 v=m for i in range(n): if l[i][1]<=v: p+=l[i][0]*l[i][1] v=v-l[i][1] else: p+=v*l[i][0] print(p) exit()
p02705
s001415785
Accepted
import math i = int(input()) print(2*i*math.pi)
p03639
s145137603
Wrong Answer
N = int(input()) A = list(map(int,input().split())) cnt_2 = 0 cnt_4 = 0 for a in A: if a % 4 == 0: cnt_4 += 1 elif a % 2 == 0: cnt_2 += 1 if N <= cnt_4 * 3 or N <= cnt_2: print('Yes') else: N -= cnt_4 * 3 if N % 2 != 0: N += 1 if N <= cnt_2: print('Yes') else: print('No')
p02697
s022039871
Accepted
n, m = map(int, input().split()) a, b = n, 1 V = [False for d in range(1, n + 1)] for i in range(m): d = min(a - b, n - (a - b)) if 2 * d == n or V[d]: a -= 1 print(a, b) d = min(a - b, n - (a - b)) V[d] = True a -= 1 b += 1
p04012
s502148229
Accepted
w=list(input()) alpha=list('abcdefghijklmnopqrstuvwxyz') for i in alpha: if w.count(i)%2 ==1: print('No') exit() print('Yes')
p03487
s330854946
Wrong Answer
n = int(input()) a = list(map(int, input().split())) count = [0 for i in range(n+1)] tmp = 0 for i in a: if i > n: tmp+=1 else: count[i] += 1 ans = 0 for i in range(n+1): if count[i] > 0: ans += min(abs(count[i] - i), count[i]) print(ans+tmp)
p02718
s971684002
Accepted
x,y= list(map(int, input().split())) i = list(map(int, input().split())) i.sort(reverse=True) k=sum(i) flag=0 if i[y-1]>=k/(4*y): print("Yes") else: print("No")
p02582
s541942383
Wrong Answer
str = input() r = 0 for c in str: if c == "R": r += 1 print(r)
p02690
s637518875
Accepted
x=int(input()) for a in range(-120,121): for b in range(-120,121): if a**5-b**5==x: print(a,b) exit()
p02897
s268755104
Wrong Answer
N = int(input()) if N % 2 == 0: print(N / 2) else: print('{:.06f}'.format((N+1) / (2 * N)))
p03799
s980631455
Wrong Answer
from collections import defaultdict from collections import deque import itertools import math def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() n,m = readInts() if n<m*2: ans = n m-=n*2 ans+=m//4 el...
p03109
s920299890
Accepted
y,m,d=map(int,input().split("/")) print("Heisei" if (y,m,d)<=(2019,4,30) else "TBD")
p03059
s487199401
Wrong Answer
A, B, T = map(int, input().split()) if A < T: x = 0 for i in range(1, T, A): x += B print(x) else: print(0)
p02862
s847365809
Accepted
X, Y = map(int, input().split()) mod = 10**9+7 def com(n, r): p, q = 1, 1 for i in range(r): p = p*(n-i)%mod q = q*(r-i)%mod return (p*pow(q, mod-2, mod))%mod if (X + Y)%3 != 0: print(0) else: a = (2*Y-X)//3 b = (X+Y)//3 - a if a < 0 or b < 0: print(0) else: ...
p02790
s908823815
Accepted
a,b=(int(x) for x in input().split()) i = 0 if a > b: while i < a: print(str(b), end="") i += 1 else: while i < b: print(str(a), end="") i += 1
p02835
s222406923
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) a_1, a_2, a_3 = map(int, readline().split()) if a_1 + a_2 + a_3 >= 22: print('bust') else: print('win')
p02621
s201858213
Wrong Answer
a = int(input()) ans = a + a^2 + a^3 print(ans)
p02779
s649916466
Accepted
n = int(input()) a = [int(x) for x in input().split()] a = sorted(a) for i in range(n-1): if a[i] == a[i+1]: print('NO') exit(0) print('YES')
p02547
s958026105
Wrong Answer
n = int(input()) c, d = [], [] for i in range(n): a, b = [int(i) for i in input().split()] c.append(a) d.append(b) count = 1 for i in range(0, n): if c[i] == d[i]: count += 1 else: count = 1 if count == 3: break if count == 3: print('Yes') else: print('No')
p02909
s699639659
Accepted
s = input() a = (['Sunny','Cloudy','Rainy']*2) ans = a[a.index(s) +1] print(ans)
p04043
s996527153
Wrong Answer
A,B,C = list(map(int, input("入力してね:").split())) if A == 5: if B == 5: if C == 7: print("YES") elif B == 7: if C == 5: print("YES") else: print("NO") else: print("NO") if A == 7: if B == 5: if C == 5: print("YES...
p03951
s201333241
Wrong Answer
N = int(input()) s = input() t = input() kaburi = 0 if s == t: print(N) else: for i in range(N): if s[-(i+1)] == t[i]: kaburi += 1 print(2*N-kaburi)
p03607
s823674502
Accepted
import collections n=int(input()) a=[int(input()) for _ in range(n)] b=collections.Counter(a) ans=0 for i in b.keys(): if b[i]%2: ans+=1 print(ans)
p03767
s100175482
Wrong Answer
n = int(input()) lis = list(map(int, input().split())) lis =sorted(lis) t = lis[n:2*n] print(sum(t))
p03251
s064647581
Accepted
n,m,X,Y=map(int,input().split()) x=list(map(int,input().split())) y=list(map(int,input().split())) for i in range(X+1,Y+1,1): if max(x)<i and i<=min(y): print("No War") exit() print("War")
p03042
s010226794
Wrong Answer
s = input() s_u, s_l = int(s[:2]), int(s[2:]) if s_u > 12 and 1 <= s_l <= 12: print('YYMM') elif 1 <= s_u <= 12 and s_l > 12: print('MMYY') elif s_u == 0 or s_l == 0: print('NA') else: print('AMBIGUOUS')
p03086
s626114308
Wrong Answer
a = 'ATCG' s = input() ans = 0 cnt = 0 for i in range(len(s)): if s[i] in a: cnt += 1 else : if cnt > ans: ans= cnt cnt = 0 print(ans)
p02860
s765762328
Wrong Answer
n = input() s = raw_input() print s[:n/2] == s[n/2:]
p03105
s517873647
Wrong Answer
a,b,c=map(int,input().split()) total=b/a if(total>=c): print(c) else: print(total)
p02582
s611271034
Accepted
S = input() if S == "RRR": print(3) elif "RR" in S: print(2) elif "R" in S: print(1) else: print(0)
p03605
s382018655
Accepted
n = input() for c in n: if(int(c) == 9): print("Yes") exit() print("No")
p03557
s548955141
Accepted
from bisect import * N = int(input()) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) cnt = [] for b in B: cnt.append(bisect_left(A, b) * (N - bisect_right(C, b))) print(sum(cnt))
p03556
s037293644
Accepted
for i in range(int(input()), 0, -1): if i**(1/2) % 1 == 0: print(i) break
p02601
s552739258
Accepted
a,b,c = map(int, input().split()) k = int(input()) for _ in range(k): if c <= b or c <= a: c*=2 elif b <= a: b*=2 if a < b and b < c: print('Yes') break else: print('No')
p02994
s932176602
Accepted
n,l=map(int,input().split()) t=[] #各リンゴの味 for i in range(1,n+1): a=l+i-1 t.append(a) t_total=sum(t) #N個のリンゴの味の総和 t2=[] #全リンゴの味の総和から1個のリンゴを引いたもの味 for j in t: b=t_total-j t2.append(b) ans=[] for k in t2: c=t_total-k ans.append(abs(c)) ind=ans.index(min(ans)) print(t_total-t[ind])
p03795
s201322323
Wrong Answer
import math N = int(input()) print(math.factorial(N) % (10**9+7))
p02658
s113040324
Accepted
def main(): N = int(input()) A = list(map(int, input().split())) if 0 in A: print(0) return ans = 1 for a in A: ans *= a if ans > 1000000000000000000: print(-1) return print(ans) main()
p03720
s136041387
Wrong Answer
n,m=map(int,input().split()) al=[] bl=[] for i in range(m): a,b=map(int,input().split()) al.append(a) bl.append(b) for i in range(1,m+1): print(al.count(i)+bl.count(i))
p03544
s021890801
Wrong Answer
N = int(input()) l = [2, 1] i = 2 ans =0 if N ==1: print(1) while i < N +1: l.append(str(int(l[i-1]) + int(l[i-2]))) ans = l[i] i = i+1 print(ans)
p02817
s033410594
Accepted
# coding: utf-8 s,t = input().split() print(t+s)
p03282
s740601147
Accepted
S = input() K = int(input()) for i in range(min(len(S), K)): if(S[i] != '1' and S[i] != '0'): print(int(S[i])) exit() print(1)
p03910
s460159079
Wrong Answer
N = int(input()) left = 0 right = 4000 while right - left > 1: mid = (left + right) // 2 if mid * (mid + 1) // 2 < N: left = mid else: right = mid ans = {i for i in range(1, right + 1)} ans -= {right * (right - 1) // 2 - N + right} print('\n'.join(map(str, ans)))
p03136
s245504625
Accepted
N=int(input()) L=list(map(int,input().split())) sum=0 for i in range(N): sum=sum+L[i] L.sort(reverse=True) if ((sum-L[0])>L[0]): print("Yes") else: print("No")
p03838
s013892025
Wrong Answer
x,y=map(int,input().split()) dist=abs(abs(x)-abs(y)) if x*y<0: print(dist+1) elif x>=0 and y>=0: print(dist) else: print(dist+2)
p02607
s081306017
Accepted
n = int(input()) a = list(map(int,input().split())) ans = 0 for i in range(n): if i%2==0 and a[i]%2==1: ans+= 1 print(ans)
p03861
s836295617
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) a, b, x = map(int, read().split()) print(b // x - (a - 1) // x)
p02705
s160011719
Accepted
import math R = int(input()) ans = 2 * math.pi * R print("%.20f"%ans)
p03251
s325703886
Accepted
M, N, X, Y = map(int, input().split()) X_city = list(map(int, input().split())) Y_city = list(map(int, input().split())) X_city.append(X) Y_city.append(Y) if max(X_city) < min(Y_city) : print("No War") else : print("War")
p02818
s641274323
Wrong Answer
import sys A,B,K = map(int,input().split()) if A >= K: A -= K print(str(A) + ' ' + str(B)) sys.exit(0) else: B = B - (K-A) A = 0 print(str(A) + ' ' + str(B))
p03012
s828742689
Accepted
N = int(input()) W = list(map(int, input().split())) ans = 10**5 for i in range(1,N): temp = abs(sum(W[:i+1]) - sum(W[i+1:])) ans = min(ans, temp) print(ans)
p02882
s101561680
Accepted
import math a, b, x = map(int, input().split()) if x >= a**2*b/2: print(math.degrees(math.atan((2*b-2*x/a**2)/a))) else: print(math.degrees(math.atan(b**2*a/2/x)))
p02765
s908441837
Accepted
N,R =map(int,input().split()) print(R if N>=10 else R+100*(10-N))
p03556
s722808619
Accepted
print(int(int(input())**0.5)**2)
p02953
s398703467
Accepted
N=int(input()) H=list(map(int, input().split())) H=list(reversed(H)) ans='Yes' for i in range(N-1): if H[i]<H[i+1]: if H[i]<H[i+1]-1: ans='No' else: H[i+1]=H[i+1]-1 print(ans)
p03759
s629009006
Wrong Answer
a, b, c = map(int, input().split()) if a - b == c - b: print("YES") else: print("NO")
p03545
s216984482
Accepted
import itertools A,B,C,D = list(input()) for ops in itertools.product(['+', '-'], repeat=3): eq = A+ops[0]+B+ops[1]+C+ops[2]+D x = eval(eq) if x == 7: break print(eq+'=7')
p03150
s850860922
Wrong Answer
s = input() asw='keyence' l=7 m=len(s) n=m-7 z=0 if n==0 and s==asw: print('YES') elif n<0: print('NO') elif n>0: for i in range(0, n): st = s[0:i] ed = s[i+n:m+1] con = st+ed if con==asw: print('YES') z=1 if z==0: print('NO')
p03617
s377098789
Accepted
import sys from collections import deque sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) Q, H, S, D = lr() N = ir() H = min(Q * 2, H) S = min(H * 2, S) if S * 2 <= D: print(S * N) else: print((N // 2) * D + (N % 2) * S)
p02959
s654456550
Wrong Answer
n =int(input()) a =list(map(int ,input().split())) b =list(map(int ,input().split())) b.append(0) c =0 d =0 enemy =0 for i in range(len(a)): if a[i] >b[i] +c: d += a[i] -(b[i]+c) elif a[i] <b[i] +c: c =b[i]+c -a[i] for i in range(len(a)): enemy +=a[i] print(enemy -d)
p02972
s593450396
Wrong Answer
n = int(input()) a = list(map(int,input().split())) ans = set() for i in range(n,0,-1): count = 0 for j in range(1,n//i+1): if j in ans: count += 1 if count % 2 != a[i-1] : ans.add(i) print(len(ans)) if ans: print("".join(map(str,ans)))