problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p03720 | s923594012 | Wrong Answer | from collections import Counter
N, M = map(int, input().split())
R = []
for i in range(M):
R += list(map(int, input().split()))
R = Counter(R)
K = sorted(R)
for k in K:
print(R[k]) |
p02939 | s309754642 | Accepted | S=input()
cnt=0
i=1
while i<len(S):
if S[i]==S[i-1]:
cnt+=1
i+=2
i+=1
print(len(S)-cnt)
|
p02972 | s644344268 | Accepted | import sys
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = [-1 for _ in range(N)]
ans = []
for i in range(N, 0, -1):
tmp_sum = 0
tmp_i = 2 * i
while N >= tmp_i :
tmp_sum += B[tmp_i - 1]
tmp_i += i
# print(i, tmp_sum)
if A[i-1] == tmp_sum % 2:
... |
p02684 | s670519679 | Accepted | n,k=map(int, input().split())
a=list(map(int, input().split()))
b=[False]*n
pos=0
for i in range(min(n,k)):
if b[pos]!=False:
loop=i-b[pos]+1
break
b[pos]=i+1
pos=a[pos]-1
k-=1
if k>0:
for i in range(k%loop):
pos=a[pos]-1
print(pos+1) |
p02684 | s917878873 | Wrong Answer | N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [1]
C = [1] + [0] * (N - 1)
i = 0
while C[A[i] - 1] == 0:
B.append(A[i])
C[A[i] - 1] = 1
i = A[i] - 1
ans = 0
for j in range(len(B)):
if B[j] == A[i]:
ans += j
if (len(B) - ans != 0) and (K - ans > 0):
ans += (K - an... |
p03479 | s183185520 | Accepted | from math import floor
from decimal import Decimal
A, B = list(map(int, input().split()))
num = A
c = 0
while num <= B:
num *= 2
c+=1
print(c)
|
p02699 | s975795241 | Wrong Answer | S, W = map(int, input().split())
if S/2 < W:
print('unsafe')
else:
print('safe')
|
p02701 | s788396426 | Accepted | N = int(input())
S = [input() for _ in range(N)]
print(len(set(S)))
|
p02658 | s560963954 | Accepted | n = int(input())
num = list(map(int, input().split()))
ans = 1
if 0 in num:
print(0)
exit()
else:
for i in num:
ans *= i
if ans > 10**18:
print(-1)
exit()
print(ans)
|
p02854 | s658467655 | Accepted | def main():
import sys
import bisect
from itertools import accumulate
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
b = list(accumulate(a))
l = b[-1]
i = bisect.bisect(b, l // 2)
ans = min(abs(l - 2 * b[i - 1]), abs(l - 2 * b[i]))
print(ans)
if __name__ ==... |
p03971 | s122151358 | Accepted | n, a, b = map(int, input().split())
t, o = 0, 0
s = input()
for i in range(n):
if s[i]=="a":
t += 1
if t <= a+b:
print("Yes")
else:
print("No")
elif s[i]=="b":
o += 1
if o <= b and t < a+b:
t += 1
print("Yes")
else:
... |
p03206 | s142278851 | Wrong Answer | # -*- coding: <encoding name> -*-
d = int(input())
# print('Chrestmas' if d == 25 else 'Chrestmas Eve' if d == 24)
print('Chrestmas' + ' Eve' * (25 -d)) |
p02645 | s862386511 | Accepted | S = str(input())
print(S[:3]) |
p02939 | s871284476 | Wrong Answer | S = str(input())
ans = ''
ans2 = ''
con = 0
for s in S:
ans += s
if s != ans2:
if ans != ans2:
con += 1
ans2 = ans
ans = ''
print(con)
|
p02594 | s297669016 | Accepted | x=int(input())
if x>=30:
print("Yes")
else:
print("No") |
p02689 | s368547925 | Accepted | from collections import Counter
N,M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for i in range(M):
AB.append(list(map(int, input().split())))
l = [True]*N
for m in AB:
if H[m[0]-1] == H[m[1]-1]:
l[m[0]-1] = False
l[m[1]-1] = False
elif H[m[0]-1] > H[m[1]-1]:
... |
p03617 | s043524178 | Wrong Answer | q,h,s,d=map(int,input().split())
n=int(input())
l=min(q*n*4,h*n*2,s*n,d*n/2)
if l != d*n/2:
print(l)
else:
m=min(q*4,h*2,s)
print((d*(n-1)/2)+m if n%2==1 else l) |
p03126 | s796682011 | Accepted | n, m=map(int, input().split())
results=[0]*m
for i in range(n):
check=list(map(int, input().split()))
num=check[0]
for j in range(1, num+1):
results[check[j]-1]+=1
ans=0
for result in results:
if result==n:
ans+=1
print(ans) |
p02683 | s780285802 | Accepted | N,M,X = map(int,input().split())
array = [ list(map(int,input().split())) for _ in range(N) ]
ans = 10**18
for i in range ( 2**N ):
price = 0
skill = [0]*M
count = 0
for k in range(N):
if ( i >> k ) & 1:
price += array[k][0]
for j in range (M):
skill[j] += array[k][j+1]
for t in range(... |
p03612 | s893815422 | Accepted | n = int(input())
pp = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
if pp[i] == i + 1:
pp[i], pp[i+1] = pp[i+1], pp[i]
cnt += 1
if pp[n-1] == n:
cnt += 1
print(cnt) |
p02910 | s772416816 | Accepted | s = input()
x = len(s)
cnt = 1
ans = 0
for i in s:
if cnt == 1:
cnt = 0
if i != "L":
ans += 1
else:
cnt = 1
if i != "R":
ans += 1
if ans == x:
print("Yes")
else:
print("No") |
p03077 | s503009578 | Wrong Answer | n = int(input())
trans = sorted(list(int(input()) for _ in range(5)))
if n > trans[0]:
ans = n // trans[0] + 5
print(ans)
else:
print(5)
|
p02953 | s794062490 | Accepted | n = int(input())
h = [int(x) for x in input().split()]
for i in reversed(range(1, n)):
if h[i - 1] > h[i]:
h[i - 1] -= 1
flg = True
for i in range(n - 1):
if h[i] > h[i + 1]:
flg = False
break
if flg:
print('Yes')
else:
print('No') |
p02753 | s864153100 | Accepted | s = input()
g = set(s)
if('A' in g and 'B' in g):
print('Yes')
else: print('No') |
p03730 | s336932511 | Wrong Answer | a, b, c = map(int, input().split())
ans = 'NO'
total = 0
if a < b and c%a == 0:
ans = 'YES'
else:
for i in range(1, 100000):
total += a*i
if total%b == c:
ans = 'YES'
break
print(ans)
|
p03219 | s987510905 | Wrong Answer | def DiscountFare(x , y):
return x + (y / 2)
def main():
x , y = map(int , input().split())
print(DiscountFare(x , y))
if __name__ == '__main__':
main() |
p03456 | s103034448 | Wrong Answer | input_ = list(map(str, input().split()))
number = int(input_[0] + input_[1])
for i in range(400):
if i**2 is number:
print('Yes')
break
elif i**2 > number:
print('No')
break |
p02838 | s962152991 | Accepted | n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
one = 0
for j in range(n):
if (a[j] >> i) & 1:
one += 1
ans = (ans + (one*(n-one))*two) % mod
two = (two * 2) % mod
print(ans) |
p03069 | s490467951 | Accepted | N = int(input())
S = input()
a = 0
b = S.count('.')
num = min(N - b, b)
for i in range(N):
x = S[i] =='#'
a += x
b -= 1-x
num = min(num, a+b)
print(num) |
p03759 | s285926250 | Accepted | a, b, c = [int(_) for _ in input().split()]
if a + c == 2 * b:
print('YES')
else:
print('NO')
|
p03524 | s696099178 | Accepted | s = str(input())
A = [0,0,0]
for a in s:
if a=='a':A[0]+=1
if a=='b':A[1]+=1
if a=='c':A[2]+=1
if max(A)-min(A)>=2:
print("NO")
else:
print("YES")
|
p02759 | s461324751 | Accepted | x = int(input())
if x%2 != 1:
print(x//2)
else:
print(x//2+1) |
p03281 | s003124112 | Accepted | N = int(input())
odd = list()
count_list = list()
count = 0
for a in range(1, N+1):
if a % 2 != 0:
odd.append(a)
l = len(odd)
for a in range(0, l):
for b in range(1, odd[a]+1):
if odd[a] % b == 0:
count += 1
count_list.append(count)
count = 0
print(len(list(filter(lambd... |
p03106 | s265717209 | Wrong Answer | from math import gcd
a, b, k = map(int, input().split())
x = gcd(a, b)
for i in range(1, x+1):
cnt = 0
if x % i == 0:
if cnt == k-1:
print(i)
break
else:
cnt += 1
|
p03994 | s955223272 | Wrong Answer | S = input()
K = int(input())
oz = ord("z")
ans = ""
for s in S[:-1]:
if K==0:
break
if oz+1-ord(s) <= K:
K -= oz+1-ord(s)
ans += "a"
else:
ans += s
ans += chr(((ord(S[-1])-ord("a")+K)%26)+ord("a"))
print(ans) |
p04011 | s143044608 | Accepted | N=int(input())
K=int(input())
X=int(input())
Y=int(input())
ans=0
if N<=K:
ans=N*X
else:
ans=K*X+(N-K)*Y
print(ans) |
p02951 | s148945809 | Accepted | a, b, c=map(int, input().split())
print(max(c-(a-b), 0)) |
p03862 | s484498281 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
A.insert(0,0)
for i in range(len(A)-1):
s = A[i] + A[i+1]
if s > x:
diff = min(s - x, A[i+1])
A[i+1] -= diff
ans += diff
print(ans)
|
p02576 | s996739156 | Wrong Answer | N, X,T= map(int, input().split())
while(X<N):
X=X*2
T=T*2
print(T) |
p02792 | s114145022 | Accepted | from collections import Counter
n = int(input().strip())
cnt = Counter()
result = 0
for i in range(1, n + 1):
s = str(i)
result += cnt[s[-1], s[0]] * 2
if s[0] == s[-1]:
result += 1
cnt[s[0], s[-1]] += 1
print(result) |
p03351 | s777647086 | Accepted | from sys import stdin
A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()] # 空白区切り
if abs(A - C) <= D or (abs(A - B) <= D and abs(B - C) <= D):
print("Yes")
else:
print("No")
|
p03785 | s812309106 | Accepted | N,C,K = map(int,input().split())
T = sorted(int(input()) for _ in range(N))
i = 0
bus = 0
while i < N:
bus += 1
c = 0
limit = T[i]+K
while c < C and i < N and T[i] <= limit:
c += 1
i += 1
print(bus) |
p02748 | s606200537 | Accepted | A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [list(map(int,input().split())) for i in range(M)]
minPrice = min(a) + min(b) #割引額を考慮しない最小金額
price = 0
for x in range(len(c)):
price = a[c[x][0]-1] + b[c[x][1]-1] - c[x][2]
if minPrice > price:
... |
p02820 | s418095916 | Accepted | n, k = map(int, input().split())
score = list(map(int, input().split()))
t = input()
self = [0] * n
for i in range(n):
if t[i] == 'r':
self[i] = 2
elif t[i] == 's':
self[i] = 0
elif t[i] == 'p':
self[i] = 1
if i >= k and self[i] == self[i - k]:
self[i] = 3
ans = 0
for x i... |
p03617 | s912533422 | Wrong Answer | # coding: utf-8
# Your code here!
cost=list(map(int,input().split()))
for i in range(4):
cost[i]/=2**(i-2)
N=int(input())
if min(cost)==cost[3]:
print(int((N//2*2)*cost[3]+(N%2)*min(cost[:3])))
else:
print(int(min(cost)*N))
|
p03696 | s788207757 | Wrong Answer | N=int(input())
S=input()
stack= []
ans=""
for i in range(N):
if S[i]=="(":
stack.append(S[i])
else:
if len(stack)>0:
ans = stack.pop()+ ans + ")"
else:
ans = "(" + ans + ")"
nokori=len(stack)
ans = nokori * "(" + ans + nokori * ")"
print(ans) |
p02973 | s616980605 | Wrong Answer | n = int(input())
A = []
for i in range(n):
A.append(int(input()))
m = n
t = 0
B = [0]
while B != []:
B = []
for i in range(m-1):
if A[i] >= A[i+1]:
B.append(A[i+1])
A = B
t += 1
m = len(B)
print(t) |
p02814 | s879996820 | Accepted | from functools import reduce
from fractions import gcd
def lcm(a, b):
return a * b // gcd(a, b)
def lcm_all(A):
return reduce(lcm, A, 1)
n, M = map(int, input().split())
A = set(map(lambda x: int(x)//2, input().split()))
scm_core = lcm_all(A)
canmake_scm = True
for a in A:
if scm_core // a % 2 == 0:
... |
p03696 | s404750982 | Wrong Answer | N = int(input())
S = str(input())
if ')' in S:
for i in range(N):
if S[N-1-i] == ')':
n = N-i
break
lc = S[:n].count('(')
rc = S[:n].count(')')
if rc > lc:
S = (rc-lc) * '(' + S
s = S.index('(')
l = S[s:].count('(')
r = S[s:].count(')')
if l > r:
S = S + (l-r) * ')'
print(S) |
p03761 | s327193922 | Accepted | from collections import Counter, defaultdict
n = int(input())
lc = [chr(i) for i in range(97, 97+26)]
ans_dict = Counter(input())
for _ in range(n-1):
S = input()
tmp = {k:0 for k in lc}
for s in S:
tmp[s] += 1
for k in tmp.keys():
try:
ans_dict[k] = min(ans_dict[k], tmp[k]... |
p04044 | s696121870 | Wrong Answer | a = input()
b = []
for i in range(int(a[0])):
b.append(input())
b.sort()
for j in b:
print(j, end = "")
print("") |
p03408 | s487504220 | Accepted | n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
ans=0
for i in range(n):
tmp = s.count(s[i])-t.count(s[i])
ans=max(ans,tmp)
print(ans) |
p02831 | s112972162 | Accepted | def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
a,b=map(int,input().split())
g=gcd(a,b)
print((a*b)//g) |
p03493 | s648707056 | Accepted | print(input().count("1")) |
p02601 | s952830065 | Accepted | #!/usr/bin/env python3
A, B, C = map(int, input().split())
K = int(input())
if A < B < C:
print('Yes')
exit()
while K > 0:
if A >= B:
B *= 2
elif B >= C:
C *= 2
K -= 1
if A < B < C:
print('Yes')
else:
print('No')
|
p02678 | s409486005 | Wrong Answer | n, m = map(int, input().split())
list = [[0 for i in range(n)] for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
list[a-1][b-1] = 1
list[b-1][a-1] = 1
for ll in list:
if ll == [0]*n:
print('No')
break
else:
print('Yes')
for ll in list:
for j in range(len(ll))... |
p03076 | s974658942 | Accepted | ans = 0
s = 9
flag = True
for i in range(5):
n = int(input())
if n%10 != 0:
s = min(s,n%10)
ans += n//10+1
flag = False
else:
ans += n//10
else:
if flag:
print(ans*10)
else:
print((ans-1)*10+s)
|
p02787 | s683862903 | Wrong Answer | h,n=map(int,input().split())
H=[]
A=[]
for i in range(n):
a,b=map(int,input().split())
H.append([a,b])
A.append(a)
a_max=max(A)
dp=[10**5]*(h+a_max+1)
dp[0]=0
for i in range(1,h+a_max+1):
for j in range(n):
if i-H[j][0]<0:
continue
dp[i]=min(dp[i],dp[i-H[j][0]]+H[j][1])
print... |
p03339 | s108010378 | Wrong Answer | N = int(input())
S = list(input())
Lw = 0
Re = S.count("E")
ans_lst = [Lw+Re]*(N)
# i+1をリーダーとみなす
for i in range(1,N):
if S[i-1] == "W":
Lw += 1
else:
Re -= 1
ans_lst[i] = Lw + Re
ans = min(ans_lst)
print(ans)
|
p02627 | s406148463 | Wrong Answer | s = input()
if s.isupper():
print("A")
else:
print("B")
|
p02765 | s697417306 | Accepted | n,r=map(int,input().split())
if 10<=n:
print(r)
if n<10:
print(r+(100*(10-n)))
|
p02813 | s898096272 | Accepted | from itertools import permutations
n = int(input())
itr = permutations([i for i in range(1, n+1)])
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
for i, tpl in enumerate(itr):
if tpl == p:
val1 = i
if tpl == q:
val2 = i
print(abs(val1-val2)) |
p03095 | s130417001 | Wrong Answer | from collections import Counter
MOD = 10*9 + 7
N = int(input())
S = input()
count_si = Counter(S)
ans = 1
for v in count_si.values():
ans = (ans * (v+1)) % MOD
if ans == 0:
print(MOD-1)
else:
print((ans-1)%MOD) |
p02682 | s052558495 | Accepted | # -*- coding: utf-8 -*-
def main():
A, B, C, K = map(int, input().split())
ans = 0
if K <= A:
ans = K
else:
if K <= A + B:
ans = A
else:
ans = A + (-1 * (K - A - B))
print(ans)
if __name__ == "__main__":
main() |
p03037 | s917296998 | Accepted | N, M = map(int, input().split())
mini = 0
maxi = N
for i in range(M):
L, R = map(int, input().split())
mini = max(mini, L)
maxi = min(maxi, R)
print(maxi - mini + 1 if maxi - mini + 1 > 0 else 0) |
p02959 | s789964285 | Accepted | n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
b = list(map(int, input().split()))
for i in range(n):
if b[i] >= a[i]:
b[i] -= a[i]
a[i] = 0
else:
a[i] -= b[i]
continue
a[i + 1] -= b[i]
if a[i + 1] < 0:
a[i + 1] = 0
if a[-1] < 0:
a[-1] = ... |
p03611 | s049500796 | Accepted | from collections import Counter
n = int(input())
l = list(map(int, input().split()))
c = Counter(l)
s = set(l)
ans = 0
for i in s:
ans = max(c[i-1] + c[i] + c[i+1], ans)
print(ans)
|
p02916 | s553010177 | Accepted | n = int(input())
cuisine = list(map(int, input().split()))
saticefaction = list(map(int,input().split()))
moreSaticefaction = list(map(int, input().split()))
total = 0
beforeCuisine = -1
for i in cuisine:
total += saticefaction[i - 1]
if (i - 1) == beforeCuisine:
total += moreSaticefaction[beforeCuisine - 1]
... |
p03815 | s377544946 | Accepted | x = int(input())
ans = x//11*2
if x % 11 > 0: ans+=1
if x % 11 > 6: ans+=1
print(ans) |
p03262 | s345495022 | Wrong Answer | N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
print(W[1]-W[0])
exit()
for i in range(1,N):
dist = min(dist, W[i]-W[i-1])
print(dist) |
p02780 | s765445310 | Accepted | N, K = map(int,input().split())
dices = list(map(int,input().split()))
list =[]
check=0
for i in range(K):
check+=dices[i]
list.append(check)
for j in range(N-K):
check -= dices[j]
check += dices[j+K]
list.append(check)
print((max(list)+K)/2) |
p02578 | s379713987 | Accepted | def main():
number_of_person = int(input())
array = [int(x) for x in input().split()]
pre_h = 0
step_total = 0
for height in array:
step_total += max(pre_h - height, 0)
pre_h = max(height, pre_h)
return step_total
if __name__ == '__main__':
ans = main()
print(ans)
|
p03698 | s725731398 | Accepted | used = set()
S = input()
for s in S:
if s in used:
ans = 'no'
break
used.add(s)
else:
ans = 'yes'
print(ans)
|
p03150 | s662719542 | Wrong Answer | S = list(input())
L = len(S)
key = list("keyence")
if S[0:7] == key:
print("YES")
exit()
if S[L-7:] == key:
print("YES")
exit()
for i in range(1,6):
if S[0:i] == key[0:i] and S[L-7+i:] == key[i:]:
print("YES")
exit()
print("NO") |
p03062 | s369007958 | Wrong Answer | n = int(input())
a = list(map(int,input().split()))
dp = [[0]*2 for _ in range(n+1)]
dp[0][1] = -10**9
for i in range(n):
for j in range(2):
dp[i+1][1-j] = max(dp[i+1][1-j],dp[i][j]+(-1)**(j+1)*a[i])
dp[i+1][j] = max(dp[i+1][j],dp[i][j]+(-1)**j*a[i])
print(dp[n][0]) |
p03309 | s131635427 | Accepted |
n = int(input())
a = list(map(int, input().split()))
calc = []
for i in range(n):
calc.append(a[i] - (i + 1))
calc.sort()
b = calc[n // 2]
ans = 0
for i in range(n):
ans += abs(a[i] - (b + i + 1))
print(ans) |
p03761 | s769009951 | Accepted | n = int(input())
p = [50 for i in range(26)]
for i in range(n):
kar = input()
for i in range(26):
p[i] = min(p[i],kar.count(chr(ord("a") + i)))
for i in range(26):
for j in range(p[i]):
print(chr(ord("a") + i),end="") |
p03719 | s230349959 | Accepted | A,B,C=map(int, input().split())
print("Yes" if A<=C<=B else "No") |
p03617 | s308567265 | Accepted | Q, H, S, D = map(int, input().split()) # 0.25, 0.5, 1.0, 2.0
N = int(input())
if N%2==0:
kijun1 = min(Q*8, H*4, S*2, D)
print(N//2 * kijun1)
else:
kijun1 = min(Q*8, H*4, S*2, D)
kijun2 = min(Q*4, H*2, S)
print(N//2 * kijun1 + kijun2) |
p03637 | s111541889 | Accepted | n=int(input())
a=list(map(int,input().split()))
x=0
y=0
z=0
for i in range(n):
if a[i]%4==0:
x+=1
elif a[i]%2==0:
y+=1
else:
z+=1
if y==0:
if z<=x+1:
print("Yes")
else:
print("No")
else:
if z<=x:
print("Yes")
else:
print("No")
|
p02723 | s814112824 | Accepted | import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)
def main():
S = input().strip()
if len(S) != 6:
return "No"
if S[2] == S[3] and S[4] == S[5]:
return "Yes"
else:
return "No"
if __name__ == "__main__":
print(main())
|
p03487 | s631555515 | Accepted | import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
ans = 0
for e in c:
if e < c[e]:
ans += c[e] - e
elif e > c[e]:
ans += c[e]
print(ans) |
p02753 | s185615394 | Accepted | S = input()
if S[0] == S[1] == S[2]:
print("No")
else:
print("Yes")
|
p02953 | s324165285 | Accepted | N = int(input())
H = list(map(int, input().split()))
max=0
cnt=0
for i in range(N):
if max-H[i]>=2:
print('No')
break
else:
cnt+=1
if H[i]>max:
max=H[i]
if cnt==N:
print('Yes')
|
p02862 | s176479071 | Accepted | x,y=map(int,input().split())
def nCr(n,r,mod=10**9+7):
r=min(r,n-r)
a=b=1
for i in range(1,r+1):
a=a*n%mod
b=b*i%mod
n-=1
return a*pow(b,mod-2,mod)%mod
z=x+y
if z%3!=0 or x-(z//3)<0 or y-(z//3)<0:
print(0)
else:
z//=3
# print(z)
# print(min(x,y)-z)
print(nCr... |
p03821 | s211887190 | Accepted | N = int(input())
A = []
B = []
for i in range(N):
a,b = map(int, input().split())
A.append(a)
B.append(b)
c = 0
for i in range(N-1,-1,-1):
if (A[i]+c) % B[i] == 0:
continue
if A[i]+c < B[i]:
push = B[i] - (A[i]+c)
elif A[i]+c > B[i]:
push = B[i] - (A[i]+c) % B[i]
c +=... |
p03013 | s418113549 | Accepted | N, M = [int(x) for x in input().split()]
a = set(int(input()) for _ in range(M))
MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1#二段目の調節 0段目の場合の数
for i in range(1, N + 1):
if i in a:
continue
x = dp[i - 1]
if i > 1:
x += dp[i - 2]
dp[i] = x % MOD
ans = dp[N]
print(ans) |
p02714 | s004971878 | Wrong Answer | n = int(input())
s = input()
r_num = s.count('R')
g_num = s.count('G')
b_num = s.count('B')
tot = r_num*g_num*b_num
print(tot)
for i in range(n):
for j in range(i+1,n):
k = j+(j-i)
if k<n:
if s[i]!=s[j] and s[i]!=s[k] and s[j] != s[k]:
tot -= 1
print(tot)
|
p02597 | s612525919 | Wrong Answer | k = int(input())
if k % 2 == 0 or k % 5 == 0:
print(-1)
else:
s = i = 0
while True:
i += 1
s = (s*10 + 7) % k
if s % k == 0:
print(i)
break |
p03719 | s110759087 | Accepted | A,B,C = map(int, input().split())
if A<= C<= B:
print("Yes")
else:
print("No") |
p02730 | s954333879 | Accepted | s = input()
def check(s):
flag = True
for i in range(len(s)):
if s[i] != s[-i-1]:
flag = False
return flag
s1 = s[:(len(s)-1)//2]
s2 = s[(len(s)+3)//2-1:]
# print(s1)
# print(s2)
if check(s) and check(s1) and check(s2):
print("Yes")
else:
print("No") |
p02681 | s375057126 | Accepted | s = input()
t = input()
check = t[:-1]
a = len(s)
b = len(t) - 1
if a == b:
if s == check:
print("Yes")
else:
print("No")
else:
print("No")
|
p03474 | s817433147 | Accepted | a, b = map(int, input().split())
s = input()
if s[a] != '-':
print('No')
exit()
try:
int(s[:a])
int(s[a + 1:])
except:
print('No')
exit()
print('Yes') |
p02724 | s629565524 | Wrong Answer | X=int(input()) #1200
a=X//500 #2
b=(X-500*a)//5 #
print(a+b) |
p04033 | s541974642 | Accepted | a,b = map(int,input().split())
if a < 0 and b < 0:
if (b-a)%2 == 1:
print('Positive')
else:
print('Negative')
elif a>0:
print('Positive')
else:
print('Zero')
|
p03971 | s481839893 | Accepted | n,a,b = map(int,input().split())
s = input()
for c in s:
if c =='c':
print('No')
elif c=='a':
if a >0:
print('Yes')
a -= 1
elif b > 0:
print('Yes')
b -= 1
else:
print('No')
else:
if b > 0:
print('Yes')
b -= 1
else:
print('No') |
p03041 | s578432395 | Accepted | N,K=map(int,input().split())
S=input()
S2=S.lower()
S3=''
for i in range(N):
if i==K-1:
S3+=S2[i]
else:
S3+=S[i]
print(S3) |
p02702 | s941850425 | Accepted | s=list(input())
s=s[::-1]
l=len(s)
mod=2019
count=[0]*2019
count[0]=1
num=0
seki=1
for i in range(l):
num+=int(s[i])*seki
num=num%mod
count[num]+=1
seki=(seki*10)%mod
ans=0
for i in range(2019):
N=count[i]
ans+=N*(N-1)//2
print(ans) |
p03761 | s605473680 | Accepted | from collections import Counter
n = int(input())
alphabet = Counter(input())
for i in range(n-1):
s = Counter(input())
for x in alphabet:
if alphabet[x] > s[x]:
alphabet[x] = s[x]
print("".join(sorted(alphabet.elements()))) |
p02748 | s663253752 | Wrong Answer | A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
m = []
for i in range(M):
x, y, z = map(int, input().split())
m.append([x, y, z])
m.sort(reverse = True,key = lambda x: x[2])
ans = 100000
if a[m[0][0]-1] + b[m[0][1]-1] - m[0][2] >= min(a) + min... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.