problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03206 | s263904375 | Wrong Answer | d=int(input())
print("Christmas"+"EVE"*(25-d)) |
p03487 | s766119506 | Accepted | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a = Counter(a)
cnt = 0
for k, v in a.items():
if k == v:
continue
elif k > v:
cnt += v
else:
cnt += v - k
print(cnt) |
p03126 | s160308981 | Accepted | N,M = map(int, input().split())
K = []
A = []
for i in range(N):
k, *a = map(int, input().split())
K += [k]
A += a
counter = 0
for j in range(1,M+1):
if A.count(j) == N:
counter += 1
print(counter) |
p02598 | s240722163 | Accepted | import math
N, K=map(int,input().split())
A=list(map(int,input().split()))
def judge(ans,K,A):
cut=0
for i in range(len(A)):
cut+=(A[i]-1)//ans
if cut>K:
return False
else:
return True
ansp=max(A)
ansm=0
ans=(ansp+ansm)//2
d=1
while ansp-ansm>d:
if judge(ans,K,A):
ansp=ans
else:
ansm=ans
ans=(ansp+ansm)//2
print(ansp) |
p03437 | s597811379 | Wrong Answer | x,y = map(int,input().split())
if x == y:
print(-1)
else:
print(x) |
p03680 | s808331415 | Accepted | N = int(input())
a = [int(input()) for _ in range(N)]
cnt, i = 0, 0
for j in range(10 ** 6):
cnt += 1
if a[i] == 2:
print(cnt)
#break
quit()
else:
i = a[i] - 1
print(-1) |
p02756 | s742150490 | Accepted | import sys
s = input()
q = int(input())
a = ['', '']
r = 0
for l in sys.stdin:
if l[0] == '1':
r ^= 1
else:
a[0 if l[2] == '21'[r] else 1] += l[4]
if r:
print(a[0][::-1] + s[::-1] + a[1])
else:
print(a[1][::-1] + s + a[0]) |
p02684 | s230082055 | Wrong Answer | # D
N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
temp = []
d = [0]*(2*(10**5) + 1)
now = 1
while True:
d[now] += 1
if d[now] > 1:
break
temp.append(now)
now = A[now-1]
for t in temp[::-1]:
cnt += 1
if t == now:
break
# print(temp)
# print(cnt)
print(temp[K%cnt])
|
p03126 | s903330923 | Accepted | MM = input().split()
N =int(MM[0])
M =int(MM[1])
list1 = [i for i in range(M+1)]
for i in range(N):
MM = input().split()
list2 = [int(MM[j]) for j in range(1,int(MM[0])+1)]
list1 = set(list1)&set(list2)
print(len(list1))
|
p02702 | s233005507 | Accepted | # for i in range(10):
# print( 10 ** i % 2019)
s = list(map(int, list(input())))
n = len(s)
MODULO = 2019
power = 1
prefix_ = [0 for _ in range(n+1)]
for i in range(n-1, -1, -1):
prefix_[i] = (prefix_[i+1] + power*s[i]) % MODULO
power *= 10
power %= MODULO
seen = {}
ans = 0
for item in prefix_:
ans += seen.get(item, 0)
seen[item] = seen.get(item, 0) + 1
# print(s)
# print("prefix_", prefix_)
# print("unique", len(set(prefix_)))
# print("all", len(prefix_))
print(ans) |
p03624 | s436439587 | Wrong Answer | alphabet = [i for i in "abcdefghijklmnopqrstuvwxyz"]
S = input()
S_list = [i for i in S]
S_list = sorted(set(S_list),reverse=False)
ans = None
for index,i in enumerate(S_list):
if alphabet[index] != i:
ans = alphabet[index]
break
print(ans) |
p03067 | s504373055 | Accepted | a,b,c=map(int,input().split())
a,b=min(a,b),max(a,b)
if a < c < b:
print('Yes')
else:
print('No') |
p03994 | s404435474 | Wrong Answer | alphabet = 'abcdefghijklmnopqrstuvwxyz'
s = input()
K = int(input())
ans = ''
for i in range(len(s)):
s_i = alphabet.index(s[i])
if (26 - s_i <= K) & (s_i != 0):
K -= 26 - s_i
s_i = 0
ans += alphabet[s_i]
if K > 0:
s_i = (alphabet.index(s[-1]) + K) % 26
ans = ans[:-1] + alphabet[s_i]
print(ans)
|
p03013 | s380978154 | Accepted | #C
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [1]*N
for i in range(M):
dp[a[i]-1] = 0
for i in range(N):
if dp[i] == 0:
continue
elif i == 0:
dp[i] = 1
elif i == 1:
dp[i] = dp[i-1]+1
else:
dp[i] = dp[i-1] + dp[i-2]
ans = int(dp[N-1])%1000000007
print(ans)
|
p03061 | s916030686 | Accepted | import fractions
n = int(input())
a = list(map(int,input().split()))
l = [0 for i in range(n)]
l[0] = a[0]
for i in range(1,n):
l[i] = fractions.gcd(l[i-1],a[i])
r = [0 for i in range(n)]
r[n-1] = a[n-1]
for i in reversed(range(0,n-1)):
r[i] = fractions.gcd(r[i+1],a[i])
ans = max(l[n-2],r[1])
for i in range(n-2):
ans = max(ans,fractions.gcd(l[i],r[i+2]))
print(ans)
|
p02690 | s843524338 | Accepted | X = int(input())
if X == 0:
print(0,0)
else:
for i in range(-121,122):
for j in range(-121,122):
if i==j:
continue
else:
if X%(i-j) == 0:
if X == i**5 - j**5:
print(i,j)
exit() |
p02753 | s389349652 | Accepted | s = str(input())
if s=="AAA" or s=="BBB":
print("No")
else:
print("Yes") |
p02577 | s952091255 | Accepted | N =input()
count=0
for i in N:
count +=int(i)
if count%9 == 0:
print("Yes")
else:
print("No")
|
p03665 | s243903676 | Wrong Answer | n,p=map(int,input().split())
A=[i%2 for i in map(int,input().split())]
A0=A.count(0)
A1=A.count(1)
if p==1 and A1==0:
print(0)
else:
print((2**A0)*(2**A1)//2)
|
p02726 | s671025729 | Accepted | n, x, y = map(int, input().split())
ans = [0]*(n+1)
for i in range(1,n+1):
for j in range(i+1, n+1):
d = min(abs(i-j), abs(y-j)+abs(x-i)+1, abs(y-i)+abs(x-j)+1)
ans[d] += 1
for a in ans[1:-1]:
print(a) |
p03221 | s775245903 | Accepted | N,M = map(int,input().split())
d=[0]*M
res = []
for i in range(M):
P,Y = map(int,input().split())
res.append((P,Y,i))
c=0
res.sort()
t = str(res[0][0])
for i in res:
x = str(i[0])
if x == t:
c+=1
else:
c=1
t = x
d[i[2]] = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)
for i in d:
print(i)
|
p03386 | s995796449 | Accepted | a, b, k = map(int, input().split())
if b-a+1 >= 2*k:
[print(i) for i in range(a, a+k)]
[print(i) for i in range(b-k+1, b+1)]
else:
[print(i) for i in range(a, b+1)] |
p02933 | s387802490 | Accepted | a = int(input())
s = input()
if a >= 3200:
print(s)
elif a < 3200:
print('red') |
p02918 | s083662289 | Accepted | # Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K = map(int,input().split())
S = input().rstrip()
# 隣あう2人の向きが同じ をカウントする
cnt = 0
for i in range(N-1):
if S[i]==S[i+1]:
cnt += 1
# 1回の反転で +2 される => 最大で 2K 増える
cnt += 2*K
# ただし 最大値は 全員が同じ向きを向いた場合の N-1
print(min(N-1,cnt)) |
p03592 | s180825380 | Accepted | n , m , k = map(int,input().split())
for i in range(n+1):
for j in range(m+1):
if i*(m-j) + j*(n-i) == k:
print("Yes")
exit()
print("No") |
p03797 | s348457969 | Accepted | a,b=map(int,input().split())
A=min(a,b//2)
a-=A
b-=A*2
A+=b//4
print(A) |
p02629 | s054272340 | Wrong Answer | # ord('a'), chr(97)
N = int(input().rstrip())
ret = []
while N != 0:
ret.append(chr(96+(N % 26)))
N = N // 26
print(''.join(ret[::-1]))
|
p03061 | s929392766 | Accepted | from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
GCDF, GCDB = [0]*N, [0]*N
GCDF[1],GCDB[-2] = A[0], A[N-1]
for i in range(2, N):
GCDF[i] = gcd(GCDF[i-1],A[i-1])
GCDB[-(i+1)] = gcd(GCDB[-i], A[-i])
GCDm = [0]*N
GCDm[0] = GCDB[0]
GCDm[N-1] = GCDF[N-1]
for i in range(1, N-1):
GCDm[i] = gcd(GCDF[i],GCDB[i])
ans = max(GCDm)
print(ans) |
p03035 | s956659081 | Accepted | a,b=map(int,input().split())
if a>=13:
print(b)
elif a>=6 and a<=12:
print(b//2)
else:
print(0)
|
p03076 | s421979132 | Accepted | from itertools import permutations
a, b, c, d, e = [int(input()) for _ in range(5)]
result = 10 ** 9
p = permutations([a, b, c, d, e])
for case in p:
t = 0
for i, dish in enumerate(case):
if i != 4 and dish % 10 != 0:
dish += 10 - dish % 10
t += dish
result = min(result, t)
print(result) |
p03433 | s636935831 | Wrong Answer | a= int(input())
b= int(input())
result = a%500
if result - b < 0:
print("Yes")
else:
print("No") |
p02802 | s304976003 | Accepted | n, m = list(map(int, input().split()))
wa_count = [0] * n
is_accepted = [False] * n
ans_ac = 0
ans_wa = 0
for i in range(m):
p, s = input().split()
p = int(p) - 1
if s == 'AC':
if not is_accepted[p]:
is_accepted[p] = True
ans_ac += 1
ans_wa += wa_count[p]
else:
wa_count[p] += 1
print(ans_ac, ans_wa)
|
p02882 | s576189512 | Accepted | import math
a,b,x=map(int,input().split())
s=x/a
if s >= a*b/2:
h=(a*b-s)*2/a
rad= math.atan2(h,a)
else:
w=s*2/b
rad =math.atan2(b,w)
print(math.degrees(rad)) |
p02718 | s274654483 | Wrong Answer | from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
n, m = inpl()
a = inpl()
s = sum(a)
cnt = 0
for i in a:
if i > s//(4*m):
cnt += 1
if cnt >= m:
print('Yes')
else:
print('No') |
p03705 | s874425118 | Wrong Answer | N, A, B = map(int, input().split())
print(B * (N - 1) + A - A * (N - 1) - B + 1) |
p03623 | s095497236 | Accepted | a,b,c=map(int,input().split())
if abs(a-b)<abs(a-c):
print("A")
else:
print("B")
|
p03062 | s773241585 | Wrong Answer | n=int(input())
a=list(map(int,input().split()))
if sum([i<0 for i in a])%2:
print(sum([abs(i) for i in a])-min([abs(i) for i in a]))
else:
print(sum([abs(i) for i in a])) |
p02596 | s464955465 | Accepted | k = int(input())
dp = [0] * k
cur = 0
for i in range(k + 1):
cur = (cur * 10 + 7) % k
mod = cur % k
if mod == 0:
print(i + 1)
break
if dp[mod]:
print(-1)
break
dp[mod] = 1
|
p03705 | s907477413 | Wrong Answer | #入力(後でいじる)
def pin(type=int):
return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう?
"""
方針
O(1)
"""
#solution:
#潜 影 蛇 手 ! !
N,A,B=pin()
if A==B:
print(1)
elif A>B or N==1:
print(0)
else:
print((N-1)*(B-A)-1)
#print(["NO","YES"][1-cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM]) |
p02661 | s882983062 | Accepted | n = int(input())
A, B = [], []
for i in range(n):
a, b = map(int, input().split())
A.append(a)
B.append(b)
A.sort()
B.sort()
res = 0
if n % 2 == 1:
midA = A[n // 2]
midB = B[n // 2]
if midB >= midA:
res = midB - midA + 1
else:
res = 0
else:
midA = A[n // 2 - 1] + A[n // 2]
midB = B[n // 2 - 1] + B[n // 2]
if midB >= midA:
res = midB - midA + 1
else:
res = 0
print(res) |
p03030 | s237653143 | Wrong Answer | from operator import itemgetter
n = int(input())
l = [list(input().split())+[i+1] for i in range(n)]
l.sort(key = itemgetter(0))
l = sorted(l, key = lambda x:(x[1]),reverse = True)
print(l) |
p02641 | s343481896 | Wrong Answer | x,n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(-100, 101):
if(not i in p):
if((abs(x-ans) > abs(x-i)) or(abs(x - ans) == abs(x - i) and i < ans)):
ans = i
print(ans) |
p03760 | s723049690 | Accepted | o = list(input())
e = list(input()) + [""]
for x, y in zip(o, e):
print(x+y, end="")
|
p03475 | s422979210 | Accepted | N=int(input())
C,S,F=map(list,zip(*[list(map(int,input().split())) for i in range(N-1)]))
r=[0]*N
for i in range(N-2,-1,-1):
x=S[i]+C[i]
for j in range(i+1,N-1):
x=S[j]+C[j] if x<S[j] else -(-x//F[j])*F[j]+C[j]
r[i]=x
print(*r,sep='\n') |
p03274 | s489069856 | Wrong Answer | n, k = map(int, input().split())
l = list(map(int, input().split()))
right = n-1
left = 0
while right - left + 1 > k:
if abs(l[right]) > abs(l[left]):
right-=1
else:
left+=1
l = l[left:right+1]
if len(l) == 1:
print(abs(l[0]))
exit()
l[0] = abs(min(0, l[0]))
l[-1] = abs(max(0, l[-1]))
print(2*min(l[0], l[-1]) + max(l[0], l[-1]))
|
p02948 | s088403883 | Accepted | N, M = map(int, input().split())
works = dict()
for _ in range(N):
a, b = map(int, input().split())
if a in works.keys():
works[a].append(-1 * b)
else:
works[a] = [-1 * b]
#print(works)
import heapq
cando = []
total = 0
day = M - 1
while day >= 0:
lt = M - day
if lt in works.keys():
for salary in works[lt]:
heapq.heappush(cando, salary)
#print('day:{}, lt:{}, len(cando):{}'.format(day, lt, len(cando)))
if len(cando) > 0:
total += -1 * heapq.heappop(cando)
#print('day:{}, total:{}'.format(day, total))
day -= 1
print(total) |
p02993 | s734806815 | Accepted | S = input()
ans = "Good"
for i in range(len(S) - 1):
if S[i] == S[i + 1]:
ans = "Bad"
break
print(ans) |
p02623 | s530490406 | Accepted | N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
index = 0
index2 = 0
stackedTime = 0
while(index<N and stackedTime + A[index] <= K):
stackedTime += A[index]
index += 1
while(index2 < M and stackedTime + B[index2] <= K):
stackedTime += B[index2]
index2 += 1
maxBook = index + index2
for i in range(N):
if(index == 0 or index2 == M):
break
index -= 1
stackedTime -= A[index]
while(index2 < M and stackedTime + B[index2] <= K):
stackedTime += B[index2]
index2 += 1
maxBook = max(maxBook, index + index2)
print(maxBook)
|
p03150 | s504385930 | Accepted | import sys
S = input()
for i in range(len(S)):
for j in range(i,len(S)):
if "keyence" == (S[:i]) + (S[j:]):
print("YES")
sys.exit()
print("NO") |
p02779 | s619413096 | Accepted | t = int(input())
a = list(map(int,input().strip().split()))
b = set(a)
if len(a) ==len(b):
print('YES')
else:
print('NO')
|
p03327 | s018201140 | Wrong Answer | contest_num = int(input())
if contest_num >= 1999: # 不等号は=の手前に
print('None')
elif contest_num < 1000:
print('abc')
elif contest_num >= 1000:
print('abd') |
p04033 | s494044331 | Wrong Answer | import sys
a,b=map(int,input().split())
if a>=0:
print("Positive")
sys.exit()
if b>=0:
print("Zero")
sys.exit()
if abs(a-b)%2==1:
print("Negative")
else:
print("Positive") |
p02577 | s293378036 | Accepted | a=list(input())
p=0
for i in range(len(a)):
p+=int(a[i])
if p%9==0:
print('Yes')
else:
print('No') |
p02727 | s066404160 | Wrong Answer | x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p)
q=sorted(q)
r=sorted(r) |
p03000 | s511022581 | Accepted | N,X=map(int,input().split())
arr=list(map(int,input().split()))
a=0
ans=1
for i in range(N):
a=a+arr[i]
if a<=X:
ans+=1
print(ans) |
p02946 | s214148888 | Wrong Answer | # -*- coding: <encoding name> -*-
k, x = map(int, input().split())
for i in range(x - k + 1, x + k):
print(i, end = "") |
p03778 | s609099972 | Accepted | w, a, b = map(int, input().split())
if a + w <= b:
print(b-(a+w))
elif b + w <= a:
print(a-(b+w))
else:
print(0)
|
p03289 | s871862931 | Wrong Answer |
s=input()
if s.count("A")==1 and s.count("C")==1:
if "C" in s[2:len(s)-1] and s[0]=="A":
s=s.replace("A","")
s=s.replace("C","")
if s.isupper()==False:
print("AC")
else:
print("WA")
else:
print("WA") |
p03699 | s913735911 | Accepted | n = int(input())
s_list = [int(input()) for nesya in range(n)]
total = sum(s_list)
s_list.sort()
t = 0
if total%10 != 0:
print(total)
else:
for s in s_list:
if s%10 != 0:
print(total-s)
break
t += 1
if t == n:
print(0)
|
p03059 | s296884021 | Accepted | a, b, k = map(int, input().split( ))
n = k//a
print(b*n)
|
p02775 | s889054999 | Accepted | import collections
s = map(int,list(raw_input()))
qa = collections.deque([0])
qb = collections.deque([1])
for i in range(len(s)):
qa.append(min(qa[0] + s[i], qb[0] + 10 - s[i]))
qb.append(min(qa[0] + s[i] + 1, qb[0] + 10 - s[i] - 1))
qa.popleft()
qb.popleft()
print qa[-1]
|
p03814 | s896866627 | Wrong Answer | s = input()
x = len(s)
y = 0
z = 0
while(y <= x):
if (s[y] == "A"):
z = y
break
y += 1
while(y <= x):
if (s[y] == "Z"):
print(str(y - z + 1))
break
y += 1 |
p04030 | s329642020 | Accepted | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
s = input()
res = []
for i in s:
if i == "0":
res.append("0")
elif i == "1":
res.append("1")
else:
if len(res) > 0:
res.pop()
print("".join(res))
if __name__ == '__main__':
resolve()
|
p03633 | s629341696 | Accepted | import fractions
def lcm(x,y):
return (x*y)//fractions.gcd(x,y)
n=int(input())
ans=1
for i in range(n):
t=int(input())
ans=lcm(ans,t)
print(ans) |
p02922 | s110082497 | Accepted | from math import ceil
A, B = map(int, input().split())
print(ceil((B-1)/(A-1))) |
p02753 | s451343999 | Wrong Answer | a=input()
print('Yes' if a=='AAA' or a=='BBB' else 'No') |
p03163 | s581860901 | Wrong Answer | N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
a,b=map(int,input().split())
w.append(a)
v.append(b)
dp=[[0 for i in range(W+1)] for _ in range(N+1)]
for i in range(0,N):
for j in range(0,W+1):
if j-w[i]>=0:
dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
print(dp[N][W])
|
p03386 | s524783282 | Accepted | a,b,x = map(int, input().split())
l = list()
for i in range(x):
if a <= a+i <= b:
l.append(a+i)
if a <= b-i <= b:
l.append(b-i)
l = sorted(set(l))
for i in l:
print(i) |
p03943 | s925945604 | Wrong Answer | a, b, c = map(int, input().split())
total = a+b+c
if total%2 == 0:
print('Yes')
else:
print('No') |
p03860 | s019378759 | Accepted | a,s,c = map(str, input().split())
print(a[0] + s[0] + c[0]) |
p02959 | s062522080 | Wrong Answer | # ABC136 C-City Savers
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
ans+=min(b[i],a[i+1])
b[i]-=min(b[i],a[i+1])
ans+=min(b[i],a[i])
b[i]-=min(b[i],a[i+1])
print(ans) |
p02882 | s526469730 | Wrong Answer | import math
a, b, x = map(int, input().split())
t = (2/a)*(b-x/(a**2))
if b-a*t >= 0:
print(math.degrees(math.atan(t)))
else:
t2 = ((a**2)*b)/(2*x)
print(math.degrees(math.atan(t2)))
|
p03317 | s755593740 | Accepted | print(eval('0--~-'+input().replace(' ','//~-'))) |
p02797 | s608468829 | Accepted | N, K, S = map(int, input().split())
ans_list = []
for i in range(K):
ans_list.append(S)
if S > 10**6:
for i in range(N - K):
ans_list.append(1)
else:
for i in range(N - K):
ans_list.append(10**9)
print(*ans_list) |
p03633 | s855889635 | Accepted | def gcd(a,b):
while b:a,b=b,a%b
return a
def lcm(a,b):
return a*b//gcd(a,b)
def main():
N = int(input())
T = [int(input())for _ in range(N)]
tmp = T[0]
for i in range(1,N):
tmp = lcm(tmp,T[i])
print(tmp)
if __name__ == "__main__":
main() |
p03448 | s605264142 | Accepted | A = int(input())
B = int(input())
C = int(input())
X = int(input())
count=0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
if X==(i*500+j*100+k*50):
count = count+1
print(count) |
p03680 | s435585206 | Accepted | n = int(input())
a_lst = [int(input()) for _ in range(n)]
button = a_lst[0]
cnt = 1 #必ずボタン1は押すため一回はカウント
ans = 0
for i in range(n):
button = a_lst[button-1]
if a_lst[0] == 2:
ans = 1
break
if button == 2:
ans = cnt + 1 #2と書かれたボタンを押す分の一回を追加
break
cnt += 1
if cnt == n+1 and ans == 0: #cntの初期値が1だからn+1
print("-1")
else:
print(ans) |
p03105 | s812844694 | Accepted | a,b,c = map(int, raw_input().split(' '))
print min(c, b/a) |
p03779 | s294939879 | Accepted | import math
x = int(input())
abs_x = abs(x)
num = 0
i = 1
while abs_x > num:
num += i
i += 1
print(i - 1) |
p03485 | s776984757 | Wrong Answer | a, b = map(int, input().split())
x = (a+b+2-1)/2
print(x) |
p02665 | s199751961 | Accepted | N = int(input())
A = list(map(int, input().split()))
n = 1
result = 0
S = sum(A)
for i in range(N+1):
result += n
if n < A[i]:
print(-1)
break
n -= A[i]
S -= A[i]
if n < S:
if n*2 < S:
n *= 2
else:
n = S
else:
print(result)
|
p03160 | s412840985 | Accepted | INF = float('inf')
n = int(input())
h = [int(i) for i in input().split()]
dp = [0, abs(h[1] - h[0])]
for i in range(2, n):
dp += [min(dp[-1] + abs(h[i] - h[i - 1]), dp[-2] + abs(h[i] - h[i - 2]))]
print(dp[-1]) |
p02768 | s171772541 | Accepted | def modcmb(n,r,mod=10**9+7):
res=1
div=min(r,n-r)
for i in range(div):
res=res*(n-i)*pow(div-i,mod-2,mod)%mod
return res%mod
n,a,b=[int(i) for i in input().split()]
mod=10**9+7
ans=pow(2,n,mod)-1
ans-=modcmb(n,a)
ans%=mod
ans-=modcmb(n,b)
ans%=mod
print(ans) |
p03495 | s846810605 | Accepted | def main():
N, K = map(int, input().split())
A = list(map(int, input().split()))
lst = {}
for num in A:
if num in lst:
lst[num] += 1
else:
lst[num] = 1
lst_sorted = sorted(lst.items(), key = lambda x: x[1])
len_lst_sorted = len(lst_sorted)
if len_lst_sorted <= K:
print(0)
return
else:
ans = 0
for i in range(len_lst_sorted - K):
ans += lst_sorted[i][1]
print(ans)
return
if __name__ == "__main__":
main() |
p02699 | s733410135 | Wrong Answer | s,w = map(int,input().split())
print("unsafe" if w > s//2 else "safe") |
p03556 | s249339011 | Accepted | N=int(input())
list=[]
for a in range(1,round((10**9)**0.5)):
b=a**2
list.append(b)
newlist=[a for a in list if a<=N]
print(max(newlist))
|
p02873 | s452788727 | Accepted | S = input()
N = len(S)
num = 0
L = [0]
R = [0]
cnt = 0
for i in range(N):
if S[i] == "<":
cnt += 1
else:
cnt = 0
L.append(cnt)
ans = 0
S = S[::-1]
cnt = 0
for i in range(N):
if S[i] == ">":
cnt += 1
else:
cnt = 0
R.append(cnt)
R = R[::-1]
for i in range(N+1):
ans += max(L[i], R[i])
print(ans)
|
p02689 | s219069451 | Wrong Answer | N, M = map(int, input().split())
H = list(map(int, input().split()))
R = list(range(1, N+1))
l = []
for i in range(M):
A, B = map(int, input().split())
if H[A-1]< H[B-1]:
l.append(A)
else:
l.append(B)
ans = set(R) - set(l)
print(len(ans))
|
p03438 | s088199422 | Accepted | n = input()
aa = map(int, input().split())
bb = map(int, input().split())
d = 0
for a, b in zip(aa, bb):
if a >= b:
d += a - b
else:
d -= (b - a) // 2
print("Yes" if d <= 0 else "No") |
p02684 | s013808264 | Wrong Answer | n,k = map(int,input().split())
a =[0]+list(map(int,input().split()))
res= [1]
i = 0
while True:
go = a[res[-1]]
if i > n+1 or go in res:break
res.append(go)
i += 1
for i in range(len(res)):
if res[i] == go:
ind = i
v = res[ind:]
m = len(v)
k -= ind
ans = v[k%m]
print(ans)
|
p03760 | s878443142 | Accepted | o = input()
e = input()
ans = []
for i in range(len(e)):
ans.append(o[i])
ans.append(e[i])
if len(o) > len(e):
ans.append(o[-1])
print(''.join(ans)) |
p02771 | s401422814 | Wrong Answer | a, b, c = list(map(int, input().split()))
if a==b or a==c or b==c:
print("Yes")
else:
print("No") |
p02948 | s329289914 | Accepted | N, M = map(int, input().split())
AB = [[] for _ in range(10**5+1)]
for _ in range(N):
a, b = map(int, input().split())
AB[a].append(b)
import heapq
h = []
heapq.heapify(h)
ans = 0
for a in range(1,M+1):
for b in AB[a]:
heapq.heappush(h, -b)
heapq.heappush(h, 0)
ans -= heapq.heappop(h)
print(ans) |
p03162 | s094775657 | Wrong Answer | N = int(input())
Q = []
for _ in range(N):
Q.append(list(map(int, input().split())))
dp = [(None, 0) for _ in range(N)]
for i,v in enumerate(Q[0]):
if v>dp[0][1]:
dp[0] = (i, v)
for i in range(1, N):
for j, v in enumerate(Q[i]):
if j!=dp[i-1][0] and dp[i][1]<v+dp[i-1][1]:
dp[i] = (j, v+dp[i-1][1])
print(dp[-1][1]) |
p03379 | s256668642 | Accepted | N = int(input())
X = list(map(int, input().split()))
sorted_X = sorted(X)
med_options = [sorted_X[N//2-1], sorted_X[N//2]]
for i in range(N):
if X[i] <= med_options[0]:
print(med_options[1])
elif med_options[1] <= X[i]:
print(med_options[0])
|
p03944 | s822379450 | Wrong Answer | w, h, n = map(int,input().split())
left = 0
right = w
up = h
down = 0
for i in range(n):
x, y, a = map(int,input().split())
if a==1:
left = max(left, x)
elif a==2:
right = min(right, x)
elif a==3:
down = max(down, y)
else:
up = min(up, y)
print(max(0,(up-down)*(right-left))) |
p03137 | s410310012 | Accepted | n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
if (n >= m):
print(0)
exit()
L = sorted([x[i+1]-x[i] for i in range(m-1)], reverse=True)
print(sum(L[n-1:]))
|
p02664 | s267257515 | Wrong Answer | t = list(input())
for i in range(len(t)-1):
if t[i] == "?":
if t[i + 1] == "P":
t[i] = "D"
else:
t[i] = "P"
if t[-1] == "?":
t[-1] = "D"
print("".join(t)) |
p04012 | s863748371 | Accepted | from collections import Counter
if sum(map(lambda x: x%2, Counter(input()).values())) == 0:
print('Yes')
else:
print('No') |
p04012 | s965245256 | Wrong Answer | w = list(input())
w.sort()
c = 1
p = w[0]
for i in range(1,len(w)):
if p == w[i]:
c += 1
else:
if c%2 == 1:
print('No')
exit()
c = 1
p = w[i]
print('Yes')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.