problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p02730 | s478065285 | Accepted | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
s = input().rstrip()
n = len(s)
t = s[0:(n-1)//2]
q = s[(n+2)//2:n]
if s == s[::-1] and t == t[::-1] and q == q[::-1]:
print("Yes")
else:
print("No")
|
p02988 | s996602923 | Wrong Answer | n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-2):
if p[i-1]<p[i]<p[i+1]:
ans+=1
else :
ans+=0
print(ans) |
p02793 | s543859456 | Accepted | M=10**9+7
n=int(input())
a=list(map(int, input().split()))
def f(x, y):
while y: x,y=y,x%y
return x
l,r=a[0],1
for i in range(1,n):
g=f(l,a[i])
s,t=l//g,a[i]//g
l,r=s*t*g,(r*t+s)%M
print(r) |
p02647 | s392596635 | Accepted | import numpy as np
from numba import njit, i8
n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))
@njit(i8[:](i8, i8, i8[:]), cache=True)
def solve(n, k, arr):
for i in range(min(k, 50)):
tmp_arr = np.zeros(n + 2, np.int64)
for i, power in enumerate(arr):
tmp_arr[max(0, i - power + 1)] += 1
tmp_arr[min(n + 1, i + power + 2)] -= 1
arr = np.cumsum(tmp_arr)[1:-1]
return arr
print(*solve(n, k, arr)) |
p02923 | s095112062 | Wrong Answer | m=int(input())
h=list(map(int,input().split()))
ans1=[]
ans=0
if m>1:
for x in range(m-1):
if h[x]<h[x+1]:
ans1.append(ans)
ans=0
else:
ans+=1
ans1.append(ans)
print(max(ans1))
else:
print(1) |
p02639 | s616193422 | Accepted | a = input().split()
for i in range(5):
if i == int(a[i])-1:
continue
else:
print(i+1) |
p03910 | s744358652 | Accepted | n = int(input())
x,cs = 1,1
while n>=cs:
x +=1
cs += x
[print(i) for i in range(1,x+1) if i != cs-n] |
p03289 | s791292880 | Accepted | import re
s = input()
s1 = re.fullmatch(r"A([a-z]+)C([a-z]+)", s)
if s1 == None:
print("WA")
else:
print("AC")
|
p03293 | s883334209 | Wrong Answer | def main():
s, t = input(), input()
for _ in range(len(s) - 1):
if s == t:
print("Yes")
break
s = s[-1] + s[:-1]
else:
print("No")
if __name__ == "__main__":
main()
|
p03665 | s652260566 | Wrong Answer | n,p = map(int,input().split())
a = list(map(int,input().split()))
odd = 0
even = 0
for ai in a:
if(ai%2==0):
even += 1
else:
odd += 1
if(p==1)&(odd==0):
print(0)
elif(p==1)&(even==0):
print(2**n)
else:
print(2**(n-1)) |
p03951 | s142151875 | Wrong Answer | N=int(input())
s=str(input())
t=str(input())
c=0
tmp=0
S=list(s)
T=list(t)
for i in range(N):
if s[N-i-1:N-1]==t[0:i]:
c=i+1
print(2*N-c)
|
p02780 | s738993522 | Accepted | N,K = map(int,input().split())
p = [int(x) for x in input().split()]
cnt = 0
for i in range(K):
cnt += p[i]
ans = cnt
for i in range(1,N-K+1):
cnt -= p[i-1]
cnt += p[K+i-1]
ans = max(cnt,ans)
print((ans+K)/2) |
p03351 | s488840019 | Accepted | a, b, c, d = map(int,input().split())
if abs(a-c) <= d:
print("Yes")
elif abs(a-b) <= d and abs(b-c) <= d:
print("Yes")
else:
print("No") |
p03077 | s861845197 | Accepted | n = int(input())
x = min([int(input()) for _ in range(5)])
a, b = divmod(n, x)
if b == 0:
print(5+(a-1))
else:
print(5+a)
|
p03427 | s251974894 | Accepted | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n = list(map(int, input()))
ans = sum(n)
s = 0
for i,num in enumerate(n):
if num>=1:
ans = max(ans, s + (num-1) + 9*(len(n)-i-1))
s += num
print(ans) |
p03241 | s035337727 | Wrong Answer | import math
n,m = map(int,input().split())
ans = 1
for i in range(2,math.ceil(math.sqrt(m))):
if m % i == 0:
if m // i >= n:
ans = i
print(ans)
|
p03162 | s449025056 | Wrong Answer | # N回ループで、ABCのうち最大を選択、記録して翌日はABCのうち前日と異なる最大値
N = int(input())
H = [0]*N
abc = list(map(int, input().split()))
H[0] = max(abc)
k = abc.index(H[0])
for i in range(1, N):
abc = list(map(int, input().split()))
# kは前日に選択した0,1,2のいずれかとして
H[i] = max(abc[k-1],abc[(k+1)%3])
k = abc.index(H[i])
print(sum(H)) |
p03030 | s865071732 | Wrong Answer | def main():
n = int(input())
a = [list(input().split()) for i in range(n)]
s = sorted(a, key=lambda x:(x[0],-int(x[1])))
for i in a:
print(s.index(i)+1)
if __name__ == '__main__':
main()
|
p03673 | s835168848 | Accepted | import math
N = int(input())
x = list(map(int, input().split()))
y = []
if N%2 == 0:
for i in range(N//2):
y.append(x[N-1-2*i])
for i in range(N//2):
y.append(x[2*i])
if N%2 == 1:
for i in range(math.ceil(N/2)):
y.append(x[N-1-2*i])
for i in range(math.floor(N/2)):
y.append(x[2*i+1])
print(*y) |
p04033 | s926949750 | Wrong Answer | a, b = map(int, input().split())
if a < 0 and b > 0:
print("Zero")
elif a > 0:
print("Positive")
elif b < 0 and a < 0:
if abs(a) + abs(b) % 2 == 0:
print("Negative")
else:
print("Positive")
|
p03417 | s109025833 | Accepted | n, m = map(int, input().split())
if n == m == 1:
print(1)
elif n == 1 or m == 1:
print(n*m-2)
else:
print((n-2)*(m-2))
|
p02935 | s592510012 | Wrong Answer | def resolve():
N = int(input())
v = list(map(int, input().split()))
V = sorted(v)
one = (V[0]+V[1])/2
ans = [one]
for i in range(2, N):
ans.append((one+V[i])/2)
print(max(ans))
resolve() |
p03001 | s274340610 | Wrong Answer | import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)
W, H, x, y = rl()
area = H*W*0.5
flag = 0
if x+x == W or y+y == H:
flag = 1
print(area, flag)
|
p02618 | s871982413 | Wrong Answer | import random
D = int(input())
c_list = list(map(int, input().split()))
for i in range(D):
S_list = list(map(int, input().split()))
for i in range(1,D+1):
print(i)
# print(random.randint(1,26))
|
p03339 | s570198673 | Accepted | n = int(input())
s = input()
e = s.count("E")
w = n - e
ans = 10**9
if s[0] == "W":
cnt = e
else:
cnt = e-1
num = cnt
for i in range(n-1):
if s[i] == s[i+1] and s[i] == "E":
cnt -= 1
elif s[i] == s[i+1]:
cnt += 1
ans = min(ans,cnt,num)
ans = max(ans,0)
print(max(ans,0)) |
p03327 | s674304090 | Accepted | print("ABC" if int(input()) < 1000 else "ABD") |
p02802 | s335830091 | Accepted | n, m = map(int, input().split())
res1, res2 = 0, 0
l = [0] * (n + 1)
for _ in range(m):
p, s = input().split()
p = int(p)
if l[p] == -1:
continue
if s == "AC":
res1 += 1
res2 += l[p]
l[p] = -1
else:
l[p] += 1
print(res1, res2) |
p02917 | s114378120 | Accepted | def resolve():
N = int(input())
B = list(map(int, input().split()))
array = [0 for _ in range(N)]
prev = B[0]
array[0] = B[0]
for i in range(N-1):
if prev <= B[i]:
array[i+1] = B[i]
else:
array[i] = B[i]
array[i+1] = B[i]
prev = B[i]
print(sum(array))
if '__main__' == __name__:
resolve() |
p03455 | s109186312 | Accepted | x = input().split()
y = int(x[0])*int(x[1])
if y % 2:
print("Odd")
else:
print("Even") |
p02706 | s182107630 | Accepted | # -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, M = map(int, input().split())
# 文字列の入力
s = input()
t = s.split(" ")
sum = 0
for u in t:
sum += int(u)
if sum > N:
print(-1)
else:
print(N-sum)
|
p03262 | s318818861 | Accepted | n, x = map(int, input().split())
city = list(map(int, input().split()))
dist = [abs(c - x) for c in city]
#print(dist)
from fractions import gcd
from functools import reduce
ans = reduce(gcd, dist)
print(ans) |
p02795 | s046262549 | Accepted | H,W,N=[int(input()) for i in range(3)]
print(min((N+H-1)//H,(N+W-1)//W)) |
p03210 | s212213044 | Accepted | N = int(input())
if N in (7,5,3):
print("YES")
else:
print("NO") |
p02916 | s889198227 | Wrong Answer | import sys
[N] = [int(x) for x in sys.stdin.readline().split(" ")]
As = [int(x) - 1 for x in sys.stdin.readline().split(" ")]
Bs = [int(x) for x in sys.stdin.readline().split(" ")]
Cs = [int(x) for x in sys.stdin.readline().split(" ")]
prev = -999
result = 0
for i in range(N):
a = As[i]
print("a", a)
result += Bs[a]
print("b", Bs[a], result)
if a == prev+1:
result += Cs[prev]
print("c", Cs[prev], result)
prev = a
print(result)
|
p02631 | s949782385 | Wrong Answer | N = int(input())
A = list(map(int, input().split()))
sum_of_A = sum(A)
ans = []
for a in A:
ans.append((sum_of_A-a)^a)
print(" ".join(map(str, ans)))
|
p03126 | s102797443 | Accepted | N, M = map(int, input().split())
d = [0]*M
for _ in range(N):
K, *A = map(int, input().split())
for a in A:
d[a-1] += 1
print(d.count(N)) |
p03524 | s770127234 | Accepted | s = input()
a = s.count("a")
b = s.count("b")
c = s.count("c")
k = (a > 0) + (b > 0) + (c > 0)
if k == 1:
if len(s) >= 2:
print("NO")
else:
print("YES")
exit()
if k == 2:
if len(s) == 2:
print("YES")
else:
print("NO")
exit()
minabc = sorted([a, b, c])[0]
a = max(0, a - minabc)
b = max(0, b - minabc)
c = max(0, c - minabc)
# print(a, b, c, k)
if a <= 1 and b <= 1 and c <= 1:
print("YES")
else:
print("NO")
|
p03543 | s582731943 | Wrong Answer | def answer(N: int) -> int:
answer = len([N])
if answer <= 2:
print('Yes')
else:
print('No')
|
p02607 | s615348094 | Accepted | import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
A = A.reshape((int(N/2), 2))[:,0] if N % 2 == 0 else np.append(A, 2, 100).reshape((int((N+1)/2), 2))[:, 0]
print((A % 2 == 1).sum()) |
p02708 | s701683974 | Accepted | import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
N,K = LI()
ans = 0
for i in range(K,N+2):
ans = (ans + (N*i - (i-1) * i // 2) - i*(i-1) // 2 +1) % MOD
print (ans) |
p03821 | s633716235 | Wrong Answer | from sys import stdin
import fractions
n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)][::-1]
count = 0
for i in range(n-1):
if li[i][0]%li[i][1] != 0:
count += li[i][1]-li[i][0]%li[i][1]
li[i+1][0] += count
if li[-1][0]%li[-1][1] != 0:
count += li[-1][1]-li[-1][0]%li[-1][1]
print(count) |
p02795 | s101404127 | Accepted | h = int(input())
w = int(input())
n = int(input())
big = 0
temp = 0
if h >= w:
temp = h
big = h
else:
temp = w
big = w
c = 1
for i in range(1000000):
if big >= n:
break
big += temp
c += 1
print(c) |
p03221 | s142163663 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m = map(int, readline().split())
ipy = [[i] + list(map(int, readline().split())) for i in range(m)]
ipy.sort(key=lambda x: x[2])
c = [0] * n
l = []
for i, p, y in ipy:
c[p - 1] += 1
x = str(format(p, '06') + format(c[p - 1], '06'))
l.append([i, x])
l.sort()
for i, v in l:
print(v) |
p03293 | s742801659 | Accepted | s = str(input())
t = str(input())
z = 'No'
for i in range(len(s)):
w = s[i:] + s[:i]
if w == t:
z = 'Yes'
break
print(z) |
p03672 | s815295583 | Accepted | s = input()
if(len(s) % 2 == 0):
s = s[:-2]
else:
s = s[:-1]
while(s != ""):
if(s[:len(s)//2] == s[len(s)//2:]):
print(len(s))
break
s = s[:-2]
|
p02963 | s030866133 | Accepted | S = int(input())
v = 10**9
y = S//v + (S < 10**18)
x = v*y - S
print(0, 0, 10**9, 1, x, y) |
p02743 | s482015502 | Wrong Answer | # coding: utf-8
from math import sqrt
a, b, c = map(int, input().split())
mod = 10**9 + 7
# if c**2 - 2*(a+b)*c + (a-b)**2 > 0:
# if a**2 + b**2 + c**2 >= 2 * (a*b + b*c + c*a):
if (a+b+c) ** 2 > 4*(a*b + b*c + c*a):
# T = sqrt(a*b + b*c + c*a) * 2
# if -T <= a+b+c <= T:
print("Yes")
else:
print("No") |
p02982 | s526857751 | Accepted | n,d = map(int,input().split())
a = []
for i in range(n):
x = list(map(int,input().split()))
a.append(x)
c = 0 #count_all
for j in range(n-1):
for k in range(j+1,n):
distance = 0
for l in range(d):
distance += (abs(a[j][l]-a[k][l]))**2
distance = distance**0.5
if distance.is_integer() == True:
c += 1
print(c) |
p03557 | s090510212 | Accepted | import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
point_A = bisect.bisect_left(A, b)
possible_A = point_A
point_C = bisect.bisect_right(C, b)
possible_C = N - point_C
ans += possible_A * possible_C
print(ans)
|
p03387 | s015716362 | Wrong Answer | a = sorted(list(map( int, input().split())))
s = 0
if len(set(a)) == 1 :
print(0)
else :
if a[0]+1<a[1]:
s +=(a[1]-a[0])//2
a[0] = 2*s+a[0]
if a[0] == a[1]:
s+= a[2] -a[1]
else :
s+= a[2]-a[1] +2
else :
s+= a[2]-a[1] +2
print(s) |
p02768 | s294036125 | Wrong Answer | from math import factorial
def cmb(n,r):
return factorial(n) / factorial(r) / factorial(n - r)
list = input().split()
N = int(list[0])
a = int(list[1])
b = int(list[2])
S = 0
x = 10**9 + 7
for i in range(1,N+1):
if i != a and i != b:
S += cmb(N,i)
if S >= x:
S += -x
print(S) |
p02768 | s030207095 | Accepted | mod = 10**9 + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod)-1
# a
x = 1
for i in range(n - a + 1, n + 1):
x = (x*i) % mod
y = 1
for i in range(1, a + 1):
y = (y*i) % mod
a_ans = x*pow(y, mod-2, mod)
x = 1
for i in range(n - b + 1, n + 1):
x = (x*i) % mod
y = 1
for i in range(1, b + 1):
y = (y*i) % mod
b_ans = x*pow(y, mod-2, mod)
print((ans - a_ans - b_ans) % mod)
|
p02577 | s398434456 | Accepted | n=int(input())
if(n%9==0):
print('Yes')
else:
print('No') |
p03679 | s150019773 | Wrong Answer | x,a,b = map(int,input().split())
if b < a:
print("delicious")
elif b - a > x:
print("dangerous")
else:
print("safe") |
p04012 | s785019817 | Accepted | def count_dict(mystring):
d = {}
# count occurances of character
for w in mystring:
d[w] = mystring.count(w)
return d
w = str(input())
values = count_dict(w).values()
valmod2 = [int(i%2) for i in values]
if all(val ==0 for val in valmod2):
print('Yes')
else:
print('No') |
p02694 | s055541983 | Accepted | def solve():
X = int(input())
now = 100
year = 0
while now < X:
now = now + now // 100
year += 1
print(year)
if __name__ == '__main__':
solve() |
p03377 | s995269517 | Accepted | # -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
def main():
A,B,X=map(int,input().split())
YESNO(A<=X<=A+B)
if __name__ == '__main__':
main()
|
p02628 | s542970719 | Wrong Answer |
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(p[:k])
|
p02933 | s850439924 | Accepted | a = int(input())
s = input()
if a >= 3200:
print(s)
else:
print('red') |
p03387 | s741078062 | Wrong Answer | import math
a=list(map(int,input().split()))
a.sort()
print(a)
cnt=0
if a[0]==a[1]==a[2]:
print(0)
exit()
if a[0]==[1]:
print(a[2]-a[1])
exit()
if a[1]==a[2]:
if (a[2]-a[0])%2==0:
print((a[2]-a[0])//2)
exit()
else:
print(a[2]-a[0]+1)
exit()
cnt+=a[2]-a[1]
a[0]+=cnt
if (a[2]-a[0])%2==0:
cnt+=math.ceil((a[2]-a[0])/2)
else:
cnt+=math.ceil((a[2]-a[0])/2+1)
print(cnt)
|
p03387 | s387954917 | Wrong Answer | a,b,c=sorted(list(map(int,input().split())))
ans=c-b
if (c-a)%2==0:
print(ans+(b-a)//2)
else:
print(ans+(b-a)//2+2) |
p03796 | s461759390 | Wrong Answer | N = int(input())
for i in range(1,N+1):
N *= i
print(N%(10**9+7)) |
p03284 | s192313164 | Accepted | N, K = map(int, input().split())
print(0 if N%K == 0 else 1) |
p03251 | s083191683 | Accepted | num_s, *D, = [list(map(int, s.split())) for s in open(0)]
flag = 0
x, y = D[0], D[1]
max_x, min_y = max(x), min(y)
if max_x > min_y:
flag += 1
else:
for i in range(max_x + 1, min_y + 1):
if i > num_s[2] and i <= num_s[3]:
break
else:
flag += 1
if flag:
print("War")
else:
print("No War") |
p02681 | s634345625 | Accepted | S = input()
T = input()
if S == T[:-1]:
print("Yes")
else:
print("No") |
p02547 | s368110180 | Accepted | n=int(input())
x,y=[],[]
for i in range(n):
x_,y_=map(int,input().split())
x.append(x_)
y.append(y_)
for i in range(n-2):
if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
print("Yes")
break
else:
print("No") |
p02681 | s945534896 | Accepted | s = input()
t = input()
if s == t[:len(t)-1]:
print("Yes")
else:
print("No") |
p03062 | s589068502 | Wrong Answer | N=int(input())
A=list(map(int,input().split()))
B=A[:]
count=0
zero=0
for i in range(N):
if(A[i]<0):
count+=1
elif(A[i]==0):
zero+=1
for i in range(N):
B[i]=abs(A[i])
if(zero==0 and count%2==1):
print(sum(B)-2*min(B[0],B[-1]))
else:
print(sum(B)) |
p03449 | s486619982 | Accepted | n = int(input())
A = [int(i) for i in input().split()]
#3 2 2 4 1
B = [int(i) for i in input().split()]
#1 2 2 2 1
ans = 0
for i in range(n):
ans = max(sum(A[:i+1])+sum(B[i:]),ans)
print(ans) |
p03699 | s399349555 | Accepted | n=int(input())
a=[0]*n
for i in range(n):
a[i]=int(input())
a=sorted(a)
S=sum(a)
if S%10!=0:
print(S)
exit()
else:
for i in range(n):
if (S-a[i])%10:
print(S-a[i])
exit()
print(0) |
p02627 | s896280656 | Accepted | a = input()
if a.isupper():
print("A")
else:
print("a")
|
p02572 | s488782898 | Accepted | N = int(input())
A = list(map(int, input().split()))
mod = 1000000007
S = 0
_sum = 0
for i in range(N):
S += A[i]
S %= mod
for i in range(N):
S -= A[i]
if S<0:
S += mod
_sum += A[i]*S
_sum %= mod
print(_sum) |
p04029 | s218018555 | Wrong Answer | N = int(input())
print((N ** 2 + N) / 2) |
p03835 | s516891891 | Accepted | import sys
sys.setrecursionlimit(10 ** 5)
readline =sys.stdin.readline
def process():
k,s = map(int,readline().rstrip().split())
cnt=0
for i in range(0,k+1):
for j in range(0,k+1):
z = s-(i+j)
if z>=0 and z<=k:
cnt+=1
return cnt
print(process()) |
p02833 | s160744630 | Accepted | n = int(input())
ans = 0
if n % 2 == 0:
n //= 10
for i in range(27):
ans += n // 5 ** i
print(ans) |
p03327 | s867155740 | Wrong Answer | a = int(input())
if a < 1000:
print('ABC' + str(a))
else:
a = a - 999
if a >= 100:
print('ABD' + str(a))
elif a >=10:
print('ABD0' + str(a))
else:
print('ABD00' + str(a)) |
p02775 | s421264261 | Accepted | import sys
input = sys.stdin.readline
S = [0] + list(map(int, list(input())[: -1]))
dp = [[float("inf")] * 2 for _ in range(len(S) + 1)]
dp[-1][0] = 0
for i in range(len(dp) - 1, 0, -1):
for j in range(2):
if S[i - 1] + j <= 5:
dp[i - 1][0] = min(S[i - 1] + j + dp[i][j], dp[i - 1][0])
if S[i - 1] + j >= 5:
dp[i - 1][1] = min(10 - (S[i - 1] + j) + dp[i][j], dp[i - 1][1])
print(min(dp[0])) |
p03351 | s321961504 | Wrong Answer | a, b, c, d = map(lambda x: int(x), input().split())
if a - c <= d:
print('Yes')
elif abs(a - b) + abs(b - c) <= d:
print('Yes')
else:
print('No') |
p03017 | s383055077 | Accepted | n, a, b, c, d = map(int, input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
if '##' in s[a:max(c,d)+1]:
print('No')
exit()
if c < d:
print('Yes')
else:
if '...' in s[b-1:d+2]:
print('Yes')
else:
print('No') |
p02639 | s010136136 | Accepted | input = input().split()
count = 1
for i in input:
if i == '0':
print(str(count))
break
count = count + 1 |
p03241 | s325005277 | Wrong Answer | N, M = list(map(int, input().split()))
if M % N == 0:
print(M // N)
else:
print(M % N)
|
p02995 | s730441891 | Accepted | import fractions
a,b,c,d = map(int,input().split())
def calc(n,x,y):
cnt = n // x
cnt += n//y
lcm = x*y//fractions.gcd(x,y)
cnt -= n//lcm
return n - cnt
print(calc(b,c,d)-calc(a-1,c,d))
|
p03659 | s922961417 | Accepted | n = int(input())
a = list(map(int,input().split()))
s = a[0]
t = sum(a) - a[0]
i = 0
ans = abs(s - t)
for i in range(1, n-1):
s += a[i]
t -= a[i]
ans = min(ans, abs(s - t))
i += 1
print(ans)
|
p03254 | s571333264 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for val in a[:-1]:
x -= val
if x < 0:
break
cnt += 1
if x == a[-1]:
cnt += 1
print(cnt) |
p02613 | s237388579 | Accepted | def JudgeStatusSummary():
num = int(input())
list_result = []
for n in range(num):
result = str(input())
list_result.append(result)
print('AC x ', list_result.count('AC'))
print('WA x ', list_result.count('WA'))
print('TLE x ', list_result.count('TLE'))
print('RE x ', list_result.count('RE'))
if __name__ == '__main__':
JudgeStatusSummary()
|
p02958 | s609825682 | Accepted | N = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(N):
if p[i] != i + 1:
count += 1
if count <= 2:
print('YES')
else:
print('NO') |
p03797 | s162498376 | Accepted | n,m=map(int,input().split())
if n*2>=m:
print(m//2)
else:
print(n+(m-2*n)//4) |
p02595 | s398726207 | Accepted | n,d =map(int,input().split())
ans=0
for i in range(n):
x,y= map(int,input().split())
if x**2 + y**2 <= d**2:
ans+=1
print(ans) |
p03274 | s980643872 | Wrong Answer | N,K = map(int, input().split())
X = [int(i) for i in input().split()]
ans = float("inf")
for left in range(N-K+1):
right = left + K - 1
if X[left] <=0 and X[right] <= 0:
cur = X[left]
elif X[left] >= 0 and X[right] >= 0:
cur = X[right]
else:
if abs(X[left]) >= abs(X[right]):
cur = abs(X[right]) * 2 + abs(X[left])
else:
cur = abs(X[left]) * 2 + abs(X[right])
ans = min(ans, cur)
print(ans) |
p02633 | s374613961 | Wrong Answer | n=int(input())
print(360//n) |
p02701 | s386643059 | Wrong Answer | # -*- coding: utf-8 -*-
import numpy as np
n = int(input())
s = np.empty((n), dtype='str')
for i in range(n):
s[i] = str(input())
s = np.unique(s)
print(len(s))
|
p02691 | s537030815 | Wrong Answer | import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
# print(A)
ans = 0
for i in range(N):
ans += sum((A + A[i]) - [abs(i - j) for j in range(N)] == 0)
print(ans / 2)
|
p03387 | s034045598 | Accepted | a = list(map(int,input().split()))
a.sort()
if (a[1]-a[0]) % 2 == 0:
print((a[1]-a[0])//2 + (a[2]-a[1]))
else:
print((a[2]-a[1])//2 + (a[2]-a[1])%2 + (a[2]-a[0]+1)//2 + 1) |
p03854 | s870118663 | Accepted | S = input()
idx = len(S)
ans = 'YES'
while idx > 0:
if S[idx-5:idx] == 'dream':
idx -= 5
elif S[idx-5:idx] == 'erase':
idx -= 5
elif S[idx-7:idx] == 'dreamer':
idx -= 7
elif S[idx-6:idx] == 'eraser':
idx -= 6
else:
ans = 'NO'
break
print(ans) |
p03699 | s379423714 | Accepted | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
N = int(input())
S = [int(input()) for _ in range(N)]
S.sort()
total = sum(S)
ans = 0 if total % 10 == 0 else total
for s in S:
if (total - s) % 10 != 0:
ans = max(ans, total - s)
print (ans) |
p02665 | s665509802 | Wrong Answer | n = int(input())
a = list(map(int,input().split()))
g = [1]
for i in range(n):
g = g + [(g[-1]-a[i])*2]
print(g)
b = 0
t = 0
for i in range(n,-1,-1):
if a[i]>g[i]:
print(-1)
break
t = min(a[i]+t, g[i])
b+=t
else:
print(b) |
p02996 | s936424593 | Accepted | import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT() : return int(input())
def MAP() : return map(int,input().split())
def LIST() : return list(MAP())
n = INT()
a = [LIST() for i in range(n)]
a.sort(key=lambda x:x[1])
time = 0
for i in range(n):
time += a[i][0]
if(time>a[i][1]):
print("No")
exit()
print("Yes") |
p03319 | s894493375 | Accepted | import math
n, k = map(int,input().split())
a = list(map(int, input().split()))
ans = math.ceil((n - 1) / (k - 1))
print(ans) |
p03761 | s748682445 | Accepted | from collections import Counter
n = int(input())
S = [Counter(input()) for _ in range(n)]
ans = {}
for i in S[0].keys():
ans[i] = min([s[i] for s in S])
print("".join(sorted([i*j for i, j in ans.items()]))) |
p03437 | s425259799 | Accepted | x, y = input().split()
x = int(x)
y = int(y)
if x % y == 0:
print(-1)
else:
print(x * (y + 1))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.