problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p03071 | s084656314 | Accepted | a, b = map(int, input().split())
if a == b:
print(a + b)
elif a - b >= 1:
print(a + a - 1)
else:
print(b + b - 1) |
p03160 | s161361976 | Accepted | n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i]- h[i-2])+dp[i-2])
# print(dp)
print(dp[n-1]) |
p03407 | s314996932 | Accepted | a, b, c = map(int, input().split())
ans = 'No'
if a+b >= c:
ans = 'Yes'
print(ans) |
p03835 | s382069900 | Accepted | K,S=map(int,input().split())
count=0
for i in range(K+1):
for j in range(K+1):
if((S-i-j)<=K and 0<=S-i-j):
count=count+1
print(count)
|
p03351 | s914771821 | Wrong Answer | a,b,c,d = map(int,input().split())
if abs(a-b)<=d and (b-c)<=d or abs(a-c)<=d:
print('Yes')
else:
print('No') |
p02546 | s435645638 | Accepted | s = input()
a = s + ('es' if s[-1] == 's' else 's')
print(a) |
p02684 | s960802512 | Accepted | n, m = map(int, input().split())
lis = list(map(lambda z: int(z) - 1, map(int, input().split())))
s = {0}
res = [0]
while lis[res[-1]] not in s:
res.append(lis[res[-1]])
s.add(res[-1])
x, y = res.index(lis[res[-1]]), len(res)
if m < y:
print(res[m] + 1)
else:
mm = (m - x) % (y - x)
print(res[mm + x] + 1)
|
p02989 | s467927626 | Accepted | def main():
n = int(input())
d = list(map(int, input().split()))
d_s = sorted(d)
idx = int(n/2)
diff = d_s[idx] - d_s[idx-1]
print(diff)
if __name__ == '__main__':
main() |
p03243 | s054637533 | Accepted | n=int(input())
k=n//100
nex=111*k
if nex>=n:
print(nex)
else:
print(nex+111) |
p03723 | s405871466 | Wrong Answer | import sys
a,b,c=map(int,input().split())
ans=0
if a%2==1 or b%2==1 or c%2==1:
print(-1)
sys.exit()
if a%2==0 and a==b==c:
print(-1)
sys.exit()
while a%2==0 and b%2==0 and c%2==0:
ta=a/2
tb=b/2
tc=c/2
a=tb+tc
b=ta+tc
c=ta+tb
ans+=1
print(ans) |
p03475 | s242870909 | Accepted | import math
n = int(input())
csf = [list(map(int, input().split())) for i in range(n-1)]
ANS = []
for i in range(n):
ans = 0
for c,s,f in csf[i:]:
if ans <= s:
ans = s + c
else:
ans = s + math.ceil((ans-s)/f) * f + c
ANS.append(ans)
for i in ANS:
print(i) |
p03239 | s714632404 | Accepted | N, T = map(int, input().split())
ct = []
for i in range(N):
c,t = map(int, input().split())
if t <= T:
ct.append([c,t])
if ct == []:
print("TLE")
else:
ct.sort()
print(ct[0][0]) |
p02607 | s792037911 | Accepted | mass = int(input())
nums = list(map(int, input().split()))
c = 0
for i in range(len(nums)):
if nums[i]%2 ==1:
i += 1
if i%2 == 1:
c += 1
print(c) |
p03252 | s725607997 | Wrong Answer | from collections import Counter
S = input()
T = input()
counter_S = Counter(S)
counter_T = Counter(T)
length_CS = len(counter_S)
length_CT = len(counter_T)
# print(counter_S)
# print(counter_T)
if length_CS != length_CT:
print("No")
else:
flag = True
list_CS = list(counter_S.values())
list_CT = list(counter_T.values())
for i in range(length_CS):
if list_CS[i] != list_CT[i]:
flag = False
break
if flag:
print("Yes")
else:
print("No")
|
p02987 | s703830776 | Accepted | S = list(input())
s = set(S)
lis = {}
for x in S:
if x in lis:
lis[x] += 1
else:
lis[x] = 1
ans = True
if len(lis) == 2:
for x in s:
if lis[x] != 2:
ans = False
else:
ans = False
if ans:
print("Yes")
else:
print("No") |
p02760 | s257553540 | Accepted | a = [list(map(int,input().split()))for _ in range(3)]
n = int(input())
for i in range(n):
b= int(input())
for j in range(3):
for k in range(3):
if a[j][k] == b:a[j][k ] = 0
ans = "No"
for i in range(3):
if a[i][0] == a[i][1] == a[i][2] == 0:ans = "Yes"
if a[0][i] == a[1][i] == a[2][i] == 0:ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == 0:ans = "Yes"
if a[0][2] == a[1][1] == a[2][0] == 0:ans = "Yes"
print(ans) |
p02922 | s900458830 | Accepted | a, b = map(int, input().split())
ans = 0
tmp = 1
while tmp < b:
tmp += a-1
ans += 1
print(ans) |
p02760 | s261522386 | Wrong Answer | bingo = [list(map(int,input().split())) for i in range(3)]
n= int(input())
bs = [int(input()) for i in range(n)]
bingo.append([bingo[0][0], bingo[1][1], bingo[2][2]])
bingo.append([bingo[0][2], bingo[1][1], bingo[2][0]])
bingo.append([bingo[0][0], bingo[1][0], bingo[2][0]])
bingo.append([bingo[0][1], bingo[1][1], bingo[2][1]])
bingo.append([bingo[0][2], bingo[1][2], bingo[2][2]])
print(any([len([j for j in k if j in bs])==3 for k in bingo])) |
p03624 | s083349568 | Accepted | def main():
s = input()
l = "abcdefghijiklmopqrstuvwxyz"
for i in range(len(s)):
l = l.replace(s[i], '')
if l == "":
print('None')
else:
print(l[0])
if __name__ == "__main__":
main()
|
p02678 | s490985188 | Accepted | from collections import deque
n, m = map(int,input().split())
g = [[] for _ in range(n+1)]
for i in range(m):
a, b = map(int,input().split())
g[a].append(b)
g[b].append(a)
yet = [-1 for _ in range(n+1)]
yet[0] = 0
yet[1] = 1
d = deque([1])
while d:
v = d.popleft()
for i in g[v]:
if yet[i] == -1:
yet[i] = v
d.append(i)
ans = yet[2:]
print("Yes")
print(*ans, sep="\n") |
p03474 | s830328843 | Wrong Answer | a, b = map(int, input().split())
s = input()
ans = 'No'
s_a = s[:a]
s_h = s[a]
s_b = s[b:]
if s_a.isdecimal() and s_b.isdecimal() and s_h =='-':
ans = 'Yes'
print(ans) |
p02720 | s254507609 | Accepted | from collections import deque
k = int(input())
queue = deque(range(1, 10))
for _ in range(k):
x = queue.popleft()
y = x % 10
if y != 0:
queue.append(10*x + y-1)
queue.append(10*x + y)
if y != 9:
queue.append(10*x + y+1)
print(x) |
p02873 | s079269732 | Wrong Answer | S = list("<>>><<><<<<<>>><")
lis = [0] * (len(S)+1)
#最初は < を処理する
for i in range(len(S)):
if S[i] == "<":
lis[i+1] = lis[i] + 1
num = len(lis)
for i in reversed(S):
num = num-1
if i == "<":
lis[num] = lis[num] + 1
|
p02553 | s508554771 | Accepted | a, b, c, d = map(int, input().split())
rst = max(a*c, b*d, b*c, a*d)
print(rst) |
p03607 | s307153292 | Accepted | N=int(input())
s=set([])
for i in range(N):
t=input()
if t not in s:
s.add(t)
else:
s.remove(t)
print(len(s)) |
p03042 | s421231805 | Accepted | from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
s = input()[:-1].decode()
l = int(s[:2])
r = int(s[2:])
if (l >= 13 or l == 0) and 1 <= r <= 12:
print('YYMM')
elif 1 <= l <= 12 and (r >= 13 or r == 0):
print('MMYY')
elif 1 <= l <= 12 and 1 <= r <= 12:
print('AMBIGUOUS')
else:
print('NA')
if __name__ == "__main__":
setrecursionlimit(10000)
main()
|
p02866 | s034946381 | Accepted | import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
n=int(input())
D=[int(_) for _ in input().split()]
dc=Counter(D)
mod,ans=998244353,1
if D[0]!=0 or dc[0]!=1:
print(0)
sys.exit()
for i,_ in enumerate(list(dc.items())):
if i>1:
ans*=dc[i-1]**dc[i]%mod
print(ans%mod)
if __name__=='__main__':
main() |
p02823 | s305704963 | Accepted | n,a,b=map(int,input().split())
if (a+b)%2==0:
print((b-a)//2)
else:
print(min(((a-1)+(b-1)+1)//2,((n-a)+(n-b)+1)//2)) |
p03105 | s074602098 | Wrong Answer | a,b,c = map(int, input().split())
if b//a >= c:
print(c)
if b//a <= c:
print(b//a)
|
p02785 | s984498017 | Wrong Answer | n, k = map(int, input().split())
H = list(map(int, input().split()))
sH = sorted(H, reverse=True)
ans = sum(sH[k-1:n-1:])
print(ans) |
p02787 | s383168078 | Accepted | h, n = map(int, input().split())
monster = [[0, 0] for i in range(n)]
for i in range(n):
a, b = map(int, input().split())
monster[i][0], monster[i][1] = a, b
dps = [0 for i in range(h + 1)]
for i in range(1, h + 1):
ans = 10 ** 10
for m in monster:
ans = min(ans, dps[max(i - m[0], 0)] + m[1])
dps[i] = ans
print(dps[h]) |
p02882 | s561831351 | Accepted | import math
a, b, x = map(int, input().split())
def calc_theta(a, b, x):
if x >= 0.5 * a ** 2 * b:
# tmp = (a ** 3) / (2 * ((a **2) * b - x)) これだと 0divになる
tmp = (2/a)*(b-(x/a**2))
else:
tmp = (a * b * b) / (2 * x)
return math.degrees(math.atan(tmp))
ans = calc_theta(a, b, x)
print('{:.10f}'.format(ans))
|
p03672 | s472108651 | Accepted | s = input()
s = s[:-1]
while True:
if len(s) == 0:
print(0)
exit()
if len(s)%2 == 0:
half = len(s)//2
if s[:half] == s[half:]:
print(len(s))
exit()
else:
s = s[:-2]
else:
s = s[:-1] |
p02860 | s912471446 | Wrong Answer | import sys
a=int(input())
b=list(input())
c=0
if a==1:
print('No')
sys.exit()
for i in range(a//2):
if b[i]==b[i+(a//2)]:
c+=1
else:
pass
if c>=a//2:
break
if c==a//2:
print('Yes')
else:
print('No')
|
p02767 | s077126851 | Accepted | #ABC156 - Virtual
sel='C'
#C
if sel=='C':
def ceilT(a,b): #ceil(a/b)
return (a+b-1)//b
N=int(input())
X=[int(i) for i in input().split()]
p=ceilT(sum(X),N)
ans=sum((x-p)**2 for x in X)
p-=1
ans=min(ans,sum((x-p)**2 for x in X))
print(ans)
|
p02572 | s729697435 | Accepted | mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
S = [0] # 累積和のリスト
ans = 0
for i in range(N):
S.append(A[i] + S[i] % mod)
for i in range(N):
sum = S[N] - S[i + 1]
if sum < 0:
sum += mod
ans += A[i] * sum
print(ans % mod)
|
p02659 | s542608888 | Accepted | from decimal import *
def resolve():
X,Y = map(Decimal,input().split())
print(int(X*Y))
resolve() |
p03720 | s265336811 | Accepted | N,M = map(int,input().split())
route_list = [0] * N
for i in range(M):
a,b = map(int,input().split())
route_list[a-1] += 1
route_list[b-1] += 1
for ans in route_list:
print(ans)
|
p02570 | s325591369 | Wrong Answer | d,t,s=map(int,input().split())
if d/s<=t:
print("YES")
else:
print("NO") |
p02623 | s746250317 | Wrong Answer | import sys
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=A+B
d=0
C.sort()
if sum(C)<=K :
print(len(C))
sys.exit()
for i in range(len(C)) :
d=d+C[i]
if d>K :
print(i+1)
sys.exit() |
p02881 | s851300258 | Accepted | N=int(input())
i1 = round(N**0.5)
while True:
if N%i1==0: break
i1 -= 1
print(i1+round(N/i1)-2) |
p03038 | s861953881 | Accepted | import sys
def main():
input = sys.stdin.readline
N,M=map(int, input().split())
*A,=map(int, input().split())
BC=[tuple(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key=lambda x:x[1], reverse=True)
ans=0
i=0
from bisect import bisect_right
for b,c in BC:
j = bisect_right(A, c, i, min(N,i+b))
ans += c*(j-i)
i=j
for j in range(i,N):
ans+=A[j]
print(ans)
if __name__ == '__main__':
main() |
p03645 | s928983129 | Accepted | n,m=map(int,input().split())
M=[[] for i in range(n)]
for i in range(m):
a,b=map(int,input().split())
a-=1;b-=1
M[a].append(b)
M[b].append(a)
yes="POSSIBLE";no="IMPOSSIBLE"
for i in M[0]:
if n-1 in M[i]:
print(yes);exit()
print(no)
|
p03479 | s047583837 | Accepted | x,y=map(int,input().split())
ANS=1
X=x
while True:
if 2 * X <= y:
X = X * 2
ANS += 1
else:
break
print(ANS) |
p03221 | s960201258 | Wrong Answer | n,m = map(int,input().split())
ls = []
for i in range(m):
p,y = map(int,input().split())
ls.append([p,y])
ls.sort(key= lambda x:x[1])
ls.sort(key= lambda x:x[0])
pre = ls[0][0]
cnt = 1
for p,y in ls:
if p==pre:
print(str(p).zfill(6) + str(cnt).zfill(6))
cnt+=1
else:
pre = p
print(str(p).zfill(6) + str(1).zfill(6))
cnt=2
|
p02554 | s019418768 | Accepted | tmp = 10 ** 9 + 7
def div(n,T):
_ = 1
for t in range(T):
_ *= n
_ %= tmp
return _
N = int(input())
a = div(10,N)
b = div(9,N)
c = div(8,N)
print((a + c - 2 * b) % tmp) |
p03001 | s395153956 | Wrong Answer | w,h,x,y = map(int, input().split())
if abs(2*x-w) == abs(2*y-h):
print(h*w/2,1)
else:
print(w*h/2,0) |
p02612 | s719398167 | Accepted | N = int(input())
if N % 1000 == 0:
print(0)
else:
print(1000 - N % 1000)
|
p02957 | s551499964 | Wrong Answer | A ,B = list(map(int,input().split()))
if (A+B)%2==0:
print((A+B)/2)
else:
print('IMPOSSIBLE') |
p03069 | s138002343 | Wrong Answer | n = int(input())
s = input()
wh = [0] * n
bl = [0] * n
w , b = 0,0
for i in range(n):
if s[i] == '.':
w += 1
else:
b += 1
wh[i] = w
bl[i] = b
ans = n
wtot = wh[-1]
btot = bl[-1]
for i in range(n):
x = (wtot - wh[i]) + bl[i]
ans = min(ans, x)
ans = min(ans, btot)
print (ans) |
p03239 | s117827624 | Accepted | n,T = map(int,input().split())
cands = [tuple(map(int,input().split())) for _ in range(n)]
cands.sort()
for c,t in cands:
if t<= T:
print(c)
break
else:
print('TLE')
|
p02707 | s480555919 | Wrong Answer | def funcx(a, i):
cnt = 0
for num in a:
if num == i:
cnt = cnt + 1
return cnt
def func(a, i, ptr, n):
cnt = 0
# print("xxx", i, ptr)
while ptr < n and a[ptr] == i:
ptr = ptr + 1
cnt = cnt + 1
# print("yyy", ptr)
return cnt, ptr
n = int(input())
a = list(map(int, input().split()))
ptr = 0
for i in range(n):
# print(i+1)
cnt, ptr = func(a, i + 1, ptr, n - 1)
print(cnt)
|
p02744 | s797897716 | Accepted | n = int(input())
dict = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j"}
ans = [["a", 1]]
for i in range(n-1):
newans = []
for lis in ans:
now = lis[0]
count = lis[1]
for j in range(1, count + 2):
newans.append([now + dict[j], max(j, count)])
ans = newans
for lis in ans:
print(lis[0]) |
p03059 | s961964884 | Accepted | a, b, t = map(int, input().split())
print(b * int((t + 0.5) // a)) |
p03371 | s038664389 | Wrong Answer | a, b, c, x, y = map(int, input().split())
max_value = max(a, b)
min_value = min(a, b)
boundary_value = 2 * c
if boundary_value <= (min_value + max_value):
if boundary_value <= min_value:
print(boundary_value * max(x, y))
elif (a == max_value and y <= x) or (b == max_value and x <= y):
print(boundary_value * max(x, y))
else:
print(boundary_value * (max(x, y) - abs(x - y)) +
min_value * abs(x - y))
elif (min_value + max_value) < boundary_value:
print(a * x + b * y)
|
p02987 | s672417514 | Accepted | S = str(input())
if (S[0]==S[1] and S[2]==S[3]) or (S[0]==S[2] and S[1]==S[3]) or (S[0]==S[3] and S[1]==S[2]):
if S[0]==S[1] and S[1]==S[2] and S[2]==S[3]:
print("No")
else:
print("Yes")
else:
print("No") |
p03250 | s369882070 | Accepted | A, B, C = input().split()
print(max(
int(A+B) + int(C),
int(B+A) + int(C),
int(B+C) + int(A),
int(C+B) + int(A),
int(A+C) + int(B),
int(C+A) + int(B)
))
|
p02814 | s137588001 | Accepted | import fractions
from functools import reduce
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm, numbers, 1)
n, m = map(int, input().split())
a = list(map(int, input().split()))
a_2 = list(a[i] // 2 for i in range(n))
t = lcm_list(a_2)
if not all([(t // i) % 2 for i in a_2]):
print(0)
quit()
p = (m - t) // (2 * t) + 1
print(p)
|
p03814 | s646616164 | Accepted | def main():
s = input()
a = len(s); z = 0
for i, t in enumerate(s):
if t == 'A':
a = min(a, i)
if t == 'Z':
z = max(z, i)
ans = z-a+1
print(ans)
if __name__ == "__main__":
main()
|
p03479 | s790450638 | Accepted | def main():
f, t = [int(v) for v in input().split(' ')]
count = 0
d = 1
tmp = f
while True:
tmp = tmp * 2
if tmp > t:
break
count += 1
print(count + 1)
if __name__ == '__main__':
main()
|
p02601 | s884088501 | Accepted | A,B,C = map(int, input().split())
flag = False
K = int(input())
for i in range (K+1):
for t in range (K+1):
for u in range(K+1):
if i + t + u == K:
if B * (2**t) > A * (2**i) and C * (2**u) > B * (2**t):
flag = True
if flag:
print('Yes')
else:
print('No') |
p03745 | s196726493 | Accepted | n = int(input())
A = list(map(int,input().split()))
ans = 1
d = 0
for i in range(1,n):
diff = A[i] - A[i-1]
if not d:
d = diff
elif d*diff < 0:
d = 0
ans += 1
print(ans) |
p02777 | s009327774 | Accepted | s,t = input().split()
a,b = (int(x) for x in input().split())
u = input()
if u==s:
print("{} {}".format(a-1,b))
else:
print("{} {}".format(a,b-1))
|
p02848 | s935988089 | Wrong Answer | N = input()
S = input()
N = int(N)
A = ""
num = 0
for s in S:
num = (ord(s) + N) if ord(s) + N < 90 else (ord(s) + N - 25)
A += chr(num)
print(A) |
p03852 | s076645605 | Accepted | c = input()
vowels = ['a', 'i', 'u', 'e', 'o']
if c in vowels:
print("vowel")
else:
print("consonant") |
p03565 | s980894290 | Accepted | s=input()
t=input()
lst=[]
for i in range(len(s)-len(t)+1):
ss=s[i:i+len(t)]
f=True
for a,b in zip(ss,t):
if a!=b and a!="?":
f=False
break
if f:
st=s[:i]+t+s[i+len(t):]
lst.append(st.replace("?","a"))
if lst==[]:
print("UNRESTORABLE")
else:
lst.sort()
print(lst[0]) |
p04011 | s147654238 | Accepted | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
A = 0
if N < K:
A = X * N
else:
A = X * K + Y * (N - K)
print(A) |
p03817 | s207038120 | Accepted | x=int(input())
ans=2*(x//11)
x%=11
if 0<x and x<7:ans+=1
elif x!=0:ans+=2
print(ans) |
p02664 | s870284120 | Accepted | S = list(input())
for i in range(len(S)):
if S[i] == "?":
S[i] = "D"
print("".join(S)) |
p03162 | s418562621 | Accepted | n = int(input())
eff = [list(map(int, input().split())) for _ in range(n)]
dp = [[float('-inf')] * 3 for _ in range(n)]
from copy import deepcopy
dp[0] = deepcopy(eff[0])
for i in range(1, n):
for yi in range(3):
for ti in range(3):
if yi != ti:
dp[i][ti] = max(dp[i][ti], dp[i-1][yi] + eff[i][ti])
print(max(dp[-1])) |
p02624 | s334551881 | Accepted | n = int(input())
cnt_tb = [0]*(n+1)
for i in range(1, n + 1):
j = 1
tmp = i*j
while (tmp < n+1):
cnt_tb[tmp] += 1
j += 1
tmp = i*j
ans = 0
for i in range(1, len(cnt_tb)):
ans += i * cnt_tb[i]
print(ans)
|
p03495 | s272731568 | Accepted | def main():
from collections import Counter
n, k, *a = map(int, open(0).read().split())
c = Counter(a).values()
v = len(c) - k
l = list(c)
l.sort()
ans = sum(l[:v])
print(ans)
if __name__ == '__main__':
main()
|
p03778 | s737046736 | Accepted | W,a,b = map(int,input().split())
if b <= a+W <= b+W:
print(0)
else:
print(min(abs(b-(a+W)),abs(a-(b+W))))
|
p03474 | s084736782 | Wrong Answer | a,b = map(int, input().split())
s = input()
ok = True
ok = ok and s[0:a].isdecimal()
ok = ok and s[a] == '-'
ok = ok and s[a+1:-1].isdecimal()
if ok:
print("yes")
else:
print("no")
|
p02606 | s707527373 | Wrong Answer | import math
l, r, d = map(int, input().split())
if l % d == 0 or r % d == 0:
print(math.floor(r/d) - math.floor(r/d) + 1)
else:
print(math.floor(r/d) - math.floor(r/d)) |
p03971 | s354554561 | Accepted | n,a,b = map(int, input().split())
s = input()
c = 0
d = 1
for i in range(n):
if s[i] == "a" and c <(a+b):
print("Yes")
c += 1
elif s[i] == "b" and c < (a+b) and d <= b:
print("Yes")
c += 1
d += 1
else:
print("No") |
p02594 | s034439542 | Wrong Answer | print('Yes' if input() >= '30' else 'No') |
p04031 | s595087375 | Accepted | N = int(input())
A = list(map(int, input().split(' ')))
ans = []
if A.count(A[0]) == len(A):
print(0)
exit(0)
for i in range(-100,101):
cost = 0
for j in range(N):
if A[j] == i:
continue
else:
cost += (A[j] - i)**2
ans.append(cost)
import heapq
heapq.heapify(ans)
print(heapq.heappop(ans)) |
p02627 | s781798805 | Accepted | if input().isupper():
print('A')
else:
print('a') |
p02765 | s721316461 | Accepted | N, R = (int(x) for x in input().split())
print(R if N >= 10 else R + (100 * (10 - N))) |
p03076 | s145686671 | Accepted | import math
abc = [int(input()) for _ in range(5)]
tmp = 9
ans = 0
ii = 0
for i in range(5):
tmpp = min(tmp, (abc[i]-1)%10)
if tmp != tmpp:
tmp = tmpp
ii = i
for i in range(5):
if i == ii:
ans += abc[i]
else:
ans += (math.ceil(abc[i]/10))*10
print(ans) |
p03417 | s008415294 | Wrong Answer | n, m = map(int, input().split())
if n > 2 and m > 2:
print((n-2) * (m-2))
elif n == 2 or m == 2:
print(0)
else:
print(m*n - 2) |
p02916 | s484854765 | Accepted | n = int(input())
a = list(map(int,(input().split()))) #食べた料理
b = list(map(int,(input().split()))) #料理iの満足度
c = list(map(int,(input().split())))
result = 0
mae = 1111
for i in a:
#print("result",result)
result += b[i-1]
#print("mae,b[i-1]",mae,i)
if mae == i -1:
#print("if",result)
result += c[i-2]
mae = i
print(result) |
p02702 | s715390109 | Wrong Answer | S = input()
count = 0
for i in range(len(S)):
for j in range(i+1,i+7):
if int(S[i:j]) % 2019 == 0 and int(S[i:j]) != 0:
count = count + 1
if j >= len(S):
break
print(count) |
p03062 | s702237435 | Accepted | n = int(input())
a = [int(i) for i in input().split()]
sum_abs, min_abs, cnt_minus = 0, 10**9, 0
for ai in a:
if ai < 0:
cnt_minus += 1
abs_ai = abs(ai)
sum_abs += abs_ai
if abs_ai < min_abs:
min_abs = abs_ai
if cnt_minus % 2 == 0 or 0 in a:
print(sum_abs)
else:
print(sum_abs - 2*min_abs) |
p02897 | s387323579 | Accepted | n = int(input())
if n==1:
print(1/float(1))
elif n%2==0:
print((n//2)/float(n))
else:
print(((n//2)+1)/float(n)) |
p03030 | s105139988 | Wrong Answer | N = int(input())
L = []
for i in range(N):
S, P = input().split()
L.append([S, int(P), i+1])
LS = sorted(L)
for i in range(N):
print(LS[i][2]) |
p02732 | s931102256 | Accepted | import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
keys = c.keys()
comb = 0
for i in keys:
comb += (c[i] * (c[i]-1)) //2
for i in A:
ans = comb - (c[i]-1)
print(ans) |
p03274 | s679916343 | Accepted | def main():
n, k, *x = map(int, open(0).read().split())
l = x[k - 1] - x[0] + min(abs(x[k - 1]), abs(x[0]))
for i, j in zip(x, x[k - 1:]):
y = j - i + min(abs(i), abs(j))
if y - l < 0:
l = y
print(l)
if __name__ == '__main__':
main()
|
p03309 | s095608960 | Accepted | N = int(input())
A = list(map(int, input().split()))
def func(b):
return sum([abs(val - b) for val in I])
#y seppen wo motomeru
I=[A[i]-i-1 for i in range(N)]
I.sort()
if N % 2 ==1:
print(func(I[N//2]))
else:
print(func(I[N//2]))
|
p02759 | s168885957 | Accepted | n = int(input())
print(-(int(-n//2))) |
p02775 | s002119866 | Accepted | N = "0" + input()
ans, carry = 0, 0
for i in range(len(N) - 1, 0, -1):
n = int(N[i]) + carry
ans += min(10 - n, n)
carry = 1 if n > 5 or (n == 5 and int(N[i - 1]) >= 5) else 0
print(ans + carry)
|
p02780 | s946837386 | Wrong Answer | N, K = map(int, input().split())
P = list(map(int, input().split()))
E = []
for p in P:
e = ((p * p + p) / 2) * (1 / p)
E.append(e)
ans = 0
memo = sum(E[:K])
for i in range(0, N - K):
memo = memo - E[i] + E[i + K]
ans = max(ans, memo)
print(ans)
|
p02995 | s243147528 | Accepted | from fractions import gcd
def lcm(x, y):
return (x * y) // gcd(x, y)
A, B, C, D = map(int, input().split())
SUM = B - A + 1
c = (B // C - (A - 1) // C)
d = (B // D - (A - 1) // D)
cd = (B // lcm(C, D) - (A - 1) // lcm(C, D))
print(B - A + 1 - (B // C - (A - 1) // C + B // D - (A - 1) // D - (B // lcm(C, D) - (A - 1) // lcm(C, D))))
|
p03814 | s095363902 | Wrong Answer | s = input()
n = len(s)
x = []
for i in range(n):
if s[i] == 'A':
x.append(i)
elif s[i] == 'Z':
x.append(i)
print(len(s[x[0]:x[1]])) |
p02699 | s252471529 | Accepted |
s,w = (int(x) for x in input().split())
# xl = map(int, input().split())
if w >= s:
print('unsafe')
else:
print('safe')
|
p03699 | s327396157 | Wrong Answer | N = int(input())
S = []
for _ in range(N):
S.append(int(input()))
s = sum(S)
S.sort()
i = 0
while s != 0:
if s % 10 != 0:
break
s -= S[i]
i += 1
print(s) |
p02973 | s351294181 | Accepted | import bisect
from collections import deque
n = int(input())
l = deque([])
l.append(int(input()))
for i in range(n-1):
a = int(input())
if l[0] >= a:
l.appendleft(a)
else:
l[bisect.bisect_left(l,a)-1] = a
print(len(l))
|
p02665 | s068136604 | Accepted | N = int(input())
A = list(map(int, input().split()))
if N == 0:
print(A[0] if A[0] <= 1 else -1)
exit()
if A[0] and N >= 1:
print(-1)
exit()
# 根の数
node = 1
root = 0
s = sum(A)
for i in range(len(A) - 1):
node = min(s, node * 2) - A[i + 1]
if node < 0:
print(-1)
exit()
s -= A[i + 1]
root += node
print(root + sum(A) + 1 if not node else -1) |
p02555 | s191966198 | Accepted | s = int(input())
mod = 10**9 + 7
dp = [0]*(s+1)
dp[0] = 1
for i in range(1,s+1):
for j in range((i-3)+1):
dp[i] +=dp[j]
dp[i] %=mod
print(dp[s]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.