problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03250
s533841241
Accepted
a,b,c=map(int,input().split()) x=max(a,b,c) print(9*x+a+b+c)
p02779
s986168335
Accepted
n = int(input()) a = list(map(int,input().split())) if len(set(a)) == len(a): print("YES") else: print("NO")
p03319
s621557238
Wrong Answer
n, k = map(int, input().split()) l = list(map(int, input().split())) if sum(l) == len(l): print(0) else: print((n+k-1)//k)
p03672
s606264599
Accepted
s = input() ans = ((len(s)-1)//2)*2 while True: if s[0:ans//2] == s[ans//2:ans]: break ans -= 2 print(ans)
p03449
s054576246
Accepted
N=int(input()) list1=list(map(int,input().split())) list2=list(map(int,input().split())) t=sum(list2) M=list1[0]+t s=list1[0] for i in range(1,N): s=s+list1[i] t=t-list2[i-1] M=max(M,s+t) print(M)
p02602
s398051918
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")
p04044
s046390249
Accepted
a, b = map(int, input().split()) print("".join(sorted([input() for _ in range(a)])))
p04033
s346524393
Wrong Answer
a, b = map(int, input().split()) zero = (a == 0 | b == 0) | (a < 0 and 0 < b) | (b < 0 and 0 < a) negative_a = (a < 0 and 0 < b) and (a + b + 1) % 2 != 0 negative_b = (a < 0 | 0 < b) | (b < 0 | 0 < a) if zero: print("Zero") elif negative_a | negative_b: print("Negative") else: print("Positive")
p02717
s738580389
Accepted
X, Y, Z = input().split() print(Z + " " + X + " " + Y)
p02989
s725953557
Accepted
N = int(input()) D = sorted([int(i) for i in input().split()]) print(D[N//2]-D[N//2-1])
p03433
s999012536
Accepted
N = int(input()) A = int(input()) print("Yes" if N % 500 <= A else "No")
p03289
s089902834
Wrong Answer
s = list(input()) j= 0 count = 0 if not s[0] == 'A': print('WA') exit() for i in s[2:-1]: if i == 'C': count += 1 tmp = j j += 1 if not count == 1: print('WA') exit() del s[0] del s[tmp-1] s = ''.join(s) if s.isupper(): print('WA') exit() print('AC')
p02818
s431378176
Accepted
import fileinput a, b, k = map(int, input().split()) if a >= k: print(a - k, b) else: print(0, max(0, b - (k - a)))
p03695
s627124566
Accepted
def resolve(): n = input() c = [False] * 8 p = 0 for i in list(map(int, input().split())): if i >= 3200: p += 1 else: c[i//400] = True print(sum(c) or 1, sum(c) + p) resolve()
p02701
s195934114
Accepted
s = set([]) for i in range(int(input())): s.add(input()) print(len(s))
p02742
s583808023
Wrong Answer
H, W = map(int, input().split()) if H*W % 2 != 0: print(H*W//2+1) else: print(H*W//2)
p03821
s471442042
Wrong Answer
n = int(input()) AB = [] for i in range(n): ab = list(map(int, input().split())) AB.append(ab) ans = 0 for [a,b] in AB[::-1]: if a%b == 0: pass else: quo = (ans +a)//b ans = (quo+1)*b - a print(ans)
p02829
s834652573
Accepted
l = [] l.append(int(input().rstrip())) l.append(int(input().rstrip())) print(6 - sum(l))
p02973
s607280496
Accepted
from collections import deque from bisect import bisect_left def main(): N = int(input()) A = [int(input()) for _ in range(N)] d = deque([]) d.append(A[0]) for i in range(1,N): p = bisect_left(d, A[i]) if p == 0: d.appendleft(A[i]) else: d[p-1] = A[i] print(len(d)) if __name__ == "__main__": main()
p02724
s021866249
Wrong Answer
X = int(input()) a = X // 500 b = (X % 500) // 5 print(a+b)
p02712
s570483674
Accepted
N = int(input()) ans = 0 for i in range(1,N+1): if not (i%3 == 0 or i%5 == 0): ans += i print(ans)
p02848
s137465131
Wrong Answer
n = int(input()) s = input() al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" str = "" for i in range(len(s)): str += al[(al.find(s[i])+1+1)%26] print(str)
p02993
s366952095
Wrong Answer
S = list(input()) prev = S[0] ans = True for s in range(1, 4): if s == prev: ans = False prev = s print("Good" if ans else "Bad")
p03281
s466263303
Accepted
import math n = int(input()) ans = 0 for i in range(1, n+1): if i % 2 != 0: prime_num = 0 for j in range(1, n+1): if i % j == 0: prime_num += 1 if prime_num == 8: ans += 1 print(ans)
p03943
s833143480
Wrong Answer
a=[int(i) for i in input().split()] if a[0]==sum(a[1:]) or sum(a[:2])==a[2]: print("Yes") else: print("No")
p02720
s471773280
Accepted
cands = [1, 2, 3, 4, 5, 6, 7, 8, 9] def add_v(v): global cands global K v = str(v) v0 = int(v[-1]) if v0 == 0: cands += [int(v+'0'), int(v+'1')] K -=2 elif v0 == 9: cands += [int(v+'8'), int(v+'9')] K -= 2 else: cands += [int(v+str(v0-1)), int(v+str(v0)), int(v+str(v0+1))] K -= 3 K = int(input()) idk = K K -= 9 idx = 0 while K >= 0: add_v(cands[idx]) idx += 1 print(cands[idk-1])
p03495
s257129922
Accepted
import collections n,k=map(int,input().split()) a=list(map(int,input().split())) c=collections.Counter(a) values = sorted(c.values()) ans=0 sum_values=len(values) for i in range(len(values)): if sum_values<=k: break else: sum_values-=1 ans+=values[i] print(ans)
p03086
s055141738
Wrong Answer
S=input() acgt=["A","C","G","T"] max_length = 0 length = 0 for word in S: if word in acgt: length+=1 else: if length!=0: if max_length<length: max_length=length length=0 print(max_length)
p03261
s957325150
Accepted
n = int(input()) w = [] for i in range(n): tmp = input() w.append(tmp) ans = True for i in range(1, n): if w[i][0] != w[i-1][len(w[i-1])-1]: ans = False break else: for j in range(0, i): if w[j] == w[i]: ans = False break if ans: print("Yes") else: print("No")
p03106
s243622037
Accepted
from math import * a,b,k=map(int,input().split()) g=gcd(a,b) for i in range(g,0,-1): if(g%i==0): k-=1 if(k==0): print(i) break
p04034
s965234431
Accepted
N, M = map(int,input().split()) cnt = [1 for i in range(N+1)] flag = [0 for i in range(N+1)] flag[1] = 1 for _ in range(M): x, y = map(int,input().split()) if flag[x]: flag[y] = 1 if cnt[x] == 1 and flag[x]: flag[x] = 0 cnt[x] -= 1 cnt[y] += 1 print(sum(flag))
p03001
s155916582
Accepted
def resolve(): W,H,x,y=map(int,input().split()) if (W,H)==(2*x,2*y): print(W*H/2, 1) else: print(W*H/2, 0) resolve()
p02707
s041053399
Accepted
#abc163c n=int(input()) a=list(map(int,input().split())) res=[0]*n for x in a: res[x-1]+=1 for i in res: print(i)
p03951
s048411309
Accepted
n = int(input()) s = input() t = input() tmp = -1 for i in range(n): if s[-i - 1:] == t[:i + 1]: tmp = i print(n + n - (tmp + 1))
p03759
s331569782
Wrong Answer
a, b, c = map(int, input().split()) print('YES' if abs(a-b) == abs(b-c) else 'NO')
p03767
s035156429
Accepted
n = int(input()) l = sorted(list(map(int, input().split())), reverse=True) print(sum(l[1:2*n:2]))
p02693
s628891693
Accepted
k=int(input()) a,b=map(int,input().split()) t=a while t<b+1: if t%k==0: print("OK") exit() t+=1 print("NG")
p02777
s599528155
Accepted
#Macで実行する時 import sys import os if sys.platform=="darwin": base = os.path.dirname(os.path.abspath(__file__)) name = os.path.normpath(os.path.join(base, '../atcoder/input.txt')) sys.stdin = open(name) l = list(map(str,input().split())) a,b = map(int,input().split()) check = input() if check == l[0]: a -= 1 else: b -= 1 print(a,b)
p02792
s015436520
Accepted
N = int(input()) dp = [[0]*10 for _ in range(10)] for i in range(1, N+1): if i%10==0: continue strI = str(i) f,l = strI[-1], strI[0] dp[int(f)][int(l)] += 1 res = 0 for i in range(1,10): for j in range(1,10): res += dp[i][j] * dp[j][i] print(res)
p03109
s051936704
Accepted
S = input() print('Heisei' if S <= '2019/04/30' else'TBD')
p03309
s739719443
Accepted
import math N = int(input()) A = list(map(int,input().split())) for i in range(N): A[i] -= i+1 A.sort() b = A[N//2] sad = 0 for i in range(N): sad += abs(A[i]-b) print(sad)
p04012
s361487799
Accepted
w = list(input()) x = list(set(w)) for i in x: y = w.count(i) if y % 2 != 0: print('No') exit(0) print('Yes')
p03625
s511075923
Accepted
n=int(input()) a=sorted(list(map(int,input().split()))) c=1 x=[] for i in range(n-1): if a[i]!=a[i+1]: if c>=2: x.append(a[i]) if c>=4: x.append(a[i]) c=1 else: c+=1 if c>=2: x.append(a[n-1]) if c>=4: x.append(a[n-1]) if len(x)<=1: print(0) else: print(x[-1]*x[-2])
p03438
s884169349
Accepted
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) cnt1=[0]*n cnt2=[0]*n for i in range(n): if a[i]>b[i]: cnt2[i]=a[i]-b[i] else: num4=b[i]-a[i] cnt1[i]=-(num4//-2) cnt2[i]=num4%2 num5=abs(sum(a)-sum(b)) if max(sum(cnt1),sum(cnt2))+abs(sum(cnt1)-sum(cnt2))<=num5: print("Yes") else: print("No")
p02993
s742776701
Accepted
s = str(input().split()) i = 0 + 2 while True: if s[i] == s[i + 1]: print_ans = 'Bad' break else: print_ans = 'Good' i += 1 if i == 3 + 2: break print(print_ans)
p02909
s019154426
Wrong Answer
# -*- coding: utf-8 -*- s = input() if s == "Sunny": print("Cloudy") elif s == "Cloudy": print("Rainy") else: print("Sunday")
p04033
s022774253
Accepted
a, b = [int(i) for i in input().split()] if a > 0: print("Positive") elif a == 0: print("Zero") else: if b >= 0: print("Zero") else: if (b - a) % 2 == 0: print("Negative") else: print("Positive")
p02548
s418908332
Accepted
N = int(input()) ans = 0 for i in range(1, N): ans += (N-1) // i print(ans)
p03705
s770500902
Wrong Answer
n,a,b = map(int,input().split()) if a > b : print(0) exit() elif n == 1 and a != b: print(0) exit() else: print((b-a)*2+1)
p03721
s348006532
Wrong Answer
n,k=map(int,input().split()) ab=[list(map(int,input().split())) for _ in range(n)] tmp=0 for a,b in ab: tmp+=b if tmp>=k: print(a) exit()
p02719
s812554746
Wrong Answer
n, k = map(int, input().split()) buff = n while True: n -= k if n <= 0: n = abs(n) break print(n)
p03160
s299512711
Wrong Answer
N = int(input()) h = input().split() h = [int(i) for i in h] dp = [10**7] * 10**5 dp[0] = 0 for i in range(1, N): dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i-1])) if i > 1: dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i-2])) print(dp[N-1])
p02711
s408490981
Accepted
a = input() if a[0] == "7" or a[1] == "7" or a[2] == "7": print("Yes") else: print("No")
p03773
s368735007
Wrong Answer
a, b = map(int,input().split()) result =a+b if result > 24: print(result-24) else: print(result)
p02859
s315979154
Accepted
r=int(input()) print(r*r)
p03437
s581019566
Accepted
X, Y = map(int, input().split()) if X % Y == 0: print(-1) else: print(X)
p03860
s089471869
Accepted
def main(): s = input().split()[1] print('A{}C'.format(s[0])) if __name__ == '__main__': main()
p02747
s555369105
Wrong Answer
s = input() s.replace('hi', '') if s: print('No') else: print('Yes')
p02995
s830639665
Accepted
def gcd(a, b): while b: a, b = b, a % b return a a, b, c, d = map(int, input().split()) lcm = c * d // gcd(c, d) b_c = b - b // c b_d = b - b // d b_cd = b - b // lcm z_to_b = b_c + b_d - b_cd am1 = a-1 a_c = am1 - am1 // c a_d = am1 - am1 // d a_cd = am1 - am1 // lcm z_to_a = a_c + a_d - a_cd print(z_to_b - z_to_a)
p02779
s964589940
Wrong Answer
def main(): N = int(input()) A = list(map(int, input().split())) if len(A) == len(set(A)): return 'YES' return 'No' if __name__ == '__main__': print(main())
p02801
s013813267
Accepted
def main(): from string import ascii_lowercase c = input() idx = ascii_lowercase.index(c) print(ascii_lowercase[idx + 1]) if __name__ == '__main__': main() # import sys # # sys.setrecursionlimit(10 ** 7) # # input = sys.stdin.readline # rstrip() # int(input()) # map(int, input().split())
p03086
s222501796
Wrong Answer
def resolve(): S = input() cnt = 0 maxC = 0 for s in S: if s in "ACGT": cnt += 1 else: maxC = max(maxC, cnt) cnt = 0 print(maxC) resolve()
p03862
s599029414
Wrong Answer
N, x = map(int, input().split()) A = list(map(int, input().split())) if len(A) % 2 == 0: A = A + [0] # print('A', A) ans = 0 for i in range(1, N, 2): total = A[i - 1] + A[i] diff = total - x if diff <= 0: continue v1 = min(A[i], diff) v2 = diff - v1 A[i] -= v1 A[i - 1] -= v2 ans += v1 + v2 # print('A', A) print(ans)
p02935
s253366044
Wrong Answer
n = int(input()) a = list(map(int,input().split())) a.sort() for i in range(n-1): a[i+1] = (a[i] + a[i+1] / 2) print(a[-1])
p02789
s574923489
Accepted
""" input(): 入力を文字列として1行取ってくる "文字列".split(): 文字列をパースする(空白などで分割する) 例:"2 3 4 5" をsplitしたら、[2, 3, 4, 5] に分割する map(型, list): list の中身をそれぞれ指定した型で変数に入れる """ N, M = map(int, input().split()) if N == M: print("Yes") else: print("No")
p02687
s102795474
Accepted
def main(): s = input() if s == "ABC": print("ARC") else: print("ABC") main()
p02862
s706889079
Wrong Answer
i, j = map(int, input().split()) if (i + j) % 3 != 0 or (max(i, j) / min(i, j) >= 2): print(0) else: TW = (i + j) // 3 W = (TW - (i-j)) // 2 def mod_cmb(n, r, mod=10**9+7): r = min(r, n-r) res = 1 for i in range(r): res = res * (n - i) % mod * pow(i+1, mod-2, mod) % mod return res print(mod_cmb(TW, W))
p02623
s529183628
Wrong Answer
n,m,k=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=a+b c.sort() i=0 sum=0 flag=0 while i<(n+m): sum=sum+c[i] i=i+1 if sum<=k: flag=flag+1 else: break print(flag)
p02747
s344724745
Wrong Answer
s=input() print(len(s)) for i in range(len(s)): if s[i]=="h": if i<len(s)-1: if s[i+1]=="i": print("Yes") break print("No")
p02702
s380718630
Wrong Answer
s=input() res=0 t=1 p=[0]*2019 for i in map(int,s[::-1]): res+=i*t res%=2019 p[res]+=1 t*=10 t%=2019 print(p[0]+sum((i*(i-1)//2) for i in p[1:]))
p02690
s956872106
Accepted
from numba import njit @njit def main(X): for a in range(-2000, 2001): for b in range(-2000, 2001): if pow(a, 5) - pow(b, 5) == X: print(a, b) return if __name__ == '__main__': X = int(input()) main(X)
p03962
s423109229
Accepted
a = set(list(map(int, input().split()))) print(len(a))
p03419
s537887225
Accepted
#29 C - Flip,Flip, and Flip...... N,M = map(int,input().split()) N,M = min(N,M), max(N,M) if N == 1 and M == 1: ans = 1 elif N == 1 and M != 1: ans = M - 2 elif N == 2 : ans = 0 else: ans = M*N - (2*M + 2*N) + 4 print(ans)
p03286
s521583650
Accepted
n = int(input()) ans = 0 base = 1 n = -n while (n != 0): p = abs(n % (-2)) n = (n + p) // (-2) ans += p * base base *= 10 print(ans)
p02801
s825070949
Wrong Answer
import sys, string c = sys.stdin.readline().rstrip() a = string.ascii_lowercase i = a.index('c') + 1 print(a[i])
p02718
s624947623
Accepted
n, m = map(int, input().split()) a = sorted(list(map(int, input().split())),reverse=True) t = 0 for i in range(n): t += a[i] if a[m-1] >= t/(4*m): print("Yes") else: print("No")
p02847
s718319606
Wrong Answer
s = input() arr = ["SUN","Mon","TUE","WED","THU","FRI","SAT"] for i in range(7): if s==arr[i]: print(7-i)
p02678
s409323219
Accepted
from collections import deque n,m=map(int,input().split()) node=[[] for _ in range(n)] for i in range(m): a,b=map(int,input().split()) node[b-1].append(a-1) node[a-1].append(b-1) distance=[-1]*n distance[0]=0 d=deque() d.append(0) while d: v=d.popleft() for i in node[v]: if distance[i]!=-1: continue distance[i]=v+1 d.append(i) print('Yes') for i in range(1,n): print(distance[i])
p03469
s441187150
Accepted
S = list(input()) S[3] = '8' print(''.join(S))
p02971
s709537598
Accepted
N = int(input()) A = [int(input()) for _ in range(N)] B = sorted(A,reverse=True) for i in range(N): if A[i] == B[0]: print(B[1]) else: print(B[0])
p02760
s827828429
Accepted
a = [list(map(int, input().split())) for i in range(3)] n = int(input()) q,l,r = 0,0,0 for _ in range(n): b = int(input()) for i in range(3): if b in a[i]: a[i][a[i].index(b)]=0 for i in range(3): l += a[i][i] t,y = 0,0 for j in range(3): y += a[j][i] t += a[i][j] if i+j == 2: r += a[i][j] if not t or not y: q=1 print('Yes' if q or not l or not r else 'No')
p03136
s876795269
Accepted
input() L=sorted(map(int,input().split()))[::-1] print("Yes" if L[0]<sum(L[1:]) else "No")
p03592
s343151677
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, M, K = mapint() s = set() for i in range(N+1): for j in range(M+1): s.add(i*M+j*N-i*j*2) if K in s: print('Yes') else: print('No')
p02640
s939123084
Wrong Answer
x,y=map(int,input().split()) #x匹でy本 if y<2*x or 4*x>y: print("No") else: print("Yes")
p02754
s301853535
Accepted
import math S,A,B=map(int,input().split()) q=S//(A+B) mod=S%(A+B) if mod>=A: print(q*A+A) else: print(q*A+mod)
p03208
s587768885
Accepted
n, k = map(int, input().split()) h = [0] * n for i in range(n): h[i] = int(input()) h.sort() arr = [] for i in range(n-k+1): arr.append(abs(h[i] - h[i+k-1])) print(min(arr))
p03377
s044589420
Accepted
a, b, x = map(int, input().split()) #a to a+b if x >= a and x <= a + b: print("YES") else: print("NO")
p02789
s993095375
Accepted
a,b = input().split() a = int(a) b = int(b) if(a==b): print("Yes") else: print("No")
p02833
s160721694
Accepted
p=0 n=int(input()) for i in range(1,50): p+=n//(2*(5**i)) print(p if n%2==0 else 0)
p03557
s737826502
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, b, c = sorted(a), sorted(b), sorted(c) ans = 0 for i in b: up_index = bisect.bisect_left(a,i) down_index = bisect.bisect_right(c,i) ans += up_index * (n-down_index) print(ans)
p03493
s896547434
Accepted
s=str(input()) numbers=[] for i in s: numbers.append(i) ##3print(numbers) count=0 for number in numbers: if number=='1': count+=1 print(count)
p02627
s375998025
Accepted
#abc171a c=input() if c.islower(): print('a') else: print('A')
p02554
s726881326
Wrong Answer
mod = 10**9+7 N = int(input()) if N == 1: print(0) exit() plus = 1 minus = 1 cap = 1 for _ in range(N): plus *= 10 minus *= 9 cap *= 8 plus %= mod minus %= mod cap %= mod print(plus-2*minus+cap)
p03360
s588885671
Accepted
a = list(map(int, input().split())) k = int(input()) a.sort() print(sum(a[:-1]) + a[-1] * 2 ** k)
p02843
s627949567
Accepted
X = int(input()) more_100 = X/100 under_100 = X%100 X2 = int(under_100 / 5) X3 = under_100 % 5 if X3 != 0 and X2 + 1 <= more_100: print(1) elif X3 == 0 and X2 <= more_100: print(1) else: print(0)
p02699
s759268137
Wrong Answer
S,W=map(int,input().split()) if (W>=S): print('Unsafe') else: print('Safe')
p02787
s242691776
Wrong Answer
INF = 10**6 H, N = map(int, input().split()) magics = [tuple(map(int, input().split())) for _ in range(N)] dp = [[INF]*(H+1) for _ in range(N+1)] dp[0][0] = 0 for i, (a, b) in enumerate(magics): for j in range(H+1): dp[i+1][j] = min(dp[i+1][j], dp[i][j]) dp[i+1][min(H, j+a)] = min(dp[i+1][min(H, j+a)], dp[i+1][j] + b) print(dp[N][H])
p03030
s253709358
Accepted
""" author : halo2halo date : 9, Jan, 2020 """ import sys # import numpy as np import itertools read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) N = int(readline()) SP = [(x.split()[0].decode('utf8'), int(x.split()[1])) for x in readlines()] SPs = sorted((name, -pt, i + 1) for i, (name, pt) in enumerate(SP)) print('\n'.join(str(a[2]) for a in SPs))
p03745
s739342084
Accepted
n = int(input()) a = [int(_) for _ in input().split()] mode = 0 ans = 1 for i in range(0, n-1): if mode == 0: if a[i] < a[i+1]: mode = 1 elif a[i] > a[i+1]: mode = 2 elif mode == 1: if a[i] > a[i+1]: ans += 1 mode = 0 else: if a[i] < a[i+1]: ans += 1 mode = 0 print(ans)
p02947
s538159889
Accepted
# -*- coding: utf-8 -*- """ Created on Wed Mar 25 18:54:16 2020 @author: Kanaru Sato """ n = int(input()) Dict = {} ans = 0 for i in range(n): s = list(input()) s.sort() s = "".join(s) if s in Dict: ans += Dict[s] Dict[s] += 1 else: Dict[s] = 1 print(ans)