problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p02823
|
s854204548
|
Accepted
|
# Function for calc
def match(n, a, b):
if (b - a)% 2 == 0:
print((b-a)/2)
else:
if (n - b) >= a:
print((a)+((b-(a+1))/2))
else:
x=(n-b+1)
print(x+((n-(a+x))/2))
# Run match
in_string = raw_input()
[N, A, B] = [int(v) for v in in_string.split()]
match(N, A, B)
|
p02606
|
s088216643
|
Accepted
|
l,r,d = map(int, input().split(" "))
multiple = 0
for i in range(l, r+1):
if i % d == 0:
multiple += 1
print(multiple)
|
p03627
|
s663975566
|
Accepted
|
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
l = []
tmp = 0
for i in range(n-1):
if A[i] == A[i+1]:
l.append(A[i])
tmp = i+1
break
for i in range(tmp+1, n-1):
if A[i] == A[i+1]:
l.append(A[i])
break
print(l[0] * l[1] if len(l) == 2 else 0)
|
p03261
|
s711799549
|
Wrong Answer
|
n = int(input())
w = [input() for i in range(n)]
f = 'Yes'
for i in range(n-1):
if w[i][-1]!=w[i+1][0] or w[i] in w[:i]:
f = 'No'
print(f)
|
p03673
|
s818148683
|
Accepted
|
import numpy as np
n=int(input())
x=list(map(int,input().split()))
a=[]
b=[]
for i in range(n):
if i%2==1:
b.append(x.pop())
if i%2==0:
a.append(x.pop())
b=b[::-1]
print(*(a+b))
|
p04043
|
s209764526
|
Accepted
|
A = list(map(int, input().split()))
if A.count(7) == 1 and A.count(5) == 2:
print("YES")
else:
print("NO")
|
p02689
|
s428010747
|
Accepted
|
n, m = map(int, input().split())
h = list(map(int, input().split()))
cnt = [0] * n
for i in range(m):
a, b = map(int, input().split())
if h[a - 1] > h[b - 1]:
cnt[b - 1] = 1
elif h[a - 1] < h[b - 1]:
cnt[a - 1] = 1
else:
cnt[b - 1] = 1
cnt[a - 1] = 1
print(cnt.count(0))
|
p02711
|
s213516019
|
Accepted
|
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
n = input()
for ni in n:
if ni == "7":
print("Yes")
exit()
print("No")
|
p02879
|
s259578825
|
Accepted
|
a, b = map(int,input().split())
if a >= 10 or b >= 10:
print(-1)
else:
print(a * b)
|
p02900
|
s900861905
|
Accepted
|
a,b=map(int,input().split())
import math
c= math.gcd(a,b)
c2=c
l=[]
i=2
while i<=c:
if c % i==0:
c=c//i
l.append(i)
else:
i+=1
if i*i-1>c:
l.append(c)
break
print(len(set(l))+1)
|
p03352
|
s946236729
|
Wrong Answer
|
import math
a = int(input())
for i in range(a, 0, -1):
for j in range(2, 10):
if i == int(math.pow(i, 1/j)) ** j:
print(i)
break
else:
continue
break
|
p02829
|
s110483907
|
Accepted
|
# A - Round One
A = int(input())
B = int(input())
print(6-A-B)
|
p02584
|
s510981327
|
Wrong Answer
|
LI = lambda: list(map(int, input().split()))
X, K, D = LI()
def main():
x = abs(X)
a = x // D
if K <= a:
ans = x - K * D
print(ans)
return
x -= a * D
k = K - a
print(a, k)
if k % 2 == 0:
ans = x - a * D
else:
ans = abs(x - D)
print(ans)
if __name__ == "__main__":
main()
|
p03767
|
s638429934
|
Accepted
|
n = int(input())
a = list(map(int, input().split()))
a = list(reversed(sorted(a)))
print(sum(a[1::2][:n]))
|
p02597
|
s788639137
|
Accepted
|
def main():
n = int(input())
C = input()
r = C.count('R')
print(C[:r].count('W'))
if __name__ == '__main__':
main()
|
p03360
|
s890473144
|
Accepted
|
A,B,C=map(int,input().split())
K=int(input())
ans=A+B+C-max(A,B,C)
ans+=max(A,B,C)*(2**K)
print(ans)
|
p03544
|
s822625176
|
Wrong Answer
|
n=int(input())
s=[]
s.append(2)
s.append(1)
for i in range(2,87):
k = s[i-2]+s[i-1]
s.append(k)
if i==n:
print(s[i])
exit()
|
p03524
|
s522041525
|
Wrong Answer
|
import collections
s = input()
cnt = collections.Counter(s)
cnt = cnt.most_common()
# print(cnt)
if len(s) == 1:
print('YES')
exit()
if len(cnt) == 2:
if len(s) == 2:
print('YES')
else:
print('NO')
exit()
if cnt[0][1] > cnt[-1][1] + 1:
print('NO')
else:
print('YES')
|
p03745
|
s843059874
|
Wrong Answer
|
n = int(input())
A = list(map(int, input().split()))
ans = 1
sq = 0
a = A[0]
for i in range(1,n):
print(a,A[i], sq)
if sq == 0 and A[i] < a:
sq = -1
elif sq == 0 and A[i] > a:
sq = 1
elif (sq == 1 and A[i] < a) or (sq == -1 and A[i] > a):
print('---')
ans += 1
sq = 0
a = A[i]
print(ans)
|
p02731
|
s079383121
|
Accepted
|
n = int(input())
print((n / 3) ** 3)
|
p02725
|
s027317443
|
Accepted
|
K,N=map(int,input().split())
a=[int(i) for i in input().split()]
a.append(a[0])
max=0
b=0
for i in range(N-1):
b=a[i+1]-a[i]
if(b>=max):
max=b
m=K-a[i+1]+a[0]
if(m>max):
max=m
kyori=K-max
print(kyori)
|
p03043
|
s929143302
|
Accepted
|
import numpy as np
n, k = map(int, input().split())
nx = np.arange(1, n+1)
ans = 0
ed = n
coin = 0
while (ed > 0):
ct = 0
for i in range(ed-1, -1, -1):
if (nx[i] >= k):
ct += 1
ed = i
else:
break
ans += ct*(1/2**(coin))
# print(nx)
nx *= 2
coin += 1
print(ans/n)
|
p02577
|
s210867580
|
Accepted
|
N = int(input())
while N >= 10:
s = str(N)
array = list(map(int, s))
N = sum(array)
if N == 9 or N == 0:
print("Yes")
else:
print("No")
|
p02714
|
s896377315
|
Wrong Answer
|
N=int(input())
S=str(input())
t=N*(N-1)*(N-2)//6
print (t)
for i in range(N):
for j in range(i+1,N):
if S[i]==S[j]:
t=t-(N-j-1)
else:
for k in range(j+1,N):
if S[j]!=S[k] and S[i]!=S[k] and (i-j)!=(j-k):
continue
else:
t=t-1
print (t)
|
p02660
|
s189730089
|
Accepted
|
import math
N = int(input())
if N <= 1:
print(0)
exit()
L = math.ceil(math.sqrt(N)) + 1
isPrime = [True] * L
isPrime[0] = isPrime[1] = False
primes = []
for n in range(2, L):
if isPrime[n]:
primes.append(n)
isPrime[2*n::n] = [False] * ((L-n-1) // n)
ans = 0
for p in primes:
d = p
while N % d == 0:
ans += 1
N //= d
d *= p
while N % p == 0:
N //= p
if N != 1:
ans += 1
print(ans)
|
p03723
|
s557639812
|
Wrong Answer
|
A,B,C = map(int,input().split())
if A == B == C or (C+B == 2*A and A+B == 2*C and A+C == 2*B):
print(-1)
else:
c = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
ba = A
bb = B
bc = C
A = bb//2 + bc//2
B = ba//2 + bc//2
C = ba//2 + bb//2
c+=1
print(c)
|
p03860
|
s816260202
|
Accepted
|
s = input().split()
print('A'+ s[1][0].upper() +'C')
|
p03557
|
s024532473
|
Wrong Answer
|
from bisect import bisect_left
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
num_a = 0
num_c = 0
res = 0
for b in B:
num_a = bisect_left(A, b) # a < b となるAの要素数
num_c = N - bisect_left(C, b) # c > b となるAの要素数
if num_a != N and A[num_a] == b:
num_a -= 1
if num_c != N and A[num_c] == b:
num_a -= 1
res += num_a * num_c
print(res)
|
p02947
|
s266964434
|
Accepted
|
import collections
N = int(input())
count = []
for _ in range(N):
s = "".join(sorted(input()))
count.append(s)
ans = 0
for v in collections.Counter(count).values():
ans += v * (v - 1) // 2
print(ans)
|
p03345
|
s624440562
|
Accepted
|
#
import sys
input=sys.stdin.readline
def main():
A,B,C,K=map(int,input().split())
if K%2==0:
pm=1
else:
pm=-1
print(pm*(A-B))
if __name__=="__main__":
main()
|
p03672
|
s696936832
|
Accepted
|
S=input()
temp=len(S)+1
for i in range(0,temp):
S=S[:-1]
if len(S)%2==0 and S[0:len(S)//2]==S[len(S)//2:]:
print(len(S))
exit()
|
p03711
|
s175535887
|
Wrong Answer
|
x = input()
ls_x = x.split()
print(ls_x)
for i in range(len(ls_x)):
ls_x[i] = int(ls_x[i])
gA = [1,3,5,7,8,10,12]
gB = [4,6,9,11]
if ls_x[0] == 2 or ls_x[1] == 2:
print("No")
if ls_x[0] == gA[i] and ls_x[1] == gA[i]:
print("Yes")
else:
print("No")
if ls_x[0] == gB[i] and ls_x[1] == gB[i]:
print("Yes")
else:
("No")
|
p03037
|
s232804803
|
Wrong Answer
|
N, M = map(int, raw_input().split())
L = []
R = []
for i in range(M):
Li, Ri = map(int, raw_input().split())
L.append(Li)
R.append(Ri)
ans = min(R) - max(L) + 1
print ans
|
p03293
|
s146457190
|
Wrong Answer
|
S=input()
T=input()
for letter in S:
pass
if letter in T:
print("Yes")
else:
print("No")
|
p02726
|
s679158535
|
Accepted
|
def main():
import collections
n, x, y = map(int, input().split())
distance_list = []
for i in range(1, n):
for j in range(i+1, n+1):
distance_list.append(min(j-i, abs(i-x)+abs(j-y)+1))
distance_count = collections.Counter(distance_list)
for i in range(1, n):
print(distance_count[i])
if __name__ == '__main__':
main()
|
p03804
|
s585396521
|
Accepted
|
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(N-M+1):
for j in range(N-M+1):
for k in range(M):
if A[i+k][j:j+M] != B[k]:
break
else:
print('Yes')
exit()
print('No')
|
p02687
|
s806755292
|
Accepted
|
last = input()
if last == "ABC":
print("ARC")
else:
print("ABC")
|
p03814
|
s694550523
|
Wrong Answer
|
S=input()
count = 0
maxCount = 0
for k,i in enumerate(list(S)):
if i == "A" and count == 0:
count+=1
elif i == "Z" and count > 0 and k<len(S)-1 :
count +=1
if S[k+1] != "Z":
maxCount = max(maxCount, count)
count = 0
elif i == "Z" and count > 0:
count +=1
maxCount = max(maxCount, count)
count = 0
elif count > 0 :
count +=1
else :
None
print(maxCount)
|
p03778
|
s615010420
|
Accepted
|
W,a,b=map(int,input().split())
if b<=a<=b+W or b<=a+W<=b+W:
print(0)
elif b>a+W:
print(b-a-W)
else:
print(a-b-W)
|
p03821
|
s034286578
|
Accepted
|
n=int(input())
ab=[]
for i in range(n):
aa,bb=map(int,input().split())
ab.append((aa,bb))
t_sum=0
ab=ab[::-1]
for a,b in ab:
if (a+t_sum)%b!=0:
t=b-(a+t_sum)%b
t_sum+=t
print(t_sum)
|
p03328
|
s205917369
|
Accepted
|
a, b = map(int, raw_input().split())
c = b - a
x = 1 + c
y = x * c
f = y / 2
print f - b
|
p03030
|
s796753565
|
Accepted
|
n = int(input())
a = sorted([input().split() + [i+1] for i in range(n)], key=lambda x:(x[0], -int(x[1])))
for n, s, i in a:
print(i)
|
p02989
|
s235820589
|
Accepted
|
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
print(d[n//2]-d[n//2-1])
|
p02860
|
s340850486
|
Accepted
|
n = int(input())
s = input()
if n % 2 == 1:
print("No")
else:
if s[:int(n/2)] == s[int(n/2):]:
print("Yes")
else:
print("No")
|
p02747
|
s823833480
|
Wrong Answer
|
a = input()
ok = True
for i in range(len(a)//2, 2):
if a[i:i + 2] != "hi":
ok = False
break
if ok:
print("Yes")
else:
print("No")
|
p03162
|
s979276506
|
Accepted
|
#Educational DP c vacation
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0, 0, 0] for _ in range(n+1)]
for i in range(n):
dp[i+1][0] = abc[i][0] + max(dp[i][1], dp[i][2])
dp[i+1][1] = abc[i][1] + max(dp[i][0], dp[i][2])
dp[i+1][2] = abc[i][2] + max(dp[i][0], dp[i][1])
print(max(dp[n][0], max(dp[n][1], dp[n][2])))
|
p03625
|
s873423779
|
Accepted
|
from collections import Counter as C
n,*a=map(int,open(0).read().split())
b=[]
for i in C(a).items():
if i[1]>3:
b+=[i[0],i[0]]
elif i[1]>1:
b+=[i[0]]
b=sorted(b)
print(b[-1]*b[-2] if len(b)>1 else 0)
|
p02713
|
s834691716
|
Accepted
|
K = int(input())
from fractions import gcd
from math import ceil
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations
sum_gcd = [0]*K
for i in range(1,K+1):
c = 0
for j in range(1,K+1):
c += gcd(i,j)
sum_gcd[i-1] = c
ans = 0
for a in range(1,K+1):
for b in range(1,K+1):
ans += sum_gcd[gcd(a,b)-1]
print(ans)
|
p03910
|
s320574876
|
Wrong Answer
|
N = int(input())
from collections import OrderedDict
if N == 2:
print(2)
exit(0)
# ans = OrderedDict()
ans = set()
cur = N
i = 1
while cur != 0:
tmp = cur - i
if tmp in ans:
pass
else:
ans.add(i)
cur = tmp
i+= 1
for a in ans:
print(a)
|
p03219
|
s043120571
|
Wrong Answer
|
a,b=map(int,input().split())
print(a+b/2)
|
p02953
|
s533570790
|
Accepted
|
N = int(input())
H = list(map(int,input().split()))
for i in range(N-1,0,-1):
if H[i] < H[i-1]:
H[i-1] = H[i-1]-1
if H[i] < H[i-1]:
print("No")
exit()
print("Yes")
|
p03284
|
s573643123
|
Accepted
|
n, k = map(int, input().split())
if n % k == 0:
print(0)
else:
print(1)
|
p02771
|
s075261727
|
Accepted
|
a,b,c=map(int,input().split())
if a==b or b==c or c==a:
if a==b==c:
print("No")
else:
print("Yes")
else:
print("No")
|
p02689
|
s750089340
|
Accepted
|
# -*- coding: utf-8 -*-
N,M = map(int ,input().split())
H = input().split()
H = [int(s) for s in H]
tower = [0]*N
A=[0]*M
B=[0]*M
for i in range(0,M):
A[i],B[i] = map(int,input().split())
if H[A[i]-1] > H[B[i]-1]:
ev = B[i]-1
elif H[A[i]-1] == H[B[i]-1]:
tower[A[i]-1]+=1
tower[B[i]-1]+=1
continue
else:
ev = A[i]-1
tower[ev] += 1
print(tower.count(0))
|
p02699
|
s607663475
|
Wrong Answer
|
s,w=input().split()
if s>w:
print ("safe")
else:
print ("unsafe")
|
p02730
|
s017239006
|
Accepted
|
s = input()
for i in range(len(s)//4+1):
if not s[i] == s[len(s)//2-1-i] == s[len(s)//2+1+i] == s[-1-i]:
print('No')
break
else:
print('Yes')
|
p03673
|
s658160200
|
Accepted
|
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque([])
for i in range(n):
if (i%2==0):
b.append(a[i])
else:
b.appendleft(a[i])
if (n%2==1):
b.reverse()
print(*b)
else:
print(*b)
|
p02657
|
s889280104
|
Wrong Answer
|
s = input().split()
int(s[0]) * int(s[1])
|
p02789
|
s884850172
|
Wrong Answer
|
n,m=map(int,input().split())
if n==m:
print('AC')
else:
print('No')
|
p02792
|
s368187201
|
Accepted
|
from collections import defaultdict
N = int(input())
dic = defaultdict(int)
for i in range(1, N+1):
num_str = str(i)
if int(num_str[-1]) == 0:
continue
else:
dic[(int(num_str[0]), int(num_str[-1]))] += 1
ans = 0
for i in range(1,10):
for j in range(1,10):
if (i,j) in dic and (j,i) in dic:
ans += dic[(i,j)] * dic[(j,i)]
print(ans)
|
p03544
|
s969658744
|
Wrong Answer
|
N = int(input())
l = [2, 1]
i = 2
ans =0
if N ==2:
ans =3
while i < N +1:
l.append(str(int(l[i-1]) + int(l[i-2])))
ans = l[i]
i = i+1
print(ans)
|
p02796
|
s911942425
|
Accepted
|
N=int(input())
R=[]
for i in range(N):
x,l=map(int,input().split())
s=x-l
t=x+l
R.append([s,t])
R.sort(key=lambda x:x[1])
cur=-10**9
ans=0
for i in range(N):
if cur<=R[i][0]:
ans+=1
cur=R[i][1]
print(ans)
|
p02596
|
s383678832
|
Accepted
|
K=int(input())
i=0
if K%2==0 or K%5==0:
print('-1')
else:
for d in range(K):
i=(10*i+7)%K
if i==0:
print(d+1)
break
|
p02597
|
s939289803
|
Accepted
|
n = int(input())
s = input()
w = s.count('W')
r = s.count('R')
sw = s.count('W',0-w)
rw = 2*10**5
if r >=1:
rw = w-sw
print(min(w,r,rw))
|
p02866
|
s562996260
|
Wrong Answer
|
n = int(input())
d = list(map(int,input().split()))
m = max(d)
if(d[0] != 0 or m >= n):
print(0)
else:
s = [0] * (m+1)
for i in d:s[i] += 1
if(0 in s or s[0] != 1):
print(0)
else:
t = 1
for i in range(1,m+1):
t *= s[i-1]**s[i]
print(t)
|
p02602
|
s629617315
|
Wrong Answer
|
from functools import reduce
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 1)
N = N + 1
K = K + 1
print(A)
si = 0
ei = K - 1
before = reduce(lambda x, y: (x * y), A[si:ei])
after = before / A[si] * A[ei]
print(before, after)
for _ in range(N - K):
si = si + 1
ei = ei + 1
before = after
after = after / A[si] * A[ei]
if before < after:
print("Yes")
else:
print("No")
|
p03262
|
s939741111
|
Wrong Answer
|
import fractions
n, X = map(int, input().split())
x = [int(i) - X for i in input().split()]
ans = x[0]
for i in range(1, n):
ans = fractions.gcd(ans, x[i])
print(ans)
|
p03852
|
s579581850
|
Accepted
|
c = input()
if c in 'aiueo':
print("vowel")
else:
print("consonant")
|
p02911
|
s359922742
|
Accepted
|
n,k,q = map(int,input().split())
ans = [k-q]*n
for _ in range(q):
a = int(input())
ans[a-1] += 1
for i in range(n):
print(['No','Yes'][ans[i]>0])
|
p02795
|
s517803391
|
Accepted
|
import math
h = int(input())
w = int(input())
n = int(input())
ans = math.ceil(n / max(h, w))
print(ans)
|
p02689
|
s178331988
|
Accepted
|
n,m=map(int,input().split())
L=list(map(int,input().split()))
K=[0]*n
for i in range(1,m+1):
a,b=map(int,input().split())
if L[a-1]>L[b-1]:
K[b-1]-=1
if L[a-1]<L[b-1]:
K[a-1]-=1
if L[a-1]==L[b-1]:
K[a-1]-=1
K[b-1]-=1
print(K.count(0))
|
p02726
|
s425272471
|
Accepted
|
def readInt():
return list(map(int,input().split()))
n,x,y = readInt()
x -= 1
y -= 1
D = dict()
for i in range(n-1):
for j in range(i+1,n):
d = min(j-i, abs(x-i)+1+abs(y-j))
if d not in D:
D[d] = 1
else:
D[d] += 1
# print(D)
for k in range(1,n):
if k in D:
print(D[k])
else:
print(0)
|
p02897
|
s001171214
|
Accepted
|
N=int(input())
if(N%2==0):
ans=N//2/N
else:
ans=(N//2+1)/N
print(ans)
|
p02747
|
s513749334
|
Wrong Answer
|
S = input()
print(S)
|
p03359
|
s752494634
|
Wrong Answer
|
a, b = list(map(int, input().split()))
print(min(a,b))
|
p03495
|
s651588994
|
Accepted
|
n,k = map(int, input().split())
a = list(map(int, input().split()))
from collections import Counter
a1 = Counter(a).most_common()
num = 0
if k < len(a1):
for i in range(1,len(a1)-k+1):
num += a1[-i][1]
print(num)
else:
print(0)
|
p02970
|
s646866797
|
Accepted
|
n, d = map(int, input().split())
ans = n // (2 * d + 1)
if n % (2 * d + 1) != 0:
ans += 1
print(ans)
|
p02866
|
s386270147
|
Accepted
|
import sys
read = lambda: sys.stdin.readline().rstrip()
def counting_tree(N, D):
import collections
tot = 1
cnt = collections.Counter(D)
"""
cnt = [0]*N
for i in D:
cnt[i]+=1
"""
for i in D[1:]:
tot = tot * cnt[i-1]%998244353
return tot if D[0]==0 else 0
def main():
N0 = int(read())
D0 = tuple(map(int, read().split()))
res = counting_tree(N0, D0)
print(res)
if __name__ == "__main__":
main()
|
p03910
|
s589216519
|
Accepted
|
import sys
def input():
return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
def main():
N = int(input())
sum = 0
for i in range(1, N + 2):
if sum < N:
sum += i
else:
S = i
break
a = sum - N
for j in range(1, S):
if j == a:
continue
else:
print(j)
if __name__ == "__main__":
main()
|
p03433
|
s147608046
|
Accepted
|
n = int(input())
a = int(input())
if n % 500 <= a:
print('Yes')
else:
print('No')
|
p03220
|
s725924591
|
Accepted
|
N=int(input())
T,A=map(int,input().split())
W=list(map(int,input().split()))
U=100000000
c=0
for i in range(N):
W[i]=T-W[i]*0.006
for k in range(N):
Y=abs(W[k]-A)
if Y<U:
U=Y
c=k
print(c+1)
|
p03001
|
s173165130
|
Accepted
|
W, H, x, y = map(int, input().split())
S = W * H / 2
print (S, end = ' ')
if W == 2 * x and H == 2 * y:
print (1)
else:
print (0)
|
p03073
|
s013620119
|
Accepted
|
s = list(map(int, input()))
a = [i%2 for i in range(len(s))]
b = [(i+1)%2 for i in range(len(s))]
a_sum = sum(abs(x-y) for x, y in zip(s, a))
b_sum = sum(abs(x-y) for x, y in zip(s, b))
print(min(a_sum, b_sum))
|
p02744
|
s490113437
|
Accepted
|
n = int(input())
ans = []
def dfs(x):
if len(x) == n:
ans.append(x)
return
for i in range(0, max(x)+1):
y = x.copy()
y.append(i+1)
dfs(y)
dfs([1])
#print(ans)
r = ['a','b','c','d','e','f','g','h','i','j']
for ai in ans:
print(''.join(map(lambda x: str(r[x-1]), ai)))
|
p03760
|
s464511492
|
Wrong Answer
|
O = input()
E = input() + ""
print("".join(o + e for o, e in zip(O, E)))
|
p03162
|
s360837428
|
Accepted
|
n = int(input())
total = []
for i in range(n):
a, b, c = map(int, input().split())
total.append((a,b,c))
dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = total[0][0]
dp[0][1] = total[0][1]
dp[0][2] = total[0][2]
for i in range(1, n):
dp[i][0] = total[i][0] + max(dp[i-1][1], dp[i-1][2])
dp[i][1] = total[i][1] + max(dp[i-1][0], dp[i-1][2])
dp[i][2] = total[i][2] + max(dp[i-1][0], dp[i-1][1])
print(max(dp[-1]))
|
p02753
|
s733319291
|
Wrong Answer
|
S = input()
if len(set(S)) == 1:
print("Yes")
else:
print("No")
|
p02952
|
s212954319
|
Accepted
|
#!/usr/bin/env python3
n = int(input())
k = len(str(n))
ans = 0
if k % 2 == 0:
for i in range(k//2):
ans += 10**((i*2)+1) - 10**(i*2)
else:
for i in range(k//2):
ans += 10**((i*2)+1) - 10**(i*2)
ans += n - 10**(k-1) + 1
print(ans)
|
p02963
|
s712996351
|
Accepted
|
S = int(input())
X1 = Y1 = 0
X2 = 10**9; Y2 = 1
if S % (10**9) == 0:
X3 = 0
else:
X3 = 10**9 - S%(10**9)
Y3 = (S + X3) // (10**9)
print(X1, Y1, X2, Y2, X3, Y3)
|
p02972
|
s293928019
|
Accepted
|
N = int(input())
A = tuple(map(int, input().split()))
lst = [0] * (N + 1)
ans = set()
for i in range(N, 0, -1):
tmp = (sum(lst[i::i]) % 2 + A[i - 1]) % 2
if tmp:
ans.add(i)
lst[i] = tmp
print(len(ans))
print(*ans)
|
p02862
|
s663004474
|
Wrong Answer
|
X,Y = map(int, input().split())
num_A, num_B = 0, 0
num_A_r = int(X/3)*2
num_A_d = int(Y/3)
num_B_r = int(X/3)
num_B_d = int(Y/3)*2
num_A = num_A_d
num_B = num_B_r
if num_A_r+num_B_r == X and num_A_d+num_B_d == Y:
num_all = num_A + num_B
num_min = min(num_A, num_B)
total = 1
for i in range(num_all, num_all-num_min, -1):
total *= i
for i in range(num_min, 0, -1):
total /= i
print(int(total))
else:
print(0)
|
p02601
|
s061690972
|
Wrong Answer
|
a,b,c=map(int,input().split())
k=int(input())
ans=["Yes","no"]
while b<=a:
b*=2
k-=1
while c<=b:
c*=2
k-=1
print(ans[0] if k>=0 else ans[1])
|
p03329
|
s122936222
|
Accepted
|
N=int(input())
ans=N
for i in range(N+1):
cnt=0 #カウント初期化
t=i
while t>0: #tが正の時,カウントにtを6で割ったあまりを足す.そしてtは6で割った商に更新
cnt+=t%6
t//=6
j=N-i #jにn-iを代入
while j>0:
cnt+=j%9
j//=9
ans = min(ans,cnt)
print(ans)
|
p03659
|
s933249816
|
Accepted
|
import sys
from itertools import accumulate
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *A = map(int, read().split())
csum = [0]
csum.extend(accumulate(A))
ans = INF
for i in range(1, N):
tmp = abs(csum[i] - (csum[N] - csum[i]))
if ans > tmp:
ans = tmp
print(ans)
return
if __name__ == '__main__':
main()
|
p03943
|
s823548195
|
Accepted
|
a,b,c = map(int, input().split())
print('Yes' if a+b==c or b+c==a or a+c==b else 'No')
|
p03679
|
s439143447
|
Wrong Answer
|
x,a,b=map(int,input().split())
if a >b:
print('delicious')
elif b-a <x+1:
print('safe')
elif b-a > x+1:
print('dangerous')
|
p02880
|
s088297193
|
Accepted
|
def some():
n = int(input())
for i in range(9, 0, -1):
for j in range(9, 0, -1):
if i* j == n:
print("Yes")
exit()
print("No")
some()
|
p03387
|
s140030153
|
Accepted
|
a,b,c=map(int,input().split())
if a%2==b%2 and b%2==c%2:
print((2*max(a,b,c)-(a+b+c-max(a,b,c)))//2)
else:
if a%2==b%2:
d=a
a=c
c=d
elif a%2==c%2:
d=a
a=b
b=d
b+=1
c+=1
print(1 + (2*max(a,b,c)-(a+b+c-max(a,b,c)))//2)
|
p03001
|
s846225983
|
Accepted
|
W,H,x,y = map(int,input().split())
flag = 0
if x == W/2 and y == H/2:
flag = 1
print(W*H/2,flag)
|
p02854
|
s727140567
|
Wrong Answer
|
import bisect
N = int(input())
A = list(map(int,input().split()))
length = []
cnt = 0
for i in A:
cnt += i
length.append(cnt)
target_idx = bisect.bisect_left(length,length[-1]//2)
# length[-1] - ans = 2*(length[target] - ans)
ans = 2*length[target_idx] - length[-1]
print(ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.