problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02706 | s646937342 | Wrong Answer | n, m = map(int, input().split())
l=list(map(int, input().split()))
ans= n-sum(l)
if ans>0:
print(ans)
else:
print(-1) |
p03943 | s960932303 | Accepted | a, b, c = map(int, input().split())
ma = max(a, b, c)
rem = a + b + c - ma
if ma == rem:
print('Yes')
else:
print('No')
|
p02583 | s688444289 | Accepted | n = int(input())
a = list(map(int, input().split()))
ans = 0
if n<3:
print(0)
exit()
for i in range(n):
for j in range(i+1, n):
for k in range(j+1, n):
if a[i]==a[j] or a[j]==a[k] or a[k]==a[i]:
continue
if a[i]+a[j]<=a[k] or a[j]+a[k]<=a[i] or a[k]+a[i]<=a[j]:
continue
ans += 1
print(ans) |
p02912 | s292139183 | Accepted | import heapq
N,M = (int(x) for x in input().split())
A = []
A = list((-1)*(int(x)) for x in input().split())
heapq.heapify(A)
sum = 0
while M != 0:
heapq.heappush(A,int(heapq.heappop(A)/2))
M -= 1
for i in range(len(A)):
sum += -A[i]
print(sum)
|
p03493 | s000873150 | Accepted | x = input()
y = 0
for i in x:
y += int(i)
print(y) |
p03699 | s995210078 | Accepted | n = int(input())
a = [int(input())for i in range(n)]
s = sum(a)
if s%10 != 0:
print(s)
else :
f = [i for i in a if i%10 != 0]
if len(f) == 0:
print(0)
else:
f.sort()
print(s -f[0])
|
p02971 | s393572976 | Accepted | N=int(input())
A=[int(input()) for _ in range(N)]
B=sorted(A,reverse=True)
for i in range(N):
if A[i]==B[0]:
print(B[1])
else:
print(B[0]) |
p02700 | s250484608 | Accepted | import math
a, b, c, d = map(int, input().split())
taka = math.ceil(a/d)
ao = math.ceil(c/b)
if taka >= ao:
print('Yes')
else:
print('No') |
p03860 | s112357526 | Accepted | a, b, c = map(str, input().split())
print(a[0] + b[0] + c[0]) |
p02987 | s036190498 | Accepted | s = input()
for i in s:
if s.count(i) != 2:
print('No')
exit()
print('Yes')
|
p02675 | s813371636 | Accepted | import sys
input = sys.stdin.readline
def main():
N = list(input().rstrip())
l = len(N)-1
n = int(N[l])
if n == 3:
print('bon')
elif n == 0 or n == 1 or n == 6 or n == 8:
print('pon')
else:
print('hon')
if __name__ == '__main__':
main() |
p02701 | s692172457 | Accepted | n = int(input())
l = [input() for _ in range(n)]
print(len(set(l))) |
p03565 | s717245452 | Accepted | s = input()
t = input()
ans = []
for i in range(len(s)-(len(t)-1)):
f = True
for j in range(len(t)):
if s[j+i] != t[j] and s[j+i] != '?':
f = False
if f == True:
s2 = s[:i] + t + s[i+len(t):]
s2 = s2.replace('?','a')
ans.append(s2)
if len(ans) > 0:
print(min(ans))
else:
print('UNRESTORABLE') |
p03821 | s755226727 | Accepted | n = int(input())
a = []
b = []
for i in range(n):
x, y = map(int, input().split())
a.append(x)
b.append(y)
ans = 0
a = a[::-1]
b = b[::-1]
for i in range(n):
if (a[i] + ans) % b[i] == 0:
next
else:
ans += b[i] - ((a[i]+ ans) % b[i])
print(ans) |
p02665 | s071377133 | Accepted | N = int(input())
A = list(map(int,input().split()))
bunretsu = sum(A) - 1
zanretsu = 1
souwa = 0
for i in range(N+1):
souwa += zanretsu
if A[i] <= zanretsu:
zanretsu -= A[i]
else:
souwa = -1
break
if bunretsu >= 1 and bunretsu <= zanretsu:
zanretsu += bunretsu
bunretsu = 0
elif bunretsu >= 1 and bunretsu > zanretsu:
bunretsu -= zanretsu
zanretsu *= 2
print(souwa) |
p02621 | s776668078 | Accepted | a = int(input())
print(a+a*a+a*a*a) |
p03543 | s783555581 | Accepted | a,b,c,d=input()
if a==b==c or b==c==d:
print("Yes")
else:
print("No") |
p02577 | s536845347 | Wrong Answer | n = list(input())
m=0
for i in range(1, len(n)):
m+=i
if m%9==0:
print("Yes")
else:
print("No")
|
p02862 | s860584992 | Wrong Answer | x,y = map(int,input().split())
mod = 10**9+7
s = 0
mx = 10**6
fact = [1]*(mx+1)
for i in range(mx):
fact[i+1] = fact[i]*(i+1)%mod
def inv(n):
return pow(n,mod-2,mod)
if (x%3==0 and y%3==0) or (x%3==1 and y%3==2) or (x%3==2 and y%3==1):
n = int(2*x/3-y/3)
m = int(-x/3 + 2*y/3)
s += fact[n+m]*inv(fact[n])*inv(fact[m])%mod
print(s)
else:
print(0) |
p02790 | s017880944 | Accepted | a,b=input().split()
c = str(a)*int(b)
d = str(b)*int(a)
if a<b:
print(c)
else:
print(d) |
p02690 | s493775096 | Accepted | x=int(input())
c=0
for i in range(-130,130):
if c==1:
break
for j in range(-130,130):
if i**5-j**5==x:
print(i,j)
c=1
break |
p03803 | s933306147 | Wrong Answer | a,b=map(int,input().split())
if a==b:
print("Draw")
elif a==1 or a>=b:
print("Alice")
else:
print("Bob") |
p02677 | s560804830 | Accepted | import math
a, b, h, m = map(int, input().split())
alpha = 30.0 * h + (30 * m / 60)
beta = m * 6.0
if alpha < beta:
theta = beta - alpha
else:
theta = alpha - beta
print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(theta)))) |
p02912 | s156010723 | Accepted | import heapq
import math
from heapq import heappop
n,m = map(int,input().split())
A = list(map(lambda x:-int(x),input().split()))
heapq.heapify(A)
for i in range(m):
x = heapq.heappop(A)
heapq.heappush(A,-(-x//2))
print(-sum(A)) |
p02696 | s997291129 | Wrong Answer | print(1000000) |
p03943 | s109164113 | Wrong Answer | a, b, c = map(int, input().split())
if a + b == c:
print('yes')
elif b + c == a:
print('yes')
elif c + a == b:
print('Yes')
else:
print('No')
|
p02688 | s249006467 | Accepted | n, k = map(int, input().split())
a_set = set()
for _ in range(k):
input()
a = set(map(int, input().split()))
a_set = a_set | a
n_set = set()
for i in range(1,n+1):
n_set.add(i)
ans = n_set - a_set
print(len(ans))
|
p02786 | s977742835 | Accepted | N = int(input())
A = []
for i in range(100):
if sum(A) >= 10e12:
break
A.append(pow(2,i))
if N == 1:
print(1)
else:
for i in range(50):
N = N//2
if N <= 0:
print(sum(A[:i+1]))
break |
p04005 | s743217437 | Accepted | a, b, c = map(int, input().split())
print(0 if a * b * c % 2 == 0 else a * b * c // max(a, b, c) )
|
p02570 | s598103382 | Wrong Answer | d,t,s=map(int,input().split())
if d/s<=t:
print("YES")
else:
print("NO") |
p02783 | s375437010 | Wrong Answer | H,A = map(int,input().split())
count = H%A + 1
print(count) |
p02687 | s575522586 | Wrong Answer | s = input()
output = "ABC"
if s == output:
output = "ARC"
print(s) |
p03627 | s167841064 | Accepted | n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
b=-1
ans=[0,0]
for ai in a:
if len(ans)==4:
break
if b==ai:
ans.append(ai)
b=-1
else:
b=ai
print(ans[-1]*ans[-2])
|
p02731 | s937164896 | Accepted | l = int(input())
print(l**3/27)
|
p03001 | s575665510 | Accepted | import itertools
import math
import fractions
import functools
import copy
w, h, x, y = map(int, input().split())
ans = 0
if x == w / 2 and y == h / 2:
ans = 1
print(w*h/2,ans)
|
p02820 | s811543283 | Accepted | n, k = map(int,input().split())
r,s,p = map(int, input().split())
t = list(input())
a = [1]*n
for i in range(k,n):
if t[i] == t[i-k] and a[i-k] == 1:
a[i] = 0
ans = 0
for j in range(n):
if t[j] == 'r' and a[j] == 1:
ans += p
elif t[j] == 's' and a[j] == 1:
ans += r
elif t[j] == 'p' and a[j] == 1:
ans += s
print(ans) |
p03210 | s952505563 | Wrong Answer | x = int(input())
if x == 3 or x == 5 or x == 7:
print('Yes')
else:
print('No') |
p02899 | s475060393 | Wrong Answer | n=int(input())
a=list(input().split())
ans=[]
for i in range(n):
ans.append([a[i],i+1])
sort1=lambda val: val[0]
ans.sort(key=sort1)
num=[]
for i in range(n):
num.append(ans[i][1])
print(*num)
|
p02695 | s730549953 | Wrong Answer | # O(n^M) -> TLE
from itertools import product
N, M, Q = map(int, input().split())
ls = []
for i in range(Q):
ls.append([int(j) for j in input().split()])
arr = list(range(1, M+1))
ans = 0
for x in product(arr, repeat=N):
cur = 0
for y in ls:
if x[y[1]-1] - x[y[0]-1] == y[2]:
cur += y[3]
ans = max(ans, cur)
print(ans) |
p02660 | s212628132 | Accepted | from math import floor
from math import sqrt
N = int(input())
def f(x):
return (floor((-1+sqrt(1+8*x))/2.0))
ans = 0
i = 2
while N > 1:
x = 0
while N % i == 0:
N = N // i
x = x + 1
if x != 0:
ans = ans + f(x)
i = i + 1
if i > 10 ** 6:
ans = ans + 1
break
print(ans) |
p03250 | s304629797 | Accepted | n = [int(_) for _ in input().split()]
print(max(n)*9 + sum(n))
|
p03673 | s484435228 | Accepted | import sys
input = sys.stdin.readline
def read():
N = int(input().strip())
A = list(map(int, input().strip().split()))
return N, A
def solve(N, A):
B = [0 for a in A]
mid = N // 2
for i in range(0, N, 2):
B[mid+i//2] = A[i]
for i in range(1, N, 2):
B[mid-(i+1)//2] = A[i]
if N % 2 == 1:
print(*B[::-1])
else:
print(*B)
if __name__ == '__main__':
inputs = read()
solve(*inputs)
|
p03061 | s106876957 | Accepted | N = int(input())
A = list(map(int, input().split()))
from fractions import gcd
left = [A[0]]
right = [A[-1]]
for i in range(1, N-1):
left.append(gcd(left[-1], A[i]))
right.append(gcd(right[-1], A[-1-i]))
ans = 1
for i in range(N):
if i == 0:
tmp = right[-1]
elif i == N-1:
tmp = left[-1]
else:
tmp = gcd(left[i-1], right[N-2-i])
ans = max(ans, tmp)
print(ans)
|
p03327 | s225176616 | Accepted | n=int(input())
x=n-999 if n>999 else n
if n>999:
print("ABD")
else:
print("ABC") |
p03471 | s565986507 | Accepted |
import sys
N,Y = map(int,input().split())
for i in range(N+1):
for j in range(N-i+1):
k = N - i - j
if i * 10000 + j * 5000 + k * 1000 == Y:
print (i,j,k)
sys.exit()
print (-1,-1,-1)
|
p03241 | s833490844 | Wrong Answer | n,m = map(int,input().split())
ans = 0
for i in range(1,int(m**0.5)+1):
if m%i==0:
x = m//i
if x>=n:
ans = i
print(ans) |
p02730 | s231555102 | Accepted | s=input()
def kaibun(aa) :
for i in range(len(aa)):
if aa[i]!=aa[-i-1] :
return False
return True
b=int((len(s)-1)/2)
c=int((len(s)+3)/2)
mae=s[:b]
ato=s[c-1:]
if kaibun(s) and kaibun(mae) and kaibun(ato) :
print ('Yes')
else :
print('No') |
p03146 | s559348834 | Accepted | s = int(input())
L = []
for c in range(2 , 10 ** 6 + 1):
L.append(s)
if s % 2 == 0:
s = s // 2
elif s % 2 == 1:
s = s * 3 + 1
if s in L:
break
print(c) |
p02796 | s261003317 | Accepted | from collections import deque
import sys
input = sys.stdin.readline
from heapq import heapify
N = int(input())
table = []
for i in range(N):
X,L = map(int, input().split())
table.append((X-L,X+L))
table.sort(key=lambda x:x[0])
cur = table[0]
for i in range(1,N):
if table[i][0] < cur[1]:
N -= 1
if cur[1] >= table[i][1]:
cur = table[i]
else:
cur = table[i]
print(N) |
p02697 | s983460547 | Wrong Answer | n, m = map(int, input().split())
# 和が一定になるように出力
# even => n + 1
# odd => n
x = n // 2
s = n + 1 if n % 2 == 0 else n
cnt = 0
while True:
print(x, s - x)
x -= 1
cnt += 1
if cnt == m:
exit()
|
p02706 | s049716450 | Accepted | N,M = map(int,input().split())
A = list(map(int,input().split()))
if sum(A) > N:
print(-1)
else:
print(N-sum(A))
|
p03038 | s000516093 | Accepted | N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
from operator import itemgetter
BC.sort(key=itemgetter(1), reverse=True)
for b, c in BC:
A += [c]*b
if len(A) > 2*N:
break
A.sort(reverse=True)
print(sum(A[:N]))
|
p03109 | s848142555 | Accepted | s = input().split("/")
if int(s[0]) <= 2019 and int(s[1]) <= 4 and int(s[2]) <= 30:
print("Heisei")
else:
print("TBD")
|
p03324 | s655294083 | Accepted | D, N = map(int, input().split())
if N != 100:
print(100**D * N)
else:
print(100**D * (N+1))
|
p03264 | s688424486 | Accepted | a = int(input())
if a%2 == 1:
print((a//2+1)*(a//2))
else:
print((a//2)*(a//2)) |
p03408 | s007086010 | Wrong Answer | import sys
from collections import defaultdict
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
d=defaultdict(int)
for x in s:
d[x]+=1
for y in t:
d[y]-=1
print(max(d.values())) |
p02767 | s735266971 | Accepted | N = int(input())
X = list(map(int, input().split()))
ans_list = []
tmp = 0
for i in range(1, max(X) + 1):
tmp = 0
for j in X:
tmp += (j - i)**2
ans_list.append(tmp)
print(min(ans_list)) |
p03665 | s955907727 | Wrong Answer | n,p=map(int,input().split())
a=list(map(int,input().split()))
gu=0
ki=0
for aa in a:
if aa%2==0:
gu+=1
else:
ki+=1
gusu=2**gu
if ki>0:
kisu=2**(ki-1)
else:
kisu=1
print(gusu*kisu)
#pが0だったら選ぶ袋の合計が偶数
#kisu の個数が偶数
#nが1だったら選ぶ袋の合計が奇数
#gusu の個数が奇数
#nは50、全探索はできんね
|
p03698 | s638194397 | Accepted | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
S = readline().strip()
if len(S) == len(set(S)):
print('yes')
else:
print('no')
return
if __name__ == '__main__':
main()
|
p02755 | s292973332 | Accepted | a, b = map(int,input().split())
ans = -1
for i in range(1500):
if (a==int(i*0.08)) and (b==int(i*0.1)):
ans = i
break
print(ans)
|
p03331 | s881541896 | Accepted | N = int(input())
cmin = N
for i in range(1,N//2):
j = N-i
a = str(i)
b = str(j)
cnt = 0
for k in range(len(a)):
cnt += int(a[k])
for k in range(len(b)):
cnt += int(b[k])
cmin = min(cmin,cnt)
print(cmin) |
p02801 | s517811565 | Accepted | c = input()
alp = ["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"]
count1 = 0
count2 = 0
while count2 <= 26:
if alp[count1] == c:
count1 += 1
count2 += 27
else:
count1 += 1
count2 += 1
print(alp[count1]) |
p03644 | s106695586 | Accepted | N = int(input())
a = 1
while a*2 <= N:
a *= 2
print(a) |
p02797 | s220148940 | Accepted | N,K,S = map(int,input().split())
import numpy as np
ans = np.array([S+1]*N)
if S==10**9:
ans = np.array([S-10**5]*N)
ans[0:K]=S
ans = list(ans)
print(' '.join(map(str,ans))) |
p03455 | s965148612 | Wrong Answer | import math
a,b=map(int,input().split())
a=str(a)
b=str(b)
c=a+b
d=int(c)
e=math.sqrt(d)
if e.is_integer():
print("yes")
else:
print("no") |
p03557 | s644653456 | Accepted | import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
an = bisect.bisect_left(a, i)
cn = n - bisect.bisect_right(c, i)
ans += an * cn
print(ans)
|
p02601 | s251882957 | Wrong Answer | a = list(map(int,input().split()))
#b = list(map(int,input().split()))
b=int(input())
for i in range(b):
if a[0]<=a[1]<=a[2] or a[0]<=a[2]<=a[1] or a[2]<=a[1]<=a[0] or a[1]<=a[2]<=a[0] or a[2]<=a[0]<=a[1]:
a[2]=2*a[2]
if a[1]<=a[0]<=a[2]:
a[1]=2*a[1]
if a[0]<a[1]<a[2]:
print("Yes")
else:
print("No")
|
p02813 | s654290765 | Accepted | from itertools import product, permutations, combinations
n = int(input())
pn = tuple(map(int, input().split(' ')))
qn = tuple(map(int, input().split(' ')))
orders = []
for i, v in enumerate(permutations(range(1, n + 1), n)):
if v == pn:
orders.append(i)
if v == qn:
orders.append(i)
print(abs(orders[0] - orders[1]))
|
p03838 | s294705798 | Wrong Answer | x,y = map(int,input().split())
ans = 0
if x <= y:
ans = y - x
else: # x > y
if abs(x) > abs(y):
if y < 0:
ans = abs(x - y) + 1
else:
ans = abs(x - y) + 2
elif abs(x) < abs(y):
ans = abs(y - x) + 1
if x < 0:
ans += 1
else:
ans = 1
print(ans) |
p02888 | s405133788 | Accepted | import bisect
N = int(input())
L = sorted(map(int, input().split()))
res = 0
for i in reversed(range(1, N)):
for j in reversed(range(i)):
index = bisect.bisect_left(L, L[i] + L[j])
n = N - index
res += (N - 1 - i) - n
print(res)
|
p02600 | s954117326 | Accepted | x = int(input())
if 400 <= x < 600:
print(8)
elif 600 <= x < 800:
print(7)
elif 800 <= x < 1000:
print(6)
elif 600 <= x < 1200:
print(5)
elif 1200 <= x < 1400:
print(4)
elif 1400 <= x < 1600:
print(3)
elif 1600 <= x < 1800:
print(2)
elif 1800 <= x < 2000:
print(1) |
p02987 | s027453199 | Accepted | S = input()
s = list(set(S))
print("Yes" if len(s) == 2 and S.count(s[0]) == S.count(s[1]) == 2 else "No") |
p03352 | s977551986 | Accepted | import numpy as np
whole = np.array(list({i**j for i in range(1, 32) for j in range(2, 32) if i**j <= 1000}))
whole.sort()
X = int(input())
print(whole[np.where(whole<=X)].max()) |
p02838 | s501330446 | Wrong Answer | mod = pow(10,9)+7
N = int(input())
A =map(lambda x:int(bin(int(x))[2:]) ,input().split())
counter = 0
for a in A:
counter += a
A = str(counter)
L = len(A)
tmp = 0
for i in range(L):
tmp += int(A[i])*(N-int(A[i]))*2**(L-i-1)
tmp %= mod
print(tmp) |
p03076 | s707629826 | Accepted | l = [int(input()) for _ in range(5)]
m = [10 * ((l[i] + 9) // 10) for i in range(5)]
t = 130 * 5
for i in range(5):
u = sum(m) - m[i] + l[i]
t = min(t, u)
print(t) |
p03449 | s985196280 | Wrong Answer | N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
ans1 = []
ans2 = []
for x in range(N):
if x == 0:
ans1.append(A1[x])
ans2.append(A1[x] + A2[x])
else:
ans1.append(ans1[x - 1] + A1[x - 1])
ans2.append(max(ans1[x], ans2[x - 1]) + A2[x])
print(ans2[N - 1])
|
p03042 | s813830505 | Wrong Answer | S = list(input())
M = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
if S[0:2] in M and not(S[2:] in M):
print("MMYY")
elif not(S[0:2] in M) and S[2:] in M:
print("YYMM")
elif S[0:2] in M and S[2:] in M:
print("AMBIGUOUS")
else:
print("NA") |
p02881 | s756221089 | Wrong Answer | #!/usr/bin/env python3
import math
import numpy as np
n = int(input())
ans = np.inf
for i in range(1, int(math.sqrt(n))+1):
if n%i==0:
q = n//i
tmp = i+q
if tmp <= ans:
ans = tmp
i_ = i
q_ = q
if i_ == 1 or q_ == 1:
print(ans-1)
else:
print(ans-2)
|
p02996 | s111700117 | Accepted | N = int(input())
AB = [tuple(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])
cnt = 0
for a,b in AB:
cnt += a
if cnt > b:
print("No")
exit()
print("Yes") |
p03281 | s857144454 | Wrong Answer | n=int(input())
if n>=189:
print('2')
elif n>=105:
print('1')
else:
print('0') |
p03971 | s619828679 | Accepted | n,a,b = map(int,input().split(" "))
s = input()
m_dict = {"a":0,"b":0,"c":0}
for i in s:
if i == "a":
if m_dict["a"]+m_dict["b"] < a+b:
m_dict["a"] += 1
print("Yes")
else:
print("No")
elif i == "b":
if m_dict["a"]+m_dict["b"] < a+b and m_dict["b"] < b:
m_dict["b"] += 1
print("Yes")
else:
print("No")
else:
print("No") |
p03774 | s173044523 | Accepted | def dist(x,y):
return abs(x[0]-y[0])+abs(x[1]-y[1])
n,m = map(int,input().split())
s = []
for _ in range(n):
a,b = map(int,input().split())
s.append((a,b))
c = []
for _ in range(m):
c_,d = map(int,input().split())
c.append((c_,d))
for i in range(n):
p = s[i]
md = 10**10
mi = 0
for j in range(m):
ch = c[j]
d = dist(p,ch)
if md > d:
md = d
mi = j
print(mi+1) |
p03645 | s636052907 | Accepted | N,M=map(int,input().split())
f=set()
t=set()
for i in range(M):
a,b=map(int,input().split())
if a<2:
f.add(b)
elif b==N:
t.add(a)
print(("IM","")[len(f&t)]+"POSSIBLE") |
p02576 | s227428439 | Accepted | n, x, t = list(map(int, input().rstrip().split(" ")))
print(((n-1)//x + 1)*t) |
p04020 | s837012442 | Accepted | n = int(input())
A = list(int(input()) for _ in range(n))
ans = 0
for i in range(n):
tmp = A[i]
ans += (tmp//2)
if i < n-1 and tmp %2 and A[i+1] > 0:
ans += 1
A[i+1] -= 1
print(ans) |
p03095 | s127808602 | Accepted | N=int(input())
S=input()
K=10**9+7
T={}
for s in S:
if s in T:
T[s]+=1
else:
T[s]=2
X=1
for a in T:
X=(X*T[a])%K
print((X-1)%K)
|
p02724 | s042004720 | Accepted | x=int(input())
thousands=(x-x%500)/500
fives=(x%500-(x%500)%5)/5
happiness=int(1000*thousands+5*fives)
print(happiness)
|
p02640 | s552855057 | Accepted | x, y = map(int, input().split())
max_num = 4 * x
min_num = 2 * x
if y % 2 == 1:
print('No')
elif (min_num <= y) and (max_num >= y):
print('Yes')
else:
print('No') |
p02660 | s703733062 | Accepted | """
- Nを素因数分解する
- N = p[i]^1*p[i]^2...*p[k]^1*p[k]^2...
"""
from collections import Counter
N = int(input())
factors = []
i = 2
while N > 1:
if N < i * i:
factors.append(N)
break
while N % i == 0:
factors.append(i)
N //= i
i += 1
# N == 1
ans = 0
# print(factors)
# Counter() ->{key:count}
for count in Counter(factors).values():
i = 1
while count >= i:
count -= i
i += 1
ans += 1
print(ans) |
p03286 | s074353094 | Accepted | N=int(input())
if N==0:
print(0)
exit()
S=""
while N:
S=str(N%2)+S
N=-(N-(N%2))//2
print(S) |
p03723 | s150785189 | Accepted | a,b,c=map(int,input().split())
count=0
if a==b==c and a%2==0:
print(-1)
exit()
while a%2==0 and b%2==0 and c%2==0:
A=a//2
B=b//2
C=c//2
a=B+C
b=C+A
c=A+B
count+=1
print(count) |
p02784 | s945016001 | Wrong Answer | import fileinput
h, n = map(int, input().split())
a = list(map(int, input().split()))
print(sum(a))
if h <= sum(a):
print("Yes")
else:
print("No")
|
p02725 | s144187123 | Accepted | k,n=map(int,input().split())
a=list(map(int,input().split()))
a=a+[k+a[0]]
b=[a[i+1]-a[i] for i in range(n)]
m=max(b)
print(k-m) |
p02792 | s166433993 | Accepted | n = int(input())
start_end = [[0] * 10 for _ in range(10)]
for i in range(1,n+1):
start = int(str(i)[0])
end = int(str(i)[-1])
start_end[start][end] += 1
ans = 0
for start in range(10):
for end in range(start,10):
if start == end:
ans += start_end[start][end]**2
else:
ans += start_end[start][end] * start_end[end][start] * 2
print(ans)
|
p04029 | s564695586 | Accepted | N=int(input())
print(N*(N+1)//2) |
p02854 | s638610645 | Accepted | n = int(input())
a = [int(i) for i in input().split()]
len_f = sum(a)
sum_a = 0
min = 2020202021
for i in range(n):
sum_a += a[i]
len_f -= a[i]
if min > abs(sum_a - len_f):
min = abs(sum_a - len_f)
print(min) |
p03680 | s041538782 | Accepted | # ABC065_B
N = int(input())
A = [int(input()) for _ in range(N)]
now = 0
cnt = 0
while now != 1:
now = A[now] - 1
cnt += 1
if cnt > N:
cnt = -1
break
print(cnt) |
p03360 | s576094235 | Accepted | # input
numbers = list(map(int, input().split()))
K = int(input())
# check
for c in range(K):
max_num = max(numbers)
max_idx = numbers.index(max_num)
numbers[max_idx] *= 2
print(sum(numbers)) |
p02675 | s612416411 | Accepted | a=input()
n=int(a[len(a)-1])
l=[2,4,5,7,9]
if n in l:
print("hon")
elif n != 3:
print("pon")
else:
print("bon") |
p03494 | s577123269 | Wrong Answer | n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
ans = min(ans, len(bin(i)) - bin(i).rfind('1') - 1) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.