problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p03417 | s347582925 | Accepted | url = "https://atcoder.jp/contests/abc090/tasks/arc091_a"
import copy
def main():
tate, yoko = list(map(int, input().split()))
count = 0
if tate == 1 and yoko == 1:
print("1")
exit()
elif tate == 1:
print(yoko - 2)
exit()
elif yoko == 1:
print(tate - 2)
exit()
count += (yoko - 2) * (tate - 2)
print(count)
if __name__ == '__main__':
main()
|
p02624 | s547670595 | Accepted | N = int(input())
divisors = [1] * (N+1)
for i in range(2,N+1):
for j in range(i,N+1,i):
divisors[j] += 1
print(sum(i*divisors[i] for i in range(1,N+1))) |
p03799 | s228199201 | Accepted | N, M = map(int, input().split())
if N == M // 2:
ans = N
if N > M // 2:
ans = M // 2
if N < M // 2:
ans = N
M -= (N * 2)
ans += M // 4
print(ans)
|
p03250 | s291927635 | Accepted | abc = list(map(int, input().split()))
abc.sort()
print(int(str(abc[2]) + str(abc[1])) + abc[0]) |
p03998 | s750366877 | Wrong Answer | a = input().upper()
b = input().upper()
c = input().upper()
m = min(len(a),len(b),len(c))
t = 'A'
while m > 0:
if t=='A':
a = a[1:]
if len(a)<=0:
break
t = a[0]
elif t=='B':
b = b[1:]
if len(b)<=0:
break
t = b[0]
else:
c = c[1:]
if len(c)<=0:
break
t = c[0]
m = min(m,len(a),len(b),len(c))
print(t) |
p02933 | s344486209 | Accepted | a = int(input())
s = input()
if a < 3200:
print('red')
else:
print(s) |
p02879 | s403186588 | Accepted | l=list(map(int,input().split()))
a=l[0]
b=l[1]
if(a>9 or a<1 or b>9 or b<1):
print(-1)
else:
print(a*b) |
p02970 | s376768070 | Accepted | n, d = map(int, input().split())
a = 1 + 2 * d
if n / a % 1 == 0:
print(int(n / a))
else:
print(int(n / a) + 1) |
p03637 | s834986936 | Accepted | n=int(input())
a=list(map(int,input().split()))
x=[i for i in a if i%4==0]
b=[i for i in a if i%4!=0 and i%2==0]
if len(x)>=n//2 or +len(x)+len(b)//2>=n//2:
print("Yes")
else:
print("No") |
p02556 | s873610440 | Accepted | N=int(input())
nodes=[]
plus=[]
minus=[]
for i in range(N):
x,y=map(int,input().split())
nodes.append((x,y))
plus.append(x+y)
minus.append(x-y)
print(max(max(plus)-min(plus),max(minus)-min(minus))) |
p02727 | s800751958 | Accepted | X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)
ans = sorted(P[:X] + Q[:Y])
for i in range(min(C, X+Y)):
if R[i] > ans[i]:
ans[i] = R[i]
print(sum(ans)) |
p03645 | s429137238 | Accepted | from collections import deque
N,M=map(int,input().split())
#S = [[0 for j in range(3)] for i in range(2)] 2行3列の場合
S = [[]for i in range(N+1)]
deq=deque()
for i in range(M):
A,B=map(int,input().split())
S[A].append(B)
S[B].append(A)
#print(S)
lenN=len(S[N])
for i in range(lenN):
v=S[N][i]
#print(v)
#print(S[v])
if 1 in S[v]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE") |
p02664 | s500445366 | Wrong Answer | t=str(input())
t=list(t)
for i in range(1,len(t)):
if t[i]=="?":
t[i]="D"
print("".join(t)) |
p03338 | s570816741 | Accepted | from collections import Counter
N = int(input())
s = input()
mx = 0
for i in range(1,N):
ans1 = dict(Counter(s[:i]))
ans2 = dict(Counter(s[i:]))
count = 0
for j in ans1:
if j in ans2:
count += 1
mx = max(mx,count)
print(mx) |
p02995 | s515633023 | Accepted | from fractions import gcd
A,B,C,D = map(int,input().split())
def Num_div(num,div):
return num//div
def NoDiv(num,div1,div2):
return num-Num_div(num,div1)-Num_div(num,div2)+Num_div(num,div1*div2//gcd(div1,div2))
print(NoDiv(B,C,D)-NoDiv(A-1,C,D)) |
p03427 | s131377051 | Accepted | import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7
si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))
S = si()
digit = len(S)
head, remaining = S[0], S[1:]
ans = int(head) + 9 * (digit-1)
if remaining != '9' * (digit-1):
ans -= 1
print(ans)
|
p03285 | s207512264 | Accepted | n = int(input())
for i in range(n):
for j in range(n):
if 4 * i + 7 * j == n:
print('Yes')
exit(0)
print('No')
|
p03657 | s313858567 | Accepted | def yagi(a , b):
ans = ""
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
ans = "Possible"
else:
ans = "Impossible"
return ans
def main():
a , b= map(int , input().split())
print(yagi(a , b))
if __name__ == '__main__':
main() |
p02639 | s839175314 | Accepted | X = list(map(int, input().split()))
if X[0] == 0: print(1)
elif X[1] == 0: print(2)
elif X[2] == 0: print(3)
elif X[3] == 0: print(4)
else: print(5) |
p02658 | s700369675 | Accepted | n = int(input())
a = list(map(int,input().split()))
if 0 in a:
print(0)
exit()
ans = 1
for i in a:
ans *= i
if(ans > 10**18):
print(-1)
exit()
print(ans) |
p03013 | s454488578 | Wrong Answer | n,m=map(int,input().split())
lst=[int(input()) for i in range(m)]
DP=[0]*(n+1)
temp=0
DP[0]=1
DP[1]=1
for i in range(n+1):
if i in lst:
DP[i]=0
else:
DP[i]=(DP[i-1]+DP[i-2])%(10**9+7)
print(DP[n]) |
p03815 | s739347004 | Accepted | x=int(input())
quo=x//11
rst=x%11
if rst==0:
ans=quo*2
elif rst<=6:
ans=(quo*2)+1
else:
ans=(quo*2)+2
print(ans) |
p03838 | s648039971 | Wrong Answer | X,Y = list(map(int,input().split()))
if X==Y:
print(0)
if X<Y:
if X<0 and Y>0:
print(1+abs(Y+X))
else:
print(Y-X)
if X>Y:
if X>0 and Y<0:
print(1+abs(X+Y))
elif X>0 and Y>0:
print(1+X+Y)
elif X<0 and Y<0:
print(2+X-Y)
else:
print(X-Y)
|
p02971 | s329235663 | Accepted | n = int(input())
A = []
M = 0
j = -1
for i in range(n):
a = int(input())
A.append(a)
if a > M:
M = a
j = i
A.sort()
for i in range(n):
if i == j:
print(A[-2])
continue
print(M) |
p02922 | s693797876 | Accepted | A, B = [int(i) for i in input().split()]
res = 0
cnt = 1
while True:
if cnt >= B:
break
else:
cnt += (A-1)
res += 1
print(res)
|
p03719 | s091582234 | Wrong Answer | a,b,c=list(map(int,input().split()))
if a<=c<=b:print('YES')
else:print('NO') |
p02783 | s283286701 | Wrong Answer | h, a = map(int, input().split())
print(h // a +1) |
p03821 | s118577723 | Wrong Answer | n = int(input())
a,b=[],[]
for i in range(n):
x,y = map(int,input().split())
a.append(x)
b.append(y)
a=list(reversed(a))
b=list(reversed(b))
OK=0
for i in range(n):
A=a[i]+OK
ok=b[i]-A%b[i]
OK+=ok
print(OK)
|
p02775 | s800399468 | Accepted | #E
#greedy
n = input()
l = len(n)
#a is kuriagari naku, pittari na case
#b is kuriagari ari
a,b = 0,1
for v in n:
v = int(v)
a_next = min(a+v, b+(10-v))
b_next = min(a+v+1, b+(10-(v+1)))
a = a_next
b = b_next
#繰り上がりが発生する⇔引く数を+1する
#(10-v)や(10-(v+1)) means charges
#last keta is pittari, no amari happenes
print(a) |
p03644 | s720170163 | Accepted | N = int(input())
if N < 2:
print(1)
elif N < 4:
print(2)
elif N < 8:
print(4)
elif N < 16:
print(8)
elif N < 32:
print(16)
elif N < 64:
print(32)
elif N < 128:
print(64)
|
p02696 | s079620009 | Accepted | import math
A, B, N = map(int, input().split())
if B > N:
ans = math.floor(A * N / B) - A * math.floor(N / B)
else:
ans = math.floor(A * (B - 1) / B)
print(ans) |
p02607 | s005265636 | Wrong Answer | N = int(input())
a = list(map(int, input().split()))
count = 0
for i, a in enumerate(a):
if i % 2 == 1:
if a % 2 == 1:
count += 1
print(count)
|
p03103 | s290414140 | Accepted | # solution
nim, mike = map(int, input().split())
array = [list(map(int, input().split())) for _ in range(nim)]
array.sort()
ans = 0
for i in range(nim):
ans += array[i][0] * min(mike, array[i][1])
mike -= array[i][1]
if mike <= 0:
break
print(ans)
|
p03417 | s104371397 | Accepted | n,m = map(int,input().split())
if n == 1 and m == 1:
print(1)
elif n == 1:
print(max(0, m-2))
elif m == 1:
print(max(0, n-2))
else:
print((n-2) * (m-2))
|
p03544 | s097260768 | Wrong Answer | n = int(input())
L = [2,1]
if n == 1:
print(L[1])
else:
for i in range(2,n+1):
l = L[i-2] + L[i-1]
L.append(l)
print(L[-1]) |
p02594 | s566060471 | Accepted | x=int(input())
if x >= 30:
print('Yes')
else:
print('No') |
p02689 | s953998070 | Accepted | N, M = map(int, input().split())
H = list(map(int, input().split()))
good = [1 for i in range(N)]
for i in range(M):
A, B = map(int, input().split())
if H[A-1] < H[B-1]:
good[A-1] = 0
elif H[A-1] > H[B-1]:
good[B-1] = 0
else:
good[A-1] = good[B-1] = 0
count = 0
for g in good:
if g == 1:
count += 1
print(count)
|
p03105 | s466971042 | Accepted | A,B,C = map(int,input().split())
nec = A*C
if(B>=nec):
print(C)
else:
i = C
while all:
if(A*i <= B):
break
else:
i -= 1
print(i) |
p02691 | s845148216 | Wrong Answer | n = int(input())
a = list(map(int,input().split()))
b1 = []
b2 = []
answer = 0
for i in range(n):
b1.append(i + 1 - a[i])
b2.append(i + 1 + a[i])
for i in range(n - 1):
answer += b2[i + 1: n].count(b1[i])
print(answer) |
p03545 | s203267344 | Accepted | s = input()
def op(i):
if i == 0:
return "+"
else:
return "-"
for i in range(2):
for k in range(2):
for j in range(2):
f = s[0] + op(i) + s[1] + op(k) + s[2] + op(j) + s[3]
if eval(f) == 7:
print(f + "=7")
exit() |
p03711 | s208153964 | Accepted | lst1 = [4,6,9,11]
lst2 = [2]
lst3 = [1,3,5,7,8,10,12]
x,y = map(int,input().split())
if x in lst1 and y in lst1:
print('Yes')
elif x in lst2 and y in lst2:
print('Yes')
elif x in lst3 and y in lst3:
print('Yes')
else:
print('No') |
p02546 | s375503948 | Accepted | words = input()
if words[-1] != "s":
words += "s"
else:
words += "es"
print(words)
|
p03962 | s825652155 | Accepted | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
a,b,c=map(int, input().split())
if a==b!=c or a==c!=b or b==c!=a:
print(2)
elif a==b==c:
print(1)
else:
print(3)
resolve() |
p03131 | s915052311 | Wrong Answer | K,A,B=map(int,input().split())
bis=1
if K==1:
bis+=1
elif A>=B-1:
bis+=K
else:
if int((K-(A-1)))%2==0:
bis=int(A+(B-A)*(K-(A-1))/2)
else:
bis=int(A+(B-A)*((K-(A-1))//2))+1
print(bis) |
p03617 | s041332005 | Accepted | q, h, s, d = map(int, input().split())
n = int(input())
one = [q*4, h*2, s]
one.sort()
cost = 0
if one[0]*2>d:
cost += d*(n//2)
n %= 2
cost += one[0]*int(n)
n -= int(n)
if n==0:
print(cost)
else:
n *= 100
x = []
x.append(q*(n//25))
x.append(s*(n//50)+q*((n%50)//25))
print(min(x)+cost) |
p02860 | s811189309 | Wrong Answer | n = int(input())
s = str(input())
if n % 2 == 1:
print('No')
elif s[2//n:] == s[:2//n]:
print('Yes')
else:
print('No') |
p02909 | s303904132 | Accepted | l = ["Sunny", "Cloudy", "Rainy", "Sunny"]
s = input()
print(l[l.index(s) + 1])
|
p02971 | s128495003 | Accepted | n = int(input())
a = [int(input()) for i in range(n)]
m = max(a)
p = a.index(m)
a.remove(m)
s = max(a)
for i in range(n):
if i != p:
print(m)
else:
print(s)
|
p02694 | s117485639 | Wrong Answer | X = int(input())
n = 0
money = 100
while X > money:
money *= 1.01
money = int(money)
n += 1
print(n) |
p02700 | s571497412 | Accepted | import sys
si = sys.stdin.readline
def main():
l = [int(e) for e in si().split()]
Tcnt, Acnt = 0, 0
while l[0] > 0:
l[0] -= l[3]
Tcnt += 1
while l[2] > 0:
l[2] -= l[1]
Acnt += 1
if Tcnt >= Acnt:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
p02665 | s719905592 | Accepted | N = int(input())
A = list(map(int, input().split()))
ans = 0
leaves = sum(A)
node_num = 1
for i in range(N+1):
if A[i] > node_num:
print(-1)
exit()
ans += min(node_num, leaves)
leaves -= A[i]
node_num -= A[i]
node_num *= 2
print(ans)
|
p03611 | s503150959 | Accepted | n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in a:
ans+=(i-1),
ans+=(i),
ans+=(i+1),
from collections import*
c=Counter(ans)
res=c.most_common()[0][1]
print(res) |
p03943 | s419413613 | Wrong Answer | print(sum(map(int, input().split())) % 3 and "No" or "Yes") |
p04045 | s370322015 | Accepted | n,k = input().split()
d = input().split()
ni = int(n)
f = []
while True:
for j in range(len(d)):
if d[j] not in n:
f.append(True)
else:
f.append(False)
if False not in f:
break
f = []
ni += 1
n = str(ni)
print(ni) |
p03612 | s580252987 | Accepted | n=int(input())
alis=list(map(lambda x:int(x)-1,input().split()))
counter=0
for i in range(n):
if i!=n-1:
if i==alis[i]:
alis[i],alis[i+1]=alis[i+1],alis[i]
counter+=1
else:
if i==alis[i]:
alis[i],alis[i-1]=alis[i-1],alis[i]
counter+=1
print(counter) |
p02708 | s719582010 | Accepted | n, k = map(int, input().split())
MOD = 10 ** 9 + 7
ans = 0
a = 1
for i in range(1, n + 2):
a -= 2 * (i - 1)
if i >= k:
ans += (i * n + a)
ans %= MOD
print(ans) |
p03617 | s518070390 | Wrong Answer | Q, H, S, D = map(int, input().split())
N = int(input())
arr = [4*Q*N, 2*H*N, S*N]
if N % 2 == 0:
arr.append(int(0.5*D*N))
else:
arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
print(min(arr))
|
p03062 | s410595242 | Wrong Answer | n=int(input())
a=[0]*n
a=map(int,input().split())
z=0
result=0
min=1000000002
for i in a:
if i<0:
z+=1
i=abs(i)
result+=i
if i<min:
min=i
if z//2==1:
result-=min*2
print(result) |
p03095 | s662999418 | Wrong Answer | from collections import Counter
n = int(input())
s = input()
c = Counter(s)
k = c.keys()
ans = 1
for i in k:
ans *= (c[i]+1)
ans -= 1
print(ans)
|
p03059 | s979451984 | Wrong Answer | a,b,t = map(int,input().split())
print(float((3*a*b)/b)/float(t+0.5)) |
p03681 | s804112455 | Accepted | n, m = map(int,input().split())
ans = 1
if abs(n-m) == 0:
for i in range(1,n+1):
ans *= i
ans = ans%(10**9+7)
ans = 2*(ans**2)
print(ans%(10**9+7))
elif abs(n-m) == 1:
for i in range(1,min(n+1,m+1)):
ans *= i
ans = ans%(10**9+7)
ans = max(n,m)*(ans**2)
print(ans%(10**9+7))
else:
print(0) |
p02727 | s832985484 | Wrong Answer | 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()))
apple_point = 0
orange_point = 0
apple_taste = p + r
apple_taste.sort(reverse=True)
orange_taste = q + r
orange_taste.sort(reverse=True)
for i in range(0, X):
apple_point += apple_taste[i]
for j in range(0, Y):
orange_point += orange_taste[j]
print(apple_point + orange_point) |
p02719 | s830380271 | Wrong Answer | import sys
import math
n, k = map(int, input().split())
if k == 1:
print(0)
sys.exit()
n_start = math.floor(n / k)
# print(n_start)
n = n - n_start*k
# print(n)
while True:
min_n = n
n = abs(n-k)
# print("n, k =", n, k)
if min_n > n:
min_n = n
else:
break
print(min_n)
|
p02554 | s866671686 | Accepted | import sys
input = sys.stdin.readline
N = int(input().rstrip('\n'))
res = 10**N-(9**N)*2 + 8**N
print(res % 1000000007) |
p03379 | s311936205 | Wrong Answer | n = int(input())
x = list(map(int,input().split()))
m = x
m.sort
k = m[n//2-1]
l = m[(n-2)//2-1]
for i in range(n):
if(x[i]>l):
print(l)
else:
print(k)
|
p03644 | s043749893 | Accepted | N = int(input())
dic = {}
for i in range(1, N+1):
n = i
cnt = 0
while i % 2 == 0:
cnt += 1
i = i // 2
dic[n] = cnt
a = 0
b = 0
for k, v in dic.items():
if a < v:
b = k
a = v
if b == 0:
print(1)
else:
print(b)
|
p03324 | s868393212 | Accepted | d,n=map(int,input().split())
if n==100:
print(101*100**d)
else:
print(n*100**d)
|
p02760 | s564822808 | Accepted | import sys
A=[]
for a in range(3):
l=[int(i) for i in input().split()]
A.extend(l)
f=[0]*9
for i in range(int(input())):
b=int(input())
if b in A:
f[A.index(b)]=1
#print(f)
p=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for i in p:
if all(f[x]==1 for x in i):
print("Yes")
sys.exit()
print("No")
|
p03073 | s727822766 | Accepted | s = input()
ls = len(s)
o0 = s[::2].count('0')
e0 = s[1::2].count('0')
if e0>=o0:
print(ls//2-e0 + o0)
elif ls%2!=0:
print(ls//2+1-o0 + e0)
else:
print(ls//2-o0 + e0)
|
p03371 | s721228068 | Accepted | A, B, C, X, Y = map(int, input().split())
ans = float('INF')
for i in range(0, 2*max(X, Y)+1, 2):
ans = min(ans, int(A*max(0, X-i/2)+B*max(0, Y-i/2)+C*i))
print(ans)
|
p02779 | s551442977 | Accepted | n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
if len(a)==len(b):
print("YES")
else:
print("NO") |
p02873 | s753172896 | Accepted | s = input()
a1 = [0] * (len(s) + 1)
for i in range(len(s)):
if s[i] == '<':
a1[i + 1] = a1[i] + 1
a2 = [0] * (len(s) + 1)
for i in reversed(range(len(s))):
if s[i] == '>':
a2[i] = a2[i + 1] + 1
ans = 0
for i in range(len(a1)):
ans += max(a1[i], a2[i])
print(ans)
|
p02779 | s997393081 | Accepted | import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
N = I()
A = LI()
print("YES" if len(list(set(A)))==len(A) else "NO")
main()
|
p03592 | s594982604 | Accepted | N,M,K=map(int,input().split())
for i in range(N+1):
for j in range(M+1):
B=i*M+j*N-i*j*2
if B==K:
print('Yes')
exit()
print('No') |
p03435 | s018515002 | Accepted | c = []
for i in range(3):
c.append(list(map(int, input().split())))
a = [0]*3
b = []
for i in range(3):
b.append(c[0][i]-a[0])
for i in range(1, 3):
a[i] = c[i][0]-b[0]
for i in range(3):
for j in range(3):
if a[i]+b[j] != c[i][j]:
print("No")
exit()
print("Yes")
|
p04030 | s829498305 | Wrong Answer | s = input()
n = int(len(s))
word = "a"
for i in range(n):
if s[i] == '0':
word = word + "0"
if s[i] == '1':
word = word + "1"
if s[i] == 'B':
if int(len(s)) > 1:
word = word[:-1]
else:
word = word
w = word[1:]
print(w) |
p02678 | s237128869 | Accepted | from collections import*
(n,m),*c = [[*map(int,i.split())]for i in open(0)]
g = [[]for _ in range(n+1)]
for a,b in c:
g[a]+=[b]
g[b]+=[a]
q=deque([1])
r=[0]*(n+1)
while q:
v=q.popleft()
for i in g[v]:
if r[i]==0:
r[i]=v
q.append(i)
print("Yes",*r[2:],sep="\n")
|
p03472 | s166133794 | Accepted | from bisect import bisect_right
N,H = map(int,input().split())
A = []
B = []
for _ in range(N):
a,b = map(int,input().split())
A.append(a)
B.append(b)
A = sorted(A,reverse=True)
B = sorted(B)
a = A[0]
ind = bisect_right(B,a)
cnt = 0
flag = 0
for i in range(N-1,ind-1,-1):
H -= B[i]
cnt += 1
if H<=0:
flag = 1
break
if flag==0:
k = H//a
if H%a>0:
k += 1
cnt += k
print(cnt) |
p02924 | s766288940 | Wrong Answer | N=int(input())
print(N*(N-1)/2) |
p02818 | s858281235 | Accepted | a, b, k = map(int, input().split())
if a >= k:
print(a - k, b)
else:
print(0, max(b - k + a, 0)) |
p02917 | s136225412 | Wrong Answer | N = int(input())
B = list(map(int, input().split()))
x = 1
result = 0
count = 1
for a in B[:N-2]:
if a < B[x]:
result += a * count
if x < N - 2:
x += 1
else:
count += 1
if x < N - 2:
x += 1
continue
Z = 0
for i in range(N-2):
if B[i] < B[i + 1]:
Z = B[i]
break
print(result + B[N-2] + Z)
|
p02675 | s366992111 | Accepted | # https://atcoder.jp/contests/abc168/tasks/abc168_a
N = int(input())
last_num = int(str(N)[-1])
if last_num in {2, 4, 5, 7, 9}:
print('hon')
elif last_num in {0, 1, 6, 8}:
print('pon')
else:
print('bon') |
p02761 | s039436926 | Accepted | import sys
import math
N, M = map(int, input().split())
s, c = [0] * M, [0] * M
for i in range(M):
s[i], c[i] = map(int, input().split())
for i in range(0 if N == 1 else 10 ** (N - 1), 10 ** N):
x = str(i)
if M == 0:
print(i)
sys.exit(0)
for j in range(M):
if x[s[j] - 1] != str(c[j]):
break
elif j == M - 1:
print(i)
sys.exit(0)
print(-1) |
p03160 | s001989615 | Wrong Answer | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n = ni()
h = na()
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
count = 1
for i in range(2,n):
dp[i] = min(abs(h[i-1]-h[i])+dp[i-1], abs(h[i-2]-h[i])+dp[i-2])
print(dp) |
p02802 | s385458589 | Wrong Answer | from sys import stdin as s
n,m=map(int,s.readline().split())
l=[0]*n
wa=[0]*n
pen=0
for i in range(m):
x,y=s.readline().split()
x=int(x)-1
if y=="AC":
l[x]=1
elif not l[x] and not wa[x]:
wa[x]=1
pen+=1
print(sum(l),pen) |
p03069 | s914122781 | Wrong Answer | n = int(input())
s = input()
cou = 0
for i in range(n-1):
if "#."==s[i:i+2]:
cou += 1
print(cou)
|
p03416 | s221455306 | Accepted | a,b=map(int,input().split())
count = 0
for i in range(a,b+1):
if str(i)[0]==str(i)[4] and str(i)[1]==str(i)[3]:
count+=1
print(count) |
p03479 | s069670554 | Accepted | x,y = map(int,input().split())
ans = 0
cur = x
while cur <= y:
ans += 1
cur *= 2
print(ans) |
p02701 | s611778103 | Accepted | a = int(input())
d={}
r=0
for _ in range(a):
b= input()
if d.get(b): continue
else: d[b]= True; r+=1
print(r)
|
p03210 | s955674387 | Accepted | x = int(input())
if x==7 or x==5 or x==3:
print('YES')
else:
print('NO') |
p02854 | s703265257 | Accepted | n = int(input())
A = list(map(int, input().split()))
ca = [0]
for i in range(n):
ca.append(A[i]+ca[i])
ans = 2020202020
for i in range(n):
ans = min(ans, abs(ca[i]-(ca[-1]-ca[i])))
print(ans)
|
p03241 | s397993292 | Wrong Answer | n,m=map(int,input().split())
r=m//n
for i in range(n,r):
if m%i==0:
print(m//i)
break |
p03000 | s193974397 | Wrong Answer | N,X = map(int,input().split())
L = [int(i) for i in input().split()]
D = 0
for i in range(N) :
D = L[i]+D
# print(i,D)
if D>X :
print(i+1)
exit()
print(N) |
p02946 | s156425657 | Accepted | k, x = map(int, input().split())
ans = list(range(x - k + 1, x + k))
print(*ans, sep=' ') |
p03001 | s792711723 | Accepted | #!/usr/bin/env python3
def main():
W, H, x, y = map(int, input().split())
area = W * H / 2
multi = int((x == W / 2) and (y == H / 2))
print(area, multi)
if __name__ == '__main__':
main()
|
p02712 | s729842277 | Wrong Answer | n=int(input())
result=0
for i in range(n):
if i % 3 == 0 and i % 5 == 0:
result=result
elif i % 3 == 0:
result=result
elif i % 5 == 0:
result=result
else:
result=result+i
print(result)
|
p02859 | s629358033 | Accepted | r = int(input())
print(r*r) |
p02548 | s498111473 | Wrong Answer | num = 0
ans = 0
n = int(input())
for i in range(1,n):
for j in range(1,n):
for k in range(1,n):
if(((i * j) + k) == n):
num += 1
print(i, j, k)
print(num) |
p03632 | s650754604 | Accepted | a, b, c, d = map(int, input().split())
if a <= c and d <= b:
print(d-c)
elif c <= a and b <= d :
print(b-a)
elif b <= c :
print(0)
elif a <= c and c <= b :
print(b-c)
elif a <= d and d <= b :
print(d-a)
elif d <= a :
print(0) |
p02606 | s100309595 | Accepted | import sys
input = sys.stdin.readline
#N, K = (int(i) for i in input().split())
#B = [int(x) for x in input().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
L, R, d = (int(i) for i in input().split())
count = 0
for i in range(L, R+1):
if i%d == 0:
count += 1
print(count)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.