problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03711 | s554784788 | Accepted | group = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
x, y = map(int, input().split())
for i in range(3):
if x in group[i] and y in group[i]:
print("Yes")
exit()
print("No") |
p03627 | s931120465 | Accepted | N = int(input())
ls = list(map(int,input().split()))
import collections
c = collections.Counter(ls)
unique_ls = list(reversed(sorted(([i[0] for i in c.items() if i[1] >= 2]))))
square_max = 0
rectan_a = 0
rectan_b =0
if len(unique_ls) >=2:
if ls.count(unique_ls[0]) >=4:
print(unique_ls[0]**2)
else:
print(unique_ls[0]*unique_ls[1])
elif len(unique_ls) ==1:
if ls.count(unique_ls[0]) >=4:
print(unique_ls[0]**2)
else:
print(0)
else:
print(0) |
p03069 | s967642795 | Wrong Answer | N=int(input())
A=input()
kuro=0
shiro=0
count=-1
for i in range(N):
if A[i:i+2]=="#.":
count=i
break
for i in range(N):
if A[i]=="#":
kuro+=1
for i in range(count+1,N):
if A[i]==".":
shiro+=1
if count==-1:
print(0)
else:
print(min(shiro,kuro)) |
p02790 | s353867337 | Accepted | import sys
a, b = [int(i) for i in sys.stdin.readline().split()]
if a == b:
print(str(a) * b)
elif a < b:
print(str(a) * b)
else:
print(str(b) * a) |
p02819 | s262454066 | Accepted | X = int(input())
while True:
if X == 2 or X % 2 != 0:
for i in range(3, X):
if X % i == 0:
break
else:
break
X += 1
print(X) |
p03000 | s964275426 | Accepted | n,x=map(int,input().split())
Len=[int(i) for i in input().split()]
ans=n+1
test=0
for i in range(n):
test+=Len[i]
if test<=x:
continue
else:
ans=i+1
break
print(ans) |
p03131 | s327754090 | Accepted | k, a, b = map(int, input().split())
if a+ 1 >= b:
ans = k + 1
else:
if k - a - 1 < 0:
ans = k + 1
else:
n = (k - a - 1) // 2
m = (k - a - 1) % 2
ans = b + n * (b - a) + m
print(int(ans)) |
p03076 | s397228460 | Accepted | import math
A = [int(input()) for _ in range(5)]
B = 10
ans = 0
for i in range(5):
if 0 < A[i] % 10 < B:
B = A[i] % 10
ans = -10+B
for j in A:
ans += math.ceil(j/10)*10
print(ans)
|
p02571 | s789121759 | Accepted | S=str(input())
T=str(input())
ls = []
cnt = 0
for i in range(len(S)-len(T)+1):
cnt = 0
for j in range(len(T)):
#print(i,j)
if T[j] != S[j+i]:
#print(T[j],S[j+i])
cnt += 1
ls.append(cnt)
#print(ls)
print(min(ls))
|
p03543 | s423351445 | Accepted | a,b,c,d=input()
print("Yes" if a==b==c or b==c==d else "No") |
p02548 | s979666015 | Accepted | N=int(input())
ans = 0
for a in range(1,1+N):
if int((N-1)/a) == 0:
continue
else:
ans += int((N-1)/a)
print(ans) |
p02572 | s071050439 | Accepted | import sys
def input():
return sys.stdin.readline()[:-1]
def main():
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
ans = 0
for i in range(n):
s = s - a[i]
ans = ans + a[i] * s
print(ans % (10 ** 9 + 7))
if __name__ == "__main__":
main() |
p02836 | s202734036 | Wrong Answer | S = input()
T = ""
L = len(S)
for i in range(L):
T += S[L-i-1]
print(T)
ans = 0
for i in range(L):
if S[i] != T[i]:
ans += 1
print(ans//2) |
p03821 | s475591018 | Wrong Answer | #!/usr/bin/env python
n = int(input())
a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
a[i], b[i] = map(int, input().split())
ans = 0
for i in reversed(range(n)):
if a[i]%b[i] == 0:
continue
else:
ans += (a[i]//b[i]+1)*b[i]-a[i]
if i!=0:
a[i-1] += ans
print(ans)
|
p03150 | s715688972 | Accepted | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
def main():
s=input()
n=len(s)
if s=='keyence':
return 'YES'
else:
for i in range(n):
for j in range(i+1,n+1):
if s[:i]+s[j:]=='keyence':
return 'YES'
return 'NO'
print(main())
resolve() |
p03000 | s070756187 | Wrong Answer | n, x = map(int, input().split())
l = list(map(int, input().split()))
cnt = 1
d = 0
for i in range(n):
d += l[i]
if d == x:
cnt += 1
break
elif d > x:
break
print(cnt) |
p02701 | s768218382 | Accepted | n=int(input())
strs=set()
for i in range(0,n):
temp=input()
strs.add(temp)
print(len(strs))
|
p03592 | s803616757 | Accepted | import sys
N, M, K = map(int, input().split())
for n in range(0, N+1):
for m in range(0, M+1):
if (N - n) * m + n * (M - m) == K:
print("Yes")
sys.exit()
print("No") |
p02778 | s328598588 | Accepted | s = len(input())
x = ''
for i in range(0, s):
x += 'x'
print(x) |
p02631 | s354937861 | Wrong Answer | import sys
input = sys.stdin.readline
def S():
return input().rstrip()
def I():
return int(input())
def MI():
return map(int, input().split())
n = I()
al = list(MI())
s = 0
for a in al:
s ^= a
ans = []
for a in al:
ans.append(str(s ^ a))
print(" ".join(ans[::-1]))
|
p03352 | s096255669 | Accepted | x = int(input())
b = []
for i in range(2,32):
for j in range(2, 10):
b.append(i**j)
b.sort()
ans = 1
for i in b:
if i <= x:
ans = i
else:
break
print(ans) |
p02761 | s601494775 | Wrong Answer | n,m=map(int,input().split())
ans=[0]*n
for _ in range(m):
s,c=map(int,input().split())
ans[s-1]=c
if n>1 and ans[0]==0:
print(-1)
exit()
elif n==1 and ans[0]==0:
print(0)
exit()
else:
for i in ans:
print(i,end="")
|
p03345 | s331794699 | Wrong Answer | a,b,c,k = map(int,input().split())
if k % 2 == 0:
if abs(a-b) >= 10*8:
print('Unfair')
else:
print(a-b)
else:
if abs(b-a) >= 10**8:
print('Unfair')
else:
print(b-a) |
p03163 | s744132440 | Accepted | import numpy as np
n,w=map(int,input().split())
dp=np.zeros(w+1,np.int64)
for i in range(n):
w,v = map(int,input().split())
dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
print(np.max(dp)) |
p03327 | s142940607 | Accepted | # 1回目から順に ABC001,ABC002...
# 1000 回目から 1998回目のコンテストを順に ABD001,ABD002...
# 1以上 1998以下の整数 N が与えられるので、
# N回目のコンテストの名前の最初の 3 文字を出力
N = int(input())
if N < 1000:
print('ABC')
else:
print('ABD') |
p03252 | s484992361 | Accepted | import sys
def o(c): return ord(c) - ord('a')
s, t = sys.stdin.read().split()
def main():
g1 = [set() for _ in range(26)]
g2 = [set() for _ in range(26)]
for i in range(len(s)):
a = o(s[i]); b = o(t[i])
g1[a].add(b); g2[b].add(a)
for i in range(26):
if len(g1[i]) >= 2 or len(g2[i]) >= 2:
print('No')
return
print('Yes')
if __name__ == '__main__':
main() |
p03555 | s354068194 | Accepted | S1 = input()
S2 = input()
if S1[::-1] == S2:
print("YES")
else:
print("NO")
|
p03289 | s346117552 | Wrong Answer | s = input()
ans = "AC"
if s[0] != 'A':
ans = "WA"
s = list(s)
s[0] = 'a'
f = 0
for i in range(2,len(s)-1):
if s[i] == "C":
if f:
ans = "WA"
else:
f = 1
s[i] = "c"
if not f:
ans = "WA"
for si in s:
if si not in "abcdefghijklmnopqrstuvwxyz":
print(si, 1)
ans = "WA"
print(ans)
|
p02712 | s075154302 | Accepted | n = int(input())
rslt = 0
for i in range(1, n+1):
if i % 3 == 0 or i % 5 == 0:
continue
else:
rslt += i
print(rslt) |
p04030 | s999902050 | Wrong Answer | s= input()+"x"
ans = ""
for i in range(len(s)-1):
if s[i]!="B" and s[i+1]!="B":
ans += s[i]
else:
continue
print(ans) |
p02595 | s445370465 | Accepted | import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7
def input():
return sys.stdin.readline()[:-1]
def mi():
return map(int, input().split())
def ii():
return int(input())
def i2(n):
tmp = [list(mi()) for i in range(n)]
return [list(i) for i in zip(*tmp)]
def main():
N, D = mi()
X, Y = i2(N)
print(sum(1 for i in range(N) if X[i]**2+Y[i]**2 <= D**2))
if __name__ == '__main__':
main() |
p02660 | s824988806 | Accepted | import math
from collections import Counter
N = int(input())
max_itr = math.ceil(math.sqrt(N))
factors = []
while True:
for i in range(2, max_itr):
if N%i == 0:
N = N // i
factors.append(i)
break
else:
if N != 1:
factors.append(N)
break
c = Counter(factors)
f = lambda x: math.floor((math.sqrt(8*x+1) - 1)/2)
print(sum(f(v) for v in c.values())) |
p02939 | s339590714 | Accepted | def resolve():
S = input()
cnt = 0
pre = ""
tmp = ""
for s in S:
tmp += s
if tmp != pre:
pre = tmp
tmp = ""
cnt += 1
print(cnt)
resolve()
|
p03852 | s030509049 | Accepted | c = input()
if c == 'a' or c =='i' or c == 'u' or c == 'e' or c =='o':
print('vowel')
else:
print('consonant') |
p02862 | s954045088 | Wrong Answer | import numpy as np
import math
def cmb(n, r, mod):
n_1 = 1
n_2 = 1
r = min(r, n-r)
for i in range(1, r+1):
n_1 = n_1 * i % mod
n_2 = n_2 * (n - i + 1) % mod
return (n_2 * pow(n_1, mod - 2, mod))%mod
mod = 10**9+7
X, Y = map(int, input().split())
x = (2*Y - X) // 3
y = (2*X - Y) // 3
if x < 0 or y < 0:
print(0)
else:
print(cmb(int(x+y), int(x), mod))
|
p03456 | s934600086 | Wrong Answer | from math import sqrt
a, b = map(str, input().split())
f = int(a+b)
#print(f)
for i in range(1, 101):
if sqrt(f) / i == i:
print('Yes')
exit()
print('No') |
p03971 | s043547958 | Wrong Answer | from sys import stdin
from math import ceil, floor
n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
s = list(stdin.readline().rstrip())
c = a + b
d = 0
e = 0
for i in range(n):
if d < c and s[i] == "a":
print("YES")
d += 1
elif d < c and e < b and s[i] == "b":
print("YES")
d += 1
e += 1
else:
print("NO") |
p02720 | s110049971 | Accepted | import queue
q = queue.Queue()
for i in range(1, 10): q.put(i)
K = int(input())
t = 0
ans = 0
while t < K:
t += 1
ans = q.get()
p = int(str(ans)[-1])
for i in range(-1, 2):
if 0 <= p+i < 10: q.put(int(str(ans) + str(p+i)))
print(ans)
|
p03495 | s703750444 | Accepted | from collections import Counter
n, k = map(int, input().split())
A = list(map(int, input().split()))
cnt_A = sorted(Counter(A).values())
ans = 0
if len(cnt_A) <= k:
print(ans)
else:
for i in range(len(cnt_A) - k):
ans += cnt_A[i]
print(ans) |
p03910 | s730061612 | Accepted | N = int(input())
for i in range(1,N+1):
if i*(i+1) >= 2*N:
n = i
break
for j in range(1,n+1):
if j == ((i*(i+1)//2)-N):
continue
print(j) |
p02783 | s815102660 | Accepted |
def main():
h, a = map(int, input().split())
if h % a == 0:
print(h // a)
else:
print(h // a + 1)
if __name__ == "__main__":
main()
|
p02801 | s406464097 | Wrong Answer | import string
print(type(string.ascii_lowercase))
input = input()
alphabets = string.ascii_lowercase
print(alphabets.index(input))
i = alphabets.index(input)
ans = alphabets[i + 1]
print(ans) |
p02789 | s468347491 | Accepted | a,b = map(int, input().split())
print("Yes" if a == b else "No") |
p03427 | s320977911 | Accepted | def digit_sum2(num):
total = 0
for digit in str(num):
total += int(digit)
return total
n = input()
l = len(n)
n = int(n)
print(max(digit_sum2(n), n // (10 ** (l-1)) - 1 + 9 * (l-1))) |
p02687 | s759672018 | Accepted | s = input()
if s == 'ABC':
print("ARC")
else:
print("ABC") |
p03779 | s763649422 | Accepted | n = int(input())
tmp = 0
num_list = []
for i in range(1,10**9):
if tmp < 10**9:
tmp += i
num_list.append(tmp)
else:
break
for i in range(len(num_list)):
if num_list[i] >= n:
print(i+1)
break |
p03827 | s651626060 | Wrong Answer | N = int(input())
S = list(input())
a = [0]*N
x = 0
for i in range(N):
if S[i] == 'I':
x += 1
a[i] = x
else:
x -= 1
a[i] = x
print(max(a)) |
p03289 | s096344381 | Wrong Answer | s=input()
result=True
total=0
for i in range(len(s)):
if i==0:
if s[i]!="A":
result=False
break
elif 2<=i<=len(s)-2:
if s[i]=="C":
total+=1
if total!=1:
result=False
break
else:
if s[i].islower()==False:
result=False
break
if result==False:
print("WA")
else:
print("AC") |
p02848 | s344318977 | Accepted | n=int(input())
s=input()
ans=''
for i in s:
if ord(i)+n>ord('Z'):
ans+=chr(ord(i)+n-26)
else:
ans+=chr(ord(i)+n)
print(ans) |
p03814 | s254855062 | Wrong Answer | S = input()
N = len(S)
Aflag = 0
Zflag = 0
for i in range(N):
if Aflag == 0 and S[i] == 'A':
Aflag = i
elif S[i] == 'Z':
Zflag = i
print(Zflag-Aflag+1)
|
p03328 | s656939832 | Accepted | a, b = map(int, input().split())
n = b - a - 1
print(n * (n + 1) // 2 - a) |
p02708 | s679153101 | Wrong Answer | import math
n,k = map(int,input().split())
#全部選ぶときの和の個数は0+1+2+ ~ +nの1+(n+1)n/2個
#k個は好きな選び方ができる。
#k個以上の数を選ぶときに「絶対に満たせない和の値」を考える。
#その数は10**100 + 10**100+1 + ... + 10*100+k-1 -1 の(k-1)k/2である。
result_before_division = 1+(n+1)*n/2 - (k-1)*k/2
result = result_before_division % (10**9 + 7)
print(result)
|
p03162 | s687683319 | Accepted | n = int(input())
abc = [ list(map(int,input().split())) for _ in range(n) ]
dp = [ [0,0,0] for _ in range(n) ]
dp[0] = abc[0]
for i in range(1,n):
# print("i={}".format(i))
dp[i][0] = max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0])
dp[i][1] = max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1])
dp[i][2] = max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2])
print(max(dp[n-1])) |
p03693 | s606720419 | Wrong Answer | i = int("".join(input().split()))
print(i) |
p03211 | s119184273 | Accepted | S = [list(map(int, i.split())) for i in input()]
num = []
for i in range(len(S)-2):
aa = []
aa.append(S[i])
aa.append(S[i+1])
aa.append(S[i+2])
aa = sum(aa, [])
aa = "".join(list(map(str, aa)))
test = abs(int(aa) - 753)
num.append(test)
minimum = min(num)
print(minimum) |
p02973 | s978943922 | Accepted | import sys
from bisect import bisect_left, insort_right
input = sys.stdin.readline
def main():
N = int(input())
A = [0] * N
for i in range(N):
A[i] = int(input())
colors = []
for a in A:
idx = bisect_left(colors, a)
if idx != 0:
colors.pop(idx - 1)
insort_right(colors, a)
ans = len(colors)
print(ans)
if __name__ == "__main__":
main()
|
p04029 | s203754180 | Accepted | N = int(input())
print(int(N * (N + 1) / 2)) |
p03971 | s437817635 | Wrong Answer | from sys import stdin
n, a, b = [int(x) for x in stdin.readline().strip().split()]
s = stdin.readline()
a = a + b
all_num = 0
oversea_num = 0
for i, t in enumerate(s):
if t == 'a' and all_num < a:
print('Yes')
all_num += 1
elif t == 'b' and oversea_num < b and all_num < a:
print('Yes')
all_num += 1
oversea_num += 1
else:
print('No') |
p03624 | s597563183 | Accepted | from string import ascii_lowercase as abc
s = input()
if set(abc) == set(s):
print('None')
else:
print(sorted(list(set(abc)-set(s)))[0]) |
p02744 | s694317959 | Accepted | from collections import defaultdict
import string
import sys
sys.setrecursionlimit(10 ** 7)
from functools import lru_cache
N = int(input())
alph = string.ascii_lowercase
def search(S, mx):
if len(S) == N:
print(S)
else:
for s in alph[: mx + 1]:
search(S + s, mx)
search(S + alph[mx + 1], mx + 1)
search('a', 0)
|
p02553 | s401507319 | Accepted |
[a,b,c,d] = list(map(int,input().split()))
dam=[]
dam.append(a*c)
dam.append(a*d)
dam.append(b*c)
dam.append(b*d)
print(max(dam)) |
p02700 | s799568736 | Accepted | turn = "A"
A, B, C, D = map(int, input().split(' '))
while A > 0 and B > 0:
if turn == "A":
C -= B
turn = "C"
if not C > 0:
print('Yes')
break
else:
A -= D
turn = "A"
if not A > 0:
print('No')
break |
p03986 | s570899723 | Wrong Answer | s = input()
count = 0
for i in range(len(s)):
if s[len(s) - i - 1] == 'T':
break
count += 1
print(count * 2) |
p02778 | s626673374 | Accepted | s = input()
for i in range(len(s)):
print("x", end="") |
p02793 | s699295181 | Accepted | #???
n=int(input())
a=list(map(int,input().split()))
MOD=10**9+7
def gcd(x,y):
if x<y:x,y=y,x
if y==0:return x
return gcd(x%y,y)
def lcm(x,y):
return x*y//gcd(x,y)
def inv(x):
return pow(x,MOD-2,MOD)
L=1
for i in a:
L=lcm(L,i)
L=L%MOD
ans=0
for i in a:
ans=(ans+L*inv(i))%MOD
print(ans) |
p02726 | s029569737 | Accepted | n,x,y=map(int,input().split())
x,y=x-1,y-1
ans=[0]*(n+1)
for i in range(n):
for j in range(i+1,n):
a=abs(i-j)
b=abs(i-x)+1+abs(y-j)
c=abs(y-i)+1+abs(x-j)
ans[min(a,b,c)]+=1
for i in range(1,n):
print(ans[i])
|
p03696 | s641408479 | Accepted | N = int(input())
S = input()
ans = ''
count = 0
for i in range(N):
if S[i] == '(':
count += 1
else:
count -= 1
if count < 0:
ans = '(' + ans
count += 1
ans += S[i]
if count > 0:
ans += ')' * count
print(ans) |
p03455 | s053571728 | Accepted | a, b = map(int, input().split())
if a*b %2 == 0:
print("Even")
else:
print("Odd") |
p02957 | s410040842 | Wrong Answer | a,b=map(int,input().split())
i=a+b/2
print(a)
print(b)
print(i)
if i.is_integer()==True:
print(i)
else:
print("IMPOSSIBLE") |
p03639 | s547953532 | Accepted | n = int(input())
lis = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
cnt4 = 0
for i in lis:
if i % 4 == 0:
cnt4 += 1
elif i % 2 == 0:
cnt2 += 1
else:
cnt1 += 1
if cnt1 - cnt4 > 1:
print("No")
elif cnt1 - cnt4 == 1:
if cnt2 == 0:
print("Yes")
else:
print("No")
else:
print("Yes")
|
p03437 | s013424081 | Accepted | X,Y = list(map(int,input().split()))
if X%Y == 0:
print(-1)
else:
print(X) |
p03262 | s439176813 | Accepted | # 最大公約数
def gcd(a,b):
while b != 0:
a,b = b, a%b
return a
n,x = map(int,input().split())
X = list(map(int, input().split()))
a = []
dist = []
if len(X) == 1:
print(abs(X[0]-x))
exit()
for i in range(len(X)):
a.append(abs(X[i]-x))
ans = 0
for d in a:
ans = gcd(ans,d)
print(ans) |
p02847 | s488038900 | Wrong Answer | s = input()
if s == "SUN":
print(7)
if s == "SAT":
print(6)
if s == "FRI":
print(5)
if s == "THU":
print(4)
if s == "WED":
print(3)
if s == "TUE":
print(2)
if s == "MON":
print(1)
|
p02571 | s030364193 | Accepted | #abc177_B_1
list_1 = list(str(input()))
list_2 = list(str(input()))
int_agg_count_max_diff = 10000
for i in range(len(list_1) - len(list_2) + 1):
list_1_tmp = list_1[i:i+len(list_2)]
int_count_max_diff = 0
for j in range(len(list_2)):
if list_1_tmp[j] != list_2[j]:
int_count_max_diff = int_count_max_diff + 1
if int_agg_count_max_diff > int_count_max_diff:
int_agg_count_max_diff = int_count_max_diff
print(int_agg_count_max_diff) |
p03095 | s240422546 | Accepted | from collections import Counter
n = int(input())
s = list(input())
C = Counter(s)
p = 1
for v in C.values():
p = p * (v+1) % (10**9 +7)
print(p-1)
|
p03427 | s971116595 | Accepted | n = input()
int_n = int(n)
# 解説通り
ans = int(n[0]) + 9 * (len(n) - 1)
for i in range(1, len(n)):
if n[i] != '9':
ans -= 1
break
print(ans)
|
p03659 | s019233880 | Wrong Answer | n = int(input())
a =[int(i) for i in input().split()]
b = sum(a) // 2
c = 0
for i in range(n):
c += a[i]
if c > b:
d = i
break
e = abs(sum(a[:d+1]) - sum(a[d+1:]))
f = abs(sum(a[:d]) - sum(a[d:]))
if e > f:
ans = f
else:
ans = e
if n == 2:
ans = e
print(ans) |
p03013 | s610570205 | Wrong Answer | N,M = map(int, input().split())
a_list = [int(input()) for _ in range(M)]
MOD = 10**9+7
dp = [0] * (10**5 + 3)
dp[1] = 0
dp[2] = 1
dp[3] = 2
for i in range(3, len(dp)):
dp[i] = dp[i-1] + dp[i-2]
res = 1
if M > 0:
bef = -1
for a in a_list:
res *= dp[a-bef]
res %= MOD
bef = a
else:
bef = 0
res *= dp[N-bef+1]
res %= MOD
print(res)
|
p02836 | s103994031 | Accepted | s=input()
c=0
for n,r in zip(s[:len(s)//2],s[::-1]):
if not n==r:
c+=1
print(c)
|
p02836 | s507677270 | Accepted | s = input()
cnt = 0
for i in range(len(s)//2):
if s[i] != s[i*(-1)-1]:
cnt += 1
print (cnt) |
p03449 | s672907112 | Accepted | N = int(input())
A = [list(map(int,input().split())) for i in range(2)]
for i in range(1,N):
A[0][i]=A[0][i]+A[0][i-1]
for i in range(N-2,-1,-1):
A[1][i]=A[1][i]+A[1][i+1]
for i in range(N):
A[0][i]+=A[1][i]
print(max(A[0])) |
p03339 | s050103989 | Accepted | n = int(input())
s = [int(si == "E") for si in input()]
a = [0] * (n + 1)
for i in range(n):
a[i + 1] = a[i] + s[i]
ans = n
for i in range(n):
ans = min(a[-1] - a[i + 1] + i - a[i], ans)
print(ans) |
p02624 | s164494846 | Wrong Answer | import numpy as np
n = int(input())
ans = np.zeros(n+1)
for i in range(1, n+1):
ans[i::i] += 1
ans *= np.arange(n+1)
# [0, f(1), ..., f(n)] * [0, 1, 2, ..., n]
print(sum(ans)) |
p02552 | s728080159 | Accepted | x=int(input())
print(0 if x==1 else 1) |
p02823 | s174795718 | Accepted | n,a,b=map(int,input().split())
c=min(a,b)
d=max(a,b)
e=min(2*n-a-b,a+b-2)
f=min(c-1,n-d)
if d-c==1:
print(f+1)
elif (d-c)%2==0:
print((d-c)//2)
else:
print((e+1)//2)
|
p03137 | s248061945 | Accepted | n,m = map(int, input().split())
a = sorted(list(map(int ,input().split())))
d = []
for i in range(m-1):
d += [a[i+1] - a[i]]
d.sort(reverse=True)
print(sum(d[n-1:])) |
p04019 | s269720215 | Wrong Answer | S=input()
ans="NO"
tate=False
yoko=False
n=S.count("N")
w=S.count("W")
s=S.count("S")
e=S.count("E")
if (n>0 and s>0) or (n==0 and s==0):
tate=True
if (e>0 and w>0) or (e==0 and w==0):
yoko=True
if tate and yoko:
ans="Yes"
print(ans) |
p03997 | s857939456 | Accepted | a = int(input())
a += int(input())
a *= int(input())
print(a//2) |
p03211 | s597194539 | Accepted | s=input()
ans= 1000
for i in range(len(s)-2):
tmp=int(s[i:i+3])
ans=min(ans, abs(tmp-753))
print(ans)
|
p03672 | s086005634 | Accepted | s = input()
f = False
sl = len(s)
while f == False:
sl -= 2
if s[0:sl//2] == s[(sl+1)//2:sl]:
f = True
print(sl)
|
p02953 | s254918187 | Wrong Answer | N = int(input())
H = [int(x) for x in input().split()]
for i in range(N-1):
if H[i] - H[i+1] == 1:
H[i] -= 1
flg=True
for i in range(N-1):
if H[i] - H[i+1] == 1:
flg=False
break
ans = 'Yes' if flg else 'No'
print(ans) |
p02598 | s213073003 | Accepted | N, K = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
minlen = 0
maxlen = 10**9
while maxlen-minlen > 1:
mid = (maxlen + minlen)//2
if mid == 0:
cur = 1e9
else:
cur = sum((a+mid-1)//mid - 1 for a in A)
if cur > K:
minlen = mid
else:
maxlen = mid
print(maxlen)
|
p03150 | s729807274 | Accepted | import sys
S = input()
for i in range(len(S) + 1):
for j in range(i, len(S) + 1):
erased = S[:i] + S[j:]
# print(i, j, erased)
if erased == "keyence":
print("YES")
sys.exit()
print("NO")
|
p02972 | s129632155 | Wrong Answer | #coding: utf-8
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N-1, -1, -1):
v = 0
for j in range(2*i-1, N, i+1):
if A[i] == 1:
v += 1
if A[i] == 1 and v % 2 == 0:
B.append(i+1)
elif A[i] == 0 and v % 2 == 1:
B.append(i+1)
B.sort()
print(len(B))
if len(B) != 0:
print(*B) |
p02970 | s424731825 | Accepted | n,d=map(int,input().split())
ans=n//((2*d)+1)
if n%((2*d)+1)==0:
print(ans)
else:
print(ans+1) |
p02759 | s814144922 | Accepted | import math
n = int(input())
print(math.ceil(n/2))
|
p03745 | s511302191 | Wrong Answer | n, *lst = map(int, open(0).read().split())
if n < 3:
print(0)
quit()
group = 0
start = lst[1] >= lst[0]
for i in range(2, n - 1):
if (lst[i] >= lst[i - 1]) != start:
start = (lst[i + 1] > lst[i])
group += 1
if (lst[-1] >= lst[-2]) != start:
group += 1
if group != 0:
group += 1
print(group) |
p03657 | s686586436 | Accepted | a, b = map(int, input().split())
if (a % 3 == 0) or (b % 3 == 0) or ((a + b) % 3 == 0):
print('Possible')
else:
print('Impossible')
|
p02994 | s640617939 | Accepted | N,L=map(int,input().split())
v=[L+i for i in range(N)]
ans=sum(v)-min(v,key=abs)
print(ans) |
p03943 | s722476483 | Accepted | a, b, c = sorted(list(map(int, input().split())))
if c == a + b:
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.