problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03767 | s482252173 | Accepted | import collections,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = sorted(LI())
deque = collections.deque()
for x in a:
deque.append(x)
ans = 0
for _ in range(N):
deque.popleft()
deque.pop()
ans += deque.pop()
print(ans)
|
p03625 | s067835242 | Accepted | N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
ans1 = 0
ans2 = 0
index = N
for i in range(N-1):
if A[i] == A[i + 1]:
ans1 = A[i]
index = i + 2
break
for j in range(index, N - 1):
if A[j] == A[j + 1]:
ans2 = A[j]
flag = 1
break
print(ans1*ans2)
|
p03695 | s304940329 | Wrong Answer | n = int(input())
a = list(map(int, input().split()))
p = set()
q = 0
for i in range(n):
if a[i] < 2800:
p.add(a[i]//400)
else:
q += 1
p = len(p)
print(p, p+q) |
p03693 | s359509125 | Accepted | x = int(input().replace(' ', ''))
print('NO' if x%4 else 'YES') |
p02754 | s540786039 | Accepted | N,A,B = map(int,input().split())
print(N//(A+B)*A + min(N%(A+B),A))
|
p02773 | s793731804 | Accepted | import numpy as np
N = int(input())
S = np.array([input() for _ in range(N)], dtype=str)
keys, values = np.unique(S, return_counts=True)
cnt = []
for k, v in zip(keys, values):
cnt.append([k, v])
cnt.sort(reverse=True, key=lambda x: x[1])
a = cnt[0][1]
ans = []
for k, v in cnt:
if v < a:
break
ans.append(k)
ans.sort()
for a in ans:
print(a)
|
p02691 | s732711200 | Accepted | from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i,j in enumerate(a):
b.append(i+j)
c.append(i-j)
d=Counter(c)
for i in b:
ans+=d.get(i,0)
print(ans) |
p03457 | s822518353 | Accepted | #!/usr/bin/env python3
(n, ), *p = [[*map(int, i.split())] for i in open(0)]
t, x, y = 0, 0, 0
for a, b, c in p:
d = abs(x - b) + abs(y - c) - a + t
if d <= 0 and d % 2 < 1:
t, x, y = a, b, c
else:
print("No")
exit()
print("Yes")
|
p03705 | s987326695 | Accepted | n,a,b = map(int, input().split())
Min, Max = a*(n-1)+b, b*(n-1)+a
print(Max-Min+1 if Max-Min+1>0 else 0) |
p02583 | s555620880 | Wrong Answer | import itertools
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for v in itertools.combinations(l, 3):
t = set(v)
print(v)
if len(t) == len(v) and (abs(v[0] - v[1]) < v[2] < v[0] + v[1]):
cnt += 1
print(cnt) |
p03145 | s765333016 | Accepted | a,b,c=map(int,input().split());print(int(a*b/2)) |
p03605 | s887050649 | Accepted | n=input()
if n[0]=="9" or n[1]=="9":
print("Yes")
else:
print("No")
|
p02785 | s751201198 | Accepted | # import itertools
# import math
def solve(N, K, H):
H.sort(reverse=True)
if N <= K:
return 0
for i in range(K):
H[i] = 0
return sum(H)
# N = int(input())
# S = input()
N, K = map(int, input().split())
H = list(map(int, input().split()))
# P = []
# S = []
# for i in range(N):
# pp, ss = map(int, input().split())
# P.append(pp)
# S.append(ss)
print(solve(N, K, H))
|
p03161 | s500066303 | Accepted | N, K = map(int, input().split())
h = [i for i in map(int, input().split())]
memo = [0]*N
for i in range(N):
mini = 10**10
for j in range(i-min(i, K), i, 1):
if memo[j] + abs(h[i]-h[j]) < mini:
mini = memo[j] + abs(h[i]-h[j])
if i != 0:
memo[i] = mini
print(memo[N-1]) |
p02730 | s531285966 | Accepted | s=input()
def judge(s):
for i in range(len(s)):
if s[i]!=s[-1-i]:
return False
return True
if judge(s) and judge(s[:(len(s)-1)//2]) and judge(s[(len(s)+3)//2-1:]):
print("Yes")
else:
print("No") |
p02768 | s062195117 | Accepted | k = 2 *10**5
mod = 10**9+7
n, a, b = map(int,input().split())
modinv_table = [-1]*(k+1)
for i in range(1,k+1):
modinv_table[i] = pow(i,-1,mod)
def binomial_coefficients(n,k):
ans = 1
for i in range(k):
ans *= n-i
ans *= modinv_table[i+1]
ans %= mod
return ans
print((pow(2,n,mod)-binomial_coefficients(n,a)-binomial_coefficients(n,b)-1)%mod) |
p03799 | s374792739 | Accepted | def LI():
return list(map(int, input().split()))
S, c = LI()
if 2*S >= c:
ans = c//2
else:
ans = S
c -= 2*S
ans += c//4
print(ans)
|
p03637 | s542875556 | Accepted | with open(0) as f:
N, *a = map(int, f.read().split())
i, j, k = 0, 0, 0
for x in a:
if x%4 == 0:
i += 1
elif x%2 == 0:
j += 1
else:
k += 1
if j > 0:
k += 1
print('Yes' if k <= i+1 else 'No')
|
p02811 | s197803154 | Wrong Answer | k, x = map(int, input().split())
print('Yes') if k*500==x else print('No') |
p03012 | s553475298 | Accepted | n = int(input())
w = list(map(int, input().split()))
arr = []
for i in range(n):
a = w[:i]
b = w[i:]
arr.append(abs(sum(a) - sum(b)))
print(min(arr)) |
p04011 | s591819871 | Wrong Answer | n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n-k>0:
a=n-3
b=a*y
c=b+x*3
print(c)
else:
print(n*x)
|
p03592 | s622306966 | Wrong Answer | N, M, K = map(int, input().split())
ok = False
for i in range(N + 1):
now = M * i
for j in range(M + 1):
now -= j * i
now += j * (N - i)
if now == K:
ok = True
if ok:
print("Yes")
else:
print("No") |
p03377 | s342688573 | Accepted | a,b,x = map(int,input().split())
if x>=a and x<=a+b:
print("YES")
else:
print("NO") |
p02784 | s872783539 | Wrong Answer | H,N=map(int, input().split())
A = list(map(int, input().split()))
if(max(A) > H):
print("Yes")
elif(sum(A) > H):
print("Yes")
else:
print("No")
|
p03555 | s683395017 | Wrong Answer | print(['No','Yes'][input()==input()[::-1]]) |
p02748 | s970213803 | Wrong Answer | A,B,M=map(int,input().split())
x = [0] * M
y = [0] * M
c = [0] * M
a = [0] * M
b = [0] * M
#0から入ってる
a=input().split()
b=input().split()
#ただの最小
mina=int(min(a))
minb=int(min(b))
nomal_count=mina+minb
#割引
wari_count=0
for i in range(M):
x,y,c=map(int,input().split())
now_count=int(a[x-1])+int(b[y-1])-c
if nomal_count>now_count:
wari_count=now_count
print(min(nomal_count,wari_count)) |
p03524 | s522749165 | Accepted | s = list(input())
ac, bc, cc = 0, 0, 0
for i in range(len(s)):
if s[i] == 'a':
ac += 1
elif s[i] == 'b':
bc += 1
else:
cc += 1
if abs(ac-bc) > 1 or abs(ac-cc) > 1 or abs(bc-cc) > 1:
print('NO')
else:
print('YES') |
p03324 | s587421994 | Accepted | a,b = map(int,input().split())
num = 100**a
ans = num*b
if b!= 100:
print(ans)
else:
print(ans+num)
|
p02690 | s171714175 | Accepted | import sys
X = int(input())
i = 0
while 1:
i += 1
for j in range(-i+1, i):
if i**5 - j**5 == X:
print(i, j)
sys.exit() |
p02727 | s481137155 | Accepted | # import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
def main():
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
p = p[:X]
q = q[:Y]
all = p + q + r
all.sort(reverse=True)
all = all[:X+Y]
res = sum(all)
print(res)
main()
|
p03557 | s642761770 | Accepted | import bisect
n = int(input())
lstA = sorted(list(map(int,input().split())))
lstB = sorted(list(map(int,input().split())))
lstC = sorted(list(map(int,input().split())))
ans = 0
for i in range(n):
num = lstB[i]
top = bisect.bisect_left(lstA, num)
btm = n - bisect.bisect_right(lstC, num)
ans += top*btm
print(ans) |
p02718 | s318731036 | Wrong Answer | N, M=map(int,input().split())
alist = list(map(int,input().split()))
alist.sort(reverse = True)
su = 0
for i in alist:
su += i
if alist[M-1] >= 1/(4*su):
print("Yes")
else:
print("No") |
p02630 | s060412180 | Wrong Answer | n = int(input())
*a, = map(int,input().split())
g = []
M = 10**5+1
for i in range(1,M):
g.append((i,0))
g = dict(g); s = 0
for A in a:
g[A] += 1
s += A
q = int(input())
for loop in range(q):
b,c = map(int,input().split())
if g[b] == 0:
print(s)
continue
s += g[b] * (c - b)
g[c] += g[b]
g[b] == 0
print(s)
|
p02677 | s286521369 | Accepted | import math
a, b, h, m = map(int, input().split())
long = 360 * h / 12 + 360 / 12 * m / 60
short = 360 * m / 60
# long *= math.pi / 180
# short *= math.pi / 180
if True:
theta = abs(long - short) * math.pi / 180
B = a * math.cos(theta) - b
A = a * math.sin(theta)
print(math.sqrt(A*A + B*B)) |
p02766 | s906092153 | Wrong Answer | n, k = map(int, input().split())
i = 1
while k ** i < n:
i += 1
print(i) |
p02996 | s847401864 | Accepted | n = int(input())
a=[]
time=0
ans=True
for i in range(n):
s,p=map(int,input().split())
a+=[[s, p] ]
import operator as op
a.sort(key = op.itemgetter(1))
for i in range(n):
time+=a[i][0]
if(time>a[i][1]):
ans=False
break
if ans:
print("Yes")
else:
print("No")
|
p02603 | s290628435 | Accepted | n = int(input())
A = list(map(int, input().split()))
p = 1000
s = 0
for i, j in zip(A, A[1:]):
if i < j:
d, m = divmod(p, i)
s += d
p = m
elif i > j:
p += s * i
s = 0
if s != 0:
p += s * A[-1]
print(p) |
p03131 | s360777502 | Accepted | # coding: utf-8
K,A,B=map(int,input().split())
b_count=1
b_chenge_count=0
if B-A<=2:
b_count+=K
else:
b_chenge_count=max(0,int((K-(A-1))/2))
b_count=b_chenge_count*(B-A)+(A)+(K-(A-1)-b_chenge_count*2)
print(b_count) |
p02714 | s155978423 | Accepted | n = int(input())
s = list(input())
r = s.count('R')
g = s.count('G')
b = len(s) - r - g
ans = r*g*b
for i in range(n-2):
for j in range(i+1,i+((n-i-1)//2)+1):
if s[i] != s[j] and s[i] != s[2*j - i] and s[j] != s[2*j - i]:
ans -= 1
print(ans) |
p02973 | s593554594 | Accepted | n=int(input())
c=[]
hc=0
for i in range(n):
a=int(input())
l,r=-1,hc
while r-l!=1:
t=(l+r)//2
if c[t]<a:
r=t
else:
l=t
if r==hc:
c.append(a)
hc+=1
else:
c[r]=a
print(hc) |
p02595 | s601320559 | Wrong Answer | N,D=map(int, input().split())
ans=0
for _ in range(N):
x,y=map(int, input().split())
if x*x + y*y >= D*D:
ans+=1
print(ans) |
p02778 | s267989851 | Wrong Answer | S = input()
N = (len(S))
for i in range(N+1):
S = S[:i-1] + 'x' + S[i:]#i番目の文字をxに変える
S = S[:N-1] + '' + S[N:]#i番目の文字をxに変える
print(S) |
p02847 | s771371786 | Wrong Answer | import sys
# input = sys.stdin.readline
def main():
S = input()
if S == "SUN":
print(7)
elif S == "MON":
print(6)
elif S =="TUE":
print(5)
elif S =="WEB":
print(4)
elif S =="THU":
print(3)
elif S =="FRI":
print(2)
else:
print(1)
if __name__ == "__main__":
main() |
p02775 | s781389853 | Wrong Answer | S = input()[::-1]
l = len(S)
dp = [[0]*2 for _ in range(l+1)]
for i in range(l):
dp[i+1][0]=min(dp[i][1]+10-int(S[i]),dp[i][0]+int(S[i]))
dp[i+1][1]=min(dp[i][1]+10-int(S[i])-1,dp[i][0]+int(S[i])+1)
print(min(dp[-1][0],dp[-1][1]+1)) |
p02748 | s520655085 | Accepted | a,b,m=map(int,input().split())
reizoko=list(map(int,input().split()))
renji=list(map(int,input().split()))
ans=min(reizoko)+min(renji)
for i in range(m):
x,y,c=map(int,input().split())
cost=reizoko[x-1]+renji[y-1]-c
ans=min(ans,cost)
print(ans) |
p03150 | s049408745 | Accepted | s=input()
for i in range(len(s)):
for j in range(len(s)-i):
#print(s[:i],s[i+j:])
if s[:i]+s[i+j:]=="keyence":
print("YES")
exit()
print("NO") |
p03150 | s032136622 | Accepted | l = list(input())
ans = list("keyence")
minus = len(l)-7
for i in range(len(l)-minus):
l1 = l[:i]+l[i+minus:]
if l1 == ans:
print("YES")
exit()
print("NO")
|
p02630 | s957525078 | Wrong Answer | N = int(input())
nums = list(map(int, input().split()))
Q = int(input())
operations = [list(map(int, input().split())) for _ in range(Q)]
mappings = [ 0 for __ in range(10**5+1)]
answer = 0
for b, c in operations:
mappings[b] = c
for num in nums:
answer += mappings[num]
print(answer) |
p02923 | s449572690 | Accepted | n=int(input())
a=list(map(int,input().split()))
b,c,d,e=[0,0,0,0]
for i in range(1,n):
if(a[i]>a[i-1]):
if(d>e):
e=d
d=0
else:
d+=1
if(d>e):
e=d
print(e) |
p02778 | s198235808 | Accepted | S = input()
a = len(S)
print(a*"x") |
p03612 | s954976241 | Wrong Answer | n = int(input())
a = list(map(int,input().split(' ')))
ans = 0
for i in range(n):
if i ==0 and a[0]==1:
a[0],a[1] = a[1],a[0]
ans += 1
continue
if i<n-1 and i+1 == a[i] and i+2 ==a[i+1]:
a[i],a[i+1] = a[i+1],a[i]
if i+1 ==a[i] and i+1 != a[i-1]:
a[i-1],a[i] = a[i],a[i-1]
ans += 1
print(ans) |
p02621 | s537510416 | Accepted | x=int(input())
print(x+x**2+x**3) |
p03449 | s372469605 | Wrong Answer | N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(N-1):
ans += a[i]
if sum(a[i+1:]) < sum(b[i:]):
ans += sum(b[i:])
break
if i == N-2:
ans += b[-1]
if N == 1:
print(a[0]+b[0])
else:
print(ans)
|
p02771 | s659026889 | Accepted | s = set(map(int, input().split()))
if len(s) == 2:
print("Yes")
else:
print("No") |
p02910 | s470148113 | Wrong Answer | s=list(input())
ans='YES'
n=len(s)
for i in range(n):
if i%2:
if s[i]=='R': ans='NO';break
else:
if s[i]=='L': ans='NO';break
print(ans) |
p03043 | s786901848 | Accepted | import math
N,K = (int(x) for x in input().split())
p = 0
for i in range(1,N+1):
if i < K:
times = math.ceil(math.log2(K/i))
p = p + (1/N)*(1/2)**times
else:
p = p + (1/N)
print(p)
|
p02900 | s430851608 | Accepted | #!/usr/bin/env python3
# input = stdin.readline
def main():
A,B = map(int,input().split())
def primeLst(x):
acc = []
f = 2
while f * f <= x:
if x % f == 0:
acc.append(f)
x //= f
else:
f += 1
if x != 1:
acc.append(x)
return acc
a = set(primeLst(A))
b = set(primeLst(B))
if len(a) * len(b) == 0:
ans = 1
else:
ans = len(a&b) + 1
print(ans)
return
if __name__ == '__main__':
main()
|
p03493 | s315919724 | Accepted | # -*- coding: utf-8 -*-
## Library
from fractions import gcd
import math
from math import ceil,floor
import collections
## input
# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))
S=input()
## Logic
ans=0
for i in range(0,len(S)):
if S[i]=="1":
ans+=1
print(ans)
|
p04043 | s166771302 | Wrong Answer | ln = sorted(list(map(int, input().split())))
if ln[0] == ln[1] ==5 and ln[2] ==7:
print('Yes')
else:
print('No')
|
p02754 | s285584928 | Wrong Answer | n,a,b = map(int,input().split())
dars = n // (a+b)
amari = n % (a+b)
if amari < b:
ans = dars*a + amari
else:
ans = dars*a + a
print(ans) |
p03274 | s810728129 | Accepted | n,k,*x=map(int,open(0).read().split())
ans=float('inf')
if 0 in x:
k-=1
n-=1
del x[x.index(0)]
if k==0:
print(0)
else:
for i in range(n-k+1):
ans=min(ans,abs(x[i])+abs(x[i]-x[i+k-1]))
for i in range(k-1,n):
ans=min(ans,abs(x[i])+abs(x[i]-x[i-(k-1)]))
print(ans) |
p02622 | s178750287 | Wrong Answer | def ABC172_B():
s = input()
t = input()
counter=0
for i in range(len(s)):
if s[i] != t[i]:
counter += 1
if counter == len(s):
print(counter)
else:
print(min(counter,len(s)-counter))
ABC172_B()
|
p02695 | s257901351 | Wrong Answer | # -*- coding: utf-8 -*-
"""
Created on Sat May 2 20:59:14 2020
"""
import sys
#import numpy as np
import itertools
sys.setrecursionlimit(10 ** 9)
N, M, Q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(Q)]
A = itertools.combinations_with_replacement([i for i in range(1,M)],N)
ans = 0
for l in A:
tmp = 0
for a,b,c,d in abcd:
if l[b-1] - l[a-1] == c:
tmp += d
ans = max(ans, tmp)
print(ans)
|
p02613 | s428890448 | Accepted | N = int(input())
judge = []
for i in range(N):
judge.append(input())
counter = [0, 0, 0, 0]
for i in range(N):
if judge[i] == "AC":
counter[0] += 1
if judge[i] == "WA":
counter[1] += 1
if judge[i] == "TLE":
counter[2] += 1
if judge[i] == "RE":
counter[3] += 1
print("AC x " + str(counter[0]))
print("WA x " + str(counter[1]))
print("TLE x " + str(counter[2]))
print("RE x " + str(counter[3])) |
p03617 | s857028224 | Accepted | Q,H,S,D = map(int,input().rstrip().split(' '))
N = int(input())
one = min(S,2*H,4*Q)
two = min(D,2*one)
ans = two*(N//2)+one*(N%2)
print(ans) |
p03243 | s549295442 | Wrong Answer |
n = int(input())
a = 0
if n % 111 == 0:
print(n)
else:
a = n // 111
print(a)
print((a+1) * 111)
|
p03456 | s514391730 | Wrong Answer | # -*- coding: utf-8 -*-
a,b = map(int,input().split())
"""
if b < 10:
number = 10 * a + b
if 10 <= b < 100:
number = 100 * a + b
if b == 100:
number = 1000 * a + b
"""
number = 10 ** len(str(b)) * a + b
ans = "No"
for i in range(4, 101):
if i ** 2 == number:
ans = "Yes"
print(ans)
|
p03997 | s292256104 | Wrong Answer | a = int(input())
b = int(input())
h = int(input())
s = (a+b)*h/2
print(s) |
p02756 | s322201278 | Wrong Answer | # input1 = list(map(int, (input().split())))
S = input()
N = int(input())
c = False
for i in range(N):
Q = list(input().split())
a = int(Q[0])
if a == 1:
c = not c
elif a == 2:
if c == True:
S = S[::-1]
b = int(Q[1])
if b == 1:
S = Q[2] + S
elif b == 2:
S = S + Q[2]
if c == True:
S = S[::-1]
print(S)
|
p02613 | s341329553 | Accepted | n = int(input())
l =[input() for _ in range(n)]
a=0
b=0
c=0
d=0
for i in l:
if i == "AC":
a += 1
if i == "WA":
b += 1
if i == "TLE":
c += 1
if i == "RE":
d += 1
print("AC x "+str(a))
print("WA x "+str(b))
print("TLE x "+str(c))
print("RE x "+str(d)) |
p02705 | s644160141 | Accepted | import math
r = int(input())
ans = 2 * math.pi * r
print(ans) |
p02823 | s724899352 | Accepted | N, A, B = map(int, input().split())
D = B - A
if D % 2 == 0:
print(D // 2)
else:
print((D - 1) // 2 + min(A - 1, N - B) + 1) |
p03221 | s730879042 | Accepted | N, M = map(int, input().split())
l = []
for i in range(M):
p, y = list(map(int, input().split()))
l.append([i+1, p, y, ""])
l = sorted(l, key=lambda x: x[2])
cnt = [1]*(N+1)
for i in range(M):
l[i][3] = str(l[i][1]).zfill(6) + str(cnt[l[i][1]]).zfill(6)
cnt[l[i][1]] += 1
l = sorted(l, key=lambda x: x[0])
for i in range(M):
print(l[i][3]) |
p03680 | s423126119 | Wrong Answer | n = int(input())
a = []
for i in range(n): a.append(int(input()))
cur = 0
for i in range(10**9):
if a[cur] == 2:
print(cur)
exit()
cur = a[cur]-1
print(-1) |
p02659 | s186869202 | Accepted | import math
a,b=input().split()
a=int(a)
b= int(b.replace(".",""))
print(a*b//100)
|
p03745 | s530411603 | Accepted | n = int(input())
a = list(map(int, input().split()))
plus, minus = 0, 0
ans = 1
for i in range(n-1):
if a[i]<a[i+1]: plus = 1
elif a[i]>a[i+1]: minus = 1
if plus==minus==1:
plus, minus = 0, 0
ans += 1
print(ans)
|
p02910 | s341710938 | Wrong Answer | s=input()
for i in range(len(s)):
if (i+1)%2==0:
if s[i]=="R":
print(i+1)
print("No")
exit()
else:
if s[i]=="L":
print(i+1)
print("No")
exit()
print("Yes") |
p03162 | s435465673 | Wrong Answer | N = int(input())
l = []
for _ in range(N):
a, b, c = map(int, input().split())
l.append([a,b,c])
dp = [0]*N
choice = [-1] * N
for i in range(3):
tmp = l[0][i]
if tmp > dp[0]:
dp[0] = tmp
choice[0] = i
for i in range(1, N):
for j in range(3):
tmp = l[i][j] + dp[i-1]
if tmp > dp[i] and choice[i-1] != j:
dp[i] = tmp
choice[i] = j
print(dp[N-1]) |
p03774 | s650411323 | Accepted | n, m = map(int, input().split())
ab = list(list(map(int, input().split())) for _ in range(n))
cd = list(list(map(int, input().split())) for _ in range(m))
for j in range(n):
a, b = ab[j][0], ab[j][1]
ans, res = 0, 1001001001
for i in range(m):
c, d = cd[i][0], cd[i][1]
if abs(a-c)+abs(b-d) < res:
res = abs(a-c)+abs(b-d)
ans = i+1
print(ans) |
p04019 | s720244953 | Accepted | S = input()
ans = True
if ('S' in S) ^ ('N' in S):
ans = False
if ('W' in S) ^ ('E' in S):
ans = False
if ans:
print('Yes')
else:
print('No')
|
p02833 | s370552227 | Wrong Answer | n = int(input())
if n == 0:
print(1)
elif n%2 == 1:
print(0)
else:
answer = 0
count = 1
n=n/2
while 5**count <= n:
answer+=int(n//5**count)
count+=1
print(answer) |
p02988 | s428267796 | Accepted | from itertools import permutations
n = int(input())
*p, = map(int, input().split())
ans = 0
for j, k in enumerate(p[:-2]):
a, b, c = k, p[j+1], p[j+2]
if a < b < c or c < b < a:
ans += 1
print(ans) |
p03475 | s128555021 | Wrong Answer | n=int(input())
c=[0]*(n-1)
s=[0]*(n-1)
f=[0]*(n-1)
for i in range(n-1):
c[i],s[i],f[i]=map(int,input().split())
for i in range(n-1):
t=s[i]+c[i]
for j in range(i+1,n-1):
if t>=s[j]:
t+=f[j]-t%f[j]+c[j]
else:
t=s[j]+c[j]
print(t)
print('0') |
p04012 | s036270967 | Accepted | #coding:utf-8
w = input()
for i in range(len(w)):
if w.count(w[i]) % 2 != 0:
print('No')
exit()
print('Yes')
|
p02792 | s613579763 | Wrong Answer | n = int(input())
count = 0
for a in range(1, n):
for b in range(1, n):
if(a == b):
count += 1
break
ah = str(a)[0]
al = str(a)[-1]
bh = str(b)[0]
bl = str(b)[-1]
if ah == bl and bh == al:
count += 1
print(count)
|
p03433 | s444649891 | Accepted | N=int(input())
A=int(input())
if N%500<=A:
print("Yes")
else:
print("No")
|
p02701 | s870148694 | Accepted | N = int(input())
keihin =[]
cnt = 0
for i in range(N):
keihin.append(str(input()))
print(len(set(keihin))) |
p02552 | s162168081 | Accepted | print(1-int(input())) |
p03611 | s049753851 | Accepted | from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools
logging.basicConfig(level=logging.ERROR)
input = sys.stdin.readline
setrecursionlimit(1000000)
def main():
n = int(input())
a = list(map(int,input().split()))
d = defaultdict(int)
for i in a:
d[i-1] += 1
d[i] += 1
d[i+1] += 1
ans = -1
for i in range(-1,max(a)+3):
if(d[i] > ans):
ans = d[i]
print(ans)
main() |
p03962 | s230058524 | Accepted | import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
a,b,c=MI()
print(len(list(set([a,b,c]))))
main()
|
p03711 | s817294628 | Accepted | x, y = list(map(int,input().split()))
a= [1,3,5,7,8,10,12]
b= [4,6,9,11]
c= [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
print('Yes')
else:
print('No') |
p03627 | s084191105 | Accepted | from collections import Counter
N = int(input())
c = Counter(map(int, input().split()))
usables = sorted([(k, v) for k, v in c.items() if v >= 2])
if len(usables) <= 1:
print(0)
else:
if usables[-1][1] >= 4:
print(usables[-1][0] ** 2)
else:
print(usables[-1][0] * usables[-2][0])
|
p02866 | s364392875 | Accepted | n = int(input())
li = [int (i) for i in input().split()]
cnt = [0] * n
for i in li:
cnt[i] += 1
ans = 1
for i in li[1:]:
ans = ans*cnt[i-1]%998244353
if li[0] != 0:
ans = 0
print(ans)
|
p03150 | s974146960 | Accepted | S = input()
key = 'keyence'
ans = 'NO'
for i in range(7):
f = key[:i]
if S[:i] == f:
if key[i:][::-1] == S[::-1][:7-i]:
ans = 'YES'
break
print(ans) |
p03220 | s472478228 | Accepted | n = int(input())
t, a = map(int,input().split())
h = list(map(int,input().split()))
atlist = []
for i in h:
atlist.append(abs(a - (t - i * 0.006)))
print(atlist.index(min(atlist)) + 1) |
p02657 | s815097800 | Wrong Answer | import sys
def input():
return sys.stdin.readline()[:-1]
a, b= input().split()
a = int(a)
b = int(b * 100)
output = a * b // 100
print(output)
|
p03998 | s822557844 | Accepted | S={c:list(input()) for c in "abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper()) |
p03680 | s672589331 | Wrong Answer | n=int(input())
l=[]
for _ in range(n):
a=int(input())
l.append(a)
count=1
result=l[0]
f=-1
while n>0:
result=l[result-1]
if result==l[1]:
f=count
count+=1
n-=1
print(f)
|
p03377 | s477651535 | Accepted | a, b, x = map(int, input().split())
ans = "YES" if a <= x <= a + b else "NO"
print(ans)
|
p03062 | s817975454 | Accepted | N = int(input())
A = list(map(int,input().split()))
ans = 0
m = 10**10
k = 0
for i in range(N):
ans += abs(A[i])
m = min(m,abs(A[i]))
if A[i] < 0:
k += 1
if k % 2 == 0:
print(ans)
else:
print(ans - 2*m) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.