problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03211
s656723256
Accepted
import sys def input(): return sys.stdin.readline().strip() def main(): S = input() ans = 1000 for i in range(len(S) - 2): val = int(S[i:i+3]) ans = min(ans, abs(val - 753)) print(ans) if __name__ == "__main__": main()
p03695
s075886964
Accepted
N = int(input()) A = list(map(int, input().split())) color = [0] * 8 select = 0 for i in range(N): for j in range(8): if 400 * j <= A[i] < 400 * (j + 1): color[j] += 1 break elif 400 * (j + 1) == 3200: select += 1 break ans = 0 for k in range(8): ...
p02711
s898451666
Accepted
n = int(input()) a = set() while n != 0: rem = n % 10 a.add(rem) n //= 10 if 7 in a: print("Yes") else: print("No")
p02682
s239589867
Wrong Answer
A, B, C, K = list(map(int,input().split())) if K <= A: print(K) elif K <= (A + B): print(A) elif K <= (A + B + C): print(K - B) else: print(A + B - C)
p02742
s395224074
Accepted
import math h,w = map(int, input().split()) if (h == 1 or w == 1): print(1) else: print(math.ceil(h/2)*math.ceil(w/2)+math.floor(h/2)*math.floor(w/2))
p02993
s496806169
Wrong Answer
n=list(map(int, input().split())) for i in range(len(n)-1): if n[i]==n[i+1]: print('Bad') break else: print('Good')
p03971
s508112954
Accepted
N,A,B=map(int,input().split()) S=input() S=list(S) count=0 world=1 for i in S: if i=="a": if count<A+B: print("Yes") count+=1 else: print("No") elif i=="b": if (count<A+B) & (world<=B): print("Yes") count+=1 world+=1...
p02777
s435739334
Accepted
s,t = input().split() a,b = map(int,input().split()) u=input() if u==s: print(a-1,b) else: print(a,b-1)
p02699
s776065719
Wrong Answer
s, w = map(int, input().split()) if s<w: print('safe') else: print('unsafe')
p02697
s680975528
Accepted
n,m = map(int,input().split()) ANS = [[0] * 2 for i in range(m)] a = 0 b = 1 c = 0 f = 1 for i in range(m): if n%2 == 0 and (c+2) > n//2 and f == 1: b = (b+1) % n f = 0 ANS[i] = [a, b] c += 2 a = (a-1) % n b = (b+1) % n for i in range(m): print(ANS[i][0]+1, ANS[i][1]+1)
p03126
s379369297
Accepted
n,m=map(int,input().split()) d=[0 for i in range(m)] for i in range(n): k=list(map(int,input().split())) for i in range(len(k)-1): d[k[i+1]-1]+=1 ans=0 for i in d: if i==n: ans+=1 print(ans)
p02676
s635569712
Accepted
k = int(input()) s = input() print(s if len(s) <= k else s[:k] + "...")
p03107
s357619120
Wrong Answer
import re S = input() ans = 0 while True: num0 = S.count('11') S = re.sub('11', '', S) num1 = S.count('00') S = re.sub('00', '', S) ans += 2*(num0+num1) if num0+num1 == 0: print(ans) break
p02948
s718096964
Accepted
import heapq x = [[] for _ in range(10**5+1)] n,m = map(int,input().split()) for i in range(n): a,b = map(int,input().split()) x[a].append(b) cur = [] heapq.heapify(cur) ans = 0 for l in range(1,m+1): for k in x[l]: heapq.heappush(cur, k*(-1)) if cur != []: mi = heapq.heappop...
p03286
s335832443
Wrong Answer
import sys N = int(sys.stdin.readline()) binN = "" pN = abs(N) while N != 0: if abs(N % -2) == 1: binN += "1" else: binN += "0" N += N%(-2) N //= -2 print(binN[::-1])
p03637
s131392396
Accepted
n=int(input()) lst=list(map(int,input().split())) four=0 two=0 odd=0 for i in lst: if i%4==0: four+=1 elif i%2==0: two+=1 else: odd+=1 if four>=odd: print("Yes") elif four+1==odd: if two==0: print("Yes") else: print("No") else: print("No")
p02731
s538397694
Accepted
L = int(input()) print((L/3)**3)
p03545
s934016282
Accepted
A,B,C,D = input('') for i in range(2**3): op = [0] * 3 for j in range(3): if (i >> j) & 1: op[j]='+' else: op[j]='-' if eval(A+op[0]+B+op[1]+C+op[2]+D)==7: print(A+op[0]+B+op[1]+C+op[2]+D+'=7') exit()
p02742
s965601344
Accepted
h, w = map(int, input().split()) ans = h*w // 2 if h == 1 or w == 1: print(1) elif (h*w) % 2 == 0: print(ans) else: print(ans + 1)
p03773
s374918150
Wrong Answer
a,b = map(int,input().split()) b += a if b>24: print(b-24) else: print(b)
p02723
s203680572
Wrong Answer
S=input() if len(S)==6: for i in range(6): if (S[2]==S[3] and S[4]==S[5]): print("Yes") else: print("No")
p02996
s976528693
Accepted
n = int(input()) ab = [] now = 0 for i in range(n): _a, _b = map(int, input().split()) ab.append([_a, _b]) ab.sort(key=lambda x: x[1]) for a, b in ab: now += a if now>b: print('No') exit() print('Yes')
p03659
s424159664
Wrong Answer
n=int(input()) a=list(map(int,input().split())) x=a[0] y=a[-1] suma=sum(a) for i in range(1,n-1): if x<suma//2: x+=a[i] else: break y=suma-x print(max(x,y)-min(x,y))
p02771
s246224373
Accepted
a,b,c=map(int,input().split()) if a!=b and a!=c and b!=c: print("No") elif a==b and b==c and c==a: print("No") else: print("Yes")
p02747
s961330235
Wrong Answer
S = input() def getHi(S): for i in range(0, len(S)-2, 2): if S[i] + S[i+1] != "hi": return"No" return "Yes" print(getHi(S))
p03745
s474803053
Accepted
n=int(input()) a=list(map(int,input().split())) i,ans=0,0 while i<n-1: while i<n-1 and a[i]==a[i+1]: i+=1 if a[i]<=a[i+1]: while i<n-1 and a[i]<=a[i+1]: i+=1 ans+=1 elif a[i]>=a[i+1]: while i<n-1 and a[i]>=a[i+1]: i+=1 ans+=1 i+=1 if i==n-1: ans+=1 if ans==0: ans=1 pr...
p02818
s614630246
Accepted
input_from = input() info = input_from.split(' ') a = int(info[0]) b = int(info[1]) k = int(info[2]) a -= k if a < 0: b += a a = 0 if b < 0: b = 0 print("{0} {1}".format(a, b))
p02787
s150932779
Accepted
h, n = map(int, input().split()) a, b = [], [] for _ in range(n): A, B = map(int, input().split()) a.append(A) b.append(B) a_max = max(a) dp = [0]*(h+a_max) for i in range(h+a_max): dp[i] = min(dp[i-a] + b for a, b in zip(a, b)) print(min(dp[h-1:]))
p03105
s878102197
Wrong Answer
a, b, c = map(int,input().split()) if b/a < c: print(round(b/a)) else: print(c)
p02778
s944774697
Wrong Answer
from sys import stdin def get_result(data): return 'x' * len(data[0]) if __name__ == '__main__': data = list(map(str, stdin.readline().split(' '))) result = get_result(data) print(result)
p03075
s244805961
Accepted
def i(): return int(input()) a = i() b = i() c = i() d = i() e = i() k = i() if (e-a <= k): print('Yay!') else: print(":(")
p03719
s406138597
Accepted
a,b,c = map(int,input().split()) ans = 'No' if(a <= c <= b): ans = 'Yes' print(ans)
p03211
s443383898
Accepted
s = list(map(int,input())) m = 10**9 for i in range(len(s)-2): a = 100*s[i]+10*s[i+1]+s[i+2] if m > abs(753-a): m = abs(753-a) print(m)
p02548
s373725976
Accepted
n = int(input()) counted = 0 for i in range(1,n): counted += (n-1)//i print(counted)
p03137
s491418315
Wrong Answer
n, m = map(int, input().split()) if n >= m: print(0) exit() x = sorted(map(int, input().split())) l = sorted(i - j for i, j in zip(x[1:], x[:-1])) print(sum(l[: 1 - n]))
p02768
s014733745
Wrong Answer
import sys sys.setrecursionlimit(1000000) n, a, b = map(int, input().split()) mod = 10**9 + 7 nca = 1 for i in range(a): nca *= (n-i) nca *= pow(i+1, mod-2, mod) nca %= mod ncb = 1 for i in range(b): ncb *= (n-i) ncb *= pow(i+1, mod-2, mod) ncb %= mod nca %= mod ncb %= mod ans = pow(2, n, m...
p03612
s835054297
Wrong Answer
N = int(input()) p = list(map(int,input().split())) cnt = 0 for i in range(N-1): if p[i] == i+1: p[i],p[i+1] = p[i+1],p[i] cnt += 1 print(cnt)
p03075
s220612054
Wrong Answer
N = [] for i in range(6): N.append(int(input())) ans = "Yay!" for i in range(5): for j in range(i+1,5): dist = abs(N[j] - N[i]) print(dist) if dist > N[5]: ans = ":(" print(ans)
p03679
s516207384
Wrong Answer
a,b,c = map(int,input().split()) print("delicious" if b>c else "safe" if c-b-1<=a else "dangerous")
p03457
s669000828
Wrong Answer
n = int(input()) res = 0 for i in range(n): t, x, y = map(int, input().split()) if x+y<=t-res and t%2==(x+y)%2: if t-(x+y)!=res: res += t-(x+y) else: print('No') exit() print('Yes')
p03803
s029401997
Accepted
A, B = map(int, input().split()) if A == 1: A += 13 if B == 1: B += 13 if A > B : print("Alice") elif A < B: print("Bob") else: print("Draw")
p03644
s033077976
Wrong Answer
n=int(input()) m=0 p=-1 for i in range(1,n+1): if(i%2==0): x=i c=0 while(x%2==0): c+=1 x//=2 if(c>m): m=c p=i print(p)
p03665
s581698608
Accepted
N,P = map(int,input().split()) A = list(map(int,input().split())) su = 2 ** N guusu = True for a in A: if a % 2 == 1: guusu = False break if P == 0: print(su if guusu else su//2) else: print(0 if guusu else su//2)
p04011
s198906487
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) ans = 0 for i in range(n): if i <= k-1: ans += x else: ans += y print(ans)
p02797
s690428410
Wrong Answer
(N, K, S) = list(map(int, input().split())) a = [S] * K b = [1] * (N-K) print(a + b)
p03471
s653921250
Accepted
N,Y=map(int,input().split()) # x+y+z=N # 10000x+5000y+1000z=Y # となるような正整数(x,y,z)はあるか? ans=[-1,-1,-1] for x in range(N+1): for y in range(N-x+1): z=N-x-y if 10000*x+5000*y+1000*z==Y: ans=[x,y,z] print(ans[0],ans[1],ans[2])
p03037
s341134148
Accepted
n, m = map(int, input().split()) a = [list(map(int, input().split())) for i in range(m)] l = [] r = [] for i in range(m): l.append(a[i][0]) r.append(a[i][1]) ans = min(r)-max(l)+1 if ans <= 0: print(0) else: print(ans)
p02607
s162263395
Wrong Answer
N = int(input()) a = list(map(int, input().split())) count = 0; for i in range(0,N): if i % 2 == 1: if a[i] % 2 == 1: count = count+1 print(count)
p02714
s512369032
Accepted
from collections import Counter def solve(): N = int(input()) S = list(input()) c = Counter(S) ans = c['R']*c['G']*c['B'] for i in range(N): for j in range(i+1,N): k = j*2-i if k>N-1: break if S[i]!=S[j] and S[j]!=S[k] and S[i]!=S[k]: ans -= 1 return ans print(solve())
p03448
s316429766
Wrong Answer
a = int(input()) b = int(input()) c = int(input()) x = int(input()) cnt = 0 for i in range(a + 1): for j in range(b + 1): C = x - 500 * i - 100 * j if C >= 0 and C <= 50: cnt += 1 print(cnt)
p02989
s342797406
Accepted
n = int(input()) d = list(map(int,input().split())) ans=0 d.sort() print(d[n//2]-d[(n//2)-1])
p03799
s298487742
Wrong Answer
[n,m] = [int(i) for i in input().split()] if n * 2 >= m: print(n) else: if m >= 2: ans = n m = max(m - n * 2,0) ans += m//4 print(ans) else: print(0)
p02708
s194881603
Accepted
import itertools def main(): N, K = map(int, input().split()) mod = 1000000007 s = list(itertools.accumulate(range(0, N+1))) ans = 1 for k in range(K, N+1): ans = (ans + s[N] - s[N-k] - s[k-1] + 1) % mod print(ans) if __name__ == '__main__': main()
p02958
s475794138
Wrong Answer
N = int(input()) MM = input().split() count = 0 list1 =[] for i in MM: a = int(i) list1.append(a) list2 = sorted(list1) for i,j in zip(list1,list2): if i != j: count +=1 if count >2: print('No') else: print('Yes')
p03836
s376303115
Accepted
sx, sy, tx, ty = map(int, input().split()) lr, ud = abs(tx - sx), abs(sy - ty) print('R' * lr + 'U' * ud + 'L' * lr + 'D' * ud, end='') print('L' + 'U' * (ud+1) + 'R' * (lr+1) + 'D' + 'R' + 'D' * (ud+1) + 'L' * (lr+1) + 'U')
p03720
s416679491
Accepted
import sys input = sys.stdin.readline def main(): ans = 0 N, M = map(int, input().split()) m = [0]*N for _ in range(M): a, b = map(int, input().split()) m[a-1] += 1 m[b-1] += 1 for i in range(N): print(m[i]) if __name__ == '__main__': main()
p03145
s666572074
Wrong Answer
a,b,c=map(int,input().split()) d=min(a*b/2,a*c/2,b*c/2) print(d)
p02780
s718335989
Accepted
expected_value_dic = {} def get_expected_value(x): return (1 + x) / 2 n, k = map(int, input().split()) P = list(map(int, input().split())) expected_values = [get_expected_value(p) for p in P] cumulative_values = [expected_values[0]] for expected_value in expected_values[1:]: cumulative_values.append(cumulati...
p03481
s190404648
Accepted
X, Y = map(int, input().split()) a = X ans = 0 while a <= Y: ans += 1 a *= 2 print(ans)
p02847
s972287350
Accepted
ls = ["SUN","MON","TUE","WED","THU","FRI","SAT"] S = input() print(7-ls.index(S))
p03854
s717324915
Accepted
S = input() while len(S) > 0: if S[-5:] == 'dream': S = S[:-5] elif S[-5:] == 'erase': S = S[:-5] elif S[-7:] == 'dreamer': S = S[:-7] elif S[-6:] == 'eraser': S = S[:-6] else: print('NO') exit() print("YES")
p03612
s617780038
Accepted
N = int(input()) numbers = [int(i)-1 for i in input().split()] need_fix_index = [] for i, v in enumerate(numbers): if i == v: need_fix_index.append(i) cnt = 0 while need_fix_index: cnt += 1 v = need_fix_index.pop(0) if len(need_fix_index) == 0: break if abs(need_fix_index...
p02783
s612618345
Accepted
H, A = map(int, input().split()) c = int(H / A) if H % A != 0: c += 1 print(c)
p03360
s281928120
Accepted
a = list(map(int,input().split())) a.sort() k = int(input()) print(a[0]+a[1]+a[2]*(2**k))
p02811
s035106701
Wrong Answer
k,x=map(int, input().split()) if 500*k >= x: print('YES') else: print('NO') exit()
p03814
s408202698
Accepted
s = input() a = s.find('A') z = s.rfind('Z') print(z-a+1)
p02744
s749787066
Wrong Answer
def dfs(n, i, s): global ans s += chr(i) if n == N: ans += [s] return for ii in range(97, i+2): dfs(n+1, ii, s) N = int(input()) i = 97 ans = [] dfs(1, 97, '') ans = sorted(ans) for a in ans: print(a)
p03352
s800423068
Accepted
import math x = int(input()) ans = [] for j in range(1, math.ceil(math.sqrt(x)) + 1): for k in range(2,x + 2): if j ** k <= x: ans.append(j ** k) print(max(ans))
p03795
s863599048
Accepted
N = int(input()) print(N*800-200*(N//15))
p02924
s894951637
Accepted
n = int(input()) print((n-1)*n//2)
p02606
s975792937
Wrong Answer
L, R, d = [int(i) for i in input().split(' ')] first = L if L == d else (L//d + 1) * d ans = 0 for i in range(first,R+1,d): ans += 1 print(ans)
p03208
s488914183
Accepted
n,k=map(int,input().split()) h=[int(input()) for _ in range(n)] h_sort=sorted(h) a=0 b=10**20 for i in range(k, n+1): a=h_sort[i-1] - h_sort[i-k] if a<b: b=a print(b)
p03565
s427035061
Accepted
s=input() T=input() s=''.join([x if x!='?' else '1' for x in list(s)]) start=[] for i in range(len(s)-len(T)+1): tmp=0 for j in range(len(T)): if s[i+j]==T[j] or s[i+j]=='1': tmp+=1 if tmp==len(T): start.append(i) candidates=[] t=len(T) ans='' if len(start): for st in start: tmp=s[:st...
p02860
s720809892
Accepted
N=int(input()) S=input() c=0 if N%2==1: print("No") else: m=N//2 for i in range(N//2): if S[i]==S[m+i]: c=c+1 if c==N//2: print("Yes") else: print("No")
p02570
s851214818
Accepted
D,T,S=map(int,input().split()) if D/S<=T: print('Yes') else: print('No')
p02675
s293641974
Accepted
# cook your dish here n=int(input()) n=n%10 if n in [2,4,5,7,9]: print('hon') if n in [0,1,6,8]: print('pon') if n==3: print('bon')
p02594
s084040216
Accepted
x = int(input()) print('Yes') if x >= 30 else print('No')
p02996
s437883704
Wrong Answer
N = int(input()) A = [] B = [] for _ in range(N): a, b = map(int, input().split()) A.append(a) B.append(b) C = list(zip(B, A)) C.sort() B, A = zip(*C) t = 0 for c in C: t += c[1] if t <= c[0]: continue else: print('no') exit() print('yes')
p03994
s283120271
Accepted
from string import ascii_lowercase s = input() k = int(input()) d = {c: (26 - i) % 26 for i, c in enumerate(ascii_lowercase)} ret = '' for c in s[:-1]: if d[c] <= k: k -= d[c] ret += 'a' else: ret += c k %= 26 idx = (ascii_lowercase.index(s[-1]) + k) % 26 c = ascii_lowercase[idx] ret...
p02795
s079266556
Wrong Answer
H = int(input()) W = int(input()) N = int(input()) L = max(H, W) for i in range(1, L+1): if N < L*i: break print(i)
p02720
s041573355
Wrong Answer
from collections import deque def main(k): q = deque([]) for i in range(10): q.append(i) count = 0 top = -1 while True: top = q.popleft() count += 1 if count == k: return top if top%10 != 0: q.append(top*10 + top%10-1) q....
p04020
s800153450
Accepted
n=int(input()) count=0 ans=0 for i in range(n): a=int(input()) if a==0: ans+=(count//2) count=0 else: count+=a print(ans+count//2)
p03103
s011002471
Wrong Answer
N,M = map(int,input().split()) Shop_List = [list(map(int,input().split())) for i in range(N)] Shop_List = sorted(Shop_List, key=lambda x:x[0]) Number_Counter = 0 Yen_Counter = 0 for i in range(N): if Number_Counter + Shop_List[i][1] <= M: Number_Counter += Shop_List[i][1] Yen_Counter = Shop_List[i][...
p02613
s459089130
Wrong Answer
n = int(input()) s = list(input() for _ in range(n)) print("AC × " + str(s.count("AC"))) print("WA × " + str(s.count("WA"))) print("TLE × " + str(s.count("TLE"))) print("RE × " + str(s.count("RE")))
p04005
s134134046
Accepted
A,B,C=map(int,input().split()) if A%2==0 or B%2==0 or C%2==0: ans = 0 else: ans = min(A*B,B*C,C*A) print(ans)
p03852
s475584475
Wrong Answer
c=input() if c=='a' or c=='i' or c=='d' or c=='e' or c=='o' : print("vowel") else: print("consonant")
p02838
s260857668
Accepted
n = int(input()) a = list(map(int, input().split())) mod = 10**9 + 7 d = [0]*60 for i in range(n): for j in range(60): if a[i] >> j & 1 == 1: d[j] += 1 ans = 0 for j in range(60): ans += 2**j * d[j] * (n - d[j]) % mod print(ans % mod)
p03681
s530318348
Accepted
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 def factorial(N, mod=MOD): res = 1 for i in range(2, N+1): res *= i res %= mod return res def main(): N, M = map(int, readline().rstrip().split()) if abs(N-M) > 1: ans = 0 elif N == M: ans = factorial(N)...
p02702
s648295560
Accepted
import math # def comb_count(n, r): # return math.factorial(n) // math.factorial(r) // math.factorial(n - r) S = input()[::-1] ans = 0 mods = [0] * 2019 #余りが0~2018 mods[0] = 1 current = 0 tmp = 1 for i in range(len(S)): current = (int(S[i]) * tmp + current) % 2019 mod = current % 2019 ans += mods[mo...
p03206
s032485201
Accepted
D = int(input()) print("Christmas"+" Eve"*(25-D))
p03486
s770205913
Wrong Answer
#!/usr/bin/env python # coding: utf-8 # In[58]: s = input() t = input() # In[59]: s_list = [[w,0] for w in s] t_list = [[w,1] for w in t] mylist = sorted(s_list+t_list, key=lambda x: x[1], reverse=True) mylist = sorted(mylist, key=lambda x: x[0]) for i in range(len(t)): if mylist[i][1] != 1: print("Y...
p02633
s209733882
Accepted
def a(): x = int(input()) k = 1 while (k * x) % 360 != 0: k += 1 print(k) a()
p02603
s208788124
Wrong Answer
N = int(input()) A = list(map(int,input().split())) M = 1000 K = 0 for i in range(1, N): if A[i-1] < A[i]: K = M // A[i-1] M = M % A[i-1] if i == N-1: M += K * A[i] elif A[i-1] > A[i]: if K > 0: M += K * A[i-1] K = 0 print(M)
p02659
s005108198
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from decimal import Decimal a, b = map(float, readline().split()) a = Decimal(str(a)) b = Decimal(str(b)) print(int(a * b))
p02952
s451012753
Accepted
N=int(input()) import math x=math.floor(math.log10(N))+1 ans=0 for i in range(1,x,2): ans+=9*10**(i-1) if x%2==1: ans+=N-10**(x-1)+1 print(ans)
p03803
s308264017
Wrong Answer
a, b = map(int, input().split()) if a == b: print('Draw') elif b == 1 and a < b: print('Bob') elif a == b: print('Draw') else: print('Alice')
p02689
s971456165
Accepted
N, M=map(int,input().split()) H=list(map(int,input().split())) ans=[1]*N for i in range(M): A, B=map(int, input().split()) if H[A-1]>H[B-1]: ans[B-1]=0 elif H[B-1]>H[A-1]: ans[A-1]=0 elif H[A-1]==H[B-1]: ans[A-1]=0 ans[B-1]=0 print(sum(ans))
p03095
s628918021
Accepted
import sys input = sys.stdin.readline def main(): N = int(input()) S = input().rstrip() M = 10**9 + 7 # a (0)+1 # ab (1)+1+1 # abc (3)+3+1 # abca (7)+1+2+1 # abcab (11)+1+3+2 # abcabc (17)+1+4+3 A = ord("a") res = 1 for i in range(26): q = chr(i+A) qc = S.count(q) res = res * (qc+1) % M ...
p02791
s427650378
Accepted
n = int(input()) P = list(map(int,input().split())) ans = 0 mi = P[0] for i in range(n): if P[i] <= mi: mi = P[i] ans += 1 print(ans)
p02713
s407372903
Wrong Answer
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) n = int(input()) answer = 0.0 for i in range(1,n+1): for j in range(1,n+1): for h in range(1,n+1): f = gcd(i,j,h) answer += f print(answer)