problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02880
s444659948
Accepted
n = int(input()) for i in range(1,10): if n % i == 0 and n / i <= 9: print("Yes") quit() print("No")
p02546
s398221238
Accepted
S = input() if S[-1] == 's': print(S+'es') exit() print(S+'s')
p02970
s558375438
Wrong Answer
import math N,D = map(int,input().split()) print(math.ceil(D/N/2))
p02682
s398311931
Wrong Answer
a, b, c, k = map(int, input().split()) if k<=a+b: print(a) else: print(a-(k-a-b))
p03379
s261263197
Accepted
import copy n = int(input()) lst1 = list(map(int,input().split())) lst2 = [] c = copy.deepcopy(lst1) c.sort() Kth = c[n//2] #上の方 med_low = Kth med_high = c[n//2-1] for i in range(n): if lst1[i] < Kth: print(med_low) else: print(med_high)
p02641
s636182984
Accepted
#関数リスト import sys input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) x,n = MI() mylist = tuple(MI()) num = 0 while True: if not(x - num in mylist): print(x- num) sys.exit() if not(x + num in mylist): print(x+ num) sys.exit() num += 1
p03041
s363556709
Accepted
cases = [int(i) for i in input().split() if i.isdigit()] w = input() print(w[0:cases[1]-1] + w[cases[1]-1].lower() + w[cases[1]:])
p02690
s181930046
Wrong Answer
x = int(input()) ans = [i**5 for i in range(66)] for i in ans: for j in ans: if i - j == x: print(ans.index(i), ans.index(j)) exit() if i + j == x: print(ans.index(i), -ans.index(j)) exit()
p02916
s127892380
Wrong Answer
N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) cnt = 0 for i in range(N): if (cnt!= 0) and (a[i]==a[i-1]+1): cnt += c[i-2] cnt += b[a[i]-1] print(cnt)
p02820
s934919515
Accepted
N,K=map(int,input().split()) R,S,P=map(int,input().split()) T=input() ans=0 chk=[0]*N for n in range(N): c=T[n] if n>=K and T[n-K]==c and chk[n-K]==0: chk[n]=1 # not used continue if c=='r': ans+=P elif c=='s': ans+=R else: ans+=S print(ans)
p02727
s642675259
Accepted
X,Y,A,B,C=map(int,input().split()) p=list(map(int,input().split())) q=list(map(int,input().split())) r=list(map(int,input().split())) p.sort() q.sort() p.reverse() q.reverse() p=p[:X] q=q[:Y] a=p[:] a.extend(q) a.extend(r) a.sort() a.reverse() sum=0 for i in range(X+Y): sum+=a[i] print(sum)
p03285
s719440374
Accepted
n = int(input()) flag = False for i in range(100): for j in range(100): price = 4*i + 7*j if price==n: flag = True break if flag: break print('Yes' if flag else 'No')
p02879
s507666851
Accepted
a, b = [int(i) for i in input().split()] if a > 9 or b > 9: print(-1) else: print(a*b)
p02848
s669938837
Accepted
N = int(input()) S = str(input()) def alpha(a): return ord(a)-65 def enum(i): return chr(i+65) list = [enum((alpha(s)+N)%26) for s in list(S)] print("".join(list))
p03105
s539654661
Accepted
a,b,c = map(int,input().split()) if b//a > c: print(c) else: print(b//a)
p03797
s290017031
Accepted
N,M = map(int,input().split()) if M >= 2*N: M -= 2*N print(N+M//4) else: print(M//2)
p02691
s127156007
Wrong Answer
n = int(input()) from collections import defaultdict a = list(map(int,input().split())) ans = 0 dp = defaultdict(int) for e,i in enumerate(a): dp[i+e]+=1 if i - e >= 0 :ans += dp[i-e] print(ans)
p02768
s632476682
Wrong Answer
import math n,a,b = map(int, input().split()) S = 2**n-1 S -= (math.factorial(n)/math.factorial(a))/math.factorial(n-a) S -= (math.factorial(n)/math.factorial(b))/math.factorial(n-a)
p03592
s029135236
Wrong Answer
n,m,k = map(int,input().split()) for i in range(n+1): for j in range(m+1): a = n*j + m*i - i*j if a == k: print("Yes") exit() print("No")
p03797
s975893588
Accepted
N,M=map(int,input().split()) M//=2 print(min(M,(N+M)//2))
p02766
s432928014
Wrong Answer
N,K = map(int,input().split()) n = N x = 0 while n > K: n = N // K x += 1 print(x)
p02843
s050654940
Accepted
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) x = I() y = x // 100 z = x % 100 if 0 <= z <= 5*y: print(1) else: print(0)
p02546
s420142891
Wrong Answer
def pural(): S = input("Enter String: ") if S.endswith('s') : output = S + "es" else : output = S + "s" print(output) # your code goes here
p03696
s427732724
Wrong Answer
n = int(input()) s = input() tmp = [] ans = "" for i in s: if i == "(": tmp.append("(") else: if len(tmp) == 0: ans = "(" + ans + ")" else: ans += tmp.pop() + ")" print(ans)
p03565
s728757749
Accepted
s = list(input()) t = list(input()) for i in range(len(s)-len(t), -1, -1): flag = True for j in range(len(t)): if not(s[i+j] == t[j] or s[i+j] == '?'): flag = False if flag : for j in range(len(t)): s[i+j] = t[j] for k in range(len(s)): if s[k] == '?': s[k] = 'a' print(''.join(s)) exit() print('UNRESTORABLE')
p02601
s342034661
Accepted
a,b,c = map(int, input().split()) k = int(input()) while(a >= b and k >0 ): b = b*2 k -= 1 c = c*2**(k) #print(a,b,c) if (a<b and b<c): print('Yes') else: print('No')
p04034
s622831928
Accepted
N, M = map(int,input().split()) z = [list(map(int,input().split())) for i in range(M)] box = [[1,1]] for i in range(N-1): box.append([0,1]) for i in range(M): box[z[i][0]-1][1] -= 1 box[z[i][1]-1][1] += 1 if (box[z[i][0]-1][0] == 1): box[z[i][1]-1][0] = 1 if (box[z[i][0]-1][1] == 0): box[z[i][0]-1][0] = 0 ans = 0 for i in range(N): if (box[i][0] != 0): ans += 1 print(ans)
p02866
s439993604
Accepted
from collections import Counter MOD = 998244353 N = int(input()) D = list(map(int, input().split())) if D[0] != 0: print(0) exit() C = sorted(Counter(D).most_common(), key=lambda x: x[0]) if C[0][1] > 1: print(0) exit() ans = 1 for i in range(1, len(C)): if C[i][0] - C[i-1][0] > 1: print(0) exit() ans *= C[i - 1][1] ** C[i][1] print(ans % MOD)
p03814
s634135060
Accepted
s = input() for i, x in enumerate(s): if x == "A": break for j, x in enumerate(s[::-1]): if x == "Z": break print(len(s) - i - j)
p02699
s720957659
Wrong Answer
s,w = map(int, input().split()) if w>=s/2: print("unsafe") else: print("safe")
p02713
s623035891
Accepted
from math import gcd k = int(input()) ans = 0 for l in range(1,k+1): for m in range(1,k+1): for n in range(1,k+1): ans += gcd(gcd(l,m),n) print(ans)
p02700
s920848115
Accepted
inp_ls = input().split(" ") a,b,c,d = [int(e) for e in inp_ls[:4]] turn = 0 while True: if a <= 0: print("No") break if c <= 0: print("Yes") break if turn % 2 == 0: c -= b else: a -= d turn += 1
p03351
s084939212
Accepted
a, b, c, d = map(int, input().split()) if (abs(c - a) <= d or (abs(b - a) <= d and abs(c - b) <= d)): print('Yes') else: print('No')
p03994
s639753596
Accepted
s = list(input()) k = int(input()) cnt = 0 ans = '' for i in range(len(s)): cnt = (ord('z') - ord(s[i]) + 1) % 26 if cnt <= k: k -= cnt s[i] = 'a' s[-1] = chr((ord(s[-1]) - ord('a') + k) % 26 + ord('a')) print(*s, sep='')
p02916
s195076705
Accepted
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) d = dict(zip(A, B)) ans = d[A[0]] for i in range(1, N): if A[i] - A[i-1] == 1: ans += d[A[i]] + C[A[i-1] -1] else: ans += d[A[i]] print(ans)
p02621
s985591735
Accepted
a=int(input()) print(a+pow(a,2)+pow(a,3))
p03427
s963280333
Wrong Answer
import bisect,collections,copy,heapq,itertools,math,numpy,string import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) N = I() A = [LI() for _ in range(N)]
p03061
s743864111
Accepted
N = int(input()) A = list(map(int, input().split())) ans = 0 def gcd(x, y): if x < y: x, y = y, x if y == 0: return x while y > 0: temp = x % y x = y y = temp return x L = [0] R = 0 for i in range(N-1): L.append(gcd(A[i], L[i])) for i in range(N): temp = gcd(L[N-i-1], R) R = gcd(R, A[N-i-1]) if ans < temp: ans = temp print(ans)
p03109
s993624077
Accepted
S=input() if int(S[5:7])<=4: print("Heisei") else: print("TBD")
p02933
s474313789
Accepted
a=int(input()) s=input() print(s if a>=3200 else "red")
p02793
s657785565
Wrong Answer
import fractions mod = 1000000007 def add(a, b): return (a + b) % mod n = int(input()) a = list(map(int,input().split())) ans = a[0] ans_ans = 0 for i in range(1, n): ans = ans * a[i] // fractions.gcd(ans, a[i]) #for j in range(0, n): # b = ans // a[j] # ans_ans = add(ans_ans,b) #print(ans_ans)
p03836
s973240411
Wrong Answer
sx, sy, tx, ty = map(int, input().split()) dx = tx - sx dy = ty - sy print('R' * dx + 'U' * dy + 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U' + 'U' * dy + 'R' * dy + 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R')
p03544
s497826502
Accepted
l = [] l.append(2) l.append(1) def lyuca(n): for i in range(n): l.append(l[i]+l[i+1]) return l[n] print(lyuca(int(input())))
p03557
s081198004
Accepted
import bisect n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() count = 0 for i in b: count += bisect.bisect_left(a, i) * (len(c) - bisect.bisect(c, i)) print(count)
p02882
s110587262
Wrong Answer
import math a, b, x = map(int, input().split()) atan0 = math.degrees(math.atan((a*b**2)/(2*x))) print(round(atan0, 10))
p02909
s310062103
Accepted
s = input() if s == 'Sunny': print('Cloudy') elif s == 'Cloudy': print('Rainy') else: print('Sunny')
p03637
s651606492
Accepted
N = int(input()) a = list(map(int, input().split())) num2 = 0 num4 = 0 odd = 0 for i in a: if i % 4 == 0: num4 += 1 continue elif i % 2 == 0: num2 += 1 continue else: odd += 1 continue if odd<=num4 or (N%2==1 and num4==N//2): print('Yes') else: print('No')
p03711
s413474027
Accepted
def main(): num = list(map(int,input().split())) if (num[0] in [1,3,5,7,8,10,12] and num[1] in [1,3,5,7,8,10,12] ) or (num[0] in [4,6,9,11] and num[1] in [4,6,9,11] ) or (num[0] ==2 and num[1] ==2): print('Yes') else: print('No') main()
p03474
s619831902
Wrong Answer
# coding: utf-8 a,b=map(int,input().split()) s=input().split('-') if len(s)!=2: print('Yes') elif len(s[0])!=a or len(s[1])!=b: print('No') else: print('Yes')
p03720
s684711229
Accepted
N,M = [int(i) for i in input().split()] road = [0]*N for _ in range(M): a,b = [int(i)-1 for i in input().split()] road[a] += 1 road[b] += 1 print("\n".join(map(str, road)))
p02719
s177398348
Accepted
N, K = map(int, input().split()) if(N <= K): ans = min(abs(N-K), abs(abs(N-K)-K)) print(ans) else: mod = N%K ans = min(abs(mod-K), mod) print(ans)
p03605
s453675936
Accepted
N=list(input()) print('Yes') if(('9' in N)==True) else print('No')
p03852
s936040296
Wrong Answer
c = input() vowel = ['a','i','u','e','o'] if c in vowel: print('vowel') else: ('consonant')
p03062
s098601328
Accepted
n = int(input()) a = list(map(int,input().split())) m = 100000000000 count = 0 ans = 0 for i in range(n): if a[i] < 0: count += 1 x = abs(a[i]) ans += x m = min(m,x) if count % 2 != 0: ans -= 2*m print(ans)
p02761
s415275902
Wrong Answer
# Code for C - Guess The Number # Use input() to fetch data from STDIN import sys [n, m] = [int(x) for x in input().split()] s = [] c = [] for i in range(m): [x, y] = [int(x) for x in input().split()] s.append(x) c.append(y) for x in range(1, 1000): a = str(x) if len(a) != n: continue test = all([a[i - 1] == str(j) for i, j in zip(s, c)]) if test: print(x) sys.exit() print("-1")
p02719
s014162837
Accepted
n, k = map(int,input().split()) print(min(n%k, abs(n%k-k)))
p02699
s323192208
Wrong Answer
s,w = map(int,input().split()) if s >= w: print("safe") else: print("unsafe")
p02832
s822093483
Wrong Answer
N = int(input()) line = list(map(int,input().split())) count = 0 while count <= N: for i in range(N): try: if line[i] == i + 1: True else: line.pop(i) break except: break count += 1 print(N - len(line))
p03943
s278626981
Wrong Answer
a=[int(i) for i in input().split()] a.sort() if a[0]==a[1]+a[2]: print("Yes") else: print("No")
p02697
s535247242
Accepted
n,m=map(int,input().split()) #1とnがつながっているときのa,bの最短距離 def dist(a,b): return min(abs(a-b),n-abs(a-b)) a,b = n,1 S=set() for i in range(m): distab = dist(a,b) #distabがnの半分のとき if 2*distab == n or distab in S: a -= 1 print(a,b) S.add(distab) a -= 1 b += 1
p03481
s389128964
Accepted
## C - Multiple Gift import math X, Y = map(int, input().split()) count = 0 while X <= Y: X *= 2 count += 1 print(count)
p03071
s924429963
Accepted
A, B = map(int, input().split()) A, B = max(A, B), min(A, B) print(2 * A if A == B else 2 * A - 1)
p02989
s185933854
Accepted
N = int(input()) d = sorted(list(map(int,input().split()))) Kmin,Kmax = d[N//2-1],d[N//2] print(Kmax-Kmin)
p03163
s442637186
Accepted
import numpy as np N, W = map(int, input().split()) dp = np.zeros(W+1, np.int64) for i in range(N): w, v = map(int, input().split()) dp[w:] = np.maximum(dp[w:], dp[:-w] + v) print(dp[-1])
p02597
s680823879
Accepted
# -*- coding: utf-8 -*- n = int(input()) s = list(input()) if s.count("W") == 0: print(0) exit() print(s[:s.count('R')].count("W"))
p04029
s113718651
Accepted
print(sum([i for i in range(1, int(input())+1)]))
p03360
s641246070
Wrong Answer
l=list(map(int,input().split())) l.sort() k=int(input()) print(l[0]+l[1]+l[2]**k)
p03695
s750300800
Wrong Answer
from collections import Counter n = int(input()) a = [min(x//400, 8) for x in map(int, input().split())] a = Counter(a) if len(a) == 1 and a[8] != 0: min_a = 1 max_a = a[8] elif a[8] != 0: min_a = len(a)-1 max_a = min([min_a+a[8], 8]) else: min_a = max_a = len(a) print(min_a, max_a)
p02705
s362801716
Wrong Answer
import math R = int(input()) 2*math.pi*R
p02700
s441714599
Accepted
t_hp, t_atk, a_hp, a_atk = map(int, input().split()) while (1): a_hp -= t_atk if a_hp <= 0: ans = "Yes" break t_hp -= a_atk if t_hp <= 0: ans = "No" break print(ans)
p03645
s522531109
Accepted
n, m = map(int, input().split()) x = [0]*n y = [0]*n for i in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 if a == 0: x[b] = 1 if b == n-1: y[a] = 1 f = 0 for i in range(n): if x[i]*y[i] > 0: f = 1 if f: print("POSSIBLE") else: print("IMPOSSIBLE")
p03760
s598524002
Accepted
O=list(input()) E=list(input()) len_=len(E) for i in range(len_): O.insert(i*2+1,E[i]) print(''.join(O))
p02951
s748258910
Accepted
A, B, C = map(int, input().split()) if C - (A - B) < 0: print(0) else: print(C - (A - B))
p03162
s705743076
Accepted
from itertools import* (n,), *D = [list(map(int, o.split())) for o in open(0)] dp = [[0]*3 for _ in [None]*-~n] for i in range(n): for j, k in permutations(range(3), 2): dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + D[i][k]) print(max(dp[n]))
p03208
s522316278
Accepted
import sys def main(): input = sys.stdin.readline N, K = map(int, input().rstrip().split()) trees = [] for _ in range(N): trees.append(int(input())) trees.sort() min_diff = float("inf") for i in range(K-1, N): min_diff = min(min_diff, trees[i]-trees[i-K+1]) print(min_diff) if __name__ == '__main__': main()
p03011
s480268751
Accepted
p,q,r=map(int,input().split()) print(min(p+q,q+r,r+p))
p03208
s388761487
Wrong Answer
from collections import Counter N, K = list(map(int,input().split())) H = [] for i in range(N): H.append(int(input())) H = sorted(H,reverse = False) C = Counter(H) CH = list(C.values()) cnt = 0 for i in range(len(CH)): if CH[i] >= K: cnt += 0 break if cnt != 0: print('0') else: print(H[K-1] - H[0])
p03639
s151574556
Accepted
n = int(input()) a = list(map(int,input().split())) c1 = 0 c2 = 0 c4 = 0 for i in range(n): if a[i] % 4 == 0: c4 += 1 elif a[i] % 2 == 0: c2 += 1 elif a[i] == 1: c1 += 1 if c2 == n: print('Yes') quit() n -= c2 c2 %= 2 n += c2 f = n // 2 if c4 >= f: print('Yes') quit() else: print('No')
p02753
s429600891
Accepted
a, b, c = input() if a==b==c: print('No') else: print('Yes')
p02743
s963369520
Accepted
a, b, c = map(int, input().split()) if c - a - b <= 0: print("No") exit() if 4 * a * b < (c - a - b) * (c - a - b): print("Yes") exit() else: print("No") exit()
p03339
s787634750
Accepted
import sys input = sys.stdin.readline N = int(input()) S = input().rstrip('\r\n') counts = [0] * N count = 0 for i, s in enumerate(S): counts[i] += count if s == 'W': count += 1 count = 0 for i, s in enumerate(S[::-1]): counts[N-1-i] += count if s == 'E': count += 1 ans = min(counts) print(ans)
p02677
s098506457
Accepted
import math a = list(map(int,input().split())) A = a[0] B = a[1] H = a[2] M = a[3] x = math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(6*M - 30*H - 0.5*M))) print(x)
p03711
s963795419
Wrong Answer
x,y = map(int,input().split()) a = [1,3,5,7,8,10,12] b = [4,6,9,11] c = [2] if x in a and y in a: print("YES") elif x in b and y in b: print("YES") elif x in c and y in c: print("YES") else: print("NO")
p03644
s283268435
Wrong Answer
N=int(input()) if 2<=N<=3: print("2") elif 4<=N<=7: print("4") elif 8<=N<=15: print("8") elif 16<=N<=31: print("16") elif 32<=N<=63: print("32") elif 64<=N<=100: print("64") elif N==1: print("0")
p03679
s840447291
Wrong Answer
x, a, b = map(int, input().split()) if (b - a) < 0: print('delicious') elif (b - a) <= x: print('safe') else: print('dangerous')
p02693
s006563716
Accepted
k = int(input()) a, b = map(int, input().split()) tmp = a if a % k == 0 or b % k == 0: print("OK") else: for i in range(a,b): if i % k == 0: if i <= b: print("OK") break else: print("NG") break else: print("NG")
p03612
s848001863
Accepted
n = int(input()) p = list(map(int,input().split())) i = 0 ans = 0 while i < n: if i+1 == p[i]: ans += 1 i += 2 else: i += 1 print(ans)
p03679
s716792203
Wrong Answer
x,a,b = map(int,input().split()) if 0<a-b: print('delicious') elif b-a<x: print('safe') else: print('dangerous')
p02723
s458655721
Accepted
ls = list(map(str,input())) if (ls[2] == ls[3]) and (ls[4] == ls[5]): print("Yes") else: print("No")
p02693
s303313863
Wrong Answer
K = int(input()) A, B = map(int, input().split()) a = int(A/K) b = int(B/K) if K == 1: print("Yes") else: if a == b: print("NG") else: print("Yes")
p03327
s046146024
Accepted
N=int(input()) if N <= 999: print('ABC') else: print('ABD')
p03146
s831621186
Wrong Answer
def Collatz_Problem(n): ans = 1 count = [] while True: if n%2 == 0: n = n/2 else: n = 3*n+1 ans += 1 if n in count: break else: count.append(n) return ans def main(): n = int(input()) print(Collatz_Problem(n)) if __name__ == '__main__': main()
p04029
s575469087
Accepted
n = int(input()) a = 0 for i in range(n): a = a + n n -= 1 print(a)
p02772
s375522119
Wrong Answer
N = int(input()) a_list = [int(x) for x in input().split(' ')] a_list = list(filter(lambda x:x%2 == 0 and (x%3 != 0 and x%5 != 0), a_list)) print(a_list) if not a_list: print('APPROVED') else: print('DENIED')
p02779
s993886441
Accepted
N = int(input()) A = list(map(int,input().split())) A.sort() ans = 'YES' for i in range(N-1): if A[i] == A[i+1]: ans = 'NO' print(ans)
p02971
s995864395
Accepted
n = int(input()) l = ([int(input()) for j in range(n)]) a = sorted(l)[-1] b = sorted(l)[-2] for i in range(n): if l[i]==a: print(b) else: print(a)
p02606
s680034094
Accepted
a,b,c=(int(x) for x in input().split()) n=a ran=b-a+1 counter=0 for num in range(ran): if n % c == 0: counter += 1 n += 1 print(counter)
p02706
s492377345
Accepted
n,m=list(map(int,input().split())) A=list(map(int,input().split())) if n>=sum(A): print(n-sum(A)) else: print(-1)
p03162
s134781444
Wrong Answer
x=int(input()) count=0 k=-1 hap=list(map(int,input().split())) count=max(hap) k=hap.index(count) for i in range(1,x): hap=list(map(int,input().split())) m=-1 for i in range(len(hap)): if i!=k: m=max(hap[i],m) ano=i count+=m k=ano print(count)
p02706
s017579863
Accepted
n,m,*l=[int(i) for i in open(0).read().split()] print(max(-1,n-sum(l)))