problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03427 | s873998312 | Accepted | N = input()
l = len(N)
f9 = True
def digitsum(s):
result = 0
S = str(s)
for d in S:
result += int(d)
return result
for i in range(0,8):
if (str(i) in N[1:l]):
f9 = False
if (f9):
print(digitsum(N))
else:
tmp = str((int(N[0])-1)) + "9"*(l-1)
print(digitsum(tmp)) |
p03994 | s961806538 | Accepted | s = list(input())
K = int(input())
"""
Kを使用する
-> aにすることができる
残りのKはs[-1]に使用
"""
from collections import defaultdict
alpha = defaultdict(int)
for i in range(97, 97 + 26):
alpha[chr(i)] = i - 97
for i in range(len(s)):
if s[i] == "a":
continue
if 26 - alpha[s[i]] <= K:
K -= 26 - alpha[s[i]]
s[i] = "a"
if K > 0:
s[-1] = chr(97 + (alpha[s[-1]] + K) % 26)
print(*s, sep="") |
p02641 | s643719514 | Accepted | X, N = map(int, input().split())
p = list(map(int, input().split()))
i = 0
while True:
if X - i not in p:
print(X - i)
break
elif X + i not in p:
print(X + i)
break
i += 1
|
p03067 | s567204192 | Accepted | a,b,c=map(int,input().split())
if a<=c<=b or b<=c<=a:
print("Yes")
else:
print("No") |
p04033 | s779976971 | Accepted | a, b = map(int, open(0).read().split())
if a > 0:
print('Positive')
elif a == 0 or b == 0:
print('Zero')
elif a < 0 and b > 0:
print('Zero')
elif (b-a)%2 == 1:
print('Positive')
else:
print('Negative') |
p02939 | s476215604 | Accepted | s = input()
cnt = 1
now = s[0]
tmp = ''
for s in s[1:]:
tmp += s
if now == tmp:
continue
else:
cnt+=1
now = tmp
tmp = ''
print(cnt) |
p03962 | s769778886 | Accepted | #ABC046 A
s = set(map(int,input().split()))
print(len(s)) |
p03474 | s238733119 | Wrong Answer | A,B=map(int,input().split())
S=input()
a='Yes'
for i in range(A+B+1):
if i!=A:
if S[i]!='-':
a='No'
else:
if S[i]=='-':
a='No'
print(a) |
p02629 | s872789685 | Wrong Answer | n=int(input())
ans=[]
num2alpha = lambda c: chr(c+64).lower()
while True:
if num2alpha(n%26)=='@':
ans.append('z')
else:
ans.append(num2alpha(n%26))
n=n//26
if n==0:
break
for i in range(len(ans)):
print(ans[-1-i], end='')
print() |
p02911 | s176157461 | Wrong Answer | import numpy as np
N,K,Q = map(int, input().split())
A = [K] * N
A_np = np.array(A)
for i in range(Q):
a = int(input())
A_np -= 1
A_np[a-1] += 1
print(A_np)
for j in range(N):
if A_np[j] > 0:
print("Yes")
else:
print("No") |
p03163 | s965085007 | Accepted | N,W = map(int,input().split())
Value = []
weight = []
inf=float("inf")
dp=[[-inf for i in range(W+1)] for j in range(N+1)]
for i in range(W+1): dp[0][i]=0
for i in range(N):
w,v = map(int,input().split())
Value.append(v)
weight.append(w)
for i in range(N):
for w in range(W+1):
if w>=weight[i]:
dp[i+1][w] = max(dp[i][w-weight[i]]+Value[i],dp[i][w])
else:
dp[i+1][w] = dp[i][w]
print(dp[N][W]) |
p02732 | s235270034 | Accepted |
n = int(input())
a = [int(x) for x in input().split()]
deta = [0] * (n+1)
for i in a:
deta[i] += 1
ans = [0] * (n+1)
for j in range(n+1):
if deta[j] > 1:
ans[j] = deta[j]*(deta[j]-1)/2
else :
ans[j] = 0
add = sum(ans)
for k in a:
print(int(add - deta[k]*(deta[k]-1)/2 + (deta[k]-1)*(deta[k]-2)/2))
|
p02699 | s334655575 | Accepted | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
s, w = map(int, input().split())
if w>=s:
print('unsafe')
else:
print('safe') |
p03285 | s120380674 | Wrong Answer | n = int(input())
for i in range(0, 101, 4):
if (n - i) % 7 == 0:
print('Yes')
exit()
print('No')
|
p03107 | s356585358 | Wrong Answer | S=input()
a=S.count('0')
b=S.count('1')
print(min(a,b)) |
p03639 | s094823856 | Accepted | N = int(input())
A = list(map(int, input().split()))
mod_four = len([i for i in A if i % 4 == 0])
odd_number = len([i for i in A if i % 2 == 1])
if mod_four >= odd_number:
print("Yes")
elif mod_four + 1 == odd_number and N - mod_four - odd_number == 0:
print("Yes")
else:
print("No") |
p02836 | s800587336 | Wrong Answer | s = input()
cnt = 0
for i in range(len(s)):
a0, a1 = s[i], s[-i-1]
if a0 != a1:
cnt += 1
print(cnt)
|
p03673 | s503688530 | Accepted | n=int(input())
a=list(map(str,input().split()))
b,c=[],[]
if n%2==0:
for i in range(n):
if i%2==0:
b.append(a[i])
else:
c.append(a[i])
c.reverse()
else:
for i in range(n):
if i%2==1:
b.append(a[i])
else:
c.append(a[i])
c.reverse()
print(" ".join(c+b)) |
p02813 | s757764447 | Accepted | import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
per=list(itertools.permutations(range(1,n+1)))
a=0
b=0
for num,i in enumerate(per):
if i==p: a=num+1
if i==q: b=num+1
print(abs(a-b)) |
p02689 | s385735500 | Accepted | N, M = map(int, input().split())
H = tuple(map(int, input().split()))
T = [set() for _ in range(N)]
for _ in range(M):
a, b = map(int, input().split())
T[a-1].add(H[b-1])
T[b-1].add(H[a-1])
count = 0
for i, t in enumerate(T):
if not t:
count+=1
continue
else:
h = H[i]
if h > max(t):
count += 1
print(count) |
p02583 | s099491444 | Accepted | n = int(input())
l = [int(entry) for entry in input().split()]
def check(a, b, c):
return (a + b) > c and (b + c) > a and (a + c) > b
count = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
if check(l[i], l[j], l[k]):
count += 1
print(count)
|
p03485 | s486311414 | Accepted | a, b = map(int, input().split())
import math
print(math.ceil((a + b) / 2)) |
p03251 | s542584093 | Wrong Answer | # max min
n, m, x, y = map(int, input().split())
xs = max(list(map(int, input().split())))
ys = min(list(map(int, input().split())))
print("No War" if xs < ys else "War")
|
p02548 | s170987546 | Accepted | import sys
n = int(sys.stdin.readline().strip())
eroot_n = int(pow(n, 0.5))
res = 0
for num_a in range(1, eroot_n + 1):
limit_b = int(n / num_a) + 1
for num_b in range(num_a, limit_b):
"""
print(num_a)
print(num_b)
print('\n')
"""
if num_a * num_b >= n:
continue
if num_a == num_b:
res = res + 1
else:
res = res + 2
print(res) |
p03624 | s790065203 | Accepted | x = list(input())
i=0
while True:
if i==26:
print('None')
break
if not chr(ord('a')+i) in x:
print(chr(ord('a')+i))
break
i+=1 |
p02959 | s242187103 | Wrong Answer | N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
A_list.reverse()
B_list.reverse()
killed_enemies = 0
killed_num = 0
for i in range(N):
if killed_num + B_list[i] >= A_list[i]:
killed_num = (killed_num + B_list[i]) - A_list[i]
killed_enemies += A_list[i]
else:
killed_num = killed_num + B_list[i]
killed_enemies += killed_num
if B_list[N-1] >= A_list[N]:
killed_enemies += A_list[N]
else:
killed_enemies += B_list[N-1]
print(killed_enemies)
|
p03612 | s911605725 | Accepted | #!/usr/bin/env python3
N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
if i+1 == P[i]:
p = P[i]
P[i] = P[i+1]
P[i+1] = p
cnt += 1
if P[N-1] == N:
cnt += 1
print(cnt)
|
p02720 | s965417070 | Wrong Answer | from itertools import product
K = int(input())
ans = []
for l in range(10):
for s in range(1, 10):
for pattern in product([-1, 0, 1], repeat=l):
X = [s]
for p in pattern:
if not (0 <= X[-1] + p <= 9):
break
X.append(X[-1] + p)
else:
ans.append(''.join(map(str, X)))
ans.sort()
print(ans[K - 1])
|
p02796 | s048667557 | Accepted | n=int(input())
points = []
for _ in range(n):
X,L = map(int,input().split())
points.append([X+L, X -L])
points.sort(key = lambda x: x[0])
cur = -10**9
answer = 0
for point in points:
if point[1] >= cur:
answer += 1
cur = point[0]
print(answer) |
p02553 | s306771694 | Accepted | def main():
a, b, c, d = map(int, input().split())
if b * d > 0 or a * c > 0:
x = max(b * d, a * c)
else:
x = max(a * d, b * c)
print(x)
return
if __name__ == '__main__':
main() |
p03693 | s149640439 | Accepted | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
r, g, b = MAP()
if int(str(g)+str(b))%4 == 0:
print("YES")
else:
print("NO")
|
p04030 | s569163623 | Wrong Answer | s=list(str(input()))
ans=[]
for i in s:
if i=='1':
ans.append('1')
elif i=='0':
ans.insert(0,'0')
else:
if ans:
ans.pop(-1)
else:
continue
print(''.join(ans)) |
p02578 | s798902199 | Accepted | try:
k = int(input())
l = list(map(int,input().split(' ')))
c = 0
for i in range(len(l)-1):
x = l[i+1]-l[i]
if x<0:
l[i+1]+=abs(x)
c+=abs(x)
print(c)
except:
pass
|
p03471 | s265662571 | Accepted | import sys
n,y=map(int,input().split())
for i in range(y//10000+1):
for j in range(y//5000+1):
k=n-(i+j)
if k<0:
continue
if 10000*i+5000*j+1000*k==y:
print(' '.join([str(i),str(j),str(k)]))
sys.exit()
print(' '.join(['-1','-1','-1'])) |
p02718 | s188128686 | Wrong Answer | N,M = map(int,input().split())
A = list(map(int,input().split()))
cut = int(sum(A)/(4*int(M)))
count = 0
for i in A:
if i > cut:
count +=1
if count >= M:
print("Yes")
else:
print("No") |
p02682 | s346411992 | Accepted | a,b,c,k=map(int,input().split())
if a >= k:
print(k)
elif a+b>=k:
print(a)
else:
print(2*a+b-k) |
p03962 | s911924585 | Accepted | B=set(map(int,input().split()))
print(len(B)) |
p02797 | s057848643 | Accepted | n, k, s = map(int, input().split())
ans = [s]*k
if s != 1: ans += [s-1]*(n-k)
else: ans += [2]*(n-k)
print(*ans) |
p03126 | s285731880 | Accepted | n,m = map(int, input().split())
#print(n, m)
l = []
for i in range(n):
a = [int(_) for _ in input().split()]
l.append(a[1:a[0]+1])
#print(l)
y = []
for j in range(1,m+1):
x = 0
for k in range(n):
if j in l[k]:
x += 1
if x == n:
y.append(1)
print(len(y))
|
p03481 | s468324035 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
x, y = map(int, readline().split())
cnt = 0
while x <= y:
x *= 2
cnt += 1
print(cnt)
if __name__ == '__main__':
main()
|
p03474 | s623339030 | Accepted | A, B = map(int, input().split())
S = input()
print('Yes' if S.count('-')==1 and S[A] == '-' else 'No') |
p02602 | s088226783 | Wrong Answer | M = 10 ** 9 + 7
N, K = map(int, input().split())
A = list(map(int, input().split()))
prefix = [1] * (N + 1)
for i, a in enumerate(A, 1):
prefix[i] = (prefix[i - 1] * a) % M
prev = prefix[K]
for i in range(K + 1, N + 1):
cur = prefix[i] * pow(prefix[i - K], -1, M)
if cur > prev:
print('Yes')
else:
print('No')
prev = cur |
p03475 | s272834890 | Accepted | import math
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n):
ans=0
for j in range(i,n-1):
c,s,f=map(lambda x:x,csf[j])
if ans<=s: ans=s+c
else: ans=math.ceil(ans/f)*f+c
print(ans) |
p02622 | s768631206 | Accepted | s = input()
t = input()
ans = 0
for i in range(len(s)):
if s[i] != t[i]:
ans += 1
print(ans) |
p03448 | s555749629 | Accepted | A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
tmp = i*500 + j*100 + k*50
if tmp == X:
cnt += 1
print(cnt) |
p03293 | s721569366 | Wrong Answer | S = input()
T = input()
t2 = T + T
if set(S) == set(T):
i = t2.find(S[0])
for j in range(1, len(S)):
if S[j] == t2[i+1]:
i += 1
r = 'Yes'
else:
r = 'No'
break
else:
r = 'No'
print(r) |
p02594 | s620667549 | Wrong Answer | #=input()
x=int(input())
#=map(int,input().split())
#=map(str,input().split())
#=list(map(int,input().split()))
if x >= 30:
print("yes")
else:
print("no") |
p03745 | s177083094 | Wrong Answer | n = int(input())
a = list(map(int,input().split()))
flg = 0
ans = 0
for i in range(1,n):
if a[i] == a[i-1]:
continue
elif a[i] > a[i-1]:
if flg == -1:
ans += 1
flg = 1
elif a[i] < a[i-1]:
if flg == 1:
ans += 1
flg = -1
print(ans+1) |
p02618 | s223382029 | Accepted | import numpy as np
d = int(input())
c = list(map(int, input().split()))
s = np.array([list(map(int, input().split())) for _ in range(d)])
init = s.argmax(axis=1) + 1
for i in range(d):
print(init[i]) |
p02795 | s748724337 | Accepted | hw = max(int(input()),int(input()))
import math
print(math.ceil(int(input())/hw)) |
p03038 | s475574100 | Accepted | N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for m in range(M)]
BC = sorted(BC,key=lambda x:x[1])[::-1]
for b,c in BC:
A.extend(b*[c])
if 2*N<len(A):
break
A = sorted(A)[::-1]
print(sum(A[:N])) |
p02761 | s360875343 | Accepted | n, m = map(int, input().split(' '))
sc = []
for i in range(m):
a, b = map(int, input().split(' '))
sc.append((a, b))
d = '0' * n
for i, j in sc:
if d[i - 1] != '0' and int(d[i - 1]) != j or n > 1 and i == 1 and j == 0:
d = '-1'
break
d = d[:i - 1 if i > 1 else 0] + str(j) + d[i if i < 3 else 3:]
if d[0] == '0' and n > 1:
d = '1' + d[1:]
print(d) |
p03407 | s596959003 | Accepted | A, B, C = map(int, input().split())
print('Yes' if A+B>=C else 'No') |
p02631 | s279517087 | Wrong Answer | N = int(input())
a = list(map(int, input().split()))
ans = []
s = 0
for i in range(N):
s = s ^ a[i]
for i in range(N):
tmp = s ^ a[i]
ans.append(tmp)
print(ans) |
p02612 | s562772174 | Accepted | n,x=int(input()),1000
a=n%x
print(x-a if a else 0) |
p02779 | s685577234 | Accepted | length = int(input())
numList = input().split()
checkSet = set()
for num in numList:
checkSet.add(num)
if(len(checkSet) == len(numList)):
print("YES")
else:
print("NO") |
p03377 | s755313649 | Wrong Answer | a,b,c=map(int,input().split())
if a-c<=b:
print('YES')
else:
print('No') |
p02684 | s692278515 | Accepted | n,k=map(int,input().split())
l=list(map(int,input().split()))
double=[[0]*(n+1) for i in range(61)]
for i in range(1,n+1):
double[0][i]=l[i-1]
for i in range(1,61):
for j in range(n+1):
double[i][j]=double[i-1][double[i-1][j]]
ans=1
for i in range(61):
if k>>i&1:
ans=double[i][ans]
print(ans) |
p02571 | s505651296 | Accepted | S = input()
T = input()
iteration = len(S) - len(T) + 1
if T in S:
ans = 0
else:
minimum = len(T)
for i in range(iteration):
# print('---------------')
s = S[i:len(T)+i]
# print(s)
# print(T)
count = 0
for j in range(len(T)):
if s[j] != T[j]:
count += 1
# print(count)
minimum = min(minimum, count)
ans = minimum
print(ans) |
p02924 | s309773295 | Accepted | N=int(input())
if N==1:print(0)
else:print((1+(N-1))*(N-1)//2) |
p03146 | s886888873 | Accepted | S = int(input())
list = [S]
cnt = 2
def solve(n):
if n % 2 == 0:
return n // 2
else:
return 3 * n + 1
while True:
n = solve(S)
if not (n in list):
list.append(n)
S = n
cnt += 1
else:
print(cnt)
exit() |
p02910 | s279481781 | Wrong Answer | s = input()
for i in range(len(s)):
if i % 2 == 0:
if s[i] != 'R':
print('No')
exit()
else:
if s[i] != 'L':
print('No')
exit()
print('Yes')
|
p03721 | s713730716 | Accepted | N, K = map(int, input().split())
T = sorted((tuple(map(int, input().split())) for _ in range(N)), key=lambda t: t[0])
k = 0
for t in T:
k += t[1]
if k >= K:
print(t[0])
break
|
p02556 | s892122332 | Wrong Answer | N = int(input())
ls = []
for _ in range(N):
x,y = map(int, input().split())
s = x+y
t = x-y
d = max(s,t)
ls.append(d)
print(max(ls) - min(ls)) |
p02996 | s106059772 | Accepted | import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
a = [LI() for _ in range(n)]
a.sort(key = lambda x: x[1])
t = 0
for i in range(n):
t += a[i][0]
if t > a[i][1]:
print('No')
break
else:
print('Yes')
|
p03417 | s611052840 | Accepted | #!/usr/bin/env python
# Initially, all cards face up.
# Given that N,M >= 0.
# Let N <= M.
# Ultimately:
# if N,M==1: singular card will flip.
# elif N==1: interior cards will flip (interior to line).
# else N,M > 1: interior cards will flip (interior to area).
# Fetching input
N,M = map(int,input().split())
# Ensuring N <= M
if N > M:
M,N = N,M
# Requires N <= M:
def numflips(N,M):
if N==0: return 0
if N==1:
if M==1: return 1
return (M-2)
return (N-2)*(M-2)
ans = numflips(N,M)
print(ans) |
p02755 | s157893549 | Accepted | a, b = map(int, input().split())
for i in range(b*10, (b+1)*10):
if int(i * 0.08) == a:
print(i)
break
else:
print(-1) |
p02838 | s569508743 | Accepted | import numpy as np
N = int(input())
A = list(map(int,input().split()))
A = np.array(A,np.int64)##Ai<2^60
ans = 0
mod = int(1e9+7)
for i in range(60+1):
bottom_bit = (A>>i)&1 ##i回シフトしたときの最下位bit
ones = np.sum(bottom_bit[bottom_bit>0])
##ans += (N-ones)*ones*(2**i) ##0の個数*1の個数*2^i個
tmp = ones*(N-ones)
for j in range(i):
tmp = (tmp * 2) % mod
ans += tmp
print(ans%mod) |
p03067 | s961115897 | Wrong Answer | a,b,c = map(int,input().split())
print('Yes' if a<=c<=b else 'No') |
p02823 | s486465279 | Wrong Answer | N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
ret = (B - A) / 2
else:
ret = min(N - A, B - 1)
print(int(ret))
|
p02702 | s798653774 | Accepted | from collections import defaultdict
S = input()
S = S[::-1]
rest = 0
ans = 0
memo = defaultdict(int)
memo[0] = 1
for i in range(len(S)):
rest = (rest + int(S[i])*pow(10,i,2019)) %2019
ans += memo[rest]
memo[rest] += 1
print(ans) |
p02696 | s800469400 | Wrong Answer | def main():
A, B, N = map(int, input().split())
n=0
if N < B:
print(int(A*N/B))
else:
for i in range(B,N+1):
if n < int(A*i/B) - A*int(i/B):
n = int(A*i/B) - A*int(i/B)
print(n)
main() |
p02572 | s152233777 | Wrong Answer | # C - Sum of product of pairs
import numpy as np
N = int(input())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7
A = np.array(A)
csA = np.zeros((N+1), np.object)
for i in range(N):
csA[i+1] = csA[i] + A[i]
ans = 0
for i in range(N-1):
ans += (A[i] * (csA[N] - csA[i+1])) % MOD
print(ans%MOD) |
p02690 | s896594318 | Wrong Answer | hoge = {}
for i in range(100):
hoge[i] = i**5
for i in range(100):
hoge[-i] = -i**5
x = int(input())
for i in hoge.items():
for j in hoge.items():
if i[1] - j[1] == x:
print(i[0], j[0])
break
else:
continue
break |
p03062 | s558468907 | Wrong Answer | def main():
N = int(input())
A = list(map(int, input().split()))
negatives = 0
zeros = 0
for a in A:
if a < 0:
negatives += 1
if a == zeros:
zeros += 1
ans = sum(map(abs, A))
if negatives % 2 == 0 or zeros != 0:
print(ans)
return
a = min(abs(A[0]), abs(A[1]))
b = min(abs(A[-2]), abs(A[-1]))
ans -= 2*min(a, b)
print(ans)
if __name__ == '__main__':
main()
|
p03817 | s883863798 | Accepted | x = int(input())
if x <= 6:
print(1)
import sys
sys.exit()
dice = 6
ans = 0
ans = x // 11 * 2
m = x % 11
if m != 0:
if m <= 6:
ans += 1
else:
ans += 2
print(ans) |
p02582 | s908879847 | Wrong Answer | S = input()
if S == "RRR":
print(3)
elif S == "SSS":
print(0)
elif S == "RSR":
print(1)
else:
print(2) |
p03774 | s040249757 | Accepted | N, M = map(int, input().split())
persons = []
checks = []
for _ in range(N):
persons.append(list(map(int, input().split())))
for _ in range(M):
checks.append(list(map(int, input().split())))
for px, py in persons:
i = 0
min_dist = -1
for k, (cx, cy) in enumerate(checks):
m = abs(px-cx) + abs(py-cy)
if k==0 or (k>0 and m < min_dist):
i = k
min_dist = m
print(i+1)
|
p03659 | s561289151 | Wrong Answer | # ABC067c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n = int(input())
a = list(map(int, input().split()))
def cum(array):
result = [0]
for i in range(len(array)):
result.append(array[i]+result[i])
return result
cumArray = cum(a)
ans = 10**9
for i in range(1, n+1):
ans = min(ans, abs(cumArray[i]-(cumArray[n]-cumArray[i])))
print(ans)
|
p03821 | s621623434 | Accepted | n = int(input())
a, b = [], []
for i in range(n):
a_, b_ = map(int, input().split())
a.append(a_)
b.append(b_)
ans = 0
for i in range(n - 1, -1, -1):
if (a[i] + ans) % b[i] != 0:
ans += b[i] - ((a[i] + ans) % b[i])
print(ans) |
p02623 | s768215267 | Accepted | N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
a.append(a[i] + A[i])
for i in range(M):
b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
if a[i] > K:
break
while b[j] > K - a[i]:
j -= 1
ans = max(ans, i+j)
print(ans) |
p03289 | s622026027 | Wrong Answer | s=input()
if s[0]=='A':
if s[2:-1].count('C')==1:
s=s[2:-1].replace('C','c')
s=s[0].replace('A','a')
if s.islower()==True:
print('AC')
else: print('WA')
else: print('WA')
else: print('WA') |
p03779 | s785730535 | Accepted | x = int(input())
ans = 0
for i in range(10**10):
if i*(i+1)//2 >= x:
ans = i
break
print(ans) |
p02629 | s101407661 | Accepted | n = int(input())
ans = ''
while n != 0:
s = n % 26
if s == 0:
ans += 'z'
n = n //26 - 1
else:
ans += chr(s + 96)
n //= 26
print(ans[::-1])
|
p03639 | s502530872 | Accepted | n=int(input())
l=[0,0,0]
for i in list(map(int,input().split())):
if i%2:l[0]+=1
elif i%4:l[1]+=1
else:l[2]+=1
print("Yes" if l[2]+1>=l[0]+int(1<=l[1]) else "No") |
p03323 | s979080510 | Wrong Answer | def f(a,b): return a <= 8 and b <= 8
a,b = map(int, raw_input().split())
print ':)' if f(a,b) else ':(' |
p03331 | s642236122 | Wrong Answer | N = int(input())
ans = 10**9+7
for i in range(1,N//2):
A = i
B = N-i
ans = min(ans, sum(list(map(int,str(A))))+sum(list(map(int,str(B)))))
print(ans) |
p02771 | s961899176 | Accepted | A,B,C =map(int,input().split())
if A == B and A != C:
print('Yes')
elif B == C and C != A:
print('Yes')
elif C == A and A != B:
print('Yes')
else:
print('No')
|
p02700 | s522242004 | Accepted | import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
a,b,c,d=MAP()
while True:
c-=b
if c<=0:
print("Yes")
exit()
a-=d
if a<=0:
print("No")
exit() |
p02717 | s574419510 | Accepted | a,b,c=map(int,input().split())
temp=a
a=b
b=temp
temp=a
a=c
c=temp
print(a,b,c) |
p02842 | s277497237 | Accepted | import math
import sys
n = int(input())
found = False
if(n <= 12):
print(n)
sys.exit()
for y in range(n):
if n == math.floor(y*1.08):
print(y)
found = True
break
if (found == False):
print(":(")
|
p02836 | s224671298 | Wrong Answer | s=input()
l=len(s)
a=s[:l//2]
b=s[(l+1)//2:]
cnt=0
for i in range(l//2):
if a[i]==b[(l//2)-1-i]:
cnt+=1
print(cnt)
|
p03644 | s427964276 | Accepted | n=int(input())
print(2**(len(bin(n))-3)) |
p02916 | s636107132 | Accepted | n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
if a[i+1]==a[i]+1:
ans+=c[a[i]-1]
print(ans) |
p03077 | s574546325 | Accepted | import math
lst = []
for i in range(6):
lst.append(int(input()))
min_ = min(lst[1:])
print(math.ceil(lst[0] / min_) + 4) |
p02708 | s759313150 | Accepted | n,k = map(int,input().split())
su = 0
mod = 10**9+7
for i in range(k,n+2):
a = i*(i-1)//2
b = i*(2*n+1-i)//2
su += b-a+1
# print(a,b,su)
su %= mod
print(su) |
p03944 | s654359376 | Wrong Answer | wmax,hmax,n=map(int,input().split())
wmin,hmin=0,0
for i in range(n):
x,y,a=map(int,input().split())
if a==1:
wmin=max(wmin,x)
elif a==2:
wmax=min(wmax,x)
elif a==3:
hmin=max(hmin,x)
elif a==4:
hmax=min(hmax,x)
if hmin>=hmax or wmin>=wmax:
print(0)
else:
print((hmax-hmin)*(wmax-wmin))
|
p02719 | s260081236 | Accepted | a,b=[int(s) for s in input().split()]
print(min([a%b,(b-a)%b]))
|
p03286 | s928080830 | Accepted | N = int(input())
s = ""
i = 0
while N != 0:
if N % 2 == 0:
s += "0"
N //= 2
else:
s += "1"
if i % 2 == 0:
N = (N - 1)//2
else:
N = (N + 1)//2
i += 1
if s == "":
print("0")
else:
print(s[::-1]) |
p02753 | s383640282 | Accepted | N = input()
ans = 'Yes'
n0 = N[0]
count = 0
if N[0] == N[1]:
count = count + 1
if N[1] == N[2]:
count = count + 1
if N[0] == N[2]:
count = count + 1
if count == 3:
ans = 'No'
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.