problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02660 | s207075025 | Wrong Answer | import math
n = int(input())
res = 0
if n <= 1:
print(res)
else:
max_num = math.ceil(math.sqrt(n + 1))
org_n = n
for z in range(2, max_num + 1):
if n % z == 0:
z_p = 1
while n % z == 0:
if n % z ** z_p == 0:
res += 1
n = n // z
z_p += 1
if n == z:
break
if org_n == n:
res += 1
print(res) |
p03071 | s443536649 | Wrong Answer | a,b = map(int, input().split())
total = max(a,b)
print(total+(total-1)) |
p04005 | s240471999 | Accepted | import sys
input = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()
def main():
A=LI()
A.sort()
ans=0
if A[0]%2 and A[1]%2 and A[2]%2:
ans=A[0]*A[1]
print(ans)
if __name__ == "__main__":
main()
|
p03210 | s956264361 | Wrong Answer | X = int(input())
if X == 3 or X == 5 or X == 7:
print('Yes')
else:
print('No') |
p02829 | s284147677 | Accepted | def f(a,b):
if a!=3 and b!=3:
return 3
if a!=2 and b!=2:
return 2
if a!=1 and b!=1:
return 1
a=int(input())
b=int(input())
print(f(a,b))
|
p02678 | s543653811 | Accepted | from collections import deque
N, M = map(int, input().split())
g = [[] for i in range(N+1)]
for _ in range(M):
A, B = map(int, input().split())
g[A].append(B)
g[B].append(A)
Q = deque()
vstd = [0]*(N+1)
mark = [0]*(N+1)
vstd[1] = 1
Q.append(1)
while Q:
par = Q.popleft()
for r in g[par]:
if vstd[r]:
continue
mark[r]=par
vstd[r]=1
Q.append(r)
print('Yes')
for mk in mark[2:]:
print(mk)
|
p02987 | s590134650 | Wrong Answer | S = input()
if S[0] == S[1] and S[2] == S[3]:
print ("Yes")
elif S[0] == S[2] and S[1] == S[3]:
print ("Yes")
elif S[0] == S[3] and S[1] == S[2]:
print ("Yes")
else:
print ("No") |
p03711 | s673158923 | Accepted | l = [4, 6, 9, 11]
x, y = map(int, input().split())
if x == 2 or y == 2:
print('No')
elif x in l and y in l:
print('Yes')
elif x not in l and y not in l:
print('Yes')
else:
print('No') |
p02933 | s548560716 | Wrong Answer | if int(input())>=3200:
print("red")
else:
print(input()) |
p02848 | s128821903 | Accepted | n = int(input())
s = input()
abc =['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']
ans = ''
for i in range(len(s)):
ans += abc[(abc.index(s[i]) + n) % 26]
print(ans) |
p02684 | s089780001 | Accepted | def main():
N, K = map(int, input().split())
A_list = input().split()
root = [1]
record = [-1]*N
break_flag = 0
for n in range(K):
new = int(A_list[ int(root[n])-1 ])
if record[new-1] <0:
record[new-1]=1
root.append(new)
else:
ind = root.index(new)
break
else:
print(new)
break_flag = 1
if break_flag == 0:
pre = len(root[:ind])
roop = len(root)-pre
print(root[ind:][(K-pre)%roop])
if __name__ == '__main__':
main() |
p02759 | s224526049 | Accepted | N = int(input())
amari = N % 2
count = int( N // 2 )
print( count + amari )
|
p03720 | s404457398 | Accepted | n,m=map(int,input().split())
t=[0]*n
for i in range(m):
a,b=map(int,input().split())
t[a-1]+=1
t[b-1]+=1
for x in t:
print(x) |
p03160 | s951759390 | Wrong Answer | n=int(input())
h=list(map(int,input().split()))
dp=[10**5]*n
for i in range(n):
if i==0:
dp[i]=0
elif i==1:
dp[i]=abs(h[1]-h[0])
else:
dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp) |
p02706 | s526766415 | Wrong Answer | N, M = map(int, input().split())
A = input().split()
travail = 0
for i in range(0, len(A)):
A[i] = int(A[i])
travail += A[i]
if N - travail > 0:
print(N - travail)
else:
print(-1)
|
p02724 | s102683436 | Wrong Answer | x=int(input())
a=x//500
y=x-(500*a)
b=y//5
print(a*1000+b*1)
|
p03545 | s484448471 | Accepted | Z = []
for s in input():
Z.append(int(s))
def dfs(index, value, ops):
if index == 4:
if value == 7:
print("{}{}{}{}{}{}{}=7".format(Z[0],ops[0],Z[1],ops[1],Z[2],ops[2],Z[3]))
# print(f"{Z[0]}{ops[0]}{Z[1]}{ops[1]}{Z[2]}{ops[2]}{Z[3]}=7")
exit()
return
dfs(index + 1, value + Z[index], ops + ["+"])
dfs(index + 1, value - Z[index], ops + ["-"])
dfs(1, Z[0], []) |
p03387 | s792049555 | Accepted | a,b,c = [int(x) for x in input().split()]
res = 3 * max(a,b,c) - (a + b + c)
if res % 2 == 1:
res += 3
print(res // 2) |
p02994 | s247667988 | Accepted | n,l = map(int,input().split())
s = int(n*(2*l+n-1)/2)
if(l<=0 and l+n-1 >=0):
print(s)
elif(l<=0):
print(s-l-n+1)
else:
print(s-l) |
p03971 | s316039287 | Wrong Answer | import sys
input=sys.stdin.buffer.readline
n,a,b=map(int,input().split())
S=input()[:-1]
print(n,a,b,S)
for i in range(n):
A=S[:i].count(97)
B=S[:i].count(98)
if S[i]==97 and A+B<=a+b:
print("Yes")
continue
if S[i]==98 and A+B<a+b and B<b:
print("Yes")
continue
else:print("No") |
p03827 | s133362107 | Accepted | def maximumx(N, S) :
x = 0
max = 0
for i in range(N) :
if S[i] == 'I' :
x += 1
if max < x :
max = x
else :
x -= 1
return max
N = int(input())
S = input()
print(maximumx(N, S)) |
p02624 | s085263284 | Accepted | n = int(input())
from math import ceil
def g(x, n):
y = n // x
return int(x * (y + 1) * y /2 )
print(sum(g(i+1, n) for i in range(n)))
|
p02987 | s634617684 | Wrong Answer | S=list(map(str,input()))
cnt1=0
cnt2=0
if S[0]!=S[1]:
for i in range(1,4):
if S[0]==S[i]:
cnt1 +=1
break
for j in range(2,4):
if S[1]==S[j]:
cnt2 +=1
break
if cnt1==1 and cnt2==1:
print("Yes")
else:print("No")
elif S[0]==S[1] and S[2]==S[3]:
print("Yes")
else:
print("No") |
p02785 | s344383599 | Accepted | N,K = map(int,input().split())
H = list(map(int,input().split()))
ans = 0
if N <= K:
print(ans)
else:
H.sort(reverse=True)
del H[:K]
ans = sum(H)
print(ans) |
p03327 | s859923729 | Accepted | n = int(input())
if n < 1000:
print('ABC')
else:
print('ABD') |
p03075 | s059526296 | Accepted | a,b,c,d,e,k=[int(input()) for i in range(6)]
if e-a<=k:
print("Yay!")
else:
print(":(") |
p03673 | s275234841 | Accepted | n = int(input())
a = list(map(int,input().split()))
if n % 2 == 0:
start = n - 1
while start >= 0:
print(a[start],end=' ')
start -= 2
start = 0
while start < n:
print(a[start],end=' ')
start += 2
elif n % 2 == 1:
start = n - 1
while start >= 0:
print(a[start],end=' ')
start -= 2
start = 1
while start < n:
print(a[start],end=' ')
start += 2 |
p03962 | s718199737 | Wrong Answer | A, B, C = map(int, input().split())
if A==B and B==C :
print(1)
elif A==B and B!=C :
print(2)
elif B==C and B!=A :
print(2)
elif A==C and A!=B :
print(2)
else :
print(1) |
p03493 | s347911502 | Wrong Answer | a = input()
a.count("1") |
p03944 | s951680281 | Accepted | w, h, n = map(int, input().split())
x_min = 0
y_min = 0
x_max = w
y_max = h
for i in range(n):
x, y, a = map(int, input().split())
if a == 1:
x_min = max(x_min, x)
elif a == 2:
x_max = min(x_max, x)
elif a == 3:
y_min = max(y_min, y)
else:
y_max = min(y_max, y)
if x_max <= x_min or y_max <= y_min:
print(0)
else:
print((x_max - x_min) * (y_max - y_min)) |
p03838 | s294177899 | Accepted | # A - Simple Calculator
x, y = map(int, input().split())
def f(x):
if x<0:
return 10**10
else:
return x
ans = min(f(y-x), f(y+x)+1, f(-y-x)+1, f(-y+x)+2)
print(ans) |
p02802 | s746318822 | Wrong Answer | N, M = map(int, input().split())
PS = [list(input().split()) for _ in range(M)]
C = [0 for _ in range(N + 1)]
cnt = 0
ans = 0
for p, s in PS:
if C[int(p)] == 0:
if s == "WA":
cnt += 1
else:
C[int(p)] += 1
ans += 1
print(ans, cnt)
|
p03360 | s855842020 | Accepted | A, B, C = map(int, input().split())
K = int(input())
print(sum([A, B, C])+max(A, B, C)*2**K-max(A, B, C)) |
p02772 | s463051858 | Accepted | N = int(input())
A = list(map(int,input().split()))
ans = 'APPROVED'
for i in A:
if i % 2 == 0:
if i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
ans = 'DENIED'
print(ans) |
p02642 | s813137505 | Accepted | import sys
input = lambda: sys.stdin.buffer.readline()
n = int(input())
a = list(map(int, input().split()))
a.sort()
m = 10**6+10
d = [False] * (m+1)
ans = 0
for i in range(n):
same = (i > 0 and a[i] == a[i-1]) or (i < (n-1) and a[i] == a[i+1])
x = a[i]
if not d[x] and not same: ans += 1
if (i > 0 and a[i] == a[i-1]): continue
for j in range(x, m+1, x):
d[j] = True
print(ans)
|
p03623 | s518269977 | Wrong Answer | x,a,b = map(int,input().split())
print(min(abs(x-a),abs(x-b))) |
p02708 | s915986490 | Accepted | n,k = map(int,input().split())
ans = 0
for i in range(k,n+1) :
# i個使う場合の最小値
min_i = (i-1)*i//2
# i個使う場合の最大値
max_i = (n-i+1+n)*i//2
ans += (max_i-min_i+1)
print(ans%(10**9+7)+1) |
p03075 | s828567435 | Accepted | def main():
num = [int(input()) for i in range(5)]
n =int(input())
flg=0
for i in range(0,4):
for j in range(i,5):
if abs(num[j]-num[i])>n :
flg=1
break
if flg==0 :
print('Yay!')
else :
print(':(')
main() |
p02612 | s873473412 | Accepted | N = int(input())
if (N % 1000) == 0:
ans = 0
else:
ans = 1000 - (N % 1000)
print(ans) |
p02972 | s433432208 | Accepted | n = int(input())
nums = [int(i) for i in input().split()]
box = [-1] * n
for i in range(1, n + 1)[::-1]:
c = i * 2
ball = nums[i - 1]
while c <= n:
ball = ball ^ box[c - 1]
c += i
box[i - 1] = ball
ans = box.count(1)
print(ans)
ball = []
for i in range(n):
if box[i] == 1:
ball.append(i + 1)
print(*ball)
|
p02952 | s454111051 | Accepted | n = int(input())
keta = len(str(n))
cnt = 0
for i in range(keta):
if i%2 != 0: #odd
cnt += 10**i - 10**(i-1)
if i == keta-1 and keta%2 != 0:
cnt += n - 10**(keta-1) + 1
print(cnt) |
p02935 | s567566766 | Wrong Answer | # -*- coding: utf-8 -*-
## Library
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
## input
# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split())
# P = [list(map(int,input().split())) for i in range(M)]
N = int(input())
V = list(map(int, input().split()))
V.sort()
tmp = (V[0]+V[1])/2
for i in range(2,N):
print(i,tmp)
tmp = (tmp + V[i])/2
print(tmp) |
p02701 | s128204184 | Accepted | N = int(input())
D = {}
ans = 0
for _ in range(N):
S = input()
if S not in D:
D[S] = True
ans += 1
print(ans)
|
p02832 | s789779897 | Wrong Answer | n = int(input())
a = [int(i)-1 for i in input().split()]
ans = 0
for i in range(n):
if a[i] != (i - ans):
ans += 1
print(ans if ans != n else 0) |
p03427 | s343970756 | Wrong Answer | N = int(input())
N_ = str(N)
n = len(N_)
if n == 1:
print(N)
exit()
for i in range(1, n):
if N_[i] != '9':
break
else:
ans = int(N_[0]) + 9*(n-1)
ans = int(N_[0])-1 + 9*(n-1)
print(ans) |
p02633 | s957954083 | Accepted | X = int(input())
n = 1
nX = [X]
k = 360
mk = [360]
while True:
if mk.count(nX[-1]) == 1:
print(n)
break
n += 1
mk.append(n * k)
nX.append(n * X) |
p02684 | s657826978 | Accepted | N, K = map(int, input().split())
*A, = map(int, input().split())
visited = [False] * N
towns = []
now = 0
length = 0
while not visited[now] and K > 0:
visited[now] = True
towns.append(now + 1)
length += 1
K -= 1
now = A[now] - 1
if K == 0: print(now + 1)
else:
idx = towns.index(now + 1)
length -= idx
print(towns[idx:][K % length]) |
p02796 | s407862511 | Accepted | n = int(input())
st = []
for i in range(n):
x, l = map(int, input().split())
st.append([x + l, x - l])
st.sort()
cnt = 1
right = st[0][0]
for i in range(1, n):
if right <= st[i][1]:
right = st[i][0]
cnt += 1
print(cnt) |
p03485 | s866026916 | Accepted | from sys import stdin
import math
a,b=map(int,input().split())
print((a+b+1)//2) |
p02973 | s215366384 | Wrong Answer | n = int(input())
A = [int(input()) for _ in range(n)]
ans = 0
b = float('inf')
for a in A:
if a <= b:
b = a
ans += 1
print(ans) |
p03408 | s591573576 | Wrong Answer | N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
st_dict = {}
for i in range(N):
if s[i] not in st_dict.keys():
st_dict[s[i]] = 1
else:
st_dict[s[i]] += 1
for i in range(M):
if t[i] not in st_dict.keys():
st_dict[t[i]] = -1
else:
st_dict[t[i]] -= 1
print(max(st_dict.values())) |
p02862 | s635116631 | Wrong Answer | x, y = map(int, input().split())
MAX = 10**6+1
MOD = 10**9+7
fac = [0, 1]
for i in range(2, MAX):
fac.append(fac[i-1] * i % MOD)
if (x % 3 == 0 and y % 3 == 0) or (min(x % 3, y % 3) == 1 and max(x % 3, y % 3) == 2):
xx, yy = max(x, y), min(x, y)
a = b = 0
while not xx == yy:
xx -= 2
yy -= 1
a += 1
a += xx // 3
b += yy // 3
print(fac[a+b] * pow(fac[a]*fac[b], MOD-2, MOD) % MOD)
else:
print(0)
|
p02694 | s592875039 | Accepted | X = int(input())
ans = 100
year = 0
while ans < X:
year += 1
ans = int(ans*1.01)
print(year)
|
p02742 | s891570038 | Wrong Answer | import math
H, W = map(int, input().split())
ans = 0
if H==1 or W==1:
print(1)
exit()
if H%2 == 0:
len = int(H/2)
ans += int(math.ceil(W/2))*len + int(math.floor(W/2))*len
else:
len = int(math.floor(H/2))
ans += int(math.ceil(W/2))*(len+1) + int(math.floor(W/2))*len
print(ans)
print(int(ans)) |
p03319 | s124343863 | Accepted | N,K = [int(i) for i in input().split()]
print(1 + (max(0, N - K) + (K-2))//(K-1)) |
p03680 | s140787896 | Wrong Answer | n, *A = map(int, open(0).read().split())
x = 0
for i in range(n):
x, A[x] = A[x]-1, 0
if x == -1:
print(-1)
exit()
if x == 1:
print(i+1)
exit() |
p02996 | s227402311 | Accepted | N, *AB = map(int, open(0).read().split())
AB = [(B, -A) for A, B in zip(AB[::2], AB[1::2])]
AB.sort()
t = 0
for b, a in AB:
a = -a
t += a
if t > b:
print("No")
break
else:
print("Yes")
|
p03633 | s889370253 | Accepted | from fractions import gcd
N=int(input())
def lcm(a,b):
return a//gcd(a,b)*b
T=[]
for i in range(N):
t=int(input())
T.append(t)
a=1
for i in range(N):
a=lcm(a,T[i])
print(a) |
p03548 | s913656087 | Accepted | x,y,z = map(int,input().split())
print((x-z)//(y+z)) |
p03416 | s501070348 | Wrong Answer | a,b = input().split()
cnt = 0
A1 = int(a[0])*10+int(a[1])
A2 = int(a[-2])*10+int(a[-1])
B1 = int(b[0])*10+int(b[1])
B2 = int(b[-2])*10+int(b[-1])
if A1 -A2 >= 0:
cnt += 1
if B1 - B2 > 0:
cnt -= 1
cnt += (int(b)-int(a))//100
print(cnt) |
p03126 | s770688883 | Wrong Answer | n,m = map( int,input().split() )
k = [ list(map( int,input().split() )) for _ in range(n) ]
c = [0] * (m+1)
for i in k:
for j,data in enumerate(i):
if j == 0:
continue
else:
c[data] += 1
ans = 0
for i in c:
if i == 3:
ans += 1
print(ans)
|
p03103 | s044488743 | Accepted | N,M = map(int,input().split())
AB = []
for i in range(N):
A,B = map(int,input().split())
AB.append((A,B))
AB.sort()
cnt = 0
ans = 0
for a,b in AB:
if cnt+b >= M:
break
cnt += b
ans += a*b
ans += a*(M-cnt)
print(ans)
|
p03862 | s768560695 | Wrong Answer | from sys import stdin
import collections
import math
n,x = [int(x) for x in stdin.readline().rstrip().split()]
arr = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in range(0,n-1):
s = arr[i] + arr[i+1]
if s > x :
d = s-x
arr[i+1] -= s - x
ans += d
print(ans) |
p02657 | s025831516 | Wrong Answer | a,b =map(int,input("数字を入力してください").split())
print(a*b) |
p02624 | s324464123 | Accepted | import numpy as np
n=int(input())
num=np.array(list(range(1,n+1)))
x=n//num
ans=num*(x+1)*x/2
print(int(np.sum(ans))) |
p02987 | s746588719 | Accepted | S = list(str(input()))
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
print('Yes')
else:
print('No') |
p02972 | s411833640 | Accepted | N = int(input())
a = list(map(int,input().split()))
ans = [0 for i in range(N+1)]
for i in range(N,0,-1):
res = 0
for j in range(1,N+1):
if i*j>N:
break
else:
res += ans[i*j]
if res%2 != a[i-1]:
ans[i] += 1
print(sum(ans))
A = []
for i,v in enumerate(ans):
if v>0:
A.append(i)
print(*A)
|
p03067 | s592526055 | Accepted | A, B, C = map(int,input().split())
if (A - C) * (B - C) < 0:
print('Yes')
else:
print('No') |
p02663 | s095715229 | Accepted | sh,sm,fh,fm,k = map(int,input().split())
h = 0
m = 0
ans = 0
if sm > fm:
h = 60*(fh-sh)
m = sm -fm
ans = h - m - k
else:
h = 60*(fh-sh)
m = fm -sm
ans = h + m - k
print(ans) |
p02760 | s705332782 | Accepted | a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
n=int(input())
B=[int(input()) for j in range(n)]
if (a in B and b in B and c in B) or (d in B and e in B and f in B) or (g in B and h in B and i in B) or (a in B and d in B and g in B) or (b in B and e in B and h in B) or (c in B and f in B and i in B) or (a in B and e in B and i in B) or (c in B and e in B and g in B):
print("Yes")
else:
print("No")
|
p03351 | s922800343 | Accepted | a,b,c,d=map(int,input().split())
print("Yes"if abs(c-a)<=d or (abs(b-a)<=d and abs(c-b)<=d) else "No") |
p03944 | s582257403 | Wrong Answer | W, H, N = [int(i) for i in input().split()]
xya = []
for _ in range(N):
xya.append([int(i) for i in input().split()])
xmin = 1
ymin = 1
xmax = W
ymax = H
for i in xya:
if i[2] == 1:
xmin = i[0]
elif i[2] == 2:
xmax = i[0]
elif i[2] == 3:
ymin = i[1]
else:
ymax = i[1]
s = (xmax - xmin) * (ymax - ymin)
print(s) |
p03434 | s979337769 | Accepted | import math
def main():
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
alice=sum(a[::2])
bob=sum(a[1::2])
print(alice-bob)
main()
|
p02578 | s427134871 | Wrong Answer | def step(N, A):
sum = 0
for i in range(1, N):
if A[i-1] < A[i]:
sum += A[i] - A[i-1]
return sum
if __name__ == "__main__":
N = int(input())
A = list(map(int, input().split()))
print(step(N, A)) |
p02694 | s750688553 | Accepted | inp = int(input())
def solve(value):
current = 100
for i in range(1000000):
current = int(current * (1.01**1))
if current >= value:
print(i+1)
return
solve(inp) |
p02697 | s491869099 | Wrong Answer | import sys
input = sys.stdin.readline
N, M = map(int, input().split())
res = []
for k in range(1, M + 1):
res.append((k, N - k))
for r in res: print(*r) |
p02818 | s638082670 | Wrong Answer | A,B,K=map(int,input().split())
if A>=K:
A-=K
else:
B=A+B-K
A=0
print(A,B)
|
p03624 | s758006144 | Accepted | import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7
s = rr()
for char in 'abcdefghijklmnopqrstuvwxyz':
if char not in s:
print(char)
exit()
else:
print('None')
|
p03767 | s701184232 | Accepted | n = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
print(sum(li[1:2*n:2])) |
p02973 | s078263236 | Accepted | from bisect import bisect_right
N, *A = map(int, open(0).read().split())
A = [-a for a in A]
q = []
for a in A:
idx = bisect_right(q, a)
if idx == len(q):
q.append(a)
else:
q[idx] = a
print(len(q))
|
p02641 | s888298661 | Wrong Answer | # import math
# x, y = map(int, input().split())
# a = (4 * x - y) / 2
# if a >= 0 and a <= x and a == math.ceil(a):
# print('Yes')
# else:
# print('No')
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
print(x)
for i in range(n):
if x - i not in p:
print(x - i)
break
elif x + i not in p:
print(x + i)
break
|
p03127 | s733599933 | Accepted | import fractions
from functools import reduce
def g(n):
return reduce(fractions.gcd,n)
n=int(input())
print(g(list(map(int,input().split())))) |
p03986 | s576289608 | Wrong Answer | def main():
S = str(input())
ans = 0
num_s = 0
flag = False
for i in range(len(S)):
if S[i] == 'S' and flag:
num_s = 0
flag = False
if S[i] == 'S':
num_s += 1
if S[i] == 'T':
flag = True
if num_s > 0:
ans += 2
num_s-=1
print(len(S)-ans)
if __name__ == "__main__":
main() |
p02694 | s561145427 | Accepted | x = int(input())
n, y = 100, 0
while n < x:
n = n * 101 // 100
y = y + 1
print(y) |
p03387 | s956357880 | Accepted | import sys
def solve():
input = sys.stdin.readline
L = [int(i) for i in input().split()]
count = 0
L.sort()
addMin = (L[2] - L[0]) // 2
addMid = (L[2] - L[1]) // 2
count = addMin + addMid
L[0] += addMin * 2
L[1] += addMid * 2
if L[0] < L[2] and L[1] < L[2]: print(count + 1)
elif L[0] == L[1] == L[2]: print(count)
else: print(count + 2)
#print(L)
return 0
if __name__ == "__main__":
solve()
|
p03821 | s330460629 | Wrong Answer | def main():
N = int(input())
A = list()
for i in range(N):
a, b = map(int, input().split())
A.append([a, b])
A.reverse()
ans = 0
offset = 0
for pair in A:
a, b = pair
if a % b == 0:
continue
else:
n = b - ((a + offset) % b)
ans += n
offset += n
print(ans)
if __name__ == "__main__":
main() |
p03796 | s463891666 | Wrong Answer | a=int(input())
b=1
for i in range(1,a):
b=b*i
print(b%1000000007) |
p02556 | s463577602 | Accepted | def manhattan(n, x, y):
x2 = [0] * n
y2 = [0] * n
for i in range(n):
x2[i] = x[i] - y[i]
y2[i] = x[i] + y[i]
print(max(max(x2) - min(x2), max(y2) - min(y2)))
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
x[i] , y[i] = map(int, input().split())
manhattan(n, x, y)
|
p03745 | s154778629 | Wrong Answer | from collections import deque
n = int(input())
a = list(map(int,input().split()))
d = deque(a)
tmp = []
cnt = 0
while d:
v = d.popleft()
if len(tmp)<=1:
pass
else:
if not (v >= tmp[-1] >= tmp[-2] or v <= tmp[-1] <= tmp[-2]):
tmp = []
cnt += 1
tmp.append(v)
# print(d,tmp,cnt)
if tmp:
cnt+=1
print(cnt) |
p02982 | s452797555 | Accepted | n, d = map(int, input().split())
point = [[int(i) for i in input().split()] for j in range(n)]
count = 0
for i in range(n):
for j in range(i + 1, n):
norm = 0
for pi, pj in zip(point[i], point[j]):
norm += (pi - pj) ** 2
if int(norm**0.5) == norm**0.5:
count += 1
print(count) |
p02832 | s278165287 | Accepted | n = int(input())
A = list(map(int, input().split()))
count = 0
find = 1
for i in range(n):
if A[i] == find:
find += 1
else:
count += 1
print(count if count != n else -1) |
p03000 | s769413560 | Accepted | n, x = map(int, input().split())
l = list(map(int, input().split()))
res = 0
for i in range(n):
res += l[i]
if x < res:
print(i+1)
exit()
print(i+2) |
p03208 | s554985100 | Accepted | N, K = map(int, input().split())
hs = []
for _ in range(N):
hs.append(int(input()))
hs.sort()
start, end = 0, K-1
ans = float('inf')
while end < N:
ans = min(ans, hs[end]-hs[start])
start += 1
end += 1
print(ans) |
p02982 | s452746838 | Wrong Answer | N, D = map(int, input().split())
X = []
for i in range(N):
X.append(list(map(int, input().split())))
print(X)
ans = 0
for i in range(N):
for j in range(i+1, N):
dist_sq = 0
for x, y in zip(X[i], X[j]):
dist_sq += (x - y) ** 2
dist = dist_sq ** 0.5
print(i, j, dist)
if dist - int(dist) == 0:
ans += 1
print(ans) |
p03695 | s784660014 | Accepted | n = int(input())
#n, k = map(int, input().split())
al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
def color(rate):
c = rate//400
return min(8, c)
dic = {i: 0 for i in range(9)}
for a in al:
dic[color(a)] = dic[color(a)]+1
count = 0
for i in range(8):
if dic[i] != 0:
count += 1
mn = count
mx = count
if dic[8] != 0:
if count>=1:
mx = mn+dic[8]
else:
mn=1
mx=dic[8]
print(mn, mx)
|
p02791 | s466864387 | Accepted | n = int(input())
number = list(map(int, input().split()))
cnt = 0
min_num = number[0]
for i in range(n):
if min_num >= number[i]:
cnt += 1
min_num = number[i]
else:
continue
print(cnt) |
p02600 | s856663659 | Wrong Answer | a = int(input())
r = 1
for i in range(1790,598,-200):
if a <= i:
r += 1
print(r) |
p03380 | s431631207 | Accepted | n = int(input())
a = list(map(int, input().split()))
m = max(a)
a = sorted(a)
ans = 0
for i in a:
if abs(m/2-i) < abs(m/2-ans):
ans = i
print(m, ans) |
p03605 | s744998474 | Wrong Answer | arr=raw_input()
for i in range(len(arr)):
if arr[i]==9:
print "Yes"
else:
print "No" |
p03339 | s484979642 | Accepted | N = int(input())
S = list(input())
cnt = (S[1:]).count("E")
ans = cnt
for i in range(1,N):
if S[i] == 'E':
cnt -= 1
if S[i-1] == 'W':
cnt += 1
ans = min(ans,cnt)
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.