problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03013
s045138015
Accepted
N, M = map(int, input().split()) #a = [int(input()) for _ in range(M)] issafe = [True] * (N + 1) for i in range(M): issafe[int(input())] = False dp = [0] * (N + 1) dp[0] = 1 if issafe[1]: dp[1] = 1 mod = 1000000007 for i in range(2, N + 1): if issafe[i - 1]: dp[i] += dp[i - 1] if issafe[i - 2]...
p03997
s607480237
Accepted
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
p02922
s904078357
Accepted
from math import ceil A, B = list(map(int, input().split())) print(1 + ceil((B - A) / (A - 1)))
p03067
s406564902
Accepted
a,b,c=map(int,input().split()) if a<=c<=b or b<=c<=a: print("Yes") else: print("No")
p02706
s866468993
Accepted
import sys N,M = map(int,input().split()) A = list(map(int,input().split())) if N - sum(A) < 0: print(-1) sys.exit() print(N - sum(A))
p02911
s499278180
Accepted
n, k, q = map(int, input().split()) a = [int(input()) for i in range(q)] points = [k - q] * n for answerer in a: points[answerer - 1] += 1 for i in range(n): if points[i] <= 0: points[i] = 'No' else: points[i] = 'Yes' print('\n'.join(points))
p03778
s349960793
Accepted
W, a, b = map(int, input().split()) if b+W < a: print(a-(b+W)) elif b > a+W: print(b-(a+W)) else: print(0)
p03943
s903183194
Wrong Answer
x=list(map(int,input().split())) x.sort() if x[2]==x[0]+x[1]: print('YES') else: print('NO')
p02854
s035408400
Accepted
import sys input = sys.stdin.readline def main(): N = int(input()) A = list(map(int, input().split())) mid = sum(A) / 2 x = 0 near_length = 0 for a in A: x += a if x >= mid: if x - mid > abs(x - a - mid): near_length = abs(x - a) else: ...
p03087
s714308258
Wrong Answer
N, Q = map(int, input().split()) S = input() lr = [tuple(map(int, input().split())) for i in range(Q)] s = [0]*(N) for i in range(1, N): s[i] = s[i-1] if S[i-1:i+1] == 'AC': s[i] += 1 for l, r in lr: l -= 1 r -= 1 if S[l] == 'C': print(s[r] - s[l]) else: print(s[r] - s...
p03797
s349373696
Wrong Answer
N,M=map(int,input().split()) s_map = [1 for _ in range(N)] c_map = [1 for _ in range(M//2)] print(len(s_map+c_map)//2)
p03317
s896424383
Wrong Answer
n,k = map(int,input().split()) a = [int(i) for i in input().split()] b = a.index(1) if b < k-1: b += k-1 -b if b > (n-1) -(k-1): b -= b - (k-1) c,d = divmod(b,k-1) ans = c if d != 0: ans +=1 e = n-1 -b c,d = divmod(e,k-1) ans += c if d != 0: ans +=1 print(ans)
p03221
s552605160
Accepted
N,M = map(int,input().split()) digit = 'zero padding: {:0=6}' dic = [[] for _ in range(N+1)] for i in range(M): p,y = map(int,input().split()) dic[p].append((y,i)) for p in dic: p.sort() ans = [None for _ in range(M)] for k in range(1,N+1): p = dic[k] for j in range(len(p)): i = p[j][1] ...
p02847
s231083884
Accepted
w = input() if w == 'SUN': print(7) elif w == 'MON': print(6) elif w == 'TUE': print(5) elif w == 'WED': print(4) elif w == 'THU': print(3) elif w == 'FRI': print(2) else: print(1)
p03759
s725115350
Wrong Answer
a,b,c=map(int, input().split()) print("YES" if abs(a-b)==abs(b-c) else "NO")
p02820
s580418808
Accepted
n,k = (int(x) for x in input().split()) r,s,p = (int(x) for x in input().split()) t = input() a = [] ans = 0 for i in range(0,n): a.append(t[i]) for j in range(0,n): if j - k >= 0 and a[j - k] == a[j]: a[j] = "o" p if a[j] == "r": ans = ans + p if a[j] == "s": ans = ans ...
p02881
s077211773
Accepted
N = int(input()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors div = make_divisors(N) if len(div) % 2 == 0: print((div[len...
p03481
s088183751
Accepted
x,y=map(int,input().split()) print((y//x).bit_length())
p03481
s820155265
Wrong Answer
X ,Y = map(int, input().split()) l = [] ans = 1 for i in range(Y-X): t = X * 2**i if t <=Y: l.append(t) else: break ans = len(l) print(ans)
p02880
s545344960
Accepted
A = int(input()) ans = min([A//i for i in range(1,10) if A%i == 0], default = 0) print("Yes") if 1<=ans<=9 else print("No")
p03264
s452312222
Accepted
n = int(input()) print((n//2)*((n+1)//2))
p02963
s622524410
Accepted
import math s=int(input()) n=math.ceil(math.sqrt(s)) if n*n-s<0: n+=1 x2=n y3=n while x2*y3-s>10**9: y3-=1 y2=x2*y3-s x3=1 print(0,0,x2,y2,x3,y3)
p02779
s356448481
Accepted
n = int(input()) a = set(map(int, input().split())) print('YES' if len(a) == n else 'NO')
p02659
s050232939
Accepted
a, b = input().split() print(int(a) * int(b[0] + b[2] + b[3]) // 100)
p03644
s399004423
Accepted
n = int(input()) t = 1 while True: if t * 2 > n: break t *= 2 print(t)
p03035
s701098818
Wrong Answer
#127 a a,b=map(int,input().split()) kane=[0,b/2,b] ans=1 if a>=13: ans=2 elif a<=5: ans=0 print(kane[ans])
p03221
s038896248
Accepted
from collections import defaultdict N, M = map(int, input().split()) PYm = [0] * M order = dict() for i in range(M): key = input().strip() PYm[i] = list(map(int, key.split())) order[key] = i d = defaultdict(list) for i in range(M): d[PYm[i][0]].append(PYm[i][1]) res = dict() for pi, ys in d.items():...
p02820
s006302191
Accepted
# 2020/04/29 # AtCoder Beginner Contest 149 - D # Input n, k = map(int,input().split()) r, s, p = map(int,input().split()) t = input() # Init d = dict() d['r'] = r d['s'] = s d['p'] = p d['wintr'] = 'p' d['wints'] = 'r' d['wintp'] = 's' ngt = [''] * n # Calc ans = 0 for i in range(n-1, -1, -1): wint = d['wint'...
p03711
s703216329
Accepted
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections MOD = 10**9 + 7 x,y = map(int,input().split()) a = set([1,3,5,7,8,10,12]) b = set([4,6,9,11]) c = set([2]) if (x in a and y in a) or (x in b and y in b) or(x in c and y in...
p03385
s403073791
Wrong Answer
s = input() ans = True if "a" not in s: ans = False if "b" not in s: asn = False if "c" not in s: ans = False if ans: print("Yes") else: print("No")
p03659
s470090720
Accepted
n = int(input()) a = list(map(int, input().split())) cum = [0] * (n+1) for i in range(n): cum[i+1] = cum[i] + a[i] s = sum(a) ans = 10 ** 18 for i in range(n-1): ans = min(ans, abs(s - 2*cum[i+1])) print(ans)
p03435
s786489889
Accepted
C = [list(map(int,input().split())) for _ in range(3)] K = C[0][0] b1,b2 = C[0][1]-K,C[0][2]-K a1,a2 = C[1][0]-K,C[2][0]-K if C[1][1]==K+a1+b1 and C[1][2]==K+a1+b2 and C[2][1]==K+a2+b1 and C[2][2]==K+a2+b2: print('Yes') else: print('No')
p02676
s493128020
Accepted
N = int(input()) S = input() #print(N) #print(S) if N < len(S): print(S[:N] + "...") else: print(S)
p03862
s551580226
Accepted
n, x = map(int, input().split()) a = list(map(lambda x: int(x), input().split())) #in1 = '5 9' #in2 = '3 1 4 1 5' #n, x = map(int, in1.split()) #a = list(map(lambda x: int(x), in2.split())) RC = 0 if a[0] > x: RC += a[0] - x a[0] = x for idx1 in range(1, len(a)): if a[idx1 - 1] + a[idx1] > x: RC +...
p03351
s876226582
Accepted
a, b, c, d = map(int, input().split()) print('Yes' if any([all([abs(a-b) <= d, abs(b-c)<= d]), abs(a-c) <= d]) else 'No')
p03699
s618635652
Accepted
n = int(input()) s_lst = [int(input()) for _ in range(n)] maximum = sum(s_lst) s_lst.sort() if maximum % 10 != 0: answer = maximum else: for i in range(n): maximum -= s_lst[i] if maximum % 10 != 0: answer = maximum break else: maximum += s_lst[i] ...
p03076
s360024607
Accepted
time = [int(input()) for _ in range(5)] dif = 0 dif_max = 0 for i in time: tmp = abs(10-int(str(i)[-1])) tmp = 0 if tmp == 10 else tmp dif += tmp dif_max = max(dif_max,tmp) print(sum(time)+dif-dif_max)
p03779
s440918028
Accepted
x = int(input()) ans = 0 for i in range(10**5): ans += i if ans >= x: print(i) exit()
p03434
s342902577
Accepted
n = int(input()) x = list(map(int, input().split())) a = 0 b = 0 x = sorted(x) for i in range(n): if i % 2 == 0: a += x.pop() else: b += x.pop() print(a-b)
p03997
s761386204
Wrong Answer
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h/2)
p02765
s502396265
Wrong Answer
N, R = map(int, input().split()) print(R if 10>=N else R+1000-N*100)
p03494
s044803632
Accepted
n = int(input()) a = map(int, input().split()) cnt = 0 def half(_a): ret = list() for i in _a: if i % 2 != 0: return None else: ret.append(i//2) return ret while True: a = half(a) if not a: break cnt += 1 print(cnt)
p02793
s922954648
Accepted
from fractions import gcd;from functools import reduce;n,*a=map(int,open(0).read().split());l=reduce(lambda a,b:a*b//gcd(a,b),a);print(sum(l//i for i in a)%1000000007)
p02939
s101861277
Accepted
S = input() d1 = "" d2 = "" res = 0 for i in range(len(S)): d1 += S[i] if d1 != d2: d2 = d1 d1 = "" res += 1 print(res)
p03698
s570396831
Wrong Answer
s = input() n = len(s) l = set(s) m = len(l) if n == m: print("Yes") else: print("No")
p02866
s386504945
Wrong Answer
from collections import defaultdict def main(): N = int(input()) D = [int(x) for x in input().split()] dic = defaultdict(int) mod = 998244353 for i in D: dic[i] += 1 if dic[0]!=1: print(0) exit() ans = 1 for i in range(1,max(dic.keys())+1): ans *= dic[i-1...
p02743
s982410452
Accepted
a,b,c=map(int,input().split()) if c-a-b<0: print("No") elif 4*a*b<(c-a-b)**2: print("Yes") else: print("No")
p02627
s003295617
Wrong Answer
a=input() if a.isupper: print("A") else: print("a")
p03478
s929706063
Accepted
n, a, b = map(int, input().split(" ")) wholeSum = 0 def digitSum(n): basis = 10 transDigit = list() while n > 0: transDigit.append(n % basis) n = int(n / basis) result = sum(transDigit) return result for pivot in range(n+1): target = digitSum(pivot) if target <= b\ and a <= target: wholeS...
p03479
s727480292
Accepted
import sys x, y = map(int, sys.stdin.readline().split()) def main(x): cnt = 0 while x <= y: cnt += 1 x *= 2 print(cnt) if __name__ == '__main__': main(x)
p03281
s517376685
Accepted
_=int(input());print(sum(ord(x)<_ for x in "h†¤¼Â"))
p02678
s546758583
Accepted
n,m = map(int,input().split()) e = [[] for _ in range(n)] for i in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 e[a].append(b) e[b].append(a) q = [0] i = 1 ans = [-1 for _ in range(n)] while(len(q) > 0): qq = [] for v in q: for u in e[v]: if ans[u] == -1: ans[u] = v qq...
p02687
s660481007
Accepted
s = input() if s == "ABC": print("ARC") else: print("ABC")
p02791
s065002382
Wrong Answer
n=int(input()) lists=list(map(int,input().split())) mn=(2*10)^5+1 cnt=0 for li in lists: if mn>li: mn=li cnt+=1 print(cnt)
p02708
s478299326
Accepted
MOD = 10**9 + 7 def mySum(a, b): return (a + b) * (b - a + 1) // 2 % MOD N, K = list(map(int, input().split())) l = mySum(N-K+1, N) - mySum(0, K-1) + 1 res = l for i in range(K, N+1): l = l - i + (N-i) res += l res %= MOD print(res)
p02848
s076700290
Accepted
n = int(input()) s = input() ans = "" for i in range(len(s)): ans +=chr((ord(s[i]) -65 +n)%26+65) print(ans)
p02714
s840078959
Wrong Answer
import collections import functools n = int(input()) s = input() total = functools.reduce(lambda x, y : x * y , (collections.Counter(s).values())) minus = 0 for i in range(n): for j in range(i, n): for k in range(j, n): if (s[i] != s[j] and s[j] != s[k] and s[i] != s[k]) and j - i == k - j: ...
p03632
s788323409
Wrong Answer
A, B, C, D = map(int, input().split()) P = [0 for _ in range(202)] for p in range(A, A + B + 1): P[p] += 1 for p in range(C, C + D + 1): P[p] += 1 count = 0 for p in P: if p == 2: count += 1 print(count)
p04043
s545353237
Accepted
a,b,c=sorted(input().split()) print(["NO","YES"][a==b=="5" and c=="7"])
p03698
s751703524
Wrong Answer
s = input() for i in range(len(s) - 1): if s[i] == s[i+1]: print('no') exit() print('yes')
p03109
s635495953
Wrong Answer
# https://atcoder.jp/contests/abc119/tasks/abc119_a y, m, d = map(int, input().split('/')) if y > 2019: print('TBD') elif m > 5: print('TBD') elif d > 31: print('TBD') else: print('Heisei')
p02801
s125225478
Accepted
C=input() C=ord(C)+1 print(chr(C))
p03030
s939534181
Accepted
n=int(input()) sp=[] for i in range(n): s,p=input().split() sp.append([s,int(p),i+1]) sort=sorted(sp, key=lambda sp: (sp[0], -sp[1])) for i in sort: print(i[2])
p02701
s157088062
Wrong Answer
N = int(input()) S = [input() for _ in range(N)] S_set = list(set(S)) print(len(S))
p04020
s772868371
Accepted
N = int(input()) A = [int(input()) for _ in range(N)] ans = 0 for i in range(N): ans += A[i] // 2 A[i] %= 2 if A[i] == 1 and i < N-1 and A[i+1] > 0: A[i+1] -= 1 ans += 1 print(ans)
p02882
s980556669
Wrong Answer
import math a,b,x = map(int,input().split()) ans = 0 sw = 2*x - a**3 sw_c = abs(math.atan(sw)) ans = abs(math.atan(2/a*(b-x/(a**2)))) ans_1 = abs(math.atan(a*b**2/(2*x))) if(ans < sw_c): print(math.degrees(ans)) else: print(math.degrees(ans_1)) #print(math.degrees(ans)) #print(sw_c)
p02714
s497393840
Wrong Answer
N = int(input()) S = input() import collections C = collections.Counter(S) count = 0 for i in range(N): j = 1 while i - j >= 0 and i + j < N: if S[i-j] != S[i] and S[i+j] != S[i] and S[i-j] != S[i+j]: count += 1 j += 1 ans = 1 for k, v in C.items(): ans *= v print(ans - co...
p03219
s304579325
Accepted
a,b=map(int,input().split()) print(a+(b//2))
p02571
s385780166
Accepted
S = input() T = input() ans = float('inf') for i in range(len(S)-len(T)+1): tmp = 0 for a,b in zip(S[i:i+len(T)],T): if a!=b: tmp+=1 ans = min(ans,tmp) print(ans)
p02577
s841250554
Wrong Answer
n = input() r = sum(map(int,list(n))) print(r)
p02700
s891598163
Wrong Answer
# coding: utf-8 # Your code here! input_line = input().split() A_HP = int(input_line[0]) A_ATTACK = int(input_line[1]) B_HP = int(input_line[2]) B_ATTACK = int(input_line[3]) X = A_HP//B_ATTACK Y = B_HP//A_ATTACK if X >= Y: print('Yes') elif Y > X: print('No') else: print('Yes')
p02701
s931306788
Accepted
n = int(input()) s_list = [] for i in range(n): s = str(input()) s_list.append(s) print(len(set(s_list)))
p02641
s626490333
Accepted
X, N = map(int, input().split()) p = list(map(int, input().split())) score = 1000 answer = -1 for i in range(-1, 102): if i in p: continue if abs(X - i) < score: score = abs(X - i) answer = i print(answer)
p02983
s874312904
Wrong Answer
l,r=map(int,input().split()) a=[] for i in range(l,min(l+2020,r+1)): a.append(i%2019) a.sort() print((a[0]*a[1])%2019)
p03419
s721450905
Wrong Answer
N, M = map(int, input().split()) if(N == 1 and M == 1): print(0) elif(N == 1): if(M == 2): print(2) else: print(1 * M-2) elif(M == 1): if(N == 2): print(1 * N-2) else: print((N - 2) * (M - 2))
p02678
s328088031
Wrong Answer
print('No')
p02973
s144041763
Accepted
import bisect n = int(input()) a = [int(input()) for i in range(n)] ans = 0 color = [a[n-1]] for i in range(n-2,-1,-1): if a[i]>=color[-1]: color.append(a[i]) else: x = bisect.bisect_right(color,a[i]) color[x] = a[i] print(len(color))
p03012
s820219240
Wrong Answer
n=int(input()) w=list(map(int,input().split())) half=sum(w)*0.5 wa=0 num=0 for i in range(n): if wa>half: break wa+=w[i] num=i print(abs(sum(w)-2*sum(w[:num])))
p03456
s985432299
Accepted
import math a, b = input().split() ab = a + b if math.sqrt(int(ab)).is_integer() == True: print("Yes") else: print("No")
p03448
s124968313
Accepted
a = int(input()) b = int(input()) c = int(input()) x = int(input()) ans = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500 * i + 100 * j + 50 * k == x: ans += 1 print(ans)
p02924
s988668364
Accepted
n=int(input()) print((n-1)*n//2)
p03944
s614289245
Accepted
w, h, n = map(int, input().split()) r, l, u, d = w, 0, h, 0 for _ in range(n): x, y, a = map(int, input().split()) if a == 1: l = max(l, x) elif a == 2: r = min(r, x) elif a == 3: d = max(d, y) else: u = min(u, y) print(max(0, r-l) * max(0, u-d))
p03698
s134567203
Accepted
S = sorted(input()) setS = set(S) if len(setS) == len(S): print("yes") else: print("no")
p03627
s768315989
Accepted
N=int(input()) *A,=map(int,input().split()) d={} for a in A: d[a] = d.get(a, 0)+1 s=sorted([(k,v) for k,v in d.items() if 2<=v], reverse=True) if len(s)<2: print(0) else: if 4<=s[0][1]: print(s[0][0]**2) else: print(s[0][0]*s[1][0])
p03986
s438287926
Accepted
x = list(input()) cnt = 0 a = 0 for i in x: if i == 'S': cnt += 1 elif i == 'T': if cnt > 0: cnt -= 1 else: a += 1 print(a+cnt)
p03071
s197653887
Wrong Answer
a,b=map(int,input().split()) print(max(a,b)+max(a-1,b-1))
p03126
s070588584
Accepted
#-*-coding:utf-8-*- import sys input=sys.stdin.readline def main(): interview=[] n,m = map(int,input().split()) interview=[list(map(int,input().split())) for _ in range(n)] set_data={} for data in interview: if len(set_data)==0: set_data = set(data[1:]) else: ...
p03817
s244547900
Accepted
a = int(input()) if a <= 6: print(1) else: if 7 <= a <= 11: print(2) else: t = a // 11 a -= t * 11 if 1 <= a <= 6: s = 1 elif 7 <= a: s = 2 else: s = 0 print(t*2 + s)
p02713
s538821381
Accepted
import math n = int(input()) sums = 0 for k in range(1,n+1): for l in range(1,n+1): a =math.gcd(k,l) for p in range(1,n+1): sums += math.gcd(a,p) print(sums)
p02657
s103576366
Accepted
a,b = map(int,input().split()) print(a*b)
p02814
s521389134
Accepted
N, M = map(int, input().split()) a = list(map(int, input().split())) from math import floor from fractions import gcd from functools import reduce def lcm(x, y): return x * y // gcd(x, y) b = [n // 2 for n in a] lcm_b = reduce(lcm, b) for n in b: if (lcm_b // n) % 2 == 0: print(0) exit() ...
p03659
s841990321
Accepted
N = int(input()) nums = list(map(int, input().split(" "))) all_sum = sum(nums) sums = [None] * N min_diff_value = float('inf') min_diff_index = -1 for i in range(N-1): if i==0: sums[i] = nums[i] else: sums[i] = sums[i-1] + nums[i] lhs_value = sums[i] rhs_value = all_sum - lhs_value ...
p03419
s245678391
Wrong Answer
N,M=list(map(int, input().split())) if N>1 and M>1: print((N-2)*(M-2)) else: print(N*M-2)
p02952
s868767909
Wrong Answer
N = int(input()) l = len(str(N)) ans = 0 n = 1 while l >= n: c = 9 * 10 ** (n - 1) if 10 ** n - 1 <= N: ans += c else: ans += N - (10 ** (n - 1)) n += 2 print(ans)
p02832
s200991576
Accepted
N = int(input()) a = list(map(int, input().split())) i = 0 for j in range(N): if a[j] == i+1: i += 1 else: if i == 0: print(-1) else: print(N-i)
p02572
s647453223
Accepted
import sys readline = sys.stdin.readline N = int(readline()) A = list(map(int,readline().split())) DIV = 10 ** 9 + 7 ans = 0 cur = 0 for i in range(1, N): cur += A[i - 1] ans += A[i] * cur ans %= DIV print(ans)
p02699
s663073612
Wrong Answer
S, W = map(int, input().split()) if (S <= W): print('unsafe') else: print('same')
p02957
s303076587
Wrong Answer
a,b=list(map(int,input().split())) if abs(int((a-b)/2))==abs(int((b-a)/2)): print(int((a+b)/2)) else: print('IMPOSSIBLE')
p03774
s200446653
Accepted
n, m = map(int, input().split()) start = [] for i in range(n): a, b = map(int, input().split()) start.append([a, b]) check = [] for i in range(m): c, d = map(int, input().split()) check.append([c, d]) for a, b in start: distance = 1001001001 ans = 0 for i in range(len(check)): c, d ...
p03371
s323073671
Accepted
def ii():return int(input()) def iim():return map(int,input().split()) def iil():return list(map(int,input().split())) def ism():return map(str,input().split()) def isl():return list(map(str,input().split())) a,b,c,x,y = iim() print(min(a*x+b*y,2*y*c+max(x-y,0)*a,2*x*c+max(y-x,0)*b))