problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03637 | s817230412 | Wrong Answer | N=int(input())
a=list(map(int,input().split()))
if 2 in a:
two_cnt=1
else:
two_cnt=0
other_cnt=len([i for i in a if i % 2 != 0])
four_cnt=len([i for i in a if i % 4 == 0])
if four_cnt+1>=two_cnt+other_cnt:
print('Yes')
else:
print('No') |
p02784 | s871788729 | Accepted | h, n = map(int,input().split())
a = list(map(int, input().split()))
if sum(a) >= h:
print("Yes")
else:
print("No") |
p03359 | s415081352 | Accepted | a,b=map(int, input().split())
if a>b:
print(a-1)
else:
print(a) |
p03803 | s701861711 | Accepted | import sys
input = sys.stdin.readline
A,B = list(map(int,input().split()))
A = (A-2)%13
B = (B-2)%13
print('Alice' if A>B else 'Bob' if B>A else 'Draw')
|
p02792 | s339008055 | Accepted | from collections import Counter
N = int(input())
A = [str(i) for i in range(1, N + 1)]
C = Counter()
for s in A:
C[s[0] + s[-1]] += 1
ans = 0
for s in A:
if s[0] != '0' and s[-1] != '0':
ans += C[s[-1] + s[0]]
print(ans)
|
p02917 | s344893545 | Accepted | N = int(input())
B = list(map(int, input().split()))
ans = 0
A = [0] * N
A[0] = B[0]
A[-1] = B[-1]
for i in range(1, N-1):
min_B = min(B[i-1], B[i])
A[i] = min_B
print(sum(A))
|
p03639 | s532706359 | Accepted | def main():
N = int(input())
A = [int(i) for i in input().split()]
mul4 = len([a for a in A if a % 4 == 0])
mul2 = len([a for a in A if a % 4 != 0 and a % 2 == 0])
less = N - 2*mul4 - 1
if less <= 0:
print("Yes")
elif less + 1 <= mul2:
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
|
p03323 | s877497377 | Wrong Answer | A, B = map(int,input().split())
if A <=8 and B <=8:
print('Yay')
else:
print(':(') |
p03086 | s562728128 | Accepted | s = input()
acgt = ['A','C','G','T']
ans = 0
p = 0
for i in range(len(s)):
if s[i] in acgt:
p += 1
else:
ans = max(ans,p)
p = 0
print(max(ans,p)) |
p02705 | s168155631 | Wrong Answer | R=int(input())
a=float(R*3.141516)
print(a) |
p03107 | s153794072 | Accepted | # import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math
import sys
# import numpy as np
ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
s = input()
zero = s.count("0")
one = s.count("1")
print(2 * min(zero, one))
if __name__ == '__main__':
main() |
p02678 | s238147796 | Accepted | import sys
input = sys.stdin.readline
from collections import deque
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b in ab:
graph[a].append(b)
graph[b].append(a)
q = deque()
q.append(1)
ans = [0 for i in range(n+1)]
ans[1] = -1
while q:
x = q.popleft()
for y in graph[x]:
if ans[y] == 0:
ans[y] = x
q.append(y)
print("Yes")
print(*ans[2:],sep="\n") |
p03695 | s403969256 | Accepted | n = input()
d = [0 for _ in range(9)]
seq = [int(x) for x in input().split()]
for val in seq:
val = min(val, 3300)
d[(val // 400)] += 1
a = sum(1 for val in d[:-1] if val > 0)
print(max(1,a), a + d[-1]) |
p03774 | s463295778 | Accepted | n,m = map(int, input().split())
abl = []
cdl = []
for _ in range(n):
a,b = map(int, input().split())
abl.append((a,b))
for _ in range(m):
c,d = map(int, input().split())
cdl.append((c,d))
for a,b in abl:
cmin = 10**10
mini = -1
for i,(c,d) in enumerate(cdl):
v = abs(a-c)+abs(b-d)
if v < cmin:
cmin = v
minc,mind = c,d
mini = i+1
print(mini) |
p04020 | s612069295 | Accepted | n = int(input())
a_list = [int(input()) for _ in range(n)]
cnt = 0
for i in range(n-1):
cnt += a_list[i] // 2
a_list[i] = a_list[i] % 2
if a_list[i] == 1 and a_list[i+1] >= 1:
cnt += 1
a_list[i] = 0
a_list[i+1] -= 1
# 最後に末尾のやつを処理する
cnt += a_list[n-1] // 2
print(cnt) |
p02720 | s364542412 | Wrong Answer | import queue
k = int(input())
q = queue.Queue()
for i in range(1,10):
q.put(i)
for i in range(k):
x = q.get()
p = 10 * x
m = x % 10
if not p == 0:
q.put(p + m - 1)
q.put(p + m)
if not p == 9:
q.put(p + m + 1)
print(x)
|
p03107 | s465479291 | Accepted | S=list(map(int,list(input())))
print(2*min(sum(S),len(S)-sum(S))) |
p03469 | s771926375 | Accepted | print(input(2018)[4:]) |
p03951 | s442380245 | Accepted | n = int(input())
s = input()
t = input() + 'x'
for i in range(n):
if s[i:]==t[:~i]:
print(n+i)
exit()
print(2*n)
|
p02694 | s523984892 | Accepted | x = int(input())
now = 100
for i in range(1,100000):
now *= 1.01
now //= 1
if now >= x:
print(i)
break |
p03435 | s324549909 | Accepted | a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a=(a[1]-a[0],a[2]-a[0])
b=(b[1]-b[0],b[2]-b[0])
c=(c[1]-c[0],c[2]-c[0])
if a==b and b==c:
print("Yes")
else:
print("No") |
p02578 | s704743706 | Accepted | n = int(input())
a = list(map(int,input().split())) + [0]
ans = 0
maxh = a[0]
for i in range(n):
if maxh > a[i]:
ans += maxh - a[i]
a[i] = maxh
else:
maxh = a[i]
print(ans) |
p03971 | s845848638 | Accepted | n, a, b = list(map(int, input().split()))
s = str(input())
count_a = 0
count_b = 0
for i in s:
j = ""
if count_a+count_b >= (a+b):
j = "No"
elif i == "a":
count_a += 1
j = "Yes"
elif i=="b":
j = "Yes"
if count_b >= b:
j = "No"
else:
count_b += 1
else:
j = "No"
print(j) |
p02814 | s903116645 | Accepted | from functools import reduce
def lcm(a, b):
ab = a * b
while b != 0:
a, b = b, a % b
return ab // a
def solve(string):
n, m, *a = map(int, string.split())
c = 2**len(bin(a[0]).split("1")[-1])
l = reduce(lcm, (2 * m + 2 if _a % c or not _a // c % 2 else _a for _a in a))
return str(max((m - l // 2) // l + 1, 0))
if __name__ == '__main__':
import sys
print(solve(sys.stdin.read().strip()))
|
p02596 | s407964344 | Wrong Answer | k=int(input())
a=0
if k%2==0:
print(-1)
else:
for i in range(k):
a=(a*10+7)%k
if a==0:
print(i+1)
exit() |
p02996 | s107555230 | Accepted | def main():
from itertools import accumulate
n, *ab = map(int, open(0).read().split())
c = list(zip(*[iter(ab)] * 2))
c.sort(key=lambda x: (x[1], x[0]))
d, f = zip(*c)
for i, j in zip(accumulate(d), f):
if i > j:
print('No')
break
else:
print('Yes')
if __name__ == '__main__':
main()
|
p03371 | s438221008 | Accepted | a, b, c, x, y = map(int, input().split())
ans = a*x + b*y
ans = min(ans, 2*c*max(x, y))
if x < y:
ans = min(ans, c*2*x + b*(y-x))
else:
ans = min(ans, c*2*y + a*(x-y))
print(ans) |
p02639 | s180884922 | Accepted | nums = list(map(int, input().split()))
for i in range(len(nums)):
if nums[i] == 0:
print(i+1) |
p02760 | s731083881 | Accepted | A = []
for _ in range(3):
for e in list(map(int, input().split())):
A.append(e)
N = int(input())
for _ in range(N):
n = int(input())
if n in A:
A[A.index(n)] = 0
patterns = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6]
]
for pattern in patterns:
if not any([A[e] for e in pattern]):
print('Yes')
exit()
print('No') |
p02747 | s741512258 | Wrong Answer | s = input()
n = list(set((s)))
print(n)
if n == ["h", "i"] or ["i", "h"]:
print("Yes")
else:
print("No") |
p02787 | s912825868 | Accepted | h, n = map(int, input().split())
a, b = [0] * n, [0] * n
for i in range(n):
a[i], b[i] = map(int, input().split())
dp = [(-(-i // a[0]) * b[0]) for i in range(h + 1)]
for i in range(1, n):
for j in range(1, h + 1):
dp[j] = min(dp[j], dp[max(j-a[i],0)] + b[i])
print(dp[-1]) |
p02775 | s596637826 | Accepted | s = input(); n = len(s)
dp = [ [0,1<<32] for i in range(n+1) ]
for i in range(n):
d = ord(s[i])-ord('0')
dp[i+1][0] = min(dp[i][0], dp[i][1])+d
dp[i+1][1] = min(dp[i][0], dp[i][1]-2)+11-d
print(min(dp[n][0],dp[n][1])) |
p03284 | s451558634 | Accepted | N,K=map(int,input().split())
if N%K==0:
print("0")
else:
print("1") |
p03387 | s976095104 | Accepted | X = list(map(int, input().split()))
X.sort()
ba = X[1] - X[0]
ca = X[2] - X[0]
cb = X[2] - X[1]
if ba % 2 == 0 and ca % 2 == 0:
print((ca + cb) // 2)
elif ba % 2 == 0:
print(1 + (ca - 1 + cb - 1) // 2)
else:
print((cb + ca + 1) // 2 + 1)
|
p03417 | s709667336 | Accepted | N, M = map(int, input().split())
if N == 1 and M == 1:
print(1)
elif (N == 1 and M >= 2) or (M == 1 and N > -2):
print(max(N, M) - 2)
else:
print((N - 2) * (M - 2)) |
p02760 | s660747857 | Accepted | A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
ans = False
for a in A:
ans |= set(a) <= set(B)
for i in range(3):
ans |= set([A[0][i], A[1][i], A[2][i]]) <= set(B)
ans |= set([A[0][0], A[1][1], A[2][2]]) <= set(B)
ans |= set([A[0][2], A[1][1], A[2][0]]) <= set(B)
print("Yes" if ans else "No")
|
p02910 | s117648083 | Accepted | S = input()
A = 'Yes'
for i in range(len(S)):
if i%2==0 and S[i] == 'L':
A = 'No'
elif i%2 == 1 and S[i] == 'R':
A = 'No'
print(A) |
p02726 | s500097942 | Wrong Answer | n ,x, y = map(int, input().split())
ans=[0 for i in range(n-1)]
def check(i, j):
a = j-i
short = abs(x-i) + 1 + abs(j-y)
if a==short:
ans[a-1] += 2
else:
mini = min(a, short)
ans[mini-1] += 1
for i in range(1, n):
for j in range(i+1, n+1):
check(i,j)
print(*ans, sep='\n') |
p03206 | s400713754 | 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") |
p03286 | s407133196 | Wrong Answer | from math import log2
def main():
N = int(input())
if N == 0:
print(0)
return
Ans = []
while N != 1:
r = N%2
Ans.append(r)
N = -1*( N // 2)
print(*Ans[::-1],sep="")
return
if __name__ == "__main__":
main() |
p03221 | s934972998 | Wrong Answer | import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
# 座標圧縮
# 座圧
N, M = map(int, input().split())
PY = [[int(x) for x in input().split()] for _ in range(M)]
PREFECTURE = defaultdict(list)
for p, y in PY:
PREFECTURE[p].append(y)
print(PREFECTURE)
for i in PREFECTURE.keys():
ys = sorted(PREFECTURE[i])
y_to_i = {y: i+1 for i, y in enumerate(ys)}
PREFECTURE[i] = y_to_i
for p, y in PY:
print('{:06}{:06}'.format(p, PREFECTURE[p][y]))
|
p02712 | s461518951 | Accepted | n=int(input())
ans=0
for i in range(n):
if (i+1)%3==0 and (i+1)%5==0:
continue
elif (i+1)%3==0:
continue
elif (i+1)%5==0:
continue
else:
ans+=i+1
print(ans) |
p02556 | s487487473 | Accepted | N=int(input())
A,B=[],[]
for i in range(N):
x,y=map(int, input().split())
A.append(x+y)
B.append(x-y)
A=sorted(A)
B=sorted(B)
print(max(abs(A[0]-A[-1]),abs(B[0]-B[-1]))) |
p03548 | s840813327 | Wrong Answer | x,y,z = map(int,input().split())
s = 0
count = 0
for i in range(10**99):
s += y+z
count += 1
if s > x:
break
if s - z <= x:
print(count)
else:
print(count-1) |
p03387 | s087239549 | Accepted | def main():
A = [int(i) for i in input().split()]
A.sort()
B = [A[2] - A[0], A[2] - A[1]]
ans = 0
if B[0] % 2 == B[1] % 2:
ans = (B[0]+B[1])//2
else:
ans = 0--(B[0]+B[1])//2 + 1
print(ans)
if __name__ == '__main__':
main()
|
p03282 | s227514038 | Wrong Answer | S=list(input())
k=int(input())
if S[0]=='1':
if k==1:
print(S[0])
elif k<(10**14+1):
print(S[2])
else:
print(S[1])
elif S[0]=='2':
if k<(10**14+1):
print(S[0])
else:
if S[1]!=1:
print(S[1])
else:
print(S[2])#1が続く場合は次の1以外の数字
else:
print(S[0]) |
p03126 | s017358489 | Accepted | import sys
input = sys.stdin.readline
def main():
N, M = map(int, input().split())
ans = [0]*(M+1)
for _ in range(N):
food = list(map(int, input().split()))
K = food[0]
for i in range(1, K + 1):
ans[food[i]] += 1
print(ans.count(N))
if __name__ == '__main__':
main()
|
p03127 | s745339175 | Wrong Answer | import sys
f = sys.stdin
n = int(f.readline())
a = list(map(int, f.readline().split()))
a.sort()
ans = a[0]
for i in range(n-1):
if a[i] == a[i+1]:
continue
if a[i]%2 == 0:
ans = 2
continue
if a[i]%2 == 1:
ans = 1
break
print(ans) |
p02768 | s987205982 | Accepted | mod = 10 ** 9 + 7
def fact(n,k,mod):
res = 1
for i in range(k):
res = res * (n-i) % mod
return res % mod
n, a, b = map(int, input().split())
ans = pow(2,n,mod) - 1
ans = (ans - fact(n,a,mod)*pow(fact(a,a,mod),mod-2,mod)) % mod
ans = (ans - fact(n,b,mod)*pow(fact(b,b,mod),mod-2,mod)) % mod
print(ans) |
p02744 | s779544708 | Accepted | n = int(input())
s = ['' for i in range(n)]
def dfs(k, c):
if k == n:
print("".join(s))
return
for i in range(c):
s[k] = chr(i+ord('a'))
dfs(k+1, c)
s[k] = chr(c+ord('a'))
dfs(k+1, c+1)
dfs(0, 0)
|
p03565 | s923605626 | Wrong Answer | S = input()
T = input()
def match(s,t):
for c,d in zip(s,t):
if c == "?":
continue
elif c == d:
continue
else:
return False
return True
for i in range(len(S)):
s = S[i:i+len(T)]
if match(s, T):
print((S[:i]+T+S[i+len(T):]).replace("?","a"))
exit(0)
print("UNRESTORABLE") |
p02699 | s293458191 | Accepted | s, w = map(int, input().split())
print("unsafe" if s <= w else "safe") |
p02689 | s602253475 | Accepted | n, m = map(int, input().split())
hs = list(map(int, input().split()))
peaks = [True] * n
for i in range(m):
a, b = map(int, input().split())
if hs[a - 1] > hs[b - 1]:
peaks[b - 1] = False
elif hs[a - 1] < hs[b - 1]:
peaks[a - 1] = False
else:
peaks[a - 1] = False
peaks[b - 1] = False
print(peaks.count(True)) |
p04033 | s358165198 | Accepted | def main():
a, b = map(int, input().split())
if a == 0 or b == 0:
print("Zero")
elif a < 0 and b > 0:
print("Zero")
elif a < 0 and b < 0:
if abs(b - a + 1) % 2 == 1:
print("Negative")
else:
print("Positive")
elif a > 0 and b > 0:
print("Positive")
if __name__ == "__main__":
main() |
p02766 | s381191424 | Wrong Answer | #!/usr/bin/env python3
import math
n, k = map(int, input().split())
print(math.ceil(math.log2(n)/math.log2(k)))
|
p02744 | s405449953 | Accepted | n=int(input())
def d(s):
if len(s)==n:print(s)
else:
for i in range(97,ord(max(s))+2):d(s+chr(i))
d("a") |
p02582 | s263717800 | Wrong Answer | ##175
##A - Rainy Season
S = str(input())
if "R" in S:
if S[1] == "S":
print(1)
else:
if S[0] == "R" and S[2] == "R":
print(3)
else:
print(2)
else:
print(0) |
p03696 | s729340965 | Accepted | N = int(input())
S = list(input())
f = 0
b = 0
count = 0
for i in range(N - 1, -1, -1):
if S[i] == '(':
if count > 0:
count -= 1
else:
b += 1
else:
count += 1
print('(' * count, end='')
print(*S, sep='', end='')
print(')' * b) |
p03000 | s058441767 | Accepted | import numpy as np
n, x = [int(_) for _ in input().split()]
l = np.cumsum(np.array([int(_) for _ in input().split()]))
print(sum([i <= x for i in l])+1)
|
p02756 | s366082557 | Wrong Answer | S = input()
Q = [input().strip() for i in range(int(input()))]
r_flg = False
for query in Q:
if query == "1":
r_flg = not r_flg
else:
_, f, c = query.split()
f_flg = (f == "1")
end = (r_flg ^ f_flg)
if end:
S = S + c
else:
S = c + S
if not r_flg:
S = S[::-1]
print(S) |
p03495 | s893302779 | Wrong Answer | from collections import Counter
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if n<=k:
print(0)
else:
c = Counter(a)
l = sorted(list(c.values()))
print(sum(l[:k-1])) |
p02665 | s843825444 | Accepted | n,*l=map(int,open(0).read().split())
e=[1]
for i in range(n):
e+=[(e[-1]-l[i])*2]
a=t=0
for i in range(n,-1,-1):
if l[i]>e[i]:
print(-1)
break
t=min(l[i]+t,e[i])
a+=t
else:
print(a) |
p02916 | s058713326 | Accepted | N = int(input())
A = [int(i) - 1 for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = 0
prev = -10
for a in A:
if a == prev + 1:
ans += C[prev]
ans += B[a]
prev = a
print(ans) |
p04020 | s509337204 | Wrong Answer | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
n = int(input())
a = list(int(input()) for i in range(n))
ans = 0
for i in range(n):
ans += a[i]//2
i=0
while i < n-2:
if a[i] %2==1 and a[i+1]%2==0 and a[i+2]%2==1:
ans+=1
i+=2
i+=1
print(ans) |
p03285 | s116697915 | Accepted | from sys import exit
n=int(input())
while n>0:
if n%7==0:
print("Yes")
exit()
n-=4
if n==0:
print("Yes")
exit()
print("No") |
p02718 | s171777558 | Wrong Answer | N, M = map(int, input().split())
A = list(map(int, input().split()))
line = sum(A) // (4 * M)
ans = [i for i in A if i > line]
print("Yes") if len(ans) >= M else print("No")
|
p03338 | s669128775 | Accepted | if __name__ == "__main__":
n = int(input())
s = input()
if n == 2:
if s[0] == s[1]:
print(1)
exit()
else:
print(0)
exit()
ans = 0
for i in range(1, n):
front = set(s[0:i])
back = set(s[i:n])
tmp = len(front.intersection(back))
if ans < tmp:
ans = tmp
print(ans)
|
p03407 | s115697906 | Wrong Answer | a, b, c = map(int, input().split())
if a + b * 2 >= c:
print("Yes")
else:
print("No")
|
p03799 | s238993317 | Accepted | import sys
input = sys.stdin.readline
def read():
N, M = map(int, input().strip().split())
return N, M
def solve(N, M):
nScc = min(N, M//2)
N -= nScc
M -= nScc * 2
if M >= 4:
nScc += M // 4
return nScc
if __name__ == '__main__':
inputs = read()
outputs = solve(*inputs)
if outputs is not None:
print("%s" % str(outputs))
|
p03274 | s901964478 | Accepted | N, K = map(int,input().split())
C = list(map(int,input().split()))
K -= 1
D = 10**9
for i in range(N-K):
d = C[i+K] - C[i]
L = d + abs(0 - C[i])
R = d + abs(0 - C[i+K])
D = min(D,min(L,R))
print(D)
|
p03407 | s572346041 | Accepted | a,b,c = map(int, input().split())
print("Yes" if a+b >= c else "No") |
p03827 | s404224557 | Wrong Answer | N = int(input())
S = input()
ans = 0
for i in range(N):
if S[i] == "I":
ans += 1
else:
ans -= 1
print(ans) |
p02952 | s669077911 | Wrong Answer |
n=input()
k=len(n)
if k>=5:
print(9+900+int(n)-10000)
elif k==4:
print(9+900)
elif k==3:
print(9+int(n)-100+1)
elif k==2:
print(9)
else:
print(int(n)+1)
|
p03612 | s080039152 | Wrong Answer | N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
if plist[i] == i + 1 or plist[i + 1] == i + 2:
plist[i], plist[i + 1] = plist[i + 1], plist[i]
ans += 1
if plist[-1] == N:
ans += 1
print(ans)
|
p02796 | s168265758 | Wrong Answer | N = int(input())
x_l = []
for i in range(N):
array = list(map(int, input().strip().split()))
x_l.append(array)
x_l.sort()
if N<3:
for i in range(1,N):
if (x_l[i-1][0] + x_l[i-1][1]) > (x_l[i][0] - x_l[i][1]):
del x_l[i]
print(len(x_l))
#else:
# for i in range(1,N-1):
# if (x_l[i-1][0] + x_l[i-1][1]) > (x_l[i][0] - x_l[i][1]):
# del x_l[i]
# print(len(x_l)) |
p03042 | s611873170 | Wrong Answer | s = input()
if s[:2] == "00" or s[2:] == "00":
print("NA")
exit()
if 1 <= int(s[:2]) <= 12 and 1 <= int(s[2:]) <= 12:
print("AMBIGUOUS")
exit()
if int(s[2:]) > 13:
print("MMYY")
else:
print("YYMM") |
p03637 | s840698760 | Wrong Answer | n=int(input())
l=list(map(int,input().split()))
x=0
for i in range(n):
if(l[i]%4==0):
x+=1
if(n%2==0):
if(x==n//2):
print("Yes")
else:
print('No')
else:
if(x==n//2 or x==(n-n//2)):
print("Yes")
else:
print("No")
|
p04020 | s868406735 | Accepted | n = int(input())
ans = 0
x = 0
for i in range(n):
a = int(input())
ans += (a + x) // 2
x = (a + x) % 2 if a != 0 else 0
#print(a, x, ans)
print(ans) |
p03408 | s727257983 | Accepted | n = int(input())
blue_cards = {}
for i in range(n):
s = input()
if s in blue_cards:
blue_cards[s] += 1
else:
blue_cards[s] = 1
m = int(input())
red_cards = {}
for i in range(m):
s = input()
if s in red_cards:
red_cards[s] += 1
else:
red_cards[s] = 1
ans = 0
for k in blue_cards:
if k in red_cards:
score = blue_cards[k] - red_cards[k]
else:
score = blue_cards[k]
ans = max(ans, score)
print(ans) |
p02777 | s805130025 | Accepted | s, t = input().split()
a, b = map(int, input().split())
u = input()
if s == u:
print(a-1, b)
else:
print(a, b-1) |
p02760 | s394814469 | Accepted | import numpy as np
A=[]
A.extend(list(map(int,input().split())))
A.extend(list(map(int,input().split())))
A.extend(list(map(int,input().split())))
N = int(input())
check = [False]*9
for i in range(N):
b=int(input())
if(b in A):
check[A.index(b)]=True
posi_list=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
np_check=np.array(check)
for i in range(len(posi_list)):
if (False not in np_check[posi_list[i]]):
print('Yes')
exit()
print('No')
|
p03672 | s268865745 | Wrong Answer | from collections import Counter
s=input()[::-1]
for i in range(1,len(s)):
if all([True if i%2==0 else False for i in Counter(s[i:]).values()]):
print(len(s[i:]))
break
else:
print(2) |
p03910 | s352174407 | Accepted | n = int(input())
total = 0
ans = []
for i in range(1, n+1):
ans.append(i)
total += i
if total > n:
break
ng = total - n
print(*[i for i in ans if i != ng], sep='\n') |
p03210 | s565862911 | Accepted | import sys
ri = lambda: int(sys.stdin.readline())
n = ri()
print('YES' if n == 3 or n == 5 or n == 7 else 'NO') |
p02988 | s697339700 | Wrong Answer | n = int(input())
number = input().split(" ")
ans = 0
for i in range(n-2):
if number[i] > number[i+1] and number[i+1] > number[i+2]:
ans += 1
elif number[i] < number[i+1] and number[i+1] < number[i+2]:
ans += 1
else:
pass
print(ans) |
p03796 | s582141658 | Wrong Answer | n=int(input())
p=1
for i in range(1,n+1):
p=p*i
p=p%(10**9+7) |
p02989 | s020921451 | Wrong Answer | D=list(map(int, input().split()))
D=sorted(D)
print(D[len(D)//2]-D[len(D)//2-1])
|
p02756 | s624508919 | Wrong Answer | s=input()
q=int(input())
count=0
while(q):
q-=1
t=list(input().split())
if t[0]=='2':
f=t[1]
c=t[2]
if f=='1':
s=c+s
else:
s=s+c
else:
count+=1
if count%2==1:
s=s[::-1]
print(s) |
p03379 | s694083091 | Accepted | # ABC094c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n = int(input())
x = list(map(int, input().split()))
for i in range(n):
x[i] = (x[i], i)
x.sort()
ans = [-1]*n
ind = n//2
for i in range(n):
if i <= n//2-1:
ans[x[i][1]] = x[n//2][0]
else:
ans[x[i][1]] = x[n//2-1][0]
print(*ans, sep='\n')
|
p02873 | s053738707 | Accepted | S = input()
N = len(S)
ans = [0] * (N + 1)
for i in range(N):
if S[i] == "<":
ans[i + 1] = ans[i] + 1
for i in range(N - 1, -1, -1):
if S[i] == ">":
if ans[i] <= ans[i + 1]:
ans[i] = ans[i + 1] + 1
print(sum(ans)) |
p03126 | s042654090 | Accepted | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter
def main():
N, M = map(int, input().split())
A, K = [], []
lst = [list(map(int, input().split())) for _ in range(N)]
for l in lst:
A.append(l[0])
if type(l[1:]) is list:
K.extend(l[1:])
else:
K.append(l[1:])
print(sum([1 for c in Counter(K).values() if c == len(A)]))
if __name__ == "__main__":
main()
|
p03803 | s123308119 | Wrong Answer | A,B=map(int,input().split())
if A==B:
print('Draw')
elif A < B or B==1:
print('Bob')
else:
print('Alice') |
p03478 | s577492890 | Accepted | N, A, B = map(int, input().split())
ans = 0
for i in range(1,N+1):
i_str = str(i)
i_len = len(i_str)
sum = 0
for j in range(i_len):
sum += int(i_str[j])
if sum >= A and sum <= B:
ans += i
print(ans) |
p02691 | s399477570 | Accepted | from collections import defaultdict
N = int(input())
A = map(int, input().split())
d = defaultdict(int)
ans = 0
for i, a in enumerate(A):
ans += d[-i+a]
d[-i-a] += 1
print(ans)
|
p03095 | s500515707 | Accepted | from collections import Counter
input()
cnt=Counter(input())
ans=1
mod=10**9+7
for v in cnt.values():
ans*=v+1
ans%=mod
print((ans-1)%mod) |
p03161 | s635176609 | Accepted | N,K=map(int,input().split())
H=[int(i) for i in input().split()]
f_inf=float('inf')
dp=[f_inf]*(N+5)
dp[0]=0
for i in range(1,N):
for j in range(1,K+1):
if (i-j)<0:
continue
dp[i]=min(dp[i-j]+abs(H[i-j]-H[i]),dp[i])
print(dp[N-1])
|
p02861 | s215762215 | Accepted | import math
N = int(input())
xi = []
yi = []
for i in range(N):
x, y = map(int, input(). split())
xi.append(x)
yi.append(y)
L=0
for j in range(N):
for k in range(N):
if j >= k:
continue
L += math.sqrt((xi[j]-xi[k])**2 + (yi[j]-yi[k])**2)
print(2*L/N) |
p03910 | s042161968 | Accepted | n = int(input())
ans = []
Sum = 0
for i in range(1, 10**4):
Sum += i
ans.append(i)
if Sum >= n:
break
if Sum == n:
print(*ans)
else:
ans.remove(Sum - n)
print(*ans) |
p02862 | s453934239 | Wrong Answer | x, y = map(int, input().split())
a = (2 * x - y) // 3
b = (2 * y - x) // 3
rent_a = (2 * x - y) % 3
rent_b = (2 * y - x) % 3
def modinv(a, mod=10**9+7):
return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
r = min(r, n-r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i+1, mod) % mod
return res
if rent_a != 0 or rent_b != 0:
ans = 0
else:
n = a + b
ans = combination(n, a)
print(ans) |
p03637 | s778715199 | Accepted | N = int(input())
a = list(map(int,input().split()))
c2 = 0
c4 = 0
for i in range(N):
if a[i]%4 == 0:
c4 += 1
elif a[i]%2 == 0:
c2 += 1
f = c4 * 2 + 1
if f >= N or f + c2 - 1 >= N:
print("Yes")
else:
print("No") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.