problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03377 | s697376778 | Accepted | #094_A
a,b,x=map(int,input().split())
print('YES' if a<=x<=a+b else 'NO') |
p03087 | s320482905 | Accepted | n,q=list(map(int,input().split()))
s=input()
acum=[0]*(n+1)
for i in range(1,n):
if s[i]=='C' and s[i-1]=='A':
acum[i]=acum[i-1]+1
else:
acum[i]=acum[i-1]
for _ in range(q):
l,r=list(map(int,input().split()))
l-=1
r-=1
print(acum[r]-acum[l]) |
p03612 | s300703007 | Accepted | n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(1,n):
if l[i-1] == i:
l[i-1],l[i] = l[i],l[i-1]
count += 1
if l[n-1] == n:
count += 1
print(count) |
p03693 | s022459714 | Accepted | A = list(map(int,input().split()))
N = 10*A[1]+A[2]
if N % 4 == 0:
print("YES")
else:
print("NO") |
p03380 | s910073918 | Accepted | import sys
def main():
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().rstrip().split()))
n = max(A)
a = -1
d = n
for e in A:
if e == n:
continue
if abs(e - n/2) < d:
a = e
d = abs(e - n/2)
print(n, a)
if __name__ == '__main__':
main() |
p02723 | s841212503 | Accepted | S = input()
m = list(S)
ans = 'No'
if (m[2] == m[3]) and (m[4] == m[5]):
ans = 'Yes'
print(ans) |
p03998 | s696403739 | Accepted | input = open(0).readline
s = {}
s['A'] = list(input().strip())
s['B'] = list(input().strip())
s['C'] = list(input().strip())
play_order = {'A':'B', 'B':'C', 'C':'A'}
def play(player):
if s[player] == []:
print(player.upper())
return player
next_play = s[player].pop(0)
play(next_play.upper())
play('A')
|
p02933 | s580551769 | Accepted | a = int(input())
s = input()
if a >= 3200:
print(s)
else:
print("red") |
p03994 | s187398706 | Accepted | def main():
S = list(input())
K = int(input())
k = K
for i,c in enumerate(S):
distance = (ord('z') + 1 - ord(c))%26
if distance <= k:
k -= distance
S[i] = 'a'
S[-1] = chr((ord(S[-1]) - ord('a') + k) % 26 + ord('a'))
print(''.join(S))
main() |
p03329 | s726150244 | Wrong Answer | N = int(input())
INF = int(1e10)
dp = [INF] * N
dp[0] = 1
bt = set()
for i in range(1, 100):
if 6**i > N:
break
bt.add(6**i)
for i in range(1, 100):
if 9**i > N:
break
bt.add(9**i)
bt = sorted(bt)
for i in range(1, N):
dp[i] = dp[i-1] + 1
for j in bt:
if i - j >= 0:
dp[i] = min(dp[i], dp[i - j] + 1)
print(dp[N-1]) |
p03836 | s925234430 | Accepted | def solve(sx, sy, tx, ty):
dx = abs(tx-sx)
dy = abs(ty-sy)
ans = "U"*dy + "R"*dx + "D"*dy + "L"*dx
dx += 1
dy += 1
ans += "L" + "U"*dy + "R"*dx + "D"
ans += "R" + "D"*dy + "L"*dx + "U"
return ans
if __name__ == "__main__":
sx,sy,tx,ty = [int(i) for i in input().split()]
print(solve(sx, sy, tx, ty))
|
p02888 | s673343158 | Accepted | import sys
import bisect
input = sys.stdin.readline
def main():
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for a in range(N - 2):
for b in range(a + 1, N - 1):
c = bisect.bisect_left(L, L[a] + L[b]) - 1
ans += c - b
print(ans)
if __name__ == "__main__":
main()
|
p03605 | s025580338 | Wrong Answer | x = input()
if x[0] == 9 or x[1] == 9:
print("Yes")
else:
print("No") |
p03281 | s998901555 | Accepted | def solve(n):
cnt = 0
for i in range(1,n+1):
if n%i == 0: cnt += 1
if cnt == 8: return True
else: return False
n = int(input())
ans = 0
for i in range(1, n+1, 2):
if solve(i): ans += 1
print(ans) |
p03281 | s640422924 | Accepted | n = int(input())
ans = 0
for i in range(1, n + 1, 2):
yakusu = 0
for j in range(1, i + 1):
if i % j == 0:
yakusu += 1
if yakusu == 8:
ans += 1
print(ans) |
p03035 | s577921278 | Accepted | a,b = map(int, input().split())
if a <= 5:
print(0)
elif 6 <= a and a <= 12:
print(int(b/2))
else:
print(b) |
p02681 | s578710838 | Accepted | S = input()
T = input()
if T[:-1] == S:
print('Yes')
else:
print('No') |
p03475 | s329090577 | Wrong Answer | N = int(input())
li = [list(map(int, input().split())) for i in range(N - 1)]
for n in range(N):
if n == N - 1:
print(0)
break
ans = 0
for index, i in enumerate(li):
if index < n:
continue
if ans < i[1]:
ans = i[1]
else:
if (ans - i[1]) % i[2] != 0:
ans += (ans - i[1]) % i[2]
ans += i[0]
print(ans) |
p02607 | s523442612 | Accepted | N = int(input())
A = list(map(int, input().split()))
answer = 0
for i, a in enumerate(A, 1):
if i % 2 and a % 2:
answer += 1
print(answer) |
p02792 | s937238499 | Accepted | N=int(input())
ans=0
c=[[0 for _ in range(10)] for _ in range(10)]
for n in range(1,N+1):
i=n%10
j=n
while 10<=j:
j=j//10
c[i][j]=c[i][j]+1
for i in range(10):
for j in range(10):
ans=ans+c[i][j]*c[j][i]
print(ans) |
p02958 | s239643388 | Accepted | import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
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())
N = I()
l = LI()
x = 0
for i in range(1, N+1):
if i != l[i-1]:
x += 1
if x > 2:
print('NO')
else:
print('YES') |
p03645 | s427655244 | Wrong Answer | n,m=map(int,input().split())
sa=set()
sb=set()
for _ in range(m):
a,b=map(int,input().split())
if a==1:
sa.add(b)
if b==n:
sb.add(a)
print("INPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")
|
p02918 | s496353853 | Accepted | n, k = map(int, input().split())
s = input()
pre = "O"
cnt = 0
for i in range(n):
now = s[i]
if now != pre:
cnt += 1
pre = now
print(min((n - cnt + 2 * k), n - 1))
|
p03416 | s132092894 | Wrong Answer | A, B = input().split()
a01 = int(A[0:2])
a43 = int(''.join(list(reversed(A[3:5]))))
if a01 <= a43:
amin = int(A[1:3])
else:
amin = int(A[1:3]) - 1
b01 = int(B[0:2])
b43 = int(''.join(list(reversed(B[3:5]))))
if b01 <= b43:
bmin = 100 - int(B[1:3]) - 1
else:
bmin = 100 - int(B[1:3])
n0 = int(B[0]) - int(A[0]) + 1
print(n0 * 100 - amin - bmin) |
p02880 | s425628120 | Accepted | n=int(input())
for i in range(1,10):
if n % i ==0 and n / i <10:
print("Yes")
break
else:
print("No") |
p03274 | s648983640 | Wrong Answer | n,k=map(int,input().split())
x=list(map(int,input().split()))
ans=2*(10**8)+1
for i in range(n-k+1):
temp=x[i+k-1]-x[i]+min(abs(x[i]),abs(x[i+k-1]))
if temp<ans: ans=temp
print(ans) |
p02796 | s908995340 | Accepted | n = int(input())
r = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
r[i] = [r[i][0] - r[i][1], r[i][0] + r[i][1]]
r.sort(key = lambda x:x[1])
#print(r)
cur = -1001001001
ans = 0
for i in range(n):
if cur <= r[i][0]:
ans += 1
cur = r[i][1]
print(ans) |
p02699 | s106064013 | Accepted | S,W=map(int, input().split())
print('unsafe' if W>=S else 'safe') |
p02748 | s319661975 | Accepted | a, b, m = map(int, input().split())
A = [int(ae) for ae in input().split()]
B = [int(be) for be in input().split()]
amin = min(A)
bmin = min(B)
smin = amin + bmin
for i in range(m):
x, y, c= map(int, input().split())
th = smin + c
apmin = A[x-1]
if apmin > th:
pass
else:
bpmin = B[y-1]
spmin = apmin + bpmin -c
if spmin < smin:
smin = spmin
else:
pass
print(smin)
|
p03617 | s249204015 | Accepted | Q,H,S,D = map(int,input().split())
a = min(8*Q,4*H,2*S,D)
N = int(input())
yen = (N//2)*a
b = min(4*Q,2*H,S)
yen += (N%2)*b
print(yen) |
p02682 | s459161797 | Accepted | # coding: utf-8
# Your code here!
A,B,C,K=map(int,input().split())
ans=0
ans+=min(A,K)
K-=min(A,K)
K-=min(B,K)
ans-=min(K,C)
print(ans) |
p03137 | s883737062 | Accepted | N,M = (int(X) for X in input().split())
if N>=M: print(0)
else:
P = sorted(int(X) for X in input().split())
Mov = sorted(P[X+1]-P[X] for X in range(0,M-1))
if N==1: print(sum(Mov))
else: print(sum(Mov[:1-N])) |
p03251 | s311948413 | Accepted | n, m, x, y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = max(a)+1
d = min(b)
e = 0
if c > d:
print("War")
else:
for i in range(c,d+1):
if x < i and i <= y:
print("No War")
e = 1
break
if e == 0:
print("War") |
p02832 | s274668719 | Accepted |
N = int(input())
a = list(map(int, input().split()))
num = 1
ans = 0
for i in range(N):
if a[i] == num:
num += 1
else:
ans += 1
if num == 1:
print(-1)
else:
print(ans) |
p02598 | s334603321 | Accepted | import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
N,K = MI()
A = LI()
left = 0
right = max(A) # 可能
while left + 1 < right:
mid = (left + right)//2
if sum((A[i]+mid-1)//mid - 1 for i in range(N)) <= K:
right = mid
else:
left = mid
print(right)
|
p04045 | s382468911 | Wrong Answer | # -*- coding: utf-8 -*-
n, k = map(int,input().split())
d = [int(i) for i in input().split()]
num = [i for i in range(10)]
tmp = []
for i in num:
if not i in d:
tmp.append(str(i))
tmp.sort()
#print(tmp)
#a = n // 10 #nの桁数
b = str(n)
ans = ''
for i in b:
for j in tmp:
if i <= j:
ans += j
break
print(ans) |
p02742 | s280380228 | Accepted | H,W = map(int,input().split())
if H == 1 or W == 1:
ans = 1
elif H%2 == 0:
ans = (H//2)*W
else:
ans = (H//2)*W + (W+1)//2
print(ans) |
p02555 | s173091936 | Accepted | import math
s = int(input())
n = 1
ans = 0
while s - (n * 3) >= 0:
val = s - n * 3
bar = n - 1
ans +=math.factorial(val + bar) // (math.factorial(val) * math.factorial(bar))
n +=1
print(ans % (10 ** 9 + 7)) |
p03774 | s200979790 | Wrong Answer | n,m=map(int,input().split())
a=[list(map(int,input().split())) for a in range(n)]
c=[list(map(int,input().split())) for b in range(m)]
print(a)
print(c)
dist=0
minnum=0
for indi,i in enumerate(a):
dist=0
min=10*14
for indj,j in enumerate(c):
dist+=abs(i[0]-j[0])
dist+=abs(i[1]-j[1])
if min>dist:
min=dist
minnum=indj
print(dist)
dist=0
print(minnum+1) |
p03327 | s198301174 | Accepted | N = int(input())
print('ABD') if N >= 1000 else print("ABC")
|
p02665 | s967822542 | Wrong Answer | n,*a=map(int,open(0).read().split())
t,v=sum(a),[1]
if ~len([print(-1) for q in a if(v:=v+[min(2*(v[-1]-q),t:=t-q)])[-1]<0]):print(sum(v)) |
p02682 | s600527099 | Accepted | a,b,c,k=map(int,input().split())
ans=0
if(a>=k):
ans=k
k=0
else:
ans=a
k=k-a
if(b>=k):
k=0
else:
k=k-b
ans=ans-k
print(ans) |
p02600 | s854792572 | Accepted | n = int(input())
print(10-n//200) |
p02983 | s424208436 | Wrong Answer | M=2019;l,r=map(int,input().split());l%=M;r%=M
print(0 if l>r or r-l>671 else min(i*j%M for i in range(l,r) for j in range(i+1,r+1))) |
p03352 | s087367720 | Wrong Answer | import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import collections
x = int(input())
li = [1]
b = 2
if x == 0:
print(0)
sys.exit()
while True:
if b == 100:
break
p = 2
while True:
d = b**p
if d>=x:
break
li.append(d)
p += 1
b+=1
li.sort()
print(li[-1]) |
p03059 | s758200356 | Accepted | def main():
a, b, t = map(int, input().split())
time = t/a
ans = int(time) * b
print(int(ans))
if __name__ == '__main__':
main() |
p02647 | s377149448 | Accepted | N, K= map(int,input().split())
a = list(map(int,input().split()))
#a=A[:]
for _ in range(K):
B=[0]*(N+1)
for i in range(N):
t = a[i]
B[max(i-t,0)] +=1
B[min(i+t+1,N)] -=1
for i in range(N):
B[i+1] += B[i]
a=B[:N]
if min(a)==N:
break
print(*a) |
p03665 | s552334342 | Accepted | N, P = map(int, input().split())
A = list(map(int, input().split()))
cnt_odd = sum([int((Ai % 2) == 1) for Ai in A])
cnt_evn = N - cnt_odd
ptn_evn = 1 << cnt_evn
tab_ncr = [1]
ncr_tmp = 1
for i in range(cnt_odd):
ncr_tmp *= (cnt_odd - i)
ncr_tmp //= (i + 1)
tab_ncr.append(ncr_tmp)
ans = 0
# print("#", tab_ncr)
for i in range(cnt_odd + 1):
if i % 2 != P: continue
#
ans += (ptn_evn * tab_ncr[i])
print(ans) |
p03681 | s708712184 | Accepted | import math
n, m = map(int, input().split())
if n==m:
print((math.factorial(n)*math.factorial(m)*2)%1000000007)
elif abs(n-m)==1:
print((math.factorial(n)*math.factorial(m))%1000000007)
else:
print(0) |
p02612 | s669954452 | Wrong Answer | n = int(input())
print(1000 - (n % 1000))
|
p02647 | s777626559 | Accepted | n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(min(50, k)):
DP = [0] * (n+1)
for j in range(n):
light = A[j]
DP[max(0, j-light)] += 1
DP[min(n, j+light+1)] -= 1
for j in range(1, n):
DP[j] += DP[j-1]
A = DP[:-1]
print(*A) |
p03944 | s398371369 | Accepted | w,h,n = map(int,input().split())
q = [[0],[w],[0],[h]]
for i in range(n):
x,y,a = map(int,input().split())
if a == 1 or a == 2:
q[a-1].append(x)
else:
q[a-1].append(y)
if max(q[0]) >= min(q[1]) or max(q[2]) >= min(q[3]):
print(0)
else:
print((min(q[1])-max(q[0]))*(min(q[3])-max(q[2])))
|
p02831 | s890688939 | Wrong Answer | import sys
import math
A,B=map(int,input().split())
if A<B:
A,B=B,A
if B%A==0:
print(A)
sys.exit()
L=[]
for i in range(1,math.ceil(A/2)):
if A%i==0 and B%i==0:
L.append(i)
print((A*B)/L[-1]) |
p04029 | s566117058 | Wrong Answer | # 043A
# N人の時のキャンディーの合計数
# 入力値 子供の人数
# 入力
n =int(input())
# 処理
answer = (n + 1) * n / 2
print(answer) |
p02993 | s400795076 | Accepted | S=input()
count=1
for i in range(3):
if S[i] == S[i+1]:
print('Bad')
break
else:
print('Good')
|
p02717 | s169110302 | Accepted | x,y,z = map(int,input().split())
print(z,x,y) |
p02556 | s326986876 | Wrong Answer | n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]
d=[]
for i in range(n):
d.append([xy[i][0]+xy[i][1],xy[i][0],xy[i][1]])
d.sort()
print(abs(d[0][1]-d[-1][1])+abs(d[0][2]-d[-1][2])) |
p03012 | s918457199 | Accepted | from itertools import accumulate
n=int(input())
w=list(map(int,input().split()))
tmp=0
l=list(accumulate(w))
ans=float("inf")
for i in range(n):
tmp=abs(l[i]-(l[n-1]-l[i]))
if tmp<ans:
ans=tmp
print(ans) |
p03162 | s139897932 | Wrong Answer | n=int(input())
temp=100
ans=0
for i in range(n):
s=list(map(int,input().split()))
if temp==0:
ans+=max(s[1], s[2])
temp=s.index(max(s[1], s[2]))
elif temp==1:
ans+=max(s[0], s[2])
temp=s.index(max(s[0], s[2]))
elif temp==2:
ans+=max(s[1], s[0])
temp=s.index(max(s[1], s[0]))
else:
ans+=max(s)
temp=s.index(max(s))
print(ans) |
p03105 | s544352107 | Accepted | A,B,C=map(int,input().split())
if A*C<=B :
print(C)
else :
print(B//A) |
p03264 | s385309993 | Accepted | k = int(input())
if k % 2 == 0:
print(int((k/2)**2))
else:
print((k//2) * (k//2+1))
|
p03038 | s757179203 | Accepted | import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
bc=[list(map(int,input().split())) for i in range(m)]
bc=sorted(bc,reverse=True,key=lambda x:x[1])
c=[]
cnt=0
for B,C in bc:
for i in range(B):
if cnt==n:break
cnt+=1
c.append(C)
c=sorted(c,reverse=True)
ans=sum(a)
temp=ans
for i in range(n):
if cnt<=i:continue
temp+=-a[i]+c[i]
if temp>ans:ans=temp
print(ans) |
p02933 | s541015048 | Accepted | A = int(input())
S = input()
ans = S if A >= 3200 else 'red'
print(ans) |
p03017 | s494640463 | Wrong Answer | n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
flag = "##" not in s[b: d] and "##" not in s[a: c]
else:
flag = "..." in s[b: d]
print("Yes" if flag else "No") |
p03106 | s193214433 | Wrong Answer | a, b, k = map(int, input().split())
ans = []
for i in range(1, 100):
if a % i == 0 and b % i == 0:
ans.append(i)
print(ans[-k])
|
p03730 | s997672316 | Accepted | A, B, C = map(int, input().split())
flag = False
for i in range(B + 1):
if A * i % B == C:
flag = True
break
print('YES' if flag else 'NO')
|
p03001 | s572416840 | Accepted | w, h, x, y = map(int, input().split())
print(w*h/2)
if 2*x == w and 2*y == h:
print(1)
else:
print(0) |
p02767 | s506574107 | Accepted | # coding: utf-8
import math
import sys
N = int(input())
Xi = list(map(int, input().split()))
Xi.sort()
min = Xi[0]
max = Xi[N-1]
tmp = 0
result = sys.maxsize
for i in range(min,max+1):
for j in range(0,N):
tmp += (Xi[j] - i)**2
if tmp <= result:
result = tmp
tmp = 0
print(result) |
p03220 | s086086574 | Accepted | n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ch = [10000]*n
for i in range(n):
ch[i] = abs(a - (t - h[i]*6/1000))
print(ch.index(min(ch))+1) |
p02658 | s424260210 | Wrong Answer | n = int(input())
ans = 1
arr = input().split(" ")
x = True
for i in range(n):
ans = ans*int(arr[i])
if ans > 1000000000000000000:
print(-1)
x = False
if x:
print(ans) |
p03475 | s203116202 | Accepted | N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N-1)]
ans = 0
memo = {}
memoset = set()
def dfs(i, time):
if i==N-1:
return time
c, s, f = CSF[i]
if time<s:
time = s
elif time%f!=0:
time = (time//f+1)*f
if (time, i) in memoset:
return memo[(time, i)]
T = dfs(i+1, time+c)
memo[(time, i)] = T
memoset.add((time, i))
return T
for i in range(N-1):
print(dfs(i, 0))
print(0) |
p03136 | s528472262 | Wrong Answer | n=int(input())
L=list(map(int,input().split()))
sum=0
max=0
for i in L:
if i>max:
sum+=max
max=i
if max<sum:
print("Yes")
else:
print("No") |
p03281 | s149806780 | Accepted | def dcount(n):
c = 0
for i in range(1, n+1):
if n % i == 0:
c += 1
return c
N = int(input())
c = 0
for i in range(1, N + 1, 2):
if dcount(i) == 8:
c += 1
print(c) |
p03625 | s843019485 | Wrong Answer | from collections import Counter
n = int(input())
A = list(map(int, input().split()))
# 長さと個数の辞書
length_num = Counter(A)
# 長い順からの長さのリスト
lengths = sorted(list(length_num.keys()), reverse=True)
ans = 0
sides = []
# 長い辺の順にループ
for l in lengths:
if len(sides) == 2:
break
if length_num[l] >= 4:
ans = l * l
break
if length_num[l] >= 2:
sides.append(l)
if len(sides) == 2:
ans = sides[0] * sides[1]
print(ans)
|
p02696 | s526271282 | Wrong Answer | import sys
import math # noqa
import bisect # noqa
import queue # noqa
def input():
return sys.stdin.readline().rstrip()
def main():
A, B, N = map(int, input().split())
if N < B:
x = N
res = math.floor(A * x / B)
return print(res)
x = (N // B) * B - 1
res = math.floor(A * x / B) - A * math.floor(x / B)
return print(res)
if __name__ == '__main__':
main()
|
p02697 | s793853568 | Accepted | N, M = map(int,input().split())
if N % 2 == 1:
for i in range(1,1+M):
print(i, 2*M+1-i)
elif N % 4 == 0:
a = [2*i for i in range(1,N//4)] + [2*j + 1 for j in range(N//4, N//2)]
for i in range(1, 1+M):
print(i, i+a[-i])
else:
a = [2*i for i in range(1,N//4+1)] + [2*j + 1 for j in range(N//4+1, N//2)]
for i in range(1, 1+M):
print(i, i+a[-i]) |
p03854 | s251773824 | Accepted | #ABC 049 C
S = input()
T = ''
S = S[::-1]
words = ["dream","dreamer","erase","eraser"]
rev_words = [w[::-1] for w in words]
flag = False
i=0
while(1):
for w in rev_words:
s = S[i:i+len(w)]
if s == w:
flag = True
T += w
i += len(w)
break
if T == S:
ans = "YES"
break
if flag == False:
ans = 'NO'
break
flag = False
print(ans)
|
p03795 | s963580506 | Wrong Answer | N = int( input() )
x = int( 800 * N )
# 15食食べるごとに200円もらえる
y = int( 200 * N / 15 )
print( x - y ) |
p03219 | s079369693 | Accepted | X, Y = map(int, input().split())
print(int(X+Y/2))
|
p03331 | s685958490 | Accepted | N = int(input())
ans = []
def digitSum(num):
s = str(num)
array = list(map(int,s))
return sum(array)
for A in range(1,N):
B = N-A
ans.append(digitSum(A)+digitSum(B))
print(min(ans)) |
p03107 | s783351881 | Accepted | S = input()
N = len(S)
L = abs(S.count('0') - S.count('1'))
print(N - L) |
p03644 | s987906884 | Wrong Answer | N=int(input())
for i in range(7):
x=2**i
if x<=N:
max=2**i
print(x) |
p04031 | s914125079 | Accepted | import math
n = int(input())
a = list(map(int,input().split()))
avg = sum(a)/n
x = math.floor(avg)
y = math.ceil(avg)
sumx = 0
sumy = 0
for i in a:
sumx += (i - x) ** 2
sumy += (i - y) ** 2
print(min([sumx,sumy])) |
p02570 | s971142497 | Accepted | d, t, s = map(int, input().split())
if d/s <= t:
print("Yes")
else:
print("No") |
p04031 | s816878306 | Accepted | n = int(input())
A = list(map(int,input().split()))
ans = 10**9
for i in range(-100,101):
tmp = 0
for a in A:
tmp += (a-i)**2
ans = min(ans, tmp)
print(ans) |
p03220 | s876192359 | Wrong Answer | N = input()
TA = input().split()
T = int(TA[0])
A = int(TA[1])
first = True
place = 0
minTmep = 0
H = list(map(int, input().split()))
for i in range(0,len(H)):
compare = abs(A * 1000 - T - H[i] * 0.006 * 1000)
if first == True:
place = i
minTmep = compare
first = False
if minTmep > compare:
place = i
minTmep = compare
print(place + 1) |
p03017 | s475727709 | Accepted | N, A, B, C, D = map(int, input().split())
S = input()
if "##" in S[A:C] or "##" in S[B:D]:
print("No")
exit()
if D - C < 0:
if "..." not in S[B-2:D+1]:
print("No")
exit()
print("Yes") |
p03105 | s286473435 | Accepted | A, B, C = [int(x) for x in input().split()]
print(min(C, B // A))
|
p02683 | s160170199 | Wrong Answer | n,m,x = map(int, input().split())
result = 10**9
A=[]
C=[]
for _ in range(n):
books=list(map(int, input().split()))
C.append(books[0])
A.append(books[1:])
for i in range(1<<n):
cnt = 0
rikaido = [0]*m
for j in range(n):
if (i>>j)&1:
for k in range(m):
rikaido[k]+=A[j][k]
cnt += C[j]
else:
pass
if min(rikaido)>=x:
result = min(result, cnt)
if result == 10*9:
print(-1)
else:
print(result) |
p03624 | s692753572 | Accepted | arb = 'abcdefghijklmnopqrstuvwxyz'
S = input()
ans =''
for i in arb:
if i not in S:
ans += i
sort_ans = sorted(ans)
if len(ans)==0:
print('None')
else:
print(sort_ans[0]) |
p02554 | s206857861 | Wrong Answer | N=int(input())
mod=10**9+7
ans1=1
ans2=1
ans3=1
ans4=1
ans=0
for x in range(1,N):
for y in range(1,N):
ans1*=(N-(x-1))
ans1%=mod
ans2*=x
ans2%=mod
ans3*=(N-x-(y-1))
ans3%=mod
ans4*=y
ans4%=mod
ans5=8**(N-(x+y))
ans5%=mod
ans+=ans1*ans3*ans5/(ans2*ans4)
ans%=mod
print(ans) |
p02833 | s310383194 | Accepted | n=int(input())
if n%2==1:
print(0)
else:
n//=2
c=0
x=5
while x<=n:
c+=n//x
x*=5
print(c)
|
p03345 | s071509613 | Wrong Answer | a,b,c,k = map(int, input().split())
ans = a - b
if(k % 2 == 1):
ans = abs(ans)
if(len(str(ans)) >= 18):
ans = 'Unfair'
print(ans) |
p02660 | s745648052 | Accepted | N = int(input())
pri_cnt = {}
n = N
i = 2
while i ** 2 <= N:
while n % i == 0:
if i not in pri_cnt:
pri_cnt[i] = 1
else:
pri_cnt[i] += 1
n = n / i
if (i == 2):
i += 1
else:
i += 2
if n > 1:
pri_cnt[int(n)] = 1
ans = 0
for pri, cnt in pri_cnt.items():
count = 1
remain = cnt
while remain >= count:
ans += 1
remain -= count
count += 1
print(ans) |
p02584 | s059160700 | Accepted | #!/usr/bin/env python3
def main():
X, K, D = map(int, input().split())
res = abs(X) // D
if res <= K:
K -= res
if K % 2:
print(abs(abs(X) % D - D))
else:
print(abs(X) % D)
else:
print(abs(X) - D * K)
if __name__ == '__main__':
main()
|
p02572 | s958295366 | Accepted | N = int(input())
A = [int(i) for i in input().split()]
B = [0]*N
res = 0
B[N-1] = A[N-1]
for i in range(1, N):
B[N-i-1] = B[N-i] + A[N-i-1]
for i in range(N-1):
res = (res + A[i] * B[i+1]) % (10**9+7)
print(res) |
p02831 | s508265347 | Accepted | from math import gcd
a, b = map(int,input().split())
print(int(a * b / gcd(a, b))) |
p02645 | s519796611 | Accepted | s = input()
print(s[:3]) |
p03211 | s367215703 | Wrong Answer |
if __name__ == '__main__':
S = input()
comp_num = 753
min = 0
tempmin = 10000000000
for i in range(0, len(S)-2):
temp = int (S[i]+S[i+1]+S[i+2])
min = abs(comp_num - temp)
if (min >= tempmin):
break
tempmin = min
print(min)
|
p03419 | s462896574 | Accepted | n,m = map(int,input().split())
if n==1 or m == 1:
if n==1 and m==1:
ans = 1
else:
ans = n*m - 2
else:
ans = (n-2)*(m-2)
print(ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.