problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02879 | s128803862 | Accepted | A,B = [int(v) for v in input().split()]
if A > 0 and A < 10 and B > 0 and B < 10:
print(A*B)
else:
print(-1)
|
p02624 | s185080950 | Wrong Answer | n=int(input())
ans=0
for i in range(1,n+1):
num=n//i
ans+=i*num*(num+1)/2
print(ans)
|
p02556 | s235589615 | Accepted | n = int(input())
p = [0 for _ in range(n)]
m = [0 for _ in range(n)]
for i in range(n):
xi,yi = map(int,input().split())
p[i] = xi+yi
m[i] = xi-yi
p.sort()
m.sort()
print(max(p[-1] - p[0],m[-1] - m[0])) |
p02596 | s472761307 | Wrong Answer | k=int(input())
sevs=7
for x in range(1,k+1):
if sevs%k==0:
print(x)
exit()
else:
sev=(10*sevs+7)%k
print('-1')
|
p02665 | s130825045 | Accepted | N = int(input())
A = list(map(int, input().split()))
R = A[:]
for i in range(N - 1, -1, -1):
R[i] = R[i + 1] + A[i]
B = 1
ans = B
for i in range(1, N + 1):
M = 2 * B - A[i]
if M < 0:
ans = -1
break
B = min(M, max(0, R[i] - A[i]))
ans += A[i] + B
print(ans if A[0] == 0 or A[0] == 1 and len(A) == 1 else -1)
|
p02918 | s054155779 | Accepted | N, K = map(int, input().split())
S = list(input())
# 初期の幸福度を計算
h = 0
for i in range(1, N):
if S[i - 1] == S[i]:
h += 1
# 基本的には1操作につき幸福度は2上がる
h += 2 * K
# 幸福度がN-1を超えることはない
if h > N - 1:
h = N - 1
print(h) |
p03360 | s161170125 | Accepted | a=list(map(int,input().split()))
k=int(input())
b=sorted(a)
print(b[0]+b[1]+b[2]*2**k) |
p03679 | s176243250 | Accepted | x,a,b = map(int, input().split())
if b-a <= 0:
print("delicious")
elif b-a <= x:
print("safe")
else:
print("dangerous") |
p03821 | s275697296 | Wrong Answer | n = int(input())
a,b=[],[]
for i in range(n):
x,y = map(int,input().split())
a.append(x)
b.append(y)
a=list(reversed(a))
b=list(reversed(b))
OK=0
for i in range(n):
A=a[i]+OK
if A==b[i]:
continue
else:
ok=b[i]-A%b[i]-A
OK+=ok
print(OK)
|
p02761 | s786346867 | Wrong Answer | N,M = list(map(int,input().split()))
SC = [0]*(N+1)
for m in range(M):
sc = list(map(int,input().split()))
if (sc[0] == 1) and (sc[1] == 0):
print(-1)
exit()
if SC[sc[0]] == 0:
SC[sc[0]] = sc[1]
else:
if SC[sc[0]] != sc[1]:
print(-1)
exit()
else:
SC[sc[0]] = sc[1]
if SC[1]==0:
SC[1] = 1
ans = 0
for i in range(N):
ans += 10**(N-i-1)*SC[i+1]
print(ans)
|
p03317 | s133932812 | Accepted | N, K = map(int, input().split())
A = list(map(int, input().split()))
idx = A.index(1)
ans = N
for k in range(K + 1):
L = idx - (K - k - 1)
R = (N - 1 - idx) - k
cntL = 0
cntR = 0
while L > 0:
cntL += 1
L -= K - 1
while R > 0:
cntR += 1
R -= K - 1
ans = min(ans, cntL + cntR + 1)
print(ans)
|
p02659 | s257507096 | Accepted | a,b=input().split()
a=int(a)
b=int(b.replace(".",""))
print(a*b//100) |
p03037 | s861428774 | Accepted | def two_input():
return map(int, input().split())
N, M = two_input()
L, R = [], []
for i in range(M):
l, r = two_input()
L.append(l)
R.append(r)
maxl = max(L)
minr = min(R)
ans = 0
for i in range(N):
if maxl <= i+1 <= minr:
ans += 1
print(ans) |
p03821 | s059547015 | Accepted | from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChar():
return input()
def readChars():
return input().split()
def f(a,b):
return math.ceil(a/b)*b-a
n = readInt()
ab = [readInts() for i in range(n)]
ans = 0
for a,b in ab[::-1]:
ans += f(a+ans,b)
print(ans) |
p02935 | s415297534 | Wrong Answer | n = int(input())
v = list(map(int, input().split()))
v.sort()
for _ in range(n - 2):
v.append((v[0] + v[1]) / 2)
del v[0], v[1]
v.sort()
print(sum(v) / 2) |
p02909 | s537794787 | Accepted | W = ["Sunny","Cloudy","Rainy","Sunny"]
M = input()
print(W[W.index(M)+1]) |
p02866 | s500321083 | Wrong Answer | N,*D=map(int,open(0).read().split())
c=[0]*N
for i in D:c[i]+=1
m=max(D)
if D[0]>0 or c[0]>1 or 0 in D[1:m+1]:print(0);exit()
a=1
for i in range(max(D)):a*=c[i]**c[i+1]
print(a)
|
p02708 | s158738310 | Wrong Answer | N, K = map(int, input().split())
a = 0
for i in range(K,N+2):
a += i*(2*N-i+1)//2 - i*(i-1)//2 + 1
print(a) |
p02748 | s303469547 | Wrong Answer | a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
buf=min(A)+min(B)
for i in range(m):
x,y,c=map(int, input().split())
cp=A[x-1]+B[y-1]-c
if buf>=cp:
buf==cp
print(buf) |
p03774 | s920999431 | Wrong Answer | N, M = map(int, input().split())
stu = []
check = []
for i in range(N):
s = list(map(int, input().split()))
stu.append(s)
for i in range(M):
c = list(map(int, input().split()))
check.append(c)
ans = [0 for i in range(N)]
for i in range(N):
min = 1000000
for j in range(M):
dis = abs(stu[i][0]-check[j][0])+abs(stu[i][1]-check[j][1])
if min > dis:
min = dis
ans[i] = j+1
for i in ans:
print(i)
|
p04045 | s409239238 | Accepted | n, k = map(int, input().split())
D = list(map(int, input().split()))
def valid(x):
for xx in str(x):
if int(xx) in D:
return False
return True
while True:
if valid(n):
print(n)
break
n += 1
|
p03000 | s373910833 | Accepted | from itertools import accumulate
N, X = [int(x) for x in input().split()]
L = list([int(x) for x in input().split()])
a = accumulate(L)
for key, i in enumerate(a):
if i > X:
print(key+1)
exit()
print(N+1)
|
p03862 | s307828852 | Wrong Answer | import sys
stdin = sys.stdin
from itertools import product
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
n, x = na()
a = na()
b = list()
if n == 2:
print(max(sum(a) - x, 0))
quit()
else:
for ai, aj in zip(a[:n-1], a[1:]):
b.append(max(0, ai + aj - x))
bpre = b[0]
ans = 0
ans += bpre
for bi in b[1:]:
bpre = max(0, bi - bpre)
ans += bpre
print(ans)
|
p02848 | s560703706 | Accepted | N = int(input())
S = input()
alphabet = ["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"]
newS = ""
for x in S:
newS += alphabet[(alphabet.index(x)+N)%26]
print(newS) |
p03475 | s253120857 | Accepted | n = int(input())
c = [0] * n
s = [0] * n
f = [0] * n
for i in range(n - 1):
c[i], s[i], f[i] = map(int, input().split())
ans = [0] * n
for i in range(n - 1):
for j in range(i, n - 1):
if ans[i] < s[j]:
ans[i] = s[j]
elif ans[i] % f[j] > 0:
ans[i] += f[j] - ans[i] % f[j]
ans[i] += c[j]
for i in range(n):
print(ans[i]) |
p04030 | s258759563 | Wrong Answer | s=input()
A=s.replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","")
B=A.replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","")
C=A.replace("B","")
print(C)
|
p02601 | s568707493 | Accepted | A, B, C = map(int, input().split())
K = int(input())
i = 0
# BがAより大きくなるために必要な回数
while(B<=A):
i += 1
B *= 2
# CがBより大きくなるために必要な回数
while(C<=B):
i += 1
C *= 2
if i <=K:
print("Yes")
else:
print("No")
|
p03012 | s576469537 | Accepted | n=int(input())
a=[int(x) for x in input().split()]
b=100
for i in range(1,n):
c=abs(sum(a[:i])-sum(a[i:]))
if c<b:
b=c
print(b) |
p02661 | s798627119 | Wrong Answer | import statistics
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)]
arr.sort()
if N % 2 == 1:
print(arr[N//2][1]-arr[N//2][0]+1)
else:
print(arr[N//2][1]-arr[(N//2)-1][0]+1) |
p02946 | s896495294 | Accepted | k, x = map(int, input().split())
max_ = x + (k - 1)
min_ = x - (k - 1)
ans = list(range(min_, max_ + 1))
for i in ans:
print(i, end = " ") |
p03998 | s305424918 | Accepted | from collections import deque
Sa = deque([ord(i) - 97 for i in list(input())] + [-1, ])
Sb = deque([ord(i) - 97 for i in list(input())] + [-1, ])
Sc = deque([ord(i) - 97 for i in list(input())] + [-1, ])
S = [Sa, Sb, Sc]
now = 0
while True:
next = S[now].popleft()
if next == -1:
print(chr(now + 97).upper())
exit()
now = next |
p03474 | s251437081 | Wrong Answer | A,B=map(int,input().split())
S=input()
if (S[0:A].isdecimal()==True) and (S[A+1:-1].isdecimal()==True) and (S[A]=='-'):
print('Yes')
else:
print('No') |
p02790 | s956568123 | Accepted | a,b = map(int, input().split())
print(str(min(a,b))*max(a,b)) |
p02598 | s997305641 | Accepted | def judge(A, x, k):
ans = 0
for a in A:
ans += a // x
if a % x == 0:
ans -= 1
if ans > k:
return False
return True
n, k = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = max(A)
while r - l != 1:
x = (r + l) // 2
if judge(A, x, k):
r = x
else:
l = x
print(r) |
p02899 | s211688510 | Accepted | n = int(input())
a = list(map(int, input().split()))
alist = [0]*n
for i in range(n):
alist[a[i]-1] = str(i+1)
print(" ".join(alist)) |
p03438 | s584684206 | Accepted | n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
da = 0
db = 0
for i in range(n):
if a[i] > b[i]:
db += a[i]-b[i]
else:
da += (b[i]-a[i])//2
if db > da:
print("No")
else:
print("Yes")
|
p02814 | s503248283 | Accepted | n,m=map(int,input().split())
a = [int(x)//2 for x in input().split()]
import fractions
lmc=a[0]
for i in range(1,n):
lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
if lmc>m:
print("0")
exit()
for i in range(n):
if (lmc//a[i])%2==0:
print("0")
exit()
if (m//lmc)%2==0:
print((m//lmc)//2)
else:
print(((m//lmc)+1)//2) |
p03206 | s695136440 | Accepted | d = int(input())
if d == 25:
print("Christmas")
elif d == 24:
print("Christmas Eve")
elif d == 23:
print("Christmas Eve Eve")
else:
print("Christmas Eve Eve Eve") |
p02665 | s707629503 | Wrong Answer | N = int(input())
A = list(map(int,input().split()))
from itertools import accumulate
Ac = list(accumulate(A))
import sys
ans = 1
num = 1
for i in range(N):
num = min(2*(num-A[i]),Ac[N]-Ac[i])
if num<=0:
print("-1")
sys.exit()
ans += num
print(ans) |
p03910 | s899027078 | Accepted | n = int(input())
aa =[]
i = 0
score = 0
while score < n:
i += 1
score += i
aa.append(i)
if score == n:
for k in range(len(aa)):
print(aa[k])
else:
aa.remove(score - n)
for k in range(len(aa)):
print(aa[k]) |
p04012 | s196592552 | Accepted | def resolve():
w = input()
uniq = []
cnt = []
for i in w:
if i not in uniq:
uniq.append(i)
for i in uniq:
cnt.append(w.count(i))
ans = "Yes"
for i in cnt:
if i % 2 != 0:
ans = "No"
break
print(ans)
resolve() |
p02658 | s528203737 | Wrong Answer | num = int(input())
num_list = input().split(" ")
result = 1
con = num >= 2 and num <= 100000
if con == True and num == len(num_list):
for i in num_list:
if int(i) >= 0 and int(i) <= 10000000000000000:
result = result * int(i)
else:
break
if result > 1000000000000000000:
print(-1)
else:
print(result)
else:
print()
|
p03951 | s071897190 | Accepted | N = int(input())
s = input()
t = input()
for i in range(min(len(s), len(t)), -1, -1):
if s[len(s) - i:] == t[:i]:
print(len(s) + len(t) - i)
break |
p02688 | s330095537 | Wrong Answer | n,k = map(int,input().split())
import itertools
grid = []
for i in range(2*k):
array = list(map(int, input().strip().split()))
grid.append(array)
print(grid)
l = []
for j in range (k):
l.append(grid[0+2*j+1])
print(l)
lis = itertools.chain.from_iterable(l)
print(list(itertools.chain.from_iterable(l)))
count = 0
for m in range(n):
if m+1 in lis:
count = count +1
print(n - count - 1) |
p03951 | s638851779 | Wrong Answer | n = input()
s = list(input().split())
t = list(input().split())
a = set(s + t)
print(len(a)) |
p04019 | s105059203 | Accepted | s = set(list(input()))
if any(s == set(list(i)) for i in ["NS","EW","NEWS"]):
print("Yes")
else:
print("No") |
p02939 | s249169506 | Wrong Answer | S=input()
ret = set([])
tmp = ''
for i in range(len(S)):
tmp += S[i]
if tmp in ret:
continue
else:
ret.add(tmp)
tmp=''
print(len(ret)) |
p03486 | s855356637 | Accepted | import itertools
s = list(input())
t = list(input())
# ss = list(itertools.permutations(s)).sort()
# tt = list(itertools.permutations(t)).sort()
s.sort()
t.sort()
ti = t[::-1]
ss = ''.join(s)
tt = ''.join(ti)
tmp = []
tmp.append(ss)
tmp.append(tt)
tmp.sort()
if tmp[0] == ss and ss != tt:
print('Yes')
else:
print('No')
|
p03161 | s493541254 | Accepted | n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [9999999999]*n
dp[0] = 0
for i in range(1,n):
for j in range(1,k+1):
if(i >= j):
dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])
|
p03672 | s963875243 | Accepted | def myAnswer(S:list) -> int:
ans = 0
for i in range(len(S)):
S.pop() # 末尾消去
if(len(S) % 2 == 1):
continue
middle = len(S) // 2
if(S[middle:] == S[:middle]):
ans = len(S)
break
return ans
def modelAnswer():
tmp=1
def main():
S = list(input())
print(myAnswer(S[:]))
if __name__ == '__main__':
main() |
p03836 | s770828143 | Accepted | SX, SY, TX, TY = map(int, input().split())
TX -= SX
TY -= SY
SX = 0
SY = 0
res = ""
res += "U"*TY
res += "R"*TX
res += "D"*TY
res += "L"*(TX+1)
res += "U"*(TY+1)
res += "R"*(TX+1)
res += "D"
res += "R"
res += "D"*(TY+1)
res += "L"*(TX+1)
res += "U"
print(res) |
p03494 | s178432076 | Wrong Answer | import math
N = int(input())
A = list(map(int, input().split()))
res = 1000
for a in A:
print('a:', a)
cnt = 0
while a%2 == 0:
a = (a//2)
cnt += 1
print(' ->', a, '(cnt:', cnt, ')')
print(' cnt:', cnt)
res = min(res, cnt)
print(' res:', res)
print(res) |
p03827 | s395816355 | Accepted | N = int(input())
S = input()
ans = 0
cnt = 0
for i in range(N):
if S[i] == 'I':
cnt += 1
ans = max(ans, cnt)
else:
cnt -= 1
print(ans) |
p03971 | s869929072 | Accepted | N,A,B = map(int,input().split())
S = input()
count_in = 0
count_out = 0
for s in S:
if s == 'a':
if count_in+count_out<A+B:
print('Yes')
count_in += 1
continue
if s == 'b':
if count_out<B and count_in+count_out<A+B:
print('Yes')
count_out += 1
continue
print('No')
|
p03163 | s702181569 | Accepted | n, w = map(int, input().split())
dp = [0]*(w+1)
for i in range(n):
weight, value = map(int, input().split())
for j in range(w, -1, -1):
if j == 0 or dp[j] != 0:
if j+weight <= w:
dp[j+weight] = max([dp[j+weight], dp[j]+value])
print(max(dp))
|
p03696 | s916864156 | Wrong Answer | N=int(input())
l=input()
l=l.replace("()","X")
ans=l
for i in range(len(l)):
if l[i]=="X":
continue
elif l[i] == "(":
ans=ans+")"
elif l[i] == ")":
ans="("+ans
ans=ans.replace("X","()")
print(ans) |
p03163 | s319400286 | Accepted | n, w = map(int, input().split())
ws, vs = zip(*[map(int, input().split()) for _ in range(n)])
dp = [0] * (w + 1)
for i in range(n):
for j in reversed(range(w + 1)):
if j + ws[i] <= w:
dp[j + ws[i]] = max(dp[j + ws[i]], dp[j] + vs[i])
print(dp[w])
|
p03077 | s291686473 | Accepted | def main():
import sys
input = sys.stdin.readline
import math
l=[int(input()) for _ in [0]*6]
print(5+math.ceil((max(l[0]-min(l[1:]),0))/min(l[1:])))
if __name__=='__main__':
main() |
p03545 | s124340529 | Wrong Answer | import itertools
S=input()
for i in itertools.product(["+","-"],repeat=3):
ans=""
for j in range(len(i)):
if i[j]=="+":
ans+=S[j]+i[j]
elif i[j]=="-":
ans+=S[j]+i[j]
ans+=S[-1]
sum_num=eval(ans)
if sum_num==7:
print(ans+"=0")
break
|
p02995 | s428041608 | Accepted | import itertools as it
import collections as col
import fractions
from functools import reduce
def lcm(x, y):
return x//fractions.gcd(x, y)*d
a,b,c,d=map(int,input().split())
A=(a-1)-(a-1)//c-(a-1)//d+(a-1)//lcm(c,d)
B=(b)-(b)//c-(b)//d+(b)//lcm(c,d)
print(B-A)
|
p03838 | s636642206 | Accepted | x,y=map(int, input().split())
if y>=x>=0 or 0>=y>= x:
print(abs(y-x))
elif x>y>0 or 0>x>y:
print(x-y+2)
else:
print(abs(abs(x)-abs(y))+1) |
p02983 | s576409821 | Accepted | import sys
L,R = map(int,input().split())
ans = 2019
for i in range(L,R):
for j in range(i+1,R+1) :
pro = (i*j) %2019
ans = min(ans,pro)
if ans == 0 :
print(0)
sys.exit()
print(ans) |
p03137 | s516179567 | Accepted | n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = []
if n > m :
print(0)
exit()
for i in range(m-1):
diff = x[i+1] - x[i]
y.append(diff)
y.sort(reverse = True)
res = x[-1] - x[0]
for i in range(n-1):
res -= y[i]
print(res)
|
p03408 | s885965595 | Accepted | from collections import defaultdict
N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]
x=defaultdict(int)
for i in s:
x[i]+=1
for i in t:
x[i]-=1
ans=0
for y in x.keys():
ans=max(ans, x[y])
print(ans) |
p04044 | s755700559 | Accepted | # bsdk idhar kya dekhne ko aaya hai, khud kr!!!
# import math
# from itertools import *
# import random
# import calendar
import datetime
# import webbrowser
# f = open("input.txt", 'r')
# g = open("output.txt", 'w')
# n, m = map(int, f.readline().split())
n, k = map(int, input().split())
arr = []
for i in range(n):
arr.append(input())
arr.sort()
print("".join(arr))
|
p02881 | s831121381 | Wrong Answer | from math import sqrt as r
from math import floor
from itertools import combinations as C
N = int(input())
P = []
while N % 2 == 0:
N //= 2
P.append(2)
for i in range(3, floor(r(N)) + 1, 2):
while N % i == 0:
N //= i
P.append(i)
if N != 1:
P.append(N)
N = 1
n, m = [], []
for p in P:
if P.count(p) >= 2:
n.append(p)
m.append(p)
P.remove(p)
P.remove(p)
print("s")
|
p02947 | s856550021 | Accepted | n = int(input())
s = [sorted(list(input())) for _ in range(n)]
res = 0
d = dict()
for list_ in s:
str_ = str(list_)
if str_ in d:
d[str_] += 1
res += d[str_] - 1
else:
d[str_] = 1
print(res) |
p03785 | s576058110 | Wrong Answer | N, C, K = map(int, input().split())
Tlist = sorted([int(input()) for _ in range(N)])
ans = 0
now = 1
start = Tlist[0]
for t in Tlist:
if now == C:
ans += 1
start = t
now = 1
else:
if t - start <= K:
now += 1
else:
ans += 1
start = t
now = 1
print(ans+1)
|
p03767 | s991268202 | Accepted | N=int(input())
L=list(map(int,input().split()))
#print(L)
L.sort()
L=L[N:]
ans=sum(L[::2])
print(ans) |
p03548 | s239697282 | Wrong Answer | X, Y, Z = map(int, input().split())
print(X // (Y + Z)) |
p02743 | s977325225 | Accepted | import math
a, b, c = map(int, input().split())
if c - (a+b) > 0:
if 4*a*b < (c-a-b)**2:
print('Yes')
else:
print('No')
else:
print('No') |
p02790 | s856581941 | Accepted | l = list(map(int, input().split()))
a = l[0]
b = l[1]
c = str(a)*b
d = str(b)*a
if c < d :
print(c)
else:
print(d)
|
p03351 | s341319443 | Accepted | a,b,c,d=map(int,input().split())
print('Yes' if (abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d))else 'No') |
p03126 | s429445854 | Wrong Answer | n,m = map(int,input().split())
d = dict()
for i in range(n):
a,*b = list(map(int,input().split()))
d[i] = b
x = 0
ans = 0
for j in range(1,m+1):
for i in range(n):
if j in d[i]:
x += 1
else:
x = 0
break
if x == n:
ans += 1
print(ans) |
p02972 | s518482305 | Wrong Answer | N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in range(N, 0, -1):
S = sum(B[m*i-1] for m in range(1, N//i))
B[i-1] = (A[i-1] + S) % 2
C = []
for i in range(N):
if B[i] == 1:
C.append(i+1)
print(len(C))
for i in range(len(C)):
if i != len(C) - 1:
print(C[i], end = ' ')
else:
print(C[i]) |
p02787 | s857521791 | Accepted | h,n=map(int,input().split())
ma=[]
for _ in range(n):
a=list(map(int,input().split()))
ma.append(a)
inf=float('inf')
dp=[inf for _ in range(h+1) ]
dp[h]=0
for i in range(1,h+1):
j=h+1-i
for x in ma:
p=x[0]
q=x[1]
if j-p>=1:
dp[j-p]=min(dp[j-p],dp[j]+q)
else:
dp[0]=min(dp[0],dp[j]+q)
print(dp[0])
|
p03387 | s045518908 | Accepted | A, B, C = map(int, input().split())
M = max(A, B, C)
d = 3*M-A-B-C
if d%2==0:
print(d//2)
else:
print((d+3)//2) |
p02665 | s904673176 | Accepted | n = int(input())
v = list(map(int, input().split()))
u = [1]*(n+1)
a = 0
b = False
tmp = 0
tt = 0
for i in range(n+1):
if u[i] < v[i]:
b = True
break
if i < n:
u[i+1] = (u[i] - v[i])*2
for i in range(n, -1, -1):
tt += v[i]
tmp = min(tt, u[i])
a += tmp
tt = tmp
if n == 0:
a = v[0]
if b:
a = -1
print(a) |
p03695 | s415889072 | Accepted | n = int(input())
a = list(map(int, input().split()))
a.sort()
l = [x//400 if x//400 <= 7 else 8 for x in a]
p = [0]*8
for i in l:
if i < 8:
p[i] = 1
pmin = sum(p) if sum(p) != 0 else 1
pmax = sum(p) + l.count(8)
print(pmin, pmax) |
p03773 | s539464800 | Wrong Answer | A,B = map(int,input().split())
print((A+B)//24) |
p03309 | s492623102 | Accepted | N = int(input())
A = list(map(int,input().split()))
B = [0]*N
ans = 0
for i in range(N):
B[i] = A[i]-(i+1)
B.sort()
b = B[N//2]
for j in range(N):
ans += abs(B[j]-b)
print(ans) |
p03486 | s033530862 | Accepted | s=input()
t=input()
data=['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']
S=[0]*len(s)
T=[0]*len(t)
for i in range(len(s)):
S[i]=data.index(s[i])
for i in range(len(t)):
T[i]=data.index(t[i])
S.sort()
T.sort(reverse=True)
if S<T:
print('Yes')
else:
print('No') |
p02628 | s671404476 | Accepted | N,K = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
print(sum(P[:K])) |
p03548 | s889093069 | Accepted | x, y, z = (int(x) for x in input().split())
print((x - z) // (y + z)) |
p02639 | s808231989 | Accepted | a = list(map(int, input().split()))
print(a.index(0) + 1) |
p03644 | s372807923 | Accepted | n = int(input())
ans = 0
m = 0
if n==1:
print(1)
else:
for i in range(2,n+1,2):
a = 0
x = i
while(True):
if x%2!=0:
break
a+=1
x = x//2
if a>m:
m=a
ans=i
print(ans) |
p03379 | s591872341 | Accepted | import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n // 2 - 1]
b = y[n // 2]
# print("a =", a)
# print("b =", b)
for i in x:
if i <= a:
print(b)
else:
print(a)
|
p02729 | s645954521 | Accepted | n,m=map(int,input().split())
print(n*(n-1)//2+m*(m-1)//2) |
p03494 | s135593842 | Wrong Answer | def calc_half(n):
return n / 2
def calc_rem(n):
return n % 2
N = input()
A = list(map(int, input().split()))
n = 0
while list(map(calc_rem, A)) == [0, 0, 0]:
A = map(calc_half, A)
n += 1
print(n) |
p02681 | s298150755 | Wrong Answer | S = input()
T = input()
T = T.replace(S,"")
print(T)
if len(T) == 1:
print("YES")
else:
print("NO") |
p02553 | s665426071 | Accepted | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
a, b, c, d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d)) |
p03136 | s768576337 | Accepted | n = int(input())
l = list(map(int, input().split()))
l.sort()
s = 0
for i in range(n-1):
s += l[i]
if s > l[-1]:
print('Yes')
else:
print('No') |
p03774 | s528473059 | Accepted | n,m=map(int,input().split())
ab,cd=[],[]
ans_dis=[1000000000 for i in range(n)]
ans=[0 for i in range(n)]
for i in range(n):
a,b=map(int,input().split())
ab.append([a,b])
for i in range(m):
c,d=map(int,input().split())
cd.append([c,d])
for i in range(n):
for j in range(m):
dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
if dis<ans_dis[i]:
ans[i]=(j+1)
ans_dis[i]=dis
for i in range(n):
print(ans[i]) |
p02687 | s187079261 | Accepted | s = input()
if s == 'ABC':
print('ARC')
else:
print('ABC') |
p02681 | s918787923 | Accepted | S=input()
T=input()
if S==T[:-1]:
print("Yes")
else:
print("No") |
p03796 | s167243116 | Wrong Answer | n=int(input())
f=1
for i in range(1,n+1):
f*=i
print(f) |
p03127 | s090933096 | Accepted | import sys
from math import gcd
from functools import reduce
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *A = map(int, read().split())
print(reduce(gcd, A))
return
if __name__ == '__main__':
main()
|
p02793 | s420377458 | Accepted | N = int(input())
A = [int(a) for a in input().split()]
import fractions
mod = 10**9+7
t = 1
for a in A:
t = a*t//fractions.gcd(a, t)
ans = 0
for a in A:
ans += t//a
print(ans%mod) |
p03071 | s121652991 | Accepted | a,b=map(int,input().split())
if a==b:print(a*2)
else:print(max(a,b)*2-1) |
p03042 | s803437008 | Accepted | S = input()
AA = int(S[:2])
BB = int(S[2:])
if (1 <= AA <= 12) and (1 <= BB <= 12):
print('AMBIGUOUS')
elif (13 <= AA or AA == 0) and (1 <= BB <= 12):
print('YYMM')
elif (1 <= AA <= 12) and (13 <= BB or BB == 0):
print('MMYY')
else:
print('NA') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.