problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p04034
s746315424
Accepted
n,m=map(int,input().split()) arr=[list(map(int,input().split())) for _ in range(m)] count=[1]*(n+1) flag=[False]*(n+1) flag[1]=True for a,b in arr: count[b]+=1 count[a]-=1 if flag[a]==True: flag[b]=True if count[a]==0: flag[a]=False print(flag.count(True))
p02694
s016106404
Wrong Answer
#a = list(map(int,input().split())) #b = list(map(int,input().split())) a = int(input()) x = int(100) count= 0 while a >= x: x += int(x/100) count+=1 print(count)
p02983
s536280441
Accepted
import sys l, r = map(int, input().split()) if 2019 <= r - l: print(0) sys.exit() ans = 2019 for i in range(l, r): for j in range(i + 1, r + 1): i %= 2019 j %= 2019 ans = min(ans, (i * j) % 2019) print(ans)
p02917
s420896964
Accepted
N = int(input()) A = [] B = list(map(int, input().split())) A.append(B[0]) for i in range(N - 2): if B[i] > B[i + 1]: A.append(B[i + 1]) else: A.append(B[i]) A.append(B[-1]) print(sum(A))
p03795
s124982193
Accepted
n=int(input()) if n>=15: x=n//15 print(800*n-200*x) else: print(800*n)
p02935
s174376742
Accepted
def cumsum(n,A): s = [0]*(n+1) s[0] = A[0] for i in range(len(A)): s[i+1] = (s[i] + A[i])/2 return s n = int(input()) v = sorted(list(map(int,input().split()))) for i in range(n-1): s = cumsum(n,v) print(s[-1])
p02744
s880688392
Accepted
ch = ['a','b','c','d','e','f','g','h','i','j','k','l','m', 'n','o','p','q','r','s','t','u','v','w','x','y','z'] n = int(input()) import queue q=queue.Queue() l = 1 q.put(["a", 0]) while True: temp = q.get() l=len(temp[0]) if l==n: break for i in range(temp[1]+2): ne = temp[0]+ch[i] nn ...
p04029
s390828680
Wrong Answer
# 入力 N = int(input()) # 処理 total = 0 for i in range(1, N+1): print(total) # total = total + i # 出力 print(total)
p04030
s390699499
Wrong Answer
s=input() ans,skip='',0 for c in reversed(s): if c == 'B': skip+=1 elif skip>0: skip-=1 else: ans+=c print(ans)
p02918
s682094905
Wrong Answer
N, K = map(int, input().split()) S = list(input()) r_cnt = 0 answer = 0 before = '' for s in S: if s == before: answer += 1 else: r_cnt += 1 before = s if r_cnt%2 == 0: print(answer+min(r_cnt//2, K)*2) elif r_cnt//2 <= K: print(answer+r_cnt) else: print(answer+K*2-1)
p03548
s617863476
Accepted
x, y, z = map(int, input().split()) print((x - z) // (y + z))
p03221
s355922022
Wrong Answer
n, m = input().split() n, m = int(n), int(m) data = [] for _ in range(m): temp_p, temp_y = input().split() temp_p, temp_y = int(temp_p), int(temp_y) data.append([temp_p, temp_y]) data.sort() result = "" for temp_data in data: result += "{:0>6}".format(temp_data[0]) + "{:0>6}".format(temp_data[1]) +...
p03107
s458124746
Accepted
S = input() print(min(S.count('0'), S.count('1'))*2)
p02687
s472399164
Wrong Answer
L = input() if L == 'ABC': print('ARC') else: print('ARC')
p02691
s481668047
Accepted
N = int(input()) L = list(map(int, input().split())) import copy U = copy.copy(L) for i in range (0, N): L[i]+=(i+1) U[i]= -U[i]+(i+1) L = sorted(L) U = sorted(U) import bisect count = 0 for i in range (0, N): count+= bisect.bisect_right(U, L[i])-bisect.bisect_left(U, L[i]) print(count)
p02629
s794180030
Accepted
n=int(input()) alphabet="abcdefghijklmnopqrstuvwxyz" ans=[] while n>0: n-=1 ans.append(alphabet[n%26]) n=n//26 ans.reverse() print("".join(ans))
p03556
s854822658
Accepted
print(int(int(input())**0.5)**2)
p03160
s038899231
Accepted
N = int(input()) *h, = map(int, input().split()) dp = [0] * N dp[0] = 0 dp[1] = abs(h[0] - h[1]) for i in range(2, N): dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i])) print(dp[-1])
p02713
s984531831
Wrong Answer
import math ans = 0 k = int(input()) for a in range(k): for b in range(k): tmp = math.gcd(a, b) for c in range(k): ans += math.gcd(tmp, c) print(ans)
p03106
s891489212
Accepted
a,b,k = map(int, input().split()) s = [] for i in range(1,101): if a % i == 0 and b % i == 0: s.append(i) if i > a or i > b: break print(s[-k])
p02640
s395744527
Accepted
x, y = map(int, input().split()) for i in range(0, x+1): if i * 2 + (x - i) * 4 == y: print('Yes') exit() print('No')
p03759
s528862434
Accepted
a, b, c = map(int,input().split()) if b - a == c - b: print('YES') else: print('NO')
p02879
s241549634
Wrong Answer
a, b = map(int, input().split()) if a > 10 or b > 10: print(-1) else: print(a * b)
p04034
s362582997
Wrong Answer
n, m = map(int, input().split()) s = [0] * n s[0] = 1 b = [1] * n for i in range(m): x, y = map(int, input().split()) b[x-1] -= 1 b[y-1] += 1 s[x-1] = int(b[x-1] != 0) s[y-1] = s[x-1] ans = 0 for i in range(n): if s[i] and b[i]: ans += 1 print(ans)
p02584
s018743632
Wrong Answer
A = list(map(int, input().split())) X=A[0] K=A[1] D=A[2] answer=X for i in range(K): if(abs(X-D) < answer): answer = abs(X-D) X = X-D i += 1 elif(abs(X+D) < answer): answer = abs(X-D) X = X-D i += 1 print(answer)
p03962
s394194109
Wrong Answer
a, b, c = map(int, input().split()) if a == b and b == c: print(1) elif a == b and b != c: print(2) elif a != b and b == c: print(2) elif a != b and b != c: print(3)
p02773
s969288403
Accepted
n=int(input()) dic = {} max = 1 for i in range(n): s = input() if s not in dic: dic[s] = 1 else: dic[s] += 1 if max < dic[s]: max = dic[s] l = [] for i in dic.keys(): if dic[i] == max: l += [i] l.sort() for i in l: print(i)
p02909
s613385742
Accepted
x=input() listp={'Sunny':'Cloudy','Cloudy':'Rainy','Rainy':'Sunny'} print(listp[x])
p03827
s083473935
Wrong Answer
n=input() s=input() x=0 xx=[] for i in s: if i=="I": x+=1 xx.append(x) else: x-=1 xx.append(x) print(max(xx))
p02641
s868827643
Wrong Answer
x,n,*a=map(int,open(0).read().split()) b=[1]*101 for i in a: b[i]=0 c=1000 ans=0 for i in range(101): if b[i] and c>=abs(x-i): c=abs(x-i) ans=i print(ans)
p02843
s172719254
Accepted
x = int(input()) q = x // 100 r = x % 100 r -= 5 * q print(1 if r <= 0 else 0)
p03131
s010249727
Accepted
K,A,B=map(int, input().split()) ans=K+1 if A<B and K>=A: n=K-A+1 ans=max(ans, A+n//2*(B-A)+(n&1)) print(ans)
p02832
s068105193
Accepted
# D N = int(input()) A = list(map(int,input().split())) next_number = 1 cnt = 0 for a in A: if a == next_number: next_number += 1 else: cnt += 1 if cnt == len(A): print('-1') else: print(cnt)
p02629
s873418719
Wrong Answer
def main(): n = int(input()) alp = "zabcdefghijklmnopqrstuvwxy" res = "" for i in range(1,100): if(n<=26**i): for j in range(i): res+=chr(ord("a")+n%26) n//=26 break else: n-=26**i print(res[::-1]) if __name__ == '...
p02584
s256362907
Wrong Answer
X, K, D = map(int, input().split()) X = abs(X) if X > K * D: print(X - K * D) elif X == D: if K % 2 == 0: print(X) else: print(abs(X - D)) else: X = X % D K -= X // D if K % 2 == 0: print(X) else: print(abs(X - D))
p03817
s403112196
Accepted
x = int(input()) n = x // 11 a = x % 11 add = 0 if 0 < a <=6: add += 1 elif a > 6: add += 2 print(add+n*2)
p03861
s796233317
Wrong Answer
import math a,b,x = map(int,input().split()) if b > 0: bb = b//x+1 else: bb = 0 if a > 0: a = a - 1 aa = a//x+1 else: aa = 0 print(bb-aa)
p02705
s979531115
Accepted
import math pi = math.pi*2 R = int(input()) print(R*pi)
p03986
s284379863
Accepted
def Solver(X): K=0 P=0 for s in X: if s=="S": P+=1 elif P>0: P-=1 else: K+=1 return 2*K #================================================ X=input() print(Solver(X))
p02744
s595325686
Accepted
n = int(input()) r = 'a', for _ in range(n - 1): r = {s + c for s in r for c in s + chr(ord(max(s)) + 1)} print(*sorted(r), sep='\n')
p02717
s902949286
Wrong Answer
a,b,c = list(map(int,input().split())) print(c,b,a)
p03030
s712103951
Wrong Answer
N = int(input()) S = [] cnt = 0 for _ in range(N): cnt += 1 i,p = input().split() S.append([i,int(p),cnt+1]) S.sort(reverse = True) for i in S: print(i[2])
p02665
s664035221
Accepted
import operator from itertools import accumulate def main(): N = int(input()) A = list(map(int, input().split())) A_sum = list(reversed(list(accumulate(reversed(A))))) + [0] B = [0] * (N+1) B[0] = 1 - A[0] d = A_sum[0] + B[0] if B[0] < 0: return -1 for i in range(1, N+1): B[i] = min(B[i - 1] *...
p02792
s512556174
Accepted
import math n = int(input()) def first_last(n):return n//(10**int(math.log10(n))), n%10 data = [] for i in range(9):data.append([0, 0, 0, 0, 0, 0, 0, 0, 0]) for i in range(1, n+1): first, last = first_last(i) if(first!=0 and last!=0):data[first-1][last-1] += 1 ans = 0 for i in range(9): for j in range(9)...
p02785
s837192120
Accepted
N, K = map(int, input().split()) H = list(map(int, input().split())) H.sort() idx = max(N-K,0) print (sum(H[:idx]))
p02786
s793374210
Accepted
h=int(input()) d=dict() d[0]=0 d[1]=1 d[2]=3 d[3]=3 def solve(h): if h in d.keys(): return d[h] d[h]=2*solve(h//2)+1 return d[h] print(solve(h))
p03438
s159208205
Accepted
import math N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt1, cnt2 = 0, 0 for i in range(N): if a[i] > b[i]: cnt1 += a[i] - b[i] elif a[i] < b[i]: cnt2 += math.ceil((b[i]-a[i])/2) cnt = sum(b) - sum(a) if cnt1 <= cnt and cnt2 <= cnt: print('Yes...
p02705
s808583535
Accepted
PI = 3.1415 # utility function def circumference(r): return (2 * PI * r) # driver function k=int(input(" ")) print ('%.3f' % circumference(k))
p03605
s116304401
Accepted
print('Yes' if '9' in input() else 'No')
p03767
s198371723
Accepted
N = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) print(sum(A[1:2*N:2]))
p02859
s308907540
Accepted
print(int(input())**2)
p04033
s084508183
Wrong Answer
a,b = map(int,input().split()) if a > 0 or a == b: print('Positive') elif a <= 0 <= b: print('Zero') else: print('Positive' if b - a % 2 == 1 else 'Negative')
p02571
s479487413
Accepted
S = input() T = input() s = len(S) t = len(T) ans = 1000 for i in range(s-t+1): cnt = 0 for j in range(t): if S[i+j] != T[j]: cnt += 1 ans = min(ans, cnt) print(ans)
p03137
s355127198
Accepted
def main(): N, M = map(int, input().split()) X = list(map(int, input().split())) if N >= M: print(0) return X.sort() distance = [] for i in range(M-1): distance.append(X[i+1] - X[i]) distance.sort() for _ in range(N-1): distance.pop() ans = sum(distanc...
p03611
s277657873
Accepted
n = int(input()) ls = list(map(int, input().split())) ans = [0] * (10**5 + 2) for i in range(n): ans[ls[i]] += 1 ans[ls[i]+1] += 1 ans[ls[i]+2] += 1 print(max(ans))
p02836
s597928792
Accepted
S = input() cnt = 0 for i in range(len(S) // 2): if S[i] != S[-(i+1)]: cnt += 1 print(cnt)
p03623
s940301763
Wrong Answer
x, a, b = map(int, input().split()) if abs(x-a) > abs(x-b): print('A') else: print('B')
p02888
s207379093
Accepted
from bisect import bisect_left n = int(input()) length_list = list(map(int, input().split())) count = 0 length_list.sort() for a_idx in range(n - 2): for b_idx in range(a_idx + 1, n - 1): a = length_list[a_idx] b = length_list[b_idx] left_count = bisect_left(length_list, a+b) cou...
p04034
s957286340
Wrong Answer
n,m=map(int,input().split()) ans=[] li=[1 for _ in range(n)] for i in range(m): x, y = map(int, input().split()) li[x-1]-=1 li[y-1]+=1 if i==0: if x==1: ans.append(y) else: if x in ans: ans.append(y) cnt=0 for j in set(ans): if li[j-1]!=0: cnt+=1 p...
p03076
s717103830
Wrong Answer
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) A = a % 10 B = b % 10 C = c % 10 D = d % 10 E = e % 10 M = min(A+1,B+1,C+1,D+1,E+1) print(a+b+c+d+e+A+B+C+D+E-(M-1))
p03000
s789242945
Wrong Answer
N, X = [int(s) for s in input().split(' ')] Ls = [int(s) for s in input().split(' ')] suma = [0] for L in Ls: suma.append(suma[-1] + L) if suma[-1] > X: break print(len(suma) - 1)
p02598
s677970826
Accepted
n,k=map(int,input().split()) *a,=map(int,input().split()) l,r=0,10**9 while r-l>1: m=(l+r)//2 t=0 for x in a: if x<=m: continue t+=(x+m-1)//m-1 if t<=k: r=m else: l=m print(r)
p02957
s798222844
Accepted
A, B = map(int, input().split()) K = A + B if K % 2 == 0: print(K//2) else: print("IMPOSSIBLE")
p03309
s409668886
Accepted
n = int(input()) a_list = list(map(int,input().split())) pr_abs = [] for i in range(n): pr_abs.append(a_list[i] - i-1) pr_abs.sort() if len(a_list) % 2 == 1: median = pr_abs[(n-1)//2] ans = 0 for i in range(n): ans += abs(pr_abs[i] - median) else: median = (pr_abs[(n-2)//2] + pr_abs[n//2])//2 ans = 0 ...
p02817
s181733577
Accepted
s, t = input().split() print(t + s)
p03352
s387510351
Accepted
x = int(input()) ans = 0 for i in range(1, 100): for j in range(2, 100): if i ** j <= x: ans = max(ans, i ** j) print(ans)
p02935
s501068886
Wrong Answer
from math import floor def main(): N = int(input()) v = list(map(int, input().split(" "))) while len(v) > 1: N = len(v) v.sort() w = [] if len(v) % 2 == 1: w.append(v[-1]) N -= 1 for i in range(floor(N / 2)): w.append((v[i * 2] + ...
p03030
s221001184
Accepted
N = int(input()) Book = [0] * N for i in range(N): s,q = input().split() p = int(q) Book[i] = (s, 100-p, i) Book.sort() for i in range(N): print(Book[i][2]+1)
p02935
s651555948
Wrong Answer
n = int(input()) v = list(map(int,input().split())) v.sort(reverse=True) if n == 2: print((v[0]+v[1])/2) else: for i in range(n-1): p = (v[-1] + v[-2])/2 v.pop(-1) v.pop(-1) v.append(p) v.sort() print(v[0])
p03815
s284643056
Wrong Answer
x = int(input()) print(x // 11 * 2 + (x % 11 > 6) + 1)
p02983
s139726969
Wrong Answer
i,j = map(int,input().split()) a,b = divmod(i,2019) c,d = divmod(j,2019) if c-a > 0: ans = 0 else: ans = b*(b+1) print(ans)
p02951
s547823113
Accepted
a, b, c = map(int, input().split()) print(max(0,c-(a-b)))
p02618
s889100104
Accepted
n=int(input()) for i in range(n): print(1)
p02729
s732635237
Wrong Answer
def checkKaibun(str): for i in range(int((len(str) - 1) / 2)): if str[i] != str[-i - 1]: return False return True s = input() n = len(s) c2e = int((n - 1) / 2) c3s = int((n + 3) / 2) if not checkKaibun(s): print('No') elif not checkKaibun(s[0:c2e]): print('No') elif not checkKaibun...
p03448
s529464269
Accepted
(A, B, C, X) = [int(input()) for i in range(4)] ways = 0 max_a = int( X / 500 ) if A < max_a : max_a = A for a in reversed(range( max_a+1 )) : max_b = int( (X - 500 * a) / 100 ) if B < max_b : max_b = B for b in reversed(range( max_b+1 )) : c = int ( ( X - 500 * a - 100 * b ) / 50 ) if c > C : ...
p02784
s346214601
Accepted
h,n=map(int,input().split()) a=list(map(int,input().split())) print("No" if h > sum(a) else "Yes")
p02784
s150939657
Accepted
H, N = map(int, input().split()) A = list(map(int, input().split())) sum_A = sum(A) if H <= sum_A: print("Yes") else: print("No")
p02584
s876365506
Accepted
import sys X,K,D = list(map(int, input().split())) ans = 9999999 if abs(X) >= K * D: ans = abs(X) - K*D else: A = abs(X) % D B = K - (abs(X) // D) if B % 2 == 0: ans = A else: ans = abs(A - D) print(ans)
p02706
s745520089
Accepted
import sys sys.setrecursionlimit(300000) def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LMI(): return list(map(int, sys.stdin.readline().split())) MOD = 10 ** 9 + 7 INF = float('inf') N, M = MI() A = LMI() print(max(-1, N - sum(A)))
p04031
s874291468
Accepted
n=int(input()) c=list(map(int,input().split())) minans=1000000000 for j in range(-101,101): ans=0 for i in range(n): ans+=(c[i]-j)**2 minans=min(ans,minans) print(minans)
p02622
s644819183
Accepted
S = input() T = input() count = 0 for i in range(len(S)): if S[i] != T[i]: count += 1 print(count)
p02744
s788047355
Accepted
def DFS(word,n): if len(word)==N: return print(word) else: for i in range(n+1): if i==0 : DFS(word+chr(97+i),n+1) elif chr(97+i-1) in word: DFS(word+chr(97+i),n+1) N=int(input()) DFS('',0)
p02695
s126632113
Accepted
from itertools import combinations_with_replacement as cr n,m,q=map(int,input().split()) s=[list(map(int,input().split()))for i in range(q)] f=0 for i in cr([i for i in range(1,m+1)],n): e=0 for a,b,c,d in s: if i[b-1]-i[a-1]==c: e+=d if f<e:f=e print(f)
p02576
s155465358
Accepted
#A N, X, T=map(int, input().split()) print((N//X)*T if N%X ==0 else (N//X+1)*T)
p04045
s979200204
Accepted
import itertools NK = input().split() N = NK[0] K = int(NK[1]) d = input().split() D = [int(s) for s in d] Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in D: Da.remove(i) Da_str = [str(j) for j in Da] a_1 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N))] a_2 = [''.join(j) for j in itertools.prod...
p02819
s354657445
Accepted
import math # import bisect # import heapq # from copy import deepcopy # from collections import deque # from collections import Counter # from itertools import accumulate # from itertools import permutations # import numpy as np x= int(input()) # p = list(map(int, input().split())) def iss(n): a = True for ...
p03797
s776417651
Wrong Answer
N, M = map(int, input().split()) if N >= M * 2: print(M // 2) else: ret = N M -= N * 2 ret += M // 4 print(ret)
p02630
s123160618
Accepted
cnt = [0]*(10**5+1) n = int(input()) a = list(map(int,input().split())) s = sum(a) for i in range(n): cnt[a[i]] += 1 q = int(input()) for i in range(q): b,c = map(int,input().split()) s += (c-b)*cnt[b] cnt[c] += cnt[b] cnt[b] = 0 print(s)
p02795
s255992812
Accepted
h = int(input()) w = int(input()) n = int(input()) for i in range(min(h,w)): if (i+1)*max(h,w)>=n: print(i+1) break
p04031
s862341650
Accepted
# -*- coding: utf-8 -*- def main(): N = int(input()) a = list(map(int, input().split())) cost = 0 listCost = [] for i in range(min(a), max(a)+1): for j in a: if i != j: cost += (i - j) ** 2 listCost.append(cost) cost = 0 ans = min(li...
p02819
s252349102
Wrong Answer
X=int(input()) flag=0 while flag==0: X=X+1 for k in range(2,int(X**0.5)+1): if k==int(X**0.5) and X%k!=0: flag=1 if k>2 and k%2==0: continue elif k>3 and k%3==0: continue elif X%k==0: break print(X)
p02779
s190351369
Wrong Answer
n = int(input()) a = list(map(int,input().split())) a.sort() tmp = 0 for i in range(n-1): if a[i]==a[i+1]: tmp = 1 break if tmp == 1: print('No') else: print('Yes')
p02707
s753779791
Accepted
n = int(input()) a = list(map(int,input().split())) emp = [0]*(n+1) for i in range(len(a)): emp[a[i]] += 1 for i in range(1,n+1): print(emp[i])
p03623
s694177545
Accepted
x,a,b=map(int,input().split()) A=abs(x-a) B=abs(x-b) if A>B: print('B') else: print('A')
p03250
s100069138
Accepted
a = sorted(list(map(int, input().split())),reverse=True) print(a[0]*10+a[1]+a[2])
p02660
s980524208
Wrong Answer
from collections import defaultdict def prime_factor(n): d = defaultdict(int) for i in range(2, n + 1): if i * i > n: break while n % i == 0: d[i] += 1 n //= i if n != 1: d[n] += 1 return d N = int(input()) d = prime_factor(N) ans = 0 fo...
p04020
s250010576
Accepted
import math N=int(input()) ans=0 cnt=0 for i in range(N): a=int(input()) if a!=0: cnt+=a else: ans+=cnt//2 cnt=0 print(ans+cnt//2)
p02725
s425760955
Accepted
import numpy as np from functools import * import sys sys.setrecursionlimit(100000) def acinput(): return list(map(int, input().split(" "))) def II(): return int(input()) K,N=acinput() A=acinput() A.append(A[0]+K) B=np.array(A)+K #A.extend(B) a=np.array(A) print(K-np.max(a[1:]-a[:-1]))
p03038
s704756073
Accepted
N, M = map(int,input().split()) An = list(map(lambda x:[int(x),1],input().split())) D = [[0]*2 for _ in range(M)] for i in range(M): B, C = map(int,input().split()) D[i] = [C,B] An.extend(D) An.sort(reverse=True) num = 0 cnt = 0 for i in range(len(An)): if cnt+An[i][1] >= N: num += An[i][0]*(N-cnt) print(...
p02819
s115674002
Accepted
x=int(input()) while True: for i in range(2,int(x**0.5)+1): if x%i == 0: x+=1 break else: break print(x)