problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02639
s714795037
Accepted
a = list(map(int,input().split())) print(a.index(0)+1)
p03485
s364934976
Accepted
import math a, b = map(int, input().split()) mean = float((a + b) / 2) print(math.ceil(mean))
p02687
s639473385
Wrong Answer
s = input() if s == "ABC": print("ARC") else: print("ARC")
p02910
s383206036
Wrong Answer
s = input() count = 0 for i in range(len(s)): if (i+1) % 2 != 0 and s[i] != 'R' and s[i] != 'U' and s[i] != 'D': count += 1 elif (i+1) % 2 == 0 and s[i] != 'L' and s[i] != 'U' and s[i] != 'D': count += 1 else: break if count == 0: print('Yes') else: print('No')
p03524
s836712598
Accepted
S = input() a = S.count('a') b = S.count('b') c = S.count('c') if abs(a-b) <= 1 and abs(a-c) <= 1 and abs(b-c) <= 1: print("YES") else: print("NO")
p02621
s375129249
Accepted
a = int(input()) print(a + a**2 + a**3)
p02688
s813882268
Accepted
n,k = list(map(int,input().split())) snk_list = [] for i in range(k): input() b = list(map(int,input().split())) snk_list+=b print(n-len(set(snk_list)))
p02963
s640871077
Accepted
import sys def solve(): input = sys.stdin.readline S = int(input()) #|ac - bd| == S, a == 10 ** 9 a = 10 ** 9 c = (S - 1) // a + 1 bd = a * c - S if bd == 0: b, d = 0, 0 else: for i in range(1, bd): if i ** 2 > bd: break if bd % i == 0: b, d = i, bd // i break print(0, 0, a, b, d, c) return 0 if __name__ == "__main__": solve()
p02953
s451088640
Accepted
n=int(input()) h=list(map(int,input().split())) ans="Yes" for i in range(n-1): if h[i]<h[i+1]: h[i+1]-=1 if h[i]>h[i+1]: ans="No" break print(ans)
p02795
s995910355
Wrong Answer
def read(): h = int(input()) w = int(input()) n = int(input()) return h, w, n def calc(h, w, n): if h > w: return int(n / h) + 1 else: return int(n / w) + 1 def main(): print(calc(*read())) if __name__ == "__main__": main()
p02707
s394747792
Wrong Answer
N = int(input()) emp = list(map(int,input().split())) emp.sort() def rem_val(arr, value): while value in arr: try: arr.remove(value) except: break for i in range(N): if(len(emp)!=0): print(emp.count(i+1)) rem_val(emp,i+1) print(0)
p03105
s283649737
Accepted
a, b, c = map(int, input().split()) cnt = 0 while cnt < c and a <= b: b -= a cnt += 1 print(cnt)
p03778
s917565429
Accepted
W, a, b = map(int, input().split()) if abs(a - b) < W: print(0) else: print(abs(a - b) - W)
p03377
s153066742
Accepted
a, b, x = map(int, input().split()) ans = 'NO' if x >= a and a + b >= x: ans = 'YES' print(ans)
p02694
s624955432
Wrong Answer
X = int(input()) ans = 0 money = 100 TAX = 1.01 while money < X: money = int(money * TAX) ans += 1 print(ans)
p02732
s850156636
Accepted
import collections n = int(input()) a = list(map(int,input().split())) x = collections.Counter(a) keys = [] values = [] b = list(set(a)) for i in b: z = x[i] keys.append(i) values.append(z*(z-1)//2) s = sum(values) d = dict(zip(keys,values)) for i in a: ans = s ans -= d[i] ans += (x[i]-1)*(x[i]-2)//2 print(ans)
p02552
s481029478
Accepted
if (int(input())) == 0: print(1) else: print(0)
p03644
s347273019
Accepted
n = int(input()) a = 1 while True: if n < 2 ** a: break a += 1 print(2**(a-1))
p02948
s904556242
Wrong Answer
import heapq N,M = map(int,input().split()) jobs = [] for _ in range(N): j = list(map(int,input().split())) if j[0] > M: continue jobs.append(((-j[1],-j[0]), j[0])) heapq.heapify(jobs) res = 0 for d in range(M): while jobs: t,i = heapq.heappop(jobs) s,_ = t if d+i <= M: res += -s break print(res)
p03779
s682177209
Accepted
X = int(input()) for i in range(10 ** 9): if (i * (i + 1)) // 2 >= X: print(i) exit()
p03043
s486825944
Accepted
n, k = map(int, input().split()) ans = 0 for i in range(1, n+1): res = 0 while i < k: i *= 2 res += 1 ans += (1/n)*(1/2)**res print(ans)
p03612
s652761206
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, *p = map(int, read().split()) p += [0] cnt = 0 for i, pp in enumerate(p): if (i + 1) == pp: p[i + 1] = 0 cnt += 1 print(cnt)
p02917
s052350840
Accepted
import numpy as np n = int(input()) B = list(map(int, input().split())) A = [0]*n A[0] = B[0] A[n-1] = B[n-2] for i in list(range(1,n-1)): A[i] = min(B[i-1], B[i]) print(sum(A))
p03607
s789381740
Wrong Answer
N = int(input()) A = [int(input()) for _ in range(N)] A=sorted(A) ans=0 cnt=1 tmp=A[0] for i in range(1,N): if A[i]!=tmp and cnt%2==0: tmp=A[i] cnt=1 elif A[i]!=tmp and cnt%2!=0: tmp=A[i] cnt=1 ans+=1 elif A[i]==tmp: cnt+=1 print(ans)
p02783
s410257255
Accepted
H, A = map(int, input().split()) ans = 0 while H > 0: ans += 1 H -= A print(ans)
p03475
s550422914
Wrong Answer
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) csf = [list(map(int, readline().split())) for _ in range(n - 1)] for i, (c, s, _) in enumerate(csf): s += c for j, (cc, ss, ff) in enumerate(csf[i + 1:]): if s <= ss: s = ss else: if j + i < n - 2: s += s % ff s += cc print(s) print(0)
p02951
s556995814
Accepted
a,b,c = map(int, input().split()) tmp = a-b if c - tmp < 0: print(0) else: print(c-tmp)
p03319
s034290755
Accepted
N,K = map(int, input().split()) A = list(map(int, input().split())) T = N - K if T == 0: print(1) elif T%(K-1) == 0: print(1+T//(K-1)) else: print(2+T//(K-1))
p03250
s850555449
Accepted
a = list(input().split()) a.sort() x = a[0] y = a[2]+a[1] print(int(x)+int(y))
p03352
s333264123
Accepted
x = int(input()) ans = 1 for b in range(1, 32): for p in range(2, 10): if b**p <= x: ans = max(ans, b**p) print(ans)
p03681
s363972382
Accepted
import math; f=math.factorial; n,m=sorted(map(int,input().split())); print(max(2-m+n,0)*f(n)*f(m)%(10**9+7))
p03073
s230398710
Wrong Answer
s = input() oi = "01" io = "10" oans = 0 ians = 0 for i in range(len(s)//2): if s[2*i]+s[2*i+1] != oi: if s[2*i] == "0" or s[2*i+1] == "1": oans += 1 else: oans += 2 if s[2*i]+s[2*i+1] != io: if s[2*i] == "1" or s[2*i+1] == "0": ians += 1 else: ians += 2 print(min(oans, ians))
p03862
s816069984
Wrong Answer
N, x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 keep = a[0] for i in range(1, N): if (keep + a[i]) > x: ans = ans + (keep + a[i] - x) keep = x - keep else: keep = a[i] ans2 = 0 a = a[::-1] keep = a[0] for i in range(1, N): if (keep + a[i]) > x: ans2 = ans2 + (keep + a[i] - x) keep = x - keep else: keep = a[i] print(min(ans2, ans))
p02629
s596813216
Accepted
def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) n = int(input()) print(num2alpha(n).lower())
p03360
s547952165
Accepted
L = list(map(int, input().split())) K = int(input()) print(sum(L) + max(L) * (2 ** K - 1))
p03136
s844056439
Accepted
def solve(): N = int(input()) Llist = list(map(int, input().split())) MAX = max(Llist) if MAX < sum(Llist)-MAX: print("Yes") else: print("No") if __name__ == "__main__": solve()
p03145
s489813783
Wrong Answer
a,b,c=map(int,input().split()) print(a*b/2)
p02723
s359082037
Accepted
s = input() if len(s) == 6 and s[2] == s[3] and s[4] == s[5]: print('Yes') else: print('No')
p03485
s231093090
Wrong Answer
a,b=map(int,input().split()) print(round((a+b)/2))
p03555
s944656219
Wrong Answer
s1 = input() s2 = input() print("YES") if s1 == s2[::-1] else print("No")
p03210
s916138087
Accepted
x = int(input()); y = [3,5,7] if x in y: print('YES') else: print('NO')
p02953
s121673133
Wrong Answer
n=int(input()) h=list(map(int,input().split())) for i in range(n-2): if h[i+1]-h[i]>=2: print("No") break else: print("Yes")
p03126
s282326764
Accepted
#ABC118B N,M=map(int,input().split()) food=[1]*(M+1) for _ in range(N): q=list(map(int,input().split())) q=q[1:] for item in range(M+1): if item not in q: food[item]=0 print(sum(food))
p02912
s895244652
Wrong Answer
n,m=map(int,input().split()) l=list(map(int,input().split())) l.sort(reverse=True) res=0 for i in range(n-1): while l[i] >= l[i+1] and m>0: l[i]= l[i] // 2 m-=1 l.sort(reverse=True) print(sum(l))
p03745
s588963727
Accepted
N = int(input()) A = list(map(int,input().split())) if N <= 2: print(1) exit() d = [] for i in range(N-1): if A[i+1] - A[i] > 0: d.append(1) elif A[i+1] - A[i] < 0: d.append(-1) flag = [True]*len(d) ans = 1 for i in range(len(d)-1): if flag[i]: if d[i] == -d[i+1]: ans += 1 flag[i+1] = False print(ans)
p03106
s827627160
Accepted
import numpy as np a,b,k = map(int,input().split()) c = np.gcd(a,b) print([i for i in range(1,c+1) if c%i==0][-k])
p02972
s607571365
Accepted
#coding: utf-8 N = int(input()) A = [0] + list(map(int, input().split())) B = [0 for _ in range(N+1)] ans = [] for i in range(N, 0, -1): v = 0 j = i while j <= N: v += B[j] j += i if A[i] != v % 2: ans.append(i) B[i] = 1 ans.sort() print(len(ans)) if len(ans) != 0: print(*ans)
p02778
s038077846
Accepted
s = input() print("x" * len(s))
p02723
s481328575
Accepted
s=input();print('YNeos'[not(s[2]==s[3] and s[4]==s[5])::2])
p03038
s623498969
Wrong Answer
import bisect n,m=map(int,input().split()) A=sorted(list(map(int,input().split()))) L=[] for i in range(m): b,c=map(int,input().split()) L.append((b,c)) L.sort(key=lambda x:x[1],reverse=True) print(A) print(L) for i in range(m): idx=bisect.bisect_left(A,L[i][1]) P=min(idx,L[i][0]) for j in range(P): A[j]=L[i][1] A.sort() print(sum(A))
p03555
s001839009
Accepted
c = [input() for i in range(2)] c0=[] for i in range(3): c0.append(c[0][i]) c1=[] for i in range(3): c1.append(c[1][i]) if c0[0]==c1[2] and c0[1]==c1[1] and c0[2]==c1[0]: print('YES') else: print('NO')
p03612
s674172527
Accepted
n = int(input()) p = list(map(int, input().split())) i = 0 ans = 0 while i != n: if p[i] == i + 1: cnt = 0 while i + cnt != n and p[i + cnt] == i + cnt + 1: cnt += 1 ans += cnt//2 + cnt%2 i += cnt else: i += 1 print(ans)
p03416
s859708304
Accepted
a,b=map(int,input().split()) print(len([i for i in map(str, range(a, b+1)) if i==i[::-1]]))
p03681
s816273335
Accepted
import math a,b=map(int,input().split()) m=10**9+7 p=math.factorial(a) q=math.factorial(b) if abs(a-b)==0:print(2*p*q%m) elif abs(a-b)==1:print(p*q%m) else:print(0)
p02947
s660586654
Wrong Answer
from collections import Counter N = int(input()) S = [str(sorted(input())) for _ in range(N)] count = 0 for i in Counter(S).values(): count = i*(i-1)//2 print(count)
p03625
s037767823
Wrong Answer
def resolve(): n = int(input()) a = list(map(int, input().split())) t = dict() for i in a: if t.get(i): t[i] += 1 else: t[i] = 1 a, b = 0, 0 for k in t: if t[k] >= 4: a = max(a, t[k]) b = max(b, t[k]) elif t[k] >= 2: if k > a: b = a a = k print(a*b) resolve()
p02880
s518506248
Wrong Answer
n = int(input()) flag = 0 for i in range(1, 10): for j in range(1, 10): if i*j == n: print('Yes') flag = 1 if flag == 0: print('No')
p03328
s011357674
Accepted
a,b = map(int,input().split()) a_all = 0 for i in range(1,(b-a)): a_all+=i print(a_all-a)
p03327
s513019410
Accepted
print(["ABC","ABD"][len(input())>3])
p03264
s920572274
Accepted
import math a=int(input())/2 print(math.floor(a)*math.ceil(a))
p02748
s954893757
Accepted
A, B, M = map(int, input().split()) As = list(map(int, input().split())) Bs = list(map(int, input().split())) min_p = min(As)+min(Bs) for i in range(M): a, b, m = map(int, input().split()) min_p = min(As[a-1]+Bs[b-1]-m, min_p) print(min_p)
p02778
s399810006
Accepted
S = input() print("x" * len(S))
p03077
s046589982
Accepted
n = int(input()) a = [int(input()) for _ in range(5)] m = min(a) t = (n-1) // m print(t+5)
p02706
s040392914
Wrong Answer
N,M = map(int,input().split()) A = list(map(int, input().split())) S=0 for a in A: S+=a if N-S>0: print(N-S) else: print(-1)
p02963
s179451671
Accepted
s = int(input()) m = 10**9 x = (m-s%m)%m y = (s+x)//m print(0,0,10**9,1,x,y)
p02641
s838037290
Accepted
X,N = map(int,input().split()) P = list(map(int,input().split())) if P == []: print(X) exit() for n in range(101): if X - n not in P: ans = X - n break if X + n not in P: ans = X + n break print(ans)
p02831
s150298047
Accepted
from fractions import gcd a,b=map(int,input().split()) def lcm(a,b): return a*b // gcd(a,b) print(lcm(a, b))
p03986
s691842874
Accepted
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): s = input() ans = len(s) cnt = 0 for char in s: if char == "S": cnt += 1 else: if cnt > 0: cnt -= 1 ans -= 2 print(ans) if __name__ == '__main__': main()
p02646
s039310993
Wrong Answer
a,v=map(float,input().split()) b,w=map(float,input().split()) t=float(input()) b = max(a,b) a = min(a,b) gap = abs(b-a) v_gap = abs(v-w) if v>w: if v_gap*t>=gap: print('YES') else: print('NO') else: print('NO')
p03013
s800912572
Accepted
import sys input = sys.stdin.readline mod = 10**9+7 N, M = map(int, input().split()) a = [int(input()) for _ in range(M)] a = a[::-1] dp = [0] * (N+1) dp[0] = 1 if a and a[-1] == 1: a.pop() else: dp[1] = 1 for i in range(2, N+1): if a and a[-1] == i: a.pop() else: dp[i] = (dp[i-1] + dp[i-2]) % mod print(dp[-1])
p03274
s108094456
Wrong Answer
#107_C N,K=map(int,input().split()) X=list(map(int,input().split())) #全探索 Ans=10**9 for i in range(N-K+1): XL,XR=X[i],X[i+K-1] if XL*XR>0: Ans=min(Ans,abs(XR-XL)) else: Ans=min(Ans,abs(XR)*2+abs(XL),abs(XL)*2+abs(XR)) print(Ans)
p03351
s232555845
Wrong Answer
a,b,c,d=map(int,input().split()) def abs__(x): if x <0: x = -1 * x return x a_b = abs__(a-b) b_c = abs__(b-c) if a_b <= d and b_c <= d: print("YES") else: print("NO")
p03035
s606226995
Accepted
a,b=map(int,input().split());print(b if a>=13 else (0 if a<=5 else b//2))
p03262
s437011349
Accepted
import fractions from functools import reduce def main(): n,x = map(int, input().split()) X = list(map(int,input().split())) array = [] for i in range(len(X)): array.append(abs(X[i]-x)) gcd1 = reduce(lambda a,b: fractions.gcd(a,b), array) print(gcd1) if __name__ == '__main__': main()
p02630
s564203797
Accepted
from collections import Counter N = int(input()) A = list(map(int, input().split())) sumA = sum(A) counter = Counter(A) Q = int(input()) for i in range(Q): B, C = map(int, input().split()) sumA += (counter[B]*C-counter[B]*B) counter[C] += counter[B] counter[B] = 0 print(sumA)
p03069
s779393614
Accepted
N = int(input()) S = input() tmp = 10 ** 9 cntB = S.count("#") cnt = 0 for i, s in enumerate(S): if s == "#": tmp = min(tmp, cnt + N - i - (cntB - cnt)) cnt += 1 print(min(cntB, tmp))
p02785
s375200767
Wrong Answer
N, K = map(int,input().split()) Monsters = list(map(int,input().split())) Monsters = sorted(Monsters) for i in range(min(K,N)): Monsters[i]=0 print(sum(Monsters))
p02787
s958544159
Accepted
h, n = map(int, input().split()) info = [list(map(int, input().split())) for i in range(n)] INF = 10**18 dp = [INF] * (h + 1) dp[h] = 0 for i in range(n): a, b = info[i] for j in range(h + 1)[::-1]: dp[max(j - a, 0)] = min(dp[j] + b, dp[max(j - a, 0)]) print(dp[0])
p03486
s710297431
Wrong Answer
n = sorted(list(input()),reverse=True) m = sorted(list(input()),reverse=True) if n<m: print('Yes') else: print('No')
p03211
s032895221
Accepted
s = input() ans = 10000000 for i in range(len(s) - 2): temp = abs(753 - int(s[i: i + 3])) ans = min(ans, temp) print(ans)
p03163
s649990765
Accepted
import math n, W = map(int, input().split()) dp = [0]*(W+1) for i in range(n): weight, cost = map(int, input().split()) for weight_already in range(W-weight, -1, -1): dp[weight_already+weight] = max(dp[weight_already+weight], dp[weight_already]+cost) ans = max(dp) print(ans)
p03448
s285387271
Wrong Answer
A,B,C,X = [int(input()) for i in range(4)] X_original = X n = 0 for i in range(int(A)+1): X = X_original X = X - i*500 for j in range(int(B)+1): X = X - j*100 for k in range(int(C)+1): if X-k*50 == 0: n += 1 print(n)
p02708
s452949932
Accepted
def main(): MOD = 10 ** 9 + 7 N, K = map(int, input().split()) ans = 0 low = sum(range(K - 1)) high = sum(range(N - K + 2, N + 1)) for take in range(K, N + 2): low += take - 1 high += N - (take - 1) ans = (ans + high - low + 1) % MOD print(ans) if __name__ == '__main__': main() # import sys # input = sys.stdin.readline # # sys.setrecursionlimit(10 ** 7) # # (int(x)-1 for x in input().split()) # rstrip()
p03077
s319291001
Accepted
#C n = int(input()) a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) t = [a,b,c,d,e] t.sort() if n % t[0] == 0: p = n // t[0] else: p = n // t[0] + 1 print(4+p)
p03416
s534882904
Wrong Answer
a, b = map(int, input().split()) ans = 0 for i in range(a, b+1): x = i % 100 y = i // 1000 if x == y: ans += 1 print(ans)
p04020
s213706308
Accepted
#B n = int(input()) cnt = 0 merge = 0 for _ in range(n): v = int(input()) if v==0: merge = 0 else: q,r = divmod(v,2) cnt += q cnt += (merge * r) merge = (1-merge)*r + (1-r)*merge print(cnt)
p02556
s326315530
Accepted
import sys n = int(sys.stdin.buffer.readline()) z, w = [0]*n, [0]*n for a, i in zip(sys.stdin.buffer.readlines(), range(n)): x, y = map(int, a.split()) z[i] = x+y w[i] = x-y print(max(abs(max(z)-min(z)), abs(max(w)-min(w))))
p02546
s712133811
Accepted
def readInt(): return int(input()) def readList(): return list(map(int,input().split())) def readMap(): return map(int,input().split()) def readStr(): return input() inf=float('inf') mod = 10**9+7 import math def solve(s): return s+'s' if s[-1]!='s' else s+'es' s=readStr() print(solve(s))
p03760
s729057810
Wrong Answer
o=input() e=input() for i in range(50): try: print(o[i]+e[i],end="") except: pass
p03131
s350549989
Wrong Answer
import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): K, A, B = map(int, readline().split()) ans = 1 if A+2>=B: ans += K else: if K<A+2: ans += K else: ans += A-1 ans += ((K-A+1)//2)*(B-A) ans += (K-A+1)%2 print(ans) if __name__ == '__main__': main()
p03767
s731880637
Accepted
n = int(input()) a = [int(i) for i in input().split()] a.sort() a.reverse() cnt = 0 for i in range(n): cnt += a[2*i+1] print(cnt)
p02918
s961466015
Accepted
n, k = map(int, input().split()) s = input() a = 'A' cnt = 0 for i in s: if a != i: a = i cnt += 1 print(n-max(1,cnt-2*k))
p03042
s581701801
Accepted
n=input() n1,n2=int(n[:2]),int(n[2:]) #if (n1>12 and n2>12) or (n1==0 and n2==0): # print("NA") if (n1!=0 and n1<=12) and (n2!=0 and n2<=12): print("AMBIGUOUS") elif n1!=0 and n1<=12: print("MMYY") elif n2!=0 and n2<=12: print("YYMM") else: print("NA")
p03910
s767478946
Accepted
import sys N = int(input()) l = [] def main(n): global l i = 1 while True: tmp = i*(i+1)//2 if tmp >= n: l.append(i) if n-i == 0: return l else: return main(n-i) i += 1 sys.setrecursionlimit(10000) li = main(N) for n in li: print(n)
p03556
s139806720
Accepted
n=int(input()) i=1 tmp=1 while True: if i**2<=n: tmp=i**2 else: break i+=1 print(tmp)
p02817
s961955854
Accepted
S, T = input().split() result = T + S print(result)
p02602
s241001626
Accepted
n,k = map(int, input().split()) a = list(map(int, input().split())) for i in range(k, n): if a[i] > a[i-k]: print('Yes') else: print('No')
p03339
s870906655
Wrong Answer
N = int(input()) S = list(input()) ans = N left_W = 0 right_E = S.count("E") for n in range(N): if n == 0: if S[n] == "E": right_E -= 1 ans = min(ans,left_W + right_E) elif n == N-1 : if S[n-1] == "W": left_W += 1 ans = min(ans,left_W + right_E) else: if S[n] == "E": right_E -= 1 if S[n-1] == "W": left_W += 1 ans = min(ans,left_W + right_E) print(ans)
p02772
s300640536
Wrong Answer
n=int(input()) a=map(int,input().split()) num = 0 for i in a: if i % 2 == 0: if i % 3 != 0 or i % 5 != 0: num='DENIED' else: num='APPROVED' else: num='DENIED' print(num)
p04029
s046158158
Accepted
a=int(input()) ans=a*(a+1)//2 print(ans)