problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03548
s275938122
Accepted
X,Y,Z = map(int,input().split()) p = X - Z a = Z+Y ans = p//a print(ans)
p03943
s893080978
Accepted
a, b, c = list(map(int, input().split())) if a == b + c or a + b == c or a + c == b: print('Yes') else: print('No')
p02899
s922990837
Wrong Answer
N=int(input()) A=list(map(int,input().split())) s=[] for i in range(1,N+1): s.append(A.index(i)+1) print(s)
p02948
s915590200
Wrong Answer
def main(): from collections import deque n, m, *ab = map(int, open(0).read().split()) c = list(zip(ab[::2], ab[1::2])) c = sorted(c, key=lambda x: (-x[1], -x[0])) q = deque(c) ans = 0 while m and q: a, b = q.popleft() if a <= m: ans += b m -= 1 ...
p03385
s318509484
Accepted
from collections import Counter s = Counter(list(input())) if len(s)==3: print('Yes') else: print('No')
p02973
s733001331
Accepted
import bisect # from collections import deque # from collections import Counter # from fractions import gcd # >=Python3.5 # lcm(最小公倍数) = (a*b)//gcd(a,b) # from fractions import Fraction # from math import gcd # <Python3.5 # from math import sqrt n = int(input()) li = [int(input()) for i in range(n)] li = [-x for x in...
p03645
s581300157
Accepted
# coding: utf-8 N,M=map(int,input().split()) L=[] B=[] A=[] flg=0 cnt=0 for i in range(M): a,b=list(map(int,input().split())) L.append([a,b]) if a==1: B.append(b) cnt+=1 elif b==N: A.append(a) #print(L) ans=[] if len(set(A)&set(B))==0: print('IMPOSSIBLE') else: p...
p03761
s138295864
Wrong Answer
N = int(input()) S = [input() for _ in range(N)] Common = list(S[0]) for s in S[1:]: Common = [x for x in Common if x in s] print(''.join(sorted(Common)))
p02933
s754466427
Wrong Answer
a = int(input()) s = input() if a>=3200: print('red') else: print(s)
p03386
s003930001
Wrong Answer
a, b, k = map(int, input().split()) min = [0] * k max = [0] * k for i in range(k): if a+i > b: break min[i] = a+i for n in range(k): if b-n < a: break max[n] = b-n ans = min + max ans.sort() ans = set(ans) for j in ans: if j == 0: continue print(j)
p03657
s846420821
Accepted
A, B = map(int, input().split()) total = A + B if total % 3 == 0 or A % 3 ==0 or B % 3 ==0: print("Possible") else: print("Impossible")
p02624
s001300835
Wrong Answer
def f(n): x = 0 for i in range(2, int(n ** 0.5 + 2)): if n == 1: x = 1 break elif n == 2: x = 2 break if n % i == 0: x += 1 else: x += 2 return x n = int(input()) ans = 0 for k in range(1, n + 1): print(k, f(k)) ans += k * f(k) print(ans)
p03795
s013123857
Accepted
n = int(input()) print(800*n - 200*(n//15))
p02702
s160532116
Accepted
s=input() l=len(s) amari=[0]*2019 amari[0]=1 d=0 digi=1 for c in s[::-1]: d=(int(c)*digi + d)%2019 amari[d]+=1 digi=(digi*10)%2019 ans=0 for i in amari: ans+=i*(i-1)//2 print(ans)
p02582
s926730510
Accepted
s = input() count = 0 if(s[1]=='R'): for i in s: if(i=='R'): count+=1 else: for i in s: if(i=='R'): count = 1 print(count)
p02873
s512769933
Wrong Answer
S = input() n = len(S) + 1 A = [0 for _ in range(n)] for i in range(n - 1): prev = A[i] if S[i] == "<": A[i + 1] = max(A[i + 1], prev + 1) for i in range(n - 2, 0, -1): prev = A[i + 1] if S[i] == ">": A[i] = max(A[i], prev + 1) print(sum(A))
p02602
s838303026
Accepted
n,k=map(int,input().split()) a=list(map(int,input().split())) tmp=0 ans=[] for i in range(n): if i>=k: if a[i]>a[i-k]: ans.append("Yes") else: ans.append("No") for item in ans: print(item)
p03803
s950417386
Accepted
a,b=list(map(int,input().split())) if a==1: a=14 if b==1: b=14 if a>b: print("Alice") elif a<b: print("Bob") else: print("Draw")
p02677
s241097083
Accepted
import math a,b,H,M=map(int,input().split()) theta=abs(30*H+0.5*M-6*M)*math.pi/180 ans=math.sqrt(a**2+b**2-2*a*b*math.cos(theta)) print(ans)
p02832
s407055238
Accepted
N=int(input()) A=list(map(int,input().split())) t=1 for i in range(len(A)): if(A[i]==t): t+=1 if(t==1): print(-1) else: print(N+1-t)
p02723
s322854548
Accepted
s = input() if s[2] == s[3] and s[4] == s[5]: print('Yes') else: print('No')
p03623
s497933375
Accepted
x, a, b = map(int, input().split()) if abs(x-a) < abs(x-b): print("A") else: print("B")
p03127
s155109256
Accepted
import functools N = int(input()) A = list(map(int,(input().split()))) def euclid(a, b): if b == 0: return a else: return euclid(b, a%b) def gcd(nums): return functools.reduce(euclid, nums) print(gcd(A))
p02916
s472372605
Accepted
pre=-1 n=int(input()) al=list(map(int,input().split())) bl=list(map(int,input().split())) cl=[0]+list(map(int,input().split())) ans=0 prec=0 for a,b in zip(al,bl): ans+=b if pre+1==a:ans+=cl[pre] pre=a print(ans)
p03681
s581825899
Accepted
n, m = map(int, input().split()) N = 10 ** 5 # N は必要分だけ用意する fact = [1, 1] # fact[n] = (n! mod p) for i in range(2, N + 1): fact.append((fact[-1] * i) % (10**9+7)) result = 0 if abs(n-m) < 2: if n == m: result = 2*(fact[n]**2) else: result = fact[n]*fact[m] print(result%(10**9+7))
p02717
s634075083
Accepted
a,b,c = map(int, input().split()) print(c, a, b)
p03385
s168825779
Accepted
s = input() print("Yes" if len(set(s)) == 3 else "No")
p04034
s388081089
Accepted
n, m = list(map(int, input().split())) moves = [list(map(int, input().split())) for i in range(m)] possibilities = [False] * n possibilities[0] = True nums = [1] * n for i in range(m): x = moves[i][0] - 1 y = moves[i][1] - 1 if possibilities[x]: possibilities[y] = True nums[x] -= 1 nums...
p02860
s237624871
Wrong Answer
N = int(input()) S = list(str(input())) if N == 1: print('No') exit() for i in range(int(N/2)): if S[i] != S[int(N/2)+i]: print('No') exit() print('Yes')
p02786
s739722485
Wrong Answer
h = int(input()) attack = 1 while h > 0 : h = h // 2 print(h) attack *= 2 print(attack - 1)
p02859
s496035044
Wrong Answer
def main(x): return int(x)**2 main(input())
p02675
s870041085
Wrong Answer
l = str(int(input())) n = [] for i in range(len(l)): n.append((l)[i]) print(n[-1]) if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9': print("hon") elif n[-1] == '3': print("bon") else: print("pon")
p02783
s263049428
Accepted
H, A = map(int,input().split()) if H <= A: print(1) else: if H%A==0: print(H//A) else: print(H//A+1)
p03434
s482569775
Accepted
N = int(input()) A = list(map(int, input().split())) A = sorted(A, reverse = True) print (sum(A[::2]) - sum(A[1::2]))
p03486
s094483779
Accepted
s = input() t = input() s=sorted(s) t=sorted(t,reverse = True) if s < t: print('Yes') else: print('No')
p02657
s977339563
Accepted
a, b = map(int, input().split(" ")) print(a*b)
p02725
s818582741
Accepted
k , n = map(int, input().split()) a = list(map(int, input().split())) d = [] for i in range(1, n): y = a[i] x = a[i-1] d.append(y-x) d.append(k - (a[n-1] - a[0])) d.sort(reverse = True) print(k-d[0])
p04033
s742090339
Accepted
a, b = list(map(int, input().split())) if a > 0 and b > 0: print("Positive") elif a < 0 and b < 0: if abs(b - a) % 2 == 1: print("Positive") else: print("Negative") elif a <= 0 and b >= 0: print("Zero")
p04012
s178446590
Accepted
s=input() li=[i for i in s] p="abcdefghijklmnopqrstuvwxyz" for i in p: if li.count(i)%2==1: print("No") exit() else: print("Yes")
p03103
s751091215
Wrong Answer
from operator import itemgetter N, M = map(int, input().split()) AB = sorted([list(map(int, input().split())) for i in range(N)], key=itemgetter(0)) ans, tmp = 0, 0 print(AB) for ab in AB: if ab[1] + tmp < M: tmp += ab[1] ans += ab[0] * ab[1] print(tmp, ans) else: ans += (M - tmp...
p02761
s203142052
Accepted
n,m=map(int,input().split()) sc=[list(map(int,input().split())) for _ in range(m)] ans=-1 for i in range(10**3): if (len(str(i))==n): flag=1 for s,c in sc: if str(i)[s-1] != str(c): flag=0 if flag==1: ans =i break print(ans)
p02729
s348494921
Wrong Answer
N, M=map(int, input().split()) print(N*(N-1)//2, M*(M-1)//2)
p03693
s805608868
Accepted
a,b,c=map(int,input().split()) s=int(str(a)+str(b)+str(c)) if s%4==0: print("YES") else: print("NO")
p02547
s561659722
Wrong Answer
n = int(input()) lst = [] for i in range(n): lst.append(list(map(int,input().split()))) print(lst) cnt = 0 for i in range(n): if lst[i][0]==lst[i][1]: cnt += 1 else: cnt = 0 if cnt == 3: print('Yes') exit() print('No')
p02688
s319817389
Wrong Answer
N, K = map(int, input().split()) d = [] A = [] s = set([i for i in range(1, N+1)]) print(s) rs = set() for i in range(K): d.append(int(input())) A.append(list(map(int, input().split()))) for i in range(K): for a in A: for j in a: rs.add(j) for i in rs: s.remove(i) print(len(s))
p02761
s007234224
Accepted
N, M = map(int, input().split()) A = [-1] * N valid = True for i in range(M): s, c = map(int, input().split()) if A[s - 1] < 0: A[s - 1] = c elif A[s - 1] != c: valid = False if A[0] < 0: A[0] = 1 if 1 < len(A) else 0 if 1 < len(A) and A[0] < 1: valid = False for i in range(1, N): if A[i] < 0: A...
p03548
s300065557
Accepted
x,y,z = map(int,input().split()) print((x-z)//(y+z))
p02873
s081464061
Wrong Answer
def left(x): a = 0 while x-1 > 0 and s[x-1]=='<': a += 1 x -= 1 return a def right(x): a = 0 while x+1 < len(s) and s[x+1]=='>': a += 1 x += 1 return a s = input() ans = 0 for i in range(len(s)+1): ans += max(left(i), right(i)) print(ans)
p02952
s294813717
Accepted
n = int(input()) cnt = 0 for i in range(1, n+1): if len(str(i)) % 2 != 0: cnt += 1 print(cnt)
p03767
s061528087
Wrong Answer
n = int(input()) a = list(map(int, input().split())) a.sort() print(sum(a[n:2*n]))
p02690
s046289177
Accepted
x = int(input()) p5 = [i ** 5 for i in range(121)] a = 0 b = 0 for _p5 in p5: if _p5 + x in p5: a = p5.index(_p5 + x) b = p5.index(_p5) break if x - _p5 in p5: a = p5.index(x - _p5) b = -(p5.index(_p5)) break print(str(a) + " " + str(b))
p02993
s573604211
Accepted
s=input() flag=True for i in range(1,len(s)): if s[i-1]==s[i]: flag=False if flag: print("Good") else: print("Bad")
p03699
s126031114
Wrong Answer
n = int(input()) a = sorted([int(input()) for _ in range(n)]) def func(): for i in range(len(a)): if sum(a[i:]) % 10 != 0: return sum(a[i:]) return 0 print(func())
p03219
s759689873
Accepted
x,y=map(int,input().split()) print(int(x+y/2))
p03485
s792165195
Accepted
a,b=map(int,input().split()) print(-(-(a+b)//2))
p02765
s913317699
Wrong Answer
time,rate = map(int,input().split()) ans = 0 if time >= 10: ans = rate else: ans = rate - 100*(10 - time) print(ans)
p02958
s359068021
Wrong Answer
n = int(input()) p = list(map(int,input().split())) c = 0 for i in range(n-1): if p[i+1]-p[i] == 1: c += 1 if c >= n-3: print("YES") else: print("NO")
p03360
s604590041
Wrong Answer
a,b,c=map(int,input().split()) k=int(input()) d=max(a,b,c) print(a+b+c-d+2*k*d)
p03284
s630837654
Accepted
n, m=map(int,input().split()) if(n%m==0): print('0') else: print('1')
p02657
s044222972
Accepted
A, B = map(int, input().split()) print(int(A * B))
p03720
s931509820
Wrong Answer
N , M = map(int,input().split()) L = [] for i in range(M): a,b = map(int,input().split()) L.append(a) L.append(b) for j in range(N+1): ans = L.count(j) print(j)
p02641
s952761325
Accepted
x,n=map(int,input().split()) p=list(map(int,input().split())) l=list(range(102)) for i in range(n): l.remove(p[i]) #print(l) ans=0 dif=1000 for i in range(102-n): temp=abs(l[i]-x) if temp<dif: dif=temp ans=l[i] print(ans)
p03479
s738207341
Wrong Answer
x,y=map(int,input().split()) a=y/x i=1 while 2**i<=a: i+=1 print(i)
p02947
s362585290
Accepted
from collections import defaultdict n = int(input()) dct = defaultdict(int) for i in range(n): s = input() sorted_s = "".join(sorted(s)) dct[sorted_s] += 1 ans = 0 for a, b in dct.items(): ans += b *(b-1)//2 print(ans)
p02706
s321665198
Accepted
#!/usr/bin/env python3 def main(): n, m = map(int, input().split()) a = list(map(int, input().split())) sa = sum(a) if sa > n: print(-1) return print(n - sa) if __name__ == "__main__": main()
p02939
s229238162
Wrong Answer
S=input() tmp=S[0] i=1 ans=1 while i<len(S): # print(S[i],tmp) if S[i]!=tmp: ans+=1 tmp=S[i] i+=1 else: ans+=1 tmp=S[i:i+2] i+=2 if S[-2]==S[-1]: ans-=1 print(ans)
p03317
s105794040
Accepted
import math def main(): n, k = map(int, input().split()) As = list(map(int, input().split())) ans = math.ceil((n-1)/(k-1)) print(ans) if __name__ == "__main__": main()
p02838
s723989199
Wrong Answer
import numpy as np MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int,input().split())) cnt = [] A = np.array(A) for _ in range(60): ad = A % 2 cnt.append(sum(ad)) A = A // 2 ans = 0 for i in range(60): num0 = N - cnt[i] num1 = cnt[i] ans += (num0 * num1) * (2 ** i) print(ans % MOD)
p02699
s285398629
Wrong Answer
S,W = map(int,input().split()) if S >= W : print("safe") else: print("unsafe")
p03264
s118213247
Wrong Answer
N=int(input()) if N%2==0: print((N/2)**2) else: print((N//2)*((N//2)+1))
p03681
s282412811
Accepted
# 2020/01/25 # AtCoder Beginner Contest 065 - C import math # Input n, m = map(int,input().split()) # Calc sub = abs(n - m) if sub >= 2: ans = 0 elif sub == 1: ans = (math.factorial(n) * math.factorial(m)) % (10 ** 9 + 7) else: ans = (math.factorial(n) * math.factorial(m) * 2) % (10 ** 9 + 7) # Outpu...
p02675
s127893813
Accepted
n = input() if n[-1] in ['2','4','5','7','9']: print('hon') elif n[-1] in ['0','1','6','8']: print('pon') else: print('bon')
p03379
s100437030
Accepted
def main(): N = int(input()) X = list(map(int, input().split())) sorted_X = sorted(X) overall_med = (sorted_X[N//2 - 1] + sorted_X[N//2]) // 2 for x in X: if x <= overall_med: print(sorted_X[N//2]) else: print(sorted_X[N//2 - 1]) if __name__ == '__main__': ...
p02576
s922014575
Wrong Answer
n,x,t = map(int,input().split()) if n%x == 0: c = n/x else: b = n/x c = b//1 a = c*t print(a)
p02768
s836421835
Accepted
from functools import reduce n, a, b = map(int, input().split()) DIV = 10**9 + 7 def nCr(N, R, DIV): f = lambda x,y: x*y%DIV X = reduce(f, range(N-R+1, N+1)) Y = reduce(f, range(1, R+1)) return X*pow(Y, DIV-2,DIV)%DIV all_combi = pow(2,n,DIV) combi_a = nCr(n,a,DIV) combi_b = nCr(n,b,DIV) output = a...
p02958
s518471282
Wrong Answer
b = int(input()) a = list(map(int,input().split())) count = 1 for i in range(b): if a[i] != i + 1 : count += 1 if count <= 2: print('YES') else: print('NO')
p03109
s476972623
Accepted
S = input() #print(int(S[5:7])) if int(S[0:4]) < 2019: print('Heisei') elif int(S[5:7]) < 4: print('Heisei') elif int(S[5:7]) == 4 and int(S[8:10]) <= 30: print('Heisei') else: print('TBD')
p02628
s876172294
Accepted
n, k = map(int, input().split()) p = list(map(int, input().split())) p.sort() print(sum(p[:k]))
p03469
s939155210
Accepted
# coding: utf-8 def main(): input_yyyymmdd = input() out_yyyy = '2018' print(out_yyyy + input_yyyymmdd[4:10]) return 0 if __name__ == '__main__': main()
p02785
s553713875
Wrong Answer
n, k = map(int, input().split()) lst = sorted(list(map(int, input().split()))) if (n<=k): print(0) else: sum_count = 0 sum_count = sum(lst[:-k]) print(sum_count)
p03137
s833088810
Accepted
n,m = map(int,input().split()) if n >= m: print(0) exit() l = list(map(int,input().split())) l.sort() ans = [] for i in range(m-1): ans.append(l[i+1]-l[i]) ans.sort() mi = 0 for i in range(m-2,m-1-n,-1): mi += ans[i] print(sum(ans)-mi)
p02665
s261602285
Wrong Answer
n = int(input()) a_list = list(map(int, input().split())) asc = [0] * (n + 1) desc = [0] * (n + 1) asc[0] = 1 desc[-1] = a_list[-1] sum = 0 for i in range(n): asc[i + 1] = (asc[i] -a_list[i]) * 2 desc[n - 1 - i] = desc[n - i] + a_list[n - 1 - i] if asc[i + 1] <= a_list[i + 1]: print(-1) ex...
p03293
s316002976
Wrong Answer
s, t = input(), input() cnt = 0 while cnt <= len(s): s = s[-1] + s[:-1] if s == t: print("YES") exit() cnt+=1 print("NO")
p02847
s691101001
Accepted
S = input() if S == "SUN": print("7") elif S == "MON": print("6") elif S == "TUE": print("5") elif S == "WED": print("4") elif S == "THU": print("3") elif S == "FRI": print("2") elif S == "SAT": print("1")
p03659
s426708582
Wrong Answer
#coding: utf-8 import math import heapq import bisect import numpy as np from collections import Counter #from scipy.misc import comb N = int(input()) A = list(map(int, input().split())) ans = 2*(10**9) S = sum(A) x = 0 for a in A: x += a y = S - x ans = min(ans, abs(x-y)) print(ans)
p02657
s189209754
Accepted
A,B = list(map(int,input().split())) print(A * B)
p03380
s515000420
Wrong Answer
import sys def solve(): input = sys.stdin.readline N = int(input()) A = [int(a) for a in input().split()] A.sort() L = A[N-1] ans = -1 for a in A[:N-1]: if abs(L/2 - a) < abs(L/2 - ans): ans = a print(ans, L) return 0 if __name__ == "__main__": solve()
p02842
s287497697
Wrong Answer
import math N = int(input()) mini = math.ceil(N / 1.08) maxx = math.floor((N + 1) / 1.08) if (mini <= maxx): ans = mini else: ans = ':(' print(ans)
p02583
s305957894
Wrong Answer
N = int(input()) L = [int(i) for i in input().split()] ans = 0 for i in range(N): for j in range(i): for k in range(j): if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] and L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[j] + L[k] > L[i]: print(L[i],L[j],L[k]) a...
p03545
s794749451
Accepted
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) import itertools A, B, C, D = list(read().rstrip().decode('utf-8')) for operators in itertools.product(['+', '-'], repeat=3): op1, op2, op3 = operators eq = A + o...
p02994
s624312521
Wrong Answer
N,L=map(int,input().split()) taste=0 for i in range(N): taste += (L + i) ans=10*6 for j in range(N): tmp = L+j if abs(tmp) < abs(ans): ans = tmp print(taste - ans)
p03250
s542725188
Wrong Answer
a, b, c = input().split() x = int(a)+int(b+c) y = int(a+b)+int(c) print(max(x, y))
p03380
s507341326
Wrong Answer
n = int(input()) a = list(map(int, input().split())) k = max(a) b = [0] * n for i in range(n): b[i] = abs(a[i]-k/2) r = a[b.index(min(b))] print(k, r)
p03730
s259869582
Accepted
a, b, c = map(int, input().split()) for i in range(b): if (a * i) % b == c: print("YES") exit() print("NO")
p02606
s088329128
Accepted
l,r,d = map(int,input().split()) print(r//d-(l-1)//d)
p02584
s635441740
Accepted
import sys def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) from itertools import combinations from collections import Counter as cc def main(): x, k , d = mi() x = abs(x) ans = max(x%d, x-k*d) k -= x...
p02615
s140374718
Accepted
n = int(input()) a = list(map(int, input().split())) a = sorted(a, reverse=True) ans = a[0] for i in range((n-2)//2): ans += a[i+1]*2 # print(ans) if (n) % 2 == 1: # print(a[i+2], i+2) ans += a[i+2] print(ans)
p02646
s685181760
Wrong Answer
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if B > A: AtoB = B - A VtoW = V - W else: AtoB = A - B VtoW = W - V if AtoB <= VtoW * T: print('YES') else: print('NO')
p03860
s841950332
Accepted
print("A"+input()[8]+"C")
p03852
s710167826
Accepted
vowel = ['a','i','u','e','o'] print('vowel' if input() in vowel else 'consonant')