problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p02983 | s424341619 | Accepted | L, R = map(int, input().split())
mod = 2019
ans = mod - 1
R = min(R, L+mod-1)
for i in range(L, R):
for j in range(i+1, R+1):
ans = min(ans, i * j % mod)
print(ans) |
p02917 | s295214497 | Accepted | n = int(input())
b = list(map(int, input().split()))
res = [0]*n
res[0] = b[0]
for i in range(1, n):
if res[i-1] > b[i-1]:
res[i-1] = b[i-1]
res[i] = b[i-1]
print(sum(res)) |
p02970 | s096318620 | Wrong Answer | import math
a,b=map(int,input().split())
print(math.ceil(a/(2*b-1))) |
p03665 | s801414756 | Accepted | N,P = map(int, input().split())
A = list(map(int, input().split()))
even_num=0
odd_num=0
for a in A:
if a%2==0:
even_num+=1
else:
odd_num+=1
ev_case = 2**even_num
from math import factorial
res=0
for i in range(P,odd_num+1,2): res += factorial(odd_num) / factorial(i) / factorial(odd_num - i)
print(int(ev_case*res)) |
p03455 | s334778401 | Accepted | a, b = map(int, input().split())
if a*b%2==0: print('Even')
else: print('Odd')
|
p02756 | s862040692 | Accepted | from collections import deque
s = deque(list(input()))
q = int(input())
flg = 1
for i in range(q):
array = input().split(' ')
if array[0] == '1':
flg *= -1
elif array[0] == '2':
if array[1] == '1' and flg == 1 or array[1] == '2' and flg == -1:
s.appendleft(array[2])
else:
s.append(array[2])
s = list(s)
if flg == -1:
s = s[::-1]
s = ''.join(s)
print(s) |
p02753 | s563036519 | Accepted | S = input()
if S[0] == S[1] == S[2]:
print('No')
else:
print('Yes')
|
p03962 | s448339841 | Wrong Answer | li = input().split()
set(li)
print(len(li)) |
p03486 | s894463399 | Accepted | s = input(); t = input()
S = sorted(s); T = sorted(t, reverse = True)
print("Yes" if S < T else "No")
|
p03495 | s859191052 | Wrong Answer | n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt_list = []
for i in range(1,10):
if i in a:
cnt_list.append(a.count(i))
else:
continue
cnt_list.sort()
ans = 0
if len(cnt_list) <= k:
ans = 0
else:
tmp = len(cnt_list) - k
ans = sum(cnt_list[:tmp])
print(ans) |
p03730 | s535824093 | Accepted | a,b,c=list(map(int,input().split()))
flag=0
for itr in range(1,100000):
if (a*itr)%b==c:
print('YES')
flag=1
break
if flag==0: print('NO') |
p03071 | s007894432 | Accepted | a,b = map(int,input().split())
if abs(a-b) < 2:
print(a+b)
else:
print(2*max(a,b) - 1)
|
p03472 | s296958464 | Accepted | from math import ceil
n, h, *AB = map(int, open(0).read().split())
a = max(AB[::2])
B = sorted(b for b in AB[1::2] if a < b)[::-1]
c = 0
for b in B:
h -= b
c += 1
if h <= 0:
break
else:
c += ceil(h / a)
print(c) |
p03632 | s984764050 | Wrong Answer | a, b, c, d = map(int, input().split())
print(min(b, d)-max(a, c))
|
p02744 | s407603171 | Accepted | N = int(input())
def dfs(ch, Ma):
if len(ch) == N:
print(ch)
return
for i in range(97, Ma+2):
dfs(ch+chr(i), max(Ma, i))
dfs('a', 97)
|
p02556 | s823785865 | Accepted | (N,) = [int(x) for x in input().split()]
XY = [[int(x) for x in input().split()] for i in range(N)]
best = 0
mn = min(XY, key=lambda pt: pt[0] + pt[1])
mx = max(XY, key=lambda pt: pt[0] + pt[1])
best = max(best, abs(mn[0] - mx[0]) + abs(mn[1] - mx[1]))
mn = min(XY, key=lambda pt: pt[0] - pt[1])
mx = max(XY, key=lambda pt: pt[0] - pt[1])
best = max(best, abs(mn[0] - mx[0]) + abs(mn[1] - mx[1]))
print(best)
|
p03338 | s917018414 | Accepted | N = int(input())
S = input()
print(max(len(set(S[:i]) & set(S[i:])) for i in range(N)))
|
p03944 | s851413695 | Wrong Answer | w, h, n = map(int, input().split())
x1 = 0
y1 = 0
x2 = w
y2 = h
for i in range(n):
x, y, a = map(int, input().split())
if a == 1:
x1 = x
elif a == 2:
x2 = x
elif a == 3:
y1 = y
else:
y2 = y
if x1 >= x2 or y1 >= y2 or x2 <= 0 or y2 <= 0:
print("0")
else:
print((x2-x1)*(y2-y1)) |
p02577 | s984711858 | Wrong Answer | n=input()
lst=list(n)
s=0
for i in lst:
s+=int(i)
if s%9==0:
print('YES')
else:
print('NO') |
p02939 | s584358254 | Accepted | import sys
import time
import math
import itertools as it
def inpl():
return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------
S = input()
ans = 0
st1 = ''
st2 = ''
for s in S:
st2 += s
if st2 != st1:
ans += 1
st1 = st2
st2 = ''
print(ans)
# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
|
p02882 | s839299496 | Wrong Answer | from math import atan, pi
a, b, x = map(int, input().split())
if x >= a*a*b:
ans = atan((2*(a*a*b - x)) / (a*a*a))
else:
ans = atan((a*b*b) / (2*x))
print((ans*180) / pi) |
p02603 | s517498234 | Accepted | from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import sys
#####################################
n=int(input())
A=INPUT()
money=1000
for i in range(n-1):
stocks=0
if A[i]<A[i+1]:
stocks=money//A[i]
money+=(A[i+1]-A[i])*stocks
print(money)
|
p03524 | s300630754 | Wrong Answer | from collections import Counter
S = [i for i in input()]
c = Counter(S)
if len(c) == 1:
if len(S) == 1:
print("YES")
else:
print("NO")
elif len(c) == 2:
print("NO")
else:
dif = c.most_common()[0][1] - c.most_common()[2][1]
print("YES" if dif<=1 else "NO")
|
p03971 | s840676243 | Accepted | N, A, B = map(int, input().split())
S = input()
capacity = A+B
rank = 1
for i in range(N):
if 'a' == S[i] and 0 < capacity:
print('Yes')
capacity -= 1
elif 'b' == S[i] and 0 < capacity and rank <= B:
print('Yes')
capacity -= 1
rank += 1
else:
print('No')
|
p02939 | s016049670 | Accepted | A=input()
ans=0
before=""
c=""
for i in A:
c+=i
if c != before:
before=c
c=""
ans+=1
print(ans) |
p03012 | s659153926 | Accepted | N = int(input())
W = tuple(map(int, input().split()))
total1 = W[0]
total2 = sum(W[1:])
ans = abs(total2 - total1)
for i in range(1, N):
total1 += W[i]
total2 -= W[i]
ans = min(ans, abs(total2 - total1))
print(ans) |
p02819 | s893944137 | Accepted | import math
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
X = int(input())
while True:
if is_prime(X) == True:
print(X)
exit()
else:
X += 1
|
p02761 | s788577182 | Accepted | N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
S = [1] + [0] * (N-1)
sc = sorted(sc, key=lambda x: x[0])
def get_unique_list(seq):
seen = []
return [x for x in seq if x not in seen and not seen.append(x)]
if N != 1 and [1, 0] in sc:
print(-1)
elif len(list(set([i[0] for i in sc]))) != len(list(get_unique_list(sc))):
print(-1)
elif N == 1 and M == 0:
print(0)
else:
for i in sc:
S[i[0]-1] = "{}".format(i[1])
print(*S, sep="")
|
p03472 | s598074063 | Accepted | import math
from bisect import bisect_left as bl
from itertools import accumulate
n,h = map(int,input().split())
A = []
B = []
ans = 0
for _ in range(n):
a,b = map(int,input().split())
A.append(a)
B.append(b)
A.sort(reverse=1)
B.sort()
index = bl(B, A[0])
B = B[index:]
B = list(accumulate(B[::-1]))
if B[-1] >= h:
print(bl(B,h)+1)
exit()
h -= B[-1]
ans += len(B)
ans += math.ceil(h/A[0])
print(ans) |
p03723 | s130792564 | Accepted | List=list(map(int,input().split()))
cnt=0
while(all(i%2==0 for i in List)):
if List[0]==List[1]==List[2]:
print(-1)
exit()
old_list=[List[0]//2,List[1]//2,List[2]//2]
List[0]=old_list[1]+old_list[2]
List[1]=old_list[0]+old_list[2]
List[2]=old_list[0]+old_list[1]
cnt+=1
print(cnt) |
p02664 | s000305531 | Accepted | T = input()
rep = str(T).replace("?","D")
print(rep) |
p02659 | s022952426 | Wrong Answer | a, b = input().split()
a = int(a)
b = float(b)
print(int(a*b)) |
p02725 | s522347296 | Accepted | KN = list(map(int, input().split()))
A = list(map(int, input().split()))
answer = []
for i,home in enumerate(A):
if home < A[i - 1]:
answer.append(home - A[i - 1] + KN[0])
else:
answer.append(home - A[i - 1])
print(KN[0] - max(answer))
|
p02900 | s475639085 | Accepted | def gcd(a, b):
while b:
a, b = b, a%b
return a
a, b = map(int, input().split())
max = gcd(a, b)
pf=[]
#print(max)
tmp=max
i=2
while tmp % 2 == 0:
pf.append(2)
tmp //= 2
f = 3
while f * f <= tmp:
if tmp % f == 0:
pf.append(f)
tmp //= f
else:
f += 2
if tmp != 1:
pf.append(tmp)
#print(pf)
spf = set(pf)
#print(spf)
print(len(spf)+1) |
p03001 | s059913884 | Wrong Answer | W,H,x,y=map(int,input().split())
area=0
if abs(H//2-y)>abs(W//2-x):
area=H*(min(x,W-x))
else:
area=W*min(y,H-y)
ans=0
if W/2==x and H/2==y:
ans=1
else:
ans=0
print(area,ans) |
p03329 | s201616675 | Wrong Answer | N=int(input())
ans=0
while N:
if 12<=N<=14:
N-=6
ans+=1
if 1458<=N<=1511:
N-=729
ans+=1
i=0
while 9**i<=N:
i+=1
i-=1
j=0
while 6**j<=N:
j+=1
j-=1
N-=max(9**i,6**j)
ans+=1
print(ans) |
p02792 | s889702214 | Accepted | n=int(input())
l=[[0]*9 for j in range(9)]
for i in range(1,n+1):
i=str(i)
if i[0]!='0' and i[-1]!='0':
l[int(i[-1])-1][int(i[0])-1]+=1
ans=0
for i in range(9):
for j in range(9):
ans+=l[i][j]*l[j][i]
print(ans) |
p03723 | s381719102 | Wrong Answer | a,b,c = map(int,input().split())
count = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
if a == b and b == c:
break
else:
aDummy = a/2
bDummy = b/2
cDummy = c/2
a = (bDummy) + (cDummy)
b = (aDummy) + (cDummy)
c = (aDummy) + (bDummy)
count += 1
print(-1 if a == b and b == c else count) |
p02835 | s743607952 | Accepted | a1,a2,a3=map(int,input().split())
print('win' if a1+a2+a3<22 else 'bust') |
p03160 | s386153319 | Accepted | n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
for i in range(1,n):
dp_0 = dp[i-1] + abs(h[i]-h[i-1])
if i -2 < 0:
dp_1 = 10**10
else:
dp_1 = dp[i-2] + abs(h[i]-h[i-2])
dp[i] = min(dp_0,dp_1)
print(dp[-1]) |
p02700 | s612133905 | Accepted | import sys
inp=input().split(" ")
thp=int(inp[0])
tat=int(inp[1])
ahp=int(inp[2])
aat=int(inp[3])
for i in range(100):
ahp-=tat
if ahp<=0:
print("Yes")
sys.exit()
thp-=aat
if thp<=0:
print("No")
sys.exit()
|
p03379 | s384057464 | Accepted | N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
index = N//2
a,b = Y[index],Y[index-1]
for i in range(N):
if X[i] < Y[index]:
print(a)
else:
print(b) |
p02829 | s144254948 | Accepted | # import math
# from itertools import permutations as permus
# from fractions import gcd
# import numpy as np
# import scipy as scp
# 入力の受け取り
a = int(input())
b = int(input())
ans = 6-a-b
print(ans) |
p03345 | s940862407 | Accepted | #!/usr/bin/env python3
a, b, c, k = map(int, input().split())
if abs(a - b) > 10**18:
print("Unfair")
else:
print((a - b) * (-1)**k)
|
p02772 | s962960201 | Accepted | n = int(input())
lis = list(map(int,input().split()))
for num in lis:
if num % 2 == 0:
if num % 3 != 0:
if num % 5 != 0:
print("DENIED")
exit()
print("APPROVED") |
p03106 | s159876821 | Accepted | a, b, k = map(int, input().split())
count = 0
for i in range(min(a, b), 0, -1):
if a % i == 0 and b % i == 0:
count = count + 1
if count == k:
print(i)
exit()
|
p02732 | s039290751 | Accepted | import collections
n = int(input())
arr = list(map(int, input().split()))
cnt = collections.Counter(arr)
total = 0
for i in cnt.keys():
patern = cnt[i]*(cnt[i]-1)//2
total += patern
for j in range(n):
tmp = total
total -= cnt[arr[j]]*(cnt[arr[j]]-1)//2
total += (cnt[arr[j]]-1)*(cnt[arr[j]]-2)//2
print(total)
total = tmp |
p02783 | s846289221 | Accepted | h, a = map(int, input().split())
n = 0
while h > 0:
h = h - a
n += 1
print(n) |
p03481 | s493008302 | Wrong Answer | import math
X, Y = map(int, input().split())
c = math.log2(Y // X)
if math.ceil(c) == int(c):
print(int(c))
else:
print(math.ceil(c)) |
p04012 | s478480929 | Wrong Answer | w = input()
wl = []
for i in range(len(w)):
wl.append(w[i])
wl.sort()
a = 1
judge = 1
for n in range(len(w)-1):
if wl[a+n] == wl[a+n-1]:
judge += 1
else:
if judge%2 != 0:
print("No")
exit()
else:
judge = 1
if n == len(w)-2:
if judge%2 == 0:
print("Yes")
else:
print("No") |
p03274 | s314734737 | Wrong Answer | n,k = map(int,input().split())
li = list(map(int,input().split()))
time_li = []
for i in range(n-k+1):
#print(li[i:i+k]) [-30, -10, 10]
tmp_time_li = []
tmp = li[i:i+k]
mi = min(tmp)
ma = max(tmp)
if mi*ma >0:
tmp_time_li.append(ma)
else:
orikaeshi = min(abs(mi),abs(ma))*2+max(abs(mi),abs(ma))
tmp_time_li.append(orikaeshi)
time_li.append(tmp_time_li[0])
print(min(time_li)) |
p02676 | s973077872 | Wrong Answer | import sys
a = []
for l in sys.stdin:
a.append(l)
if int(a[0]) <= len(a[1]):
print(a[1][0:7] + '...')
else:
print(a[1])
|
p03612 | s755679907 | Accepted | N = int(input())
*P, = map(int, input().split())
ans = 0
for i in range(N-1):
if P[i]==(i+1):
temp = P[i]
P[i] = P[i+1]
P[i+1] = temp
ans = ans + 1
if P[N-1]==(N):
ans = ans + 1
print(ans) |
p02801 | s294736485 | Accepted | #coding:utf-8
c = input()
ans = ord(c) + 1
print(chr(ans)) |
p03695 | s749876501 | Wrong Answer | import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
b=[0]*10
cnt=0
for i in range(n):
if a[i]<3200:
b[a[i]//400]=1
else:
cnt+=1
if n==1:
if a[0]>=3200:
print(1,1)
exit()
print(sum(b),sum(b)+cnt)
|
p04011 | s430666337 | Accepted | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
def hotel_price(N,K,X,Y):
if N<=K:
return N*X
else:
return K*X + (N-K)*Y
print(hotel_price(N,K,X,Y)) |
p02911 | s577863057 | Accepted | N, K, Q = map(int, input().split())
A = [K-Q] * N
for _ in range(Q):
i = int(input())
A[i-1] += 1
cnt = 0
for i in range(N):
if A[i] > 0:
ans = 'Yes'
else:
ans = 'No'
print(ans) |
p03327 | s563511422 | Accepted | N = input()
n = len(N)
ans = 'ABC'
if n > 3:
ans = 'ABD'
print(ans) |
p02939 | s916183380 | Accepted | s = input()
prev = ''
p = 0
count = 0
for i in range(1, len(s) + 1):
if s[p:i] != prev:
prev = s[p:i]
p = i
count += 1
print(count)
|
p02661 | s819904173 | 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()
if N%2 == 1:
print(B[N//2]-A[N//2]+1)
else:
x = A[N//2-1]+A[N//2]
y = B[N//2-1]+B[N//2]
print(y-x+1)
|
p02957 | s549128470 | Accepted | a, b = map(int, input().split())
print('IMPOSSIBLE' if (b + a) % 2 else (b + a) // 2) |
p02939 | s636614239 | Wrong Answer | s = input()
n = len(s)
bef = s[0]
key = 0
ans = 1
for i in range(1, n):
if key == i:
continue
if bef == s[i]:
if i == n-1:
continue
bef = s[i+1]
ans += 1
key = i+1
else:
bef = s[i]
ans += 1
print(ans) |
p03069 | s330933409 | Accepted | N = int(input())
S = input()
t_min = min(S.count("#"), S.count("."))
S_first = 0
S_second = S.count(".")
for i in range(0,N):
if S[i] == "#":
S_first += 1
else:
S_second -= 1
t = S_first + S_second
t_min = min(t_min, t)
print(t_min) |
p02971 | s157528872 | Wrong Answer | def exception_handling(n, ali):
ali.sort(reverse=True)
alimax = ali[0]
alimax2 = ali[1]
ans = []
for i in ali:
if i != alimax:
ans.append(alimax)
else:
ans.append(alimax2)
return ans
def main():
n = int(input())
ali = [int(input())for i in range(n)]
ans = exception_handling(n, ali)
for i in ans:
print(i)
if __name__ == '__main__':
main() |
p02742 | s434254829 | Accepted | H,W = map(int,input().split())
if(min(H,W) == 1):
print(1)
exit()
print((H*W+(H*W)%2)//2) |
p02888 | s862858322 | Wrong Answer | import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
for i in range(n - 1):
for j in range(i + 1, n):
ans += bisect.bisect_left(l,l[i] + l[j]) - (j + 1)
print(ans)
print(ans)
|
p02791 | s782877648 | Accepted | def solve():
N = int(input())
P = list(map(int, input().split()))
mn = P[0]
cnt = 0
for p in P:
if p <= mn:
cnt += 1
mn = min(mn, p)
print(cnt)
if __name__ == '__main__':
solve()
|
p04012 | s060067245 | Accepted | w = list(input())
c = [0] * 26
for ch in w:
c[ord(ch) - ord("a")] += 1
f = "Yes"
for cnt in c:
if cnt % 2 == 1:
f = "No"
print(f)
|
p03145 | s298772006 | Wrong Answer | a, b, c=map(int, input().split())
print(a*b/2) |
p03565 | s402762590 | Wrong Answer | S = input()
T = input()
S = S[::-1]
T = T[::-1]
cnt = 0
def answer(S):
S = S.replace('?', 'a')
print(S[::-1])
exit()
for i in range(len(S)):
if S[i] == '?' or S[i] == T[cnt]:
if cnt == len(T) - 1:
S = S[:(i-cnt)] + T + S[i+1:]
answer(S)
else:
cnt += 1
else:
cnt = 0
print('UNRESTORABLE') |
p04019 | s376574212 | Accepted | s= list(set(input()))
print('No' if s.count('N')!=s.count('S') or s.count("W") !=s.count('E') else 'Yes') |
p04045 | s057322023 | Wrong Answer | N,K = map(int,input().split())
num_list=[]
kari = 0
N -= 1
num_list.append(input().split())
num_list_3 = sorted(num_list)
while(kari != 1):
count = 0
N += 1
for i in range(K - 1):
a = num_list_3[0][i]
s = str(N).count(a)
print(s)
if(s != 0):
count+= 1
print(count)
if (count == 0):
kari = 1
print(N) |
p02780 | s420722673 | Accepted | N, K = map(int, input().split())
p = list(map(int, input().split()))
def expect(i):
return (i+1) / 2
S=[0]
for i, x in enumerate(p, start=1):
S.append(S[i-1] + expect(x))
ans = 0
for i in range(N - K + 1):
r = S[i+K] - S[i]
if r > ans:
ans = r
print(ans) |
p03998 | s691054666 | Accepted | a,b,c = [input() for i in range(3)]
sa = 'a'
for i in range(1796):
try:
if sa == 'a':
sa = a[0]
a = a[1:]
elif sa == 'b':
sa = b[0]
b = b[1:]
elif sa == 'c':
sa = c[0]
c = c[1:]
except:
print(sa.upper())
break |
p03329 | s453834821 | Wrong Answer | list=[1, 1, 1, 1, 1]
for i in range(1, 7):
list.append(6**i)
for j in range(1, 7):
list.append(9**j)
list=sorted(list, reverse=True)
N=127
count=0
for i in list:
if i <= N:
N=N-i
count+=1
if N == 0:
print(count) |
p02646 | s676612522 | Wrong Answer | A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if A >= B:
if A + V * T >= B + W * T:
print('YES')
else:
print('NO')
else:
if V >= W:
print('NO')
elif A + V * T >= B + W * T:
print('YES')
else:
print('NO') |
p03696 | s661182689 | Accepted | import sys
readline = sys.stdin.readline
def main():
N = int(readline())
S = readline().rstrip()
res = S[:]
pls_left = 0
pls_right = 0
for s in S:
if s == '(':
pls_right += 1
else:
if pls_right == 0:
pls_left += 1
else:
pls_right -= 1
res = '(' * pls_left + S + ')' * pls_right
print(res)
if __name__ == '__main__':
main() |
p02783 | s109339506 | Accepted | h, a = map(int, input().split())
print(-(-h // a)) |
p02630 | s543090787 | Wrong Answer | import collections
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
Q=int(input())
d=collections.Counter(A)
for i in range(Q):
B,C=map(int,input().split())
s += d[B]*C - d[B]*B
print(s)
if d[C] in d:
d[C]+=d[B]
else:
d[C]=d[B]
d[B]=0 |
p02795 | s547308598 | Accepted | H = int(input())
W = int(input())
N = int(input())
import math
if H > W:
print(math.ceil(N / H))
else:
print(math.ceil(N / W))
|
p03723 | s882656871 | Accepted | import sys
a, b, c = map(int,input().split())
a1 = a
b1 = b
c1 = c
cnt = 0
while (a1%2 ==0) and (b1%2 == 0) and (c1%2 == 0):
a1,b1,c1 = b1//2 + c1//2, c1//2 + a1//2, a1//2 + b1//2
cnt += 1
if (a1 == a) and (b1 == b) and (c1 == c):
print(-1)
sys.exit()
print(cnt)
|
p02848 | s233711911 | Accepted | def main():
N = int(input())
S = str(input())
ans = ''
alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
for i in range(len(S)):
c = alphabet.index(S[i]) + N
if c > 25:
c = c - 26
ans = ans + alphabet[c]
print(ans)
main() |
p02594 | s826779927 | Wrong Answer | print('YNeos'[int(input())<30]) |
p03994 | s784971047 | Wrong Answer | s = list(input())
k = int(input())
n = len(s)
for i in range(n):
d = ord('z')-ord(s[i])+1
if d<=k:
s[i] = 'a'
k -= d
if k>0:
x = ord(s[-1])+k%26
d = x-ord('z')
if d>0:
x = chr('a')+d-1
s[-1] = chr(x)
print(''.join(s)) |
p03136 | s650709721 | Accepted | N = int(input())
L = list(map(int, input().split()))
if max(L) < sum(L) - max(L):
print('Yes')
else:
print('No') |
p02948 | s911756456 | Accepted | from heapq import heappush, heappushpop
N, M = map(int, input().split())
tasks = [[] for _ in range(M)]
for _ in range(N):
a, b = map(int, input().split())
if a <= M:
tasks[M-a].append(b)
q = []
for day in range(M):
for v in tasks[day]:
if len(q) < day + 1:
heappush(q, v)
else:
heappushpop(q, v)
ans = sum(q)
print(ans) |
p03695 | s083634023 | Accepted | n = int(input())
a = map(int, input().split())
border = list(range(400, 3201, 400))
cnt = [0] * (len(border) + 1)
for aa in a:
for i, k in enumerate(border):
if aa < k:
cnt[i] += 1
break
else:
cnt[i+1] += 1
k = len([i for i in cnt[:-1] if i > 0])
print(k, k + cnt[-1]) if k != 0 else print(1, cnt[-1]) |
p03261 | s755812671 | Accepted | n=int(input())
w=[""]*n
a=set()
for i in range(n):
w[i]=input()
cnt=0
for x in w:
if x in a:
print("No")
exit()
else:
if cnt>0:
if bef!=x[0]:
print("No")
exit()
bef=x[-1]
cnt+=1
a.add(x)
print("Yes")
|
p03986 | s861542081 | Wrong Answer | s = input().rstrip()
n = len(s)
removed = 0
cnt_s = cnt_t = 0
for i in range(n):
if s[i] == 'S':
cnt_s += 1
else:
cnt_t += 1
if cnt_t > cnt_s or i == n-1:
removed += cnt_s
cnt_s = cnt_t = 0
# print(cnt_s,cnt_t)
removed += min(cnt_s,cnt_t)
print(len(s) - removed*2) |
p02797 | s770948948 | Accepted | N,K,S = map(int,input().split())
INF = 10**9
A = []
for i in range(K):
A.append(S)
if S != INF:
for i in range(N-K):
A.append(INF)
else:
for i in range(N-K):
A.append(INF-1)
print(" ".join(map(str,A)))
|
p03548 | s242681649 | Accepted | x,y,z=map(int,input().split())
cnt=0
x-=z
while x>=0:
x=x-(y+z)
if x>=0:
cnt+=1
else:
break
print(cnt) |
p02831 | s058659074 | Accepted | import sys
import fractions
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
A, B = lr()
print(lcm(A, B)) |
p02597 | s553089832 | Accepted | #!/usr/bin python3
# -*- coding: utf-8 -*-
n = int(input())
s = input()
r = s.count('R')
print(s[:r].count('W')) |
p03838 | s397136003 | Accepted | x, y = map(int, input().split())
ans = 2* (10 **9)
if y - (-x) >= 0: # 最初だけBを押す
ans = y + x + 1
if -y -x >= 0: # 最後だけBを押す
ans = min(ans, -y -x + 1)
if -y - (-x) >= 0: # 最初と最後にBを押す
ans = min(ans, -y +x +2)
if y - x >= 0: # Bは押さない
ans = min(ans, y-x)
print(ans) |
p04031 | s934445180 | Accepted | N = int(input())
A = list(map(int,input().split()))
ans = 100*100*100
for d in range(-100,101):
t = 0
for e in A:
t += (e-d)**2
ans = min(t,ans)
print(ans)
|
p02771 | s734638631 | Accepted | a, b, c = map(int, input().split())
if a == b and a != c:
print('Yes')
elif b == c and b != a:
print('Yes')
elif c == a and c != b:
print('Yes')
else:
print('No') |
p02994 | s064447435 | Accepted | # abc131_b.py
N, L = map(int,input().split())
apple = []
for i in range(N):
apple.append(L+i)
taste = sum(apple)
diff = 10**9
ans = 0
for i,v in enumerate(apple):
if diff > abs(taste-(taste-v)):
diff = abs(taste-(taste-v))
ans = taste-v
print(ans)
|
p03042 | s501816652 | Accepted | s = list(input())
if int(s[0])*10 + int(s[1]) > 12 or int(s[0]) + int(s[1]) == 0:
if int(s[2])*10 + int(s[3]) <= 12 and int(s[2]) + int(s[3]) != 0:
print("YYMM")
else:
print("NA")
else:
if int(s[2])*10 + int(s[3]) > 12 or int(s[2]) + int(s[3]) == 0:
print("MMYY")
else:
print("AMBIGUOUS") |
p04043 | s586061552 | Accepted | a,b,c = map(int,input().split())
abclist = [a,b,c]
if abclist.count(5) == 2:
print("YES")
else:
print("NO") |
p03289 | s186988135 | Accepted | S = input()
count = 0
flag = False
if S[0] == "A":
# print(S[2:-1]) #指定部分獲得できる
tmp = S[2:-1]
lower = S[1:]
for i in range(len(tmp)):
if tmp[i] == "C":
count += 1
if count == 1:
tmpS = S.replace("A","a")
tmpSS = tmpS.replace("C","c")
if tmpSS.islower():
flag = True
if flag:
print("AC")
else:
print("WA")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.