problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p03289
|
s011509145
|
Accepted
|
list_S = list(input())
ans = "WA"
if list_S[0] == "A":
list_S.remove("A")
if "C" in list_S[1:-1]:
list_S.remove("C")
for c in list_S:
if c not in ["q","a","z","w","s","x","e","d","c","r","f","v","t","g","b","y","h","n","u","j","m","i","k","o","l","p"]:
ans = "WA"
break
else:
ans = "AC"
print(ans)
|
p03951
|
s967512420
|
Accepted
|
N = int(input())
S = input()
T = input()
answer = 2*N
for i in range(N):
if S[N-i-1:] == T[:i+1]:
answer = 2*N-i-1
print(answer)
|
p02833
|
s089722110
|
Accepted
|
import math
from decimal import *
def cnt_prime(p, n):
div = Decimal(str(n))
s = 0
while True:
div /= p
if div < 1:
break
if p == 2:
s += int(div.quantize(Decimal('0.0'), rounding=ROUND_FLOOR))
else:
s += int(div.quantize(Decimal('0.0'), rounding=ROUND_FLOOR)) // 2
return s
N = int(input())
if N % 2 == 1:
print(0)
else:
print(min(cnt_prime(2, N), cnt_prime(5, N)))
|
p02694
|
s839049782
|
Accepted
|
X = int(input())
count = 0
temp = 100
ans = 0
while True:
temp+=temp//100
count += 1
ans = temp
if ans>=X:
break
print(count)
|
p02742
|
s418588744
|
Accepted
|
n,m = map(int,input().split())
ans = n*m
if n ==1 or m==1:
print(1)
else:
if ans%2==0:
print(ans//2)
else:
print((ans+1)//2)
|
p03633
|
s183299909
|
Accepted
|
import fractions
N = int(input())
G = 1
for i in range(N):
D = int(input())
G = G * D // fractions.gcd(G, D)
print(G)
|
p02910
|
s464180171
|
Wrong Answer
|
s = list(input())
k = 0
for i in range(0,len(s),2):
if s[i] == ('R' or 'U' or 'D'):
k = 1
else:
k = 0
for j in range(1,len(s),2):
if s[j] == ('L' or 'U' or 'D'):
k = 1
else:
k = 0
if k==1:
print('Yes')
else:
print('No')
|
p03773
|
s528982232
|
Accepted
|
A, B = map(int, input().split())
print((A + B) % 24)
|
p03705
|
s128890030
|
Accepted
|
n,a,b=map(int, input().split())
pot = b-a+1
if(b<a):
print(0)
exit()
if n==0:
print(0)
elif n==1:
if a==b:
print(1)
else:print(0)
elif n==2:
if a==b:print(1)
print(1)
else:
k = n-1
m = k*b
high = m+a
low = a*k + b
print(high-low+1)
|
p02627
|
s283053513
|
Accepted
|
a =input()
if a.isupper() == True:
print("A")
else:
print("a")
|
p03324
|
s255053314
|
Accepted
|
a, b = list(map(int, input().split()))
if b != 100:
ans = 100 ** a * b
else:
ans = 100 ** a * (b+1)
print(ans)
|
p02880
|
s972151211
|
Accepted
|
x = input()
x = int(x)
answer = ''
for i in range(9):
i = i + 1
if x % i == 0:
shou = x // i
if (1 <= i and i <= 9) and (1 <= shou and shou <= 9):
answer = 'Yes'
break
else:
answer = 'No'
else:
answer = 'No'
print(answer)
|
p02952
|
s233203404
|
Wrong Answer
|
N = int(input())
# 1 <= N <= 10**5 = 100,000
if N <= 9:
print(N)
elif N <= 999:
ans = 9 + (N - 99)
print(ans)
elif N <= 99999:
ans = 9 + 900 + (N - 9999)
print(ans)
else:
print(90909)
|
p03625
|
s614276568
|
Accepted
|
import collections
n = int(input())
a_lst = list(map(int, input().split()))
c = collections.Counter(a_lst)
cand = [k for k, v in c.items() if v >= 2]
cand = sorted(cand)
if len(cand) >= 2:
if c[cand[-1]] >= 4:
print(cand[-1] ** 2)
else:
print(cand[-2] * cand[-1])
else:
print(0)
|
p03071
|
s637154820
|
Accepted
|
a,b = map(int,input().split())
print(max(a,b) + max(min(a,b),max(a,b)-1))
|
p02720
|
s818056941
|
Wrong Answer
|
from collections import deque
k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
a = q.popleft()
if a % 10 == 0:
q.append(10*a)
q.append(10*a + 1)
elif a % 10 == 9:
q.append(10*a + 8)
q.append(10*a + 9)
else:
q.append(10*a + a - 1)
q.append(10*a + a)
q.append(10*a + a + 1)
else:
print(a)
|
p03107
|
s783512524
|
Accepted
|
S = input()
one = S.count('1')
zero = len(S) - one
print(min(one, zero) * 2)
|
p03069
|
s236360636
|
Accepted
|
N = int(input())
S = input()
ldp = [0] * (N+1)
rdp = [0] * (N+1)
for i in range(N):
if S[i] == "#":
ldp[i+1] = ldp[i] + 1
else:
ldp[i+1] = ldp[i]
for i in range(N-1, -1, -1):
if S[i] == ".":
rdp[i] = rdp[i+1] + 1
else:
rdp[i] = rdp[i+1]
#print(ldp)
#print(rdp)
ans = 10 ** 9
for i in range(N+1):
ans = min(ans, rdp[i]+ldp[i])
print(ans)
|
p02882
|
s497317278
|
Accepted
|
import math
a, b, x = map(int, input().split())
if 2 * x >= a * a * b: print(math.degrees(math.atan(2/a*(b-x/a** 2))))
else: print(math.degrees(math.atan(a*b*b/(2*x))))
|
p02973
|
s395982536
|
Accepted
|
from bisect import bisect_left
from collections import deque
N=int(input())
minList=deque([])
minmax=-1
for i in range(N):
if i==0:
a=int(input())
minList.append(a)
minmax=a
else:
a=int(input())
if a<=minmax:
minmax=a
minList.appendleft(a)
else:
idx=bisect_left(minList,a)
if idx==1:minmax=a
minList[idx-1]=a
print(len(minList))
|
p02989
|
s521351052
|
Wrong Answer
|
n=int(input())
l=list(map(int,input().split()))
print(n//2)
l.sort()
print(l[n//2]-l[n//2-1])
|
p03419
|
s387671088
|
Wrong Answer
|
n,m=map(int,input().split())
c=n*m
if n==1 or m==1:
print(max(0,c-2))
else:
print(c-n*2-(m-2)*2)
|
p03565
|
s265772922
|
Wrong Answer
|
S = input()
A = input()
INF = 10**18
idx = INF
word = ''
for i in range(len(A)):
key = A[:len(A)-i] + '?'*i
tmp_idx = S.rfind(key)
if tmp_idx != -1:
if tmp_idx < idx:
idx = tmp_idx
word = key
if idx == INF:
print('UNRESTORABLE')
exit(0)
ans = S[:idx] + A + S[idx+len(A):]
ans = ans.replace('?', 'a')
print(ans)
|
p02971
|
s288007277
|
Accepted
|
n = int(input())
a = [int(input()) for i in range(n)]
b = a.copy()
b.sort()
a_max = b[-1]
a_second = b[-2]
for i in range(n):
if a[i] == a_max:
print(a_second)
else:
print(a_max)
|
p02838
|
s787003333
|
Accepted
|
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
b = [0] * 65
for i in range(N):
bb = format(A[i], "060b")
for j in range(60):
if bb[j] == "1":
b[j] += 1
ans = 0
for j in range(60):
ans = (ans + b[j] * (N - b[j]) * pow(2, 59 - j, mod)) % mod
print(ans)
|
p02546
|
s181962014
|
Accepted
|
S = list(map(str, input()))
if S[-1] == "s":
S.append("e")
S.append("s")
else:
S.append("s")
print("".join(S))
|
p02759
|
s093241103
|
Wrong Answer
|
N=int(input())
print(round(N/2))
|
p03814
|
s256246038
|
Accepted
|
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = readline().rstrip().decode('utf-8')
n = len(s)
for i in range(n):
if s[i] == "A":
start = i
break
for i in range(n-1,-1,-1):
if s[i] == "Z":
end = i
break
print(end-start+1)
|
p02613
|
s924626133
|
Accepted
|
def judge_status_summary():
N = int(input())
res = {"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(N):
res[input()] += 1
for k in res:
print("{} x {}".format(k,res[k]))
judge_status_summary()
|
p03323
|
s692945038
|
Accepted
|
X, Y = map(int, input().split())
if X <= 8 and Y<=8:
print("Yay!")
else:
print(":(")
|
p03854
|
s301773357
|
Wrong Answer
|
S = input()
if len(S) == 0:
print('NO')
else:
if len(S.replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '')) == 0:
print('YES')
else:
print('NO')
|
p02767
|
s120497073
|
Accepted
|
n = int(input())
x =list(map(int, input().split()))
xl = min(x)
xr = max(x)
ans = (xr-xl)**2*n
for i in range(xl,xr+1):
ttl = 0
for j in x:
ttl+=(j-i)**2
ans = min(ans, ttl)
print(ans)
|
p02888
|
s990502567
|
Accepted
|
import bisect
N = int(input())
L_i = list(map(int, input().split()))
count = 0
L_i.sort()
for i in range(0, N - 2):
for j in range(i + 1, N - 1):
count += bisect.bisect_left(L_i,L_i[i] + L_i[j]) - j - 1
print(count)
|
p03252
|
s593267251
|
Accepted
|
from collections import defaultdict
d1 = defaultdict(list)
d2 = defaultdict(list)
S = input()
T = input()
N = len(S)
for i in range(N):
d1[S[i]].append(i)
for i in range(N):
d2[T[i]].append(i)
val1 = d1.values()
val2 = d2.values()
val1 = list(val1)
val2 = list(val2)
val1.sort()
val2.sort()
if val1 == val2:
print('Yes')
else:
print('No')
|
p03456
|
s127293505
|
Accepted
|
a = input().split()
kumiawase = int(a[0] + a[1])
result = 'No'
for i in range(kumiawase):
if i**2 == kumiawase:
result = 'Yes'
break
print(result)
|
p02785
|
s248335705
|
Wrong Answer
|
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())), reverse=True)
if n > k:
print(sum(h[k:]))
else:
print(sum(h))
|
p03319
|
s015381789
|
Wrong Answer
|
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K == 1:
print(N - 1)
elif N == K:
print(1)
else:
print((N-1)//(K-1)+1)
|
p04030
|
s049923818
|
Wrong Answer
|
s = input()
print(*[s[q] if s[q] != "B" else chr(0x08) for q in range(len(s))], sep="")
|
p02732
|
s206784746
|
Accepted
|
# coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = np.array(lr(), dtype=np.int32)
counter = np.bincount(A)
case = (counter * (counter-1) // 2).sum()
answer = case - (counter[A] - 1)
print('\n'.join(answer.astype(str)))
|
p02689
|
s189500364
|
Wrong Answer
|
N, M= (int(x) for x in input().split())
height=[int(x) for x in input().split()]
nlist=[1]*N
print(nlist)
for _ in range(M):
a, b =(int(x) for x in input().split())
a-=1
b-=1
if height[a]<height[b]:
nlist[a]=0
if height[b]<height[a]:
nlist[b]=0
print(nlist)
print(sum(nlist))
|
p02773
|
s095497833
|
Accepted
|
N = int(input())
dic = {}
for _ in range(N):
a = input()
if a in dic:
dic[a] += 1
else:
dic[a] = 1
m = max(dic.values())
for s in sorted(k for k in dic if dic[k] == m):
print(s)
|
p02603
|
s844385150
|
Wrong Answer
|
N = int(input())
A = list(map(int, input().split()))
syozi = 1000
kabu = 0
for i in range(N-1):
if A[i] < A[i+1]:
kabu = syozi // A[i]
syozi -= (syozi // A[i]) * A[i]
elif A[i] > A[i+1]:
syozi += A[i] * kabu
kabu = 0
else:
pass
syozi += A[-1] * kabu
print(syozi)
|
p02702
|
s335543223
|
Accepted
|
s = input()
mod = 2019
temp = [1]
for i in range(len(s) - 1):
temp.append(temp[-1] * 10 % mod)
temp.reverse()
temp2 = []
for i in range(len(s)):
temp2.append(int(s[i]) * temp[i])
temp3 = [0]
for i in range(len(s)):
temp3.append((temp3[-1] + temp2[i]) % mod)
temp4 = {}
for i in temp3:
temp4.setdefault(i, 0)
temp4[i] += 1
ans = 0
for i in temp4.values():
ans += (i * (i - 1) // 2)
print(ans)
|
p02829
|
s644027038
|
Wrong Answer
|
A = int(input())
B = int(input())
if (A or B == 1) and (A or B == 2):
print(3)
elif (A or B == 1) and (A or B == 3):
print(2)
elif (A or B == 2) and (A or B == 3):
print(1)
|
p02996
|
s239590335
|
Accepted
|
n = int(input())
l = []
ans = "Yes"
for i in range(n):
a, b = map(int, input().split())
l.append([b, a])
l.sort(reverse=True)
tmp = l[0][0]
for i in range(n):
if tmp > l[i][0]:
tmp = l[i][0]
tmp -= l[i][1]
if tmp < 0:
ans = "No"
break
print(ans)
|
p03639
|
s060913398
|
Accepted
|
# https://atcoder.jp/contests/arc080/tasks/arc080_a
n = int(input())
nums = [int(i) for i in input().split()]
fours = 0
twos = 0
odd = 0
for num in nums:
if num % 4 == 0:
fours += 1
elif num % 2 == 0:
twos += 1
else:
odd += 1
if twos == 0 and fours + 1 >= odd:
print('Yes')
elif fours >= odd:
print('Yes')
else:
print('No')
|
p02747
|
s095244145
|
Wrong Answer
|
s=input()
for i in range(len(s)):
if s[i-1]=="h":
if s[i]=="i":
print("Yes")
print("No")
|
p02771
|
s552605557
|
Wrong Answer
|
A,B,C = map(int,input().split())
if A == B and B == C:
print("No")
else:
print("Yes")
|
p02608
|
s387377732
|
Accepted
|
n=int(input())
l=[0]*10**7
s=int(n**0.65)+1
for x in range(1,s):
for y in range(1,s-x):
for z in range(1,s-x-y):
l[x*x+y*y+z*z+x*y+y*z+z*x-1]+=1
for i in range(n):
print(l[i])
|
p03449
|
s278135294
|
Wrong Answer
|
N = int(input())
h = list(map(int, input().split()))
l = list(map(int, input().split()))
c = h[0]
for i in range(N):
if sum(h[i+1:])< sum(l[i:]):
c += sum(l[i:])
print(c)
exit()
else:
c += h[i+1]
|
p02795
|
s679491415
|
Wrong Answer
|
H=int(input())
W=int(input())
N=int(input())
K=H
if K<W: K=W
sum = 0
ans= 0
for i in range(1,K):
if sum < N:
sum += K
ans = i
print(ans)
|
p03481
|
s260817839
|
Accepted
|
x, y = map(int, input().split())
count = 0
while (x <= y):
x *= 2
count += 1
print(count)
|
p03625
|
s444528520
|
Accepted
|
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse = True)
HW = []
i = 1
while i<N:
if A[i]==A[i-1]:
n = A.count(A[i])
HW += [A[i]]*(min(n//2,2))
i = i + n -1
else:
i = i + 1
if len(HW)>=2:
break
if len(HW)<2:
print(0)
else:
print(HW[0]*HW[1])
|
p02879
|
s704076654
|
Accepted
|
a,b = map(int,input().split())
if a <= 9 and b <= 9:
print(a*b)
else:
print(-1)
|
p02627
|
s274964619
|
Accepted
|
a = input()
if a.isupper():
print('A')
else:
print('a')
|
p02552
|
s335655966
|
Accepted
|
a = int(input())
x = 0
if a == 0:
x = 1
print(x)
|
p02790
|
s359296851
|
Accepted
|
a,b=map(int,input().split())
if a>=b:
s=[str(b)]*a
print("".join(s))
else:
s=[str(a)]*b
print("".join(s))
|
p02766
|
s530704390
|
Accepted
|
import math
N, R = map(int, input().split())
X = math.log(N + 0.000001, R)
Y = math.ceil(X)
print(Y)
|
p03071
|
s733833369
|
Accepted
|
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
a,b = I()
for i in range(2):
if a >= b:
ans += a
a -= 1
else:
ans += b
b -= 1
print(ans)
|
p02766
|
s724676495
|
Accepted
|
n,k = map(int, input().split())
for i in range(32):
if k**i <= n < k**(i+1):
print(i+1)
break
|
p02612
|
s463540118
|
Accepted
|
n = int(input())
c = n % 1000
if c == 0:
s = 0
else:
s = 1000 - c
print(s)
|
p03827
|
s078951655
|
Wrong Answer
|
n = int(input())
a = list(input())
xlist = []
x = 0
for i in range(n):
if a[i]=="D":
x+=1
elif a[i]=="I":
x-=1
xlist.append(x)
print(max(xlist))
|
p02912
|
s175805648
|
Accepted
|
import heapq
n, m = [int(i) for i in input().split()]
a = [-int(i) for i in input().split()]
heapq.heapify(a)
def d(x):
return -((-x)//2)
for _ in range(m):
b = heapq.heappop(a)
heapq.heappush(a, d(b))
print(-sum(a))
|
p02860
|
s719109662
|
Wrong Answer
|
n = int(input())
s = input()
if n%2 == 1:
print("No")
slise = n/2
a = s[:int(slise)]
b = s[int(slise):]
if a==b:
print("Yes")
else:
print("No")
|
p02771
|
s074123140
|
Wrong Answer
|
A,B,C = map(int,input().split())
if A==B and B==C and A==C:
print("No")
else:
print("Yes")
|
p03427
|
s683315635
|
Accepted
|
# n, m, l = map(int, input().split())
# list_n = list(map(int, input().split()))
# n = input()
# list = [input() for i in range(N)
# list = [[i for i in range(N)] for _ in range(M)]
import math
import sys
input = sys.stdin.readline
N = int(input())
ans = 0
k = int(math.log10(N)) + 1
A = N//(10**(k-1))
if (A + 1) * (10 ** (k - 1)) - 1 <= N:
ans = A + 9*(k-1)
else:
ans = A-1+9*(k-1)
print(ans)
|
p03836
|
s981776819
|
Accepted
|
sx, sy, tx, ty = map(int, input().split())
ans = []
for _ in range(tx-sx):
ans.append("R")
for _ in range(ty-sy):
ans.append("U")
for _ in range(tx-sx):
ans.append("L")
for _ in range(ty-sy):
ans.append("D")
ans.append("D")
for _ in range(tx-sx+1):
ans.append("R")
for _ in range(ty-sy+1):
ans.append("U")
ans.append("L")
ans.append("U")
for _ in range(tx-sx+1):
ans.append("L")
for _ in range(ty-sy+1):
ans.append("D")
ans.append("R")
print("".join(ans))
|
p03698
|
s678590240
|
Accepted
|
s = input()
n = len(s)
l = set(s)
m = len(l)
if n == m:
print("yes")
else:
print("no")
|
p03434
|
s708636131
|
Wrong Answer
|
N = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(0,N-2,2):
Alice += a[i]
Bob += a[i+1]
print(Alice-Bob)
|
p04031
|
s245171179
|
Accepted
|
import sys
n = int(input())
numeros = [int(x) for x in input().split()]
saida = sys.maxsize
for i in range(min(numeros), max(numeros)+1):
valor = 0
for j in numeros:
valor += (j-i)**2
saida = min(valor, saida)
print(saida)
|
p03131
|
s465324293
|
Wrong Answer
|
K, A, B = map(int, input().split())
if A >= B:
ans = K+1
else:
if K-A-1 < 0:
n = 0
ans = K+1
else:
n = (K-A-1)//2
m = (K-A-1)%2
ans = n*(B-A) + m + B
print(ans)
|
p03284
|
s343873807
|
Wrong Answer
|
N, K = map(int,input().split())
print(N-(N//K)*K)
|
p02996
|
s102983616
|
Wrong Answer
|
nb = int(input())
somme = 0
mmax = 0
for loop in range(nb):
n,m = map(int,input().split())
if n<=m:
somme+=n
if m>mmax:
mmax = m
if somme<=mmax:
print("Yes")
else:
print("No")
|
p03495
|
s124241152
|
Accepted
|
#n=int(input())
n,K=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
pt=set(al)
dic={}
for ai in al:
dic[ai]=dic.get(ai,0)+1
l2d=[]
for k, v in dic.items():
l2d.append([k,v])
l2d.sort(key=lambda x: x[1])
ans=0
for i in range(len(pt)-K):
ans+=l2d[i][1]
print(ans)
|
p02819
|
s311513220
|
Wrong Answer
|
x = int(input())
while True:
for i in range(2, int(x**0.5)+1):
print(i)
if x % i == 0:
break
else:
print(x)
break
x += 1
|
p02838
|
s686641855
|
Accepted
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
MOD = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
ans = 0
for i in range(60):
x = 0
for j in range(n):
if a[j] >> i & 1:
x += 1
ans += x * (n - x) * 2 ** i
ans %= MOD
print(ans)
if __name__ == '__main__':
main()
|
p02725
|
s173984534
|
Wrong Answer
|
K,N = map(int,input().split())
L = [i for i in map(int,input().split())]
L.append(L[0])
dist = []
for i in range(N):
if L[i+1] == 0 or L[i+1] == K:
dist.append(min(abs(0-L[i]),abs(K-L[i])))
else:
dist.append(abs(L[i+1]-L[i]))
print(sum(dist)-max(dist))
|
p02910
|
s537337850
|
Accepted
|
S = list(input())
ans = True
for i in range(len(S)):
if i % 2 != 0:
if S[i] != "L" and S[i] != "U" and S[i] != "D":
ans = False
else:
if S[i] != "R" and S[i] != "U" and S[i] != "D":
ans = False
if ans:
print("Yes")
else:
print("No")
|
p03126
|
s103135175
|
Wrong Answer
|
#ABC118
n,m = list(map(int,input().split()))
food = [0] * m
for i in range(n):
a = list(map(int,input().split()))
for j in a[1:]:
food[j-1] += 1
l = [food[i] for i in range(len(food)) if food[i] == n]
print(len(set(l)))
|
p02633
|
s573833046
|
Accepted
|
# do simulation
X = int(input())
Y, K = 0, 0
while True:
Y += X
K += 1
if Y % 360 == 0:
print(K)
exit()
|
p02641
|
s765043390
|
Accepted
|
''''atcoder beginner contest-170'''
import math
from collections import defaultdict
def r():
return int(input())
def rm():
return map(int,input().split())
def rl():
return list(map(int,input().split()))
'''C'''
x,n=rm()
l=True
try:
a=rl()
except:
a=[]
b=defaultdict(int)
for i in a:
b[i]=1
mini=math.inf
value=-1
for j in range(-101,201):
if b[j]!=1:
if abs(x-j)<mini:
mini=abs(x-j)
value=j
print(value)
|
p03705
|
s474704778
|
Accepted
|
N,A,B = map(int,input().split())
if A > B :
print(0)
elif N == 1 and A == B:
print(1)
elif N == 1 and A!= B:
print(0)
else:
a = (N-2)*(B-A) + 1
print(a)
|
p03017
|
s387649339
|
Wrong Answer
|
n, a, b, c, d = map(int, input().split())
s = input()
if "##" in s[a:max(c,d)]:
print ("No")
exit()
if c > d:
if "..." not in s[b:d]:
print ("No")
exit()
print ("Yes")
|
p02608
|
s268909403
|
Accepted
|
import sys
import collections
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
def main():
N = int(input())
c = collections.Counter()
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
c[x * x + y * y + z * z + x * y + y * z + z * x] += 1
for i in range(1, N + 1):
print(c[i])
if __name__ == '__main__':
main()
|
p02578
|
s335625223
|
Accepted
|
def i():
return int(input())
def i2():
return map(int,input().split())
def s():
return str(input())
def l():
return list(input())
def intl():
return list(int(k) for k in input().split())
n = i()
a = intl()
ans = 0
for i in range(1,n):
if a[i-1] > a[i]:
ans += (a[i-1] - a[i])
a[i] += (a[i-1] - a[i])
print(ans)
|
p03774
|
s567200607
|
Accepted
|
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
where=[]
for i in range(n):
distance=10**9
for j in range(m):
if distance>abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1]):
distance=abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
w=j
where.append(w+1)
[print(i) for i in where]
|
p03427
|
s066594393
|
Accepted
|
n = input()
ans = 0
accu = 0
for i, j in enumerate(n):
j = int(j)
if j>0:
ans = max(ans, accu+j-1+9*(len(n)-i-1))
accu += j
ans = max(ans, accu)
print(ans)
|
p03680
|
s559030216
|
Accepted
|
def resolve():
N = int(input())
A = [int(input()) - 1 for _ in range(N)]
flgs = [False for _ in range(N)]
flgs[0] = True
i = A[0]
flgs[i] = True
cnt = 1
while not flgs[1]:
i = A[i]
if flgs[i]:
print(-1)
return
else:
flgs[i] = True
cnt += 1
else:
print(cnt)
resolve()
|
p02784
|
s996675491
|
Wrong Answer
|
H,N = map(int,input().split())
A = list(map(int,input().split()))
Sum = sum(A)
if H - Sum < 0:
print("Yes")
elif H - Sum > 0:
print("No")
|
p03607
|
s844218647
|
Accepted
|
n=int(input())
a=[int(input()) for _ in range(n)]
paper=set()
for i in range(n):
if a[i] not in paper:
paper.add(a[i])
continue
if a[i] in paper:
paper.discard(a[i])
continue
print(len(paper))
|
p03759
|
s846390828
|
Wrong Answer
|
a , b , c = map(int,input().split())
if b - a == c - b:
print("Yes")
else:
print("No")
|
p03264
|
s080333000
|
Accepted
|
K = int(input())
print(len(range(2, K+1, 2)) * len(range(1, K+1, 2)))
|
p02833
|
s184260875
|
Wrong Answer
|
n = int(input())
ans = 0
if n%2 == 1:
print(0)
else:
n //= 2
while n > 0:
ans += n//5
n //= 5
print(ans)
|
p04019
|
s200935722
|
Accepted
|
from collections import Counter
C = Counter(input())
if ((C["N"] == 0 and C["S"] == 0) or (C["N"] != 0 and C["S"] != 0)) and ((C["W"] == 0 and C["E"] == 0) or (C["W"] != 0 and C["E"] != 0)):
print("Yes")
else:
print("No")
|
p02773
|
s771153963
|
Accepted
|
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
dic[input()] += 1
max_s = max(dic.values())
for k, v in sorted(dic.items()):
if v == max_s:
print(k)
|
p02761
|
s353850207
|
Wrong Answer
|
n,m = [int(x) for x in input().split()]
li = list()
for i in range(m):
li.append([int(x) for x in input().split()])
for i in range(1000):
length = len(str(i))
for j in li:
if (length<j[0] or length != n):
break
if (str(i)[j[0]-1] != str(j[1])):
break
else :
print(i)
break
else:
print("-1")
|
p03042
|
s734092578
|
Wrong Answer
|
S = input()
year_list = ["01","02","03","04","04","05","06","07","08","09","10","11","12"]
if S[0:2] in year_list:
if S[2:4] in year_list:
print("AMBIGUOUS")
elif S[2:4] == "00":
print("NA")
elif int(S[2:4]) >= 32:
print("NA")
else:
print("YYMM")
elif S[0:2] == "00":
print("NA")
elif int(S[0:2]) >= 32:
print("NA")
else:
if S[2:4] in year_list:
print("MMYY")
else:
print("NA")
|
p02665
|
s017509865
|
Accepted
|
N = int(input())
A = list(map(int, input().split()))
b = [0] * (N+1)
b[0] = 1
flag = True
for i in range(N):
if A[i] > b[i]:
flag = False
b[i+1] = (b[i] - A[i]) * 2
if A[N] > b[N]:
flag = False
ans = 0
l = 0
for i in range(N, -1, -1):
l += A[i]
ans += min(l, b[i])
if flag:
print(ans)
else:
print(-1)
|
p02675
|
s718010080
|
Accepted
|
n = int(input())
n = n % 10
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
print("pon")
else:
print("bon")
|
p03386
|
s885898690
|
Wrong Answer
|
A, B, K = map(int, input().split())
for i in range(A, A + K):
print(i)
for i in range(B - K + 1, B + 1):
print(i)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.