problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03095
s235840572
Accepted
from collections import defaultdict mod = 10**9+7 n = int(input()) s = list(input()) ans = 1 dd = defaultdict(lambda:0) for i in s: dd[i] += 1 for key in dd: ans *= dd[key]+1 ans %= mod ans -= 1 print(ans)
p02953
s593546855
Accepted
n = int(input()) h = list(map(int, input().split())) h[0] -= 1 for i in range(1, n-1): if h[i] == h[i+1] + 1: if h[i-1] != h[i]: h[i] -= 1 else: print('No') exit() elif h[i] < h[i+1] + 1: if h[i-1] != h[i]: h[i] -= 1 else: print('No') exit() print('Yes')
p03524
s660183309
Accepted
s = input() a = 0 b = 0 c = 0 for i in s: if i == "a": a += 1 if i == "b": b += 1 if i == "c": c += 1 if max(a,b,c)-min(a,b,c) <= 1: print("YES") else: print("NO")
p03136
s854565892
Accepted
n = int(input()) l = list(map(int,input().split())) suml = sum(l) maxl = max(l) lestl = suml-maxl if maxl<lestl: print("Yes") else: print("No")
p03633
s512657350
Wrong Answer
#!/usr/bin/env python3 N = int(input()) # S = input() # N, K = map(int, input().split()) # A = list(map(int, input().split())) mod = 10 ** 9 from functools import reduce from fractions import gcd def main(): T = list(set([int(input()) for _ in range(N)])) if len(T) == 1: print(T[0]) exit() ans = (T[0] * T[1]) // gcd(T[0], T[1]) for i in range(len(T) - 2): ans = ans // (gcd(ans, T[i])) * T[i] print(ans) if __name__ == "__main__": main()
p02767
s882718876
Accepted
n = int(input(), 10) live_pos_list = list(map(int, input().split())) def cost(live_pos, held_pos): return (live_pos - held_pos) ** 2 mean_pos = round(sum(live_pos_list) / n) print(sum(map(lambda live_pos: cost(live_pos, mean_pos), live_pos_list)))
p03264
s348154884
Accepted
n = int(input()) print(n // 2 * (n - n // 2))
p02647
s595585492
Accepted
n,k=map(int,input().split()) a=[int(i) for i in input().split()] k=min(k,41) for j in range(k): b=[0 for i in range(n)] for i in range(n): l=max(0,i-a[i]) r=min(n-1,i+a[i]) b[l]+=1 if r+1<n: b[r+1]-=1 for i in range(1,n): b[i]+=b[i-1] a=b print(" ".join(map(str,a)))
p03386
s025992972
Accepted
A,B,K = map(int, input().split()) if B-A+1<= 2*K: print(*range(A,B+1), sep="\n") else: a = list(range(A,A+K)) b = list(range(B-K+1,B+1)) C = sorted(set(a+b)) print(*C, sep="\n")
p02712
s199810415
Accepted
N = int(input()) sum = 0 for i in range(N): if (i + 1) % 3 != 0 and (i + 1) % 5 != 0: sum += (i + 1) print(sum)
p03069
s206376517
Accepted
N=int(input()) S=list(map(int,input().replace('#','1').replace('.','0'))) cum=[0] for i in range(N): cum.append(cum[-1]+S[i]) ans=10**20 for i in range(N+1): b = cum[i] w = N-i-(cum[-1]-cum[i]) ans = min(ans,b+w) print(ans)
p02615
s347079892
Accepted
N = int(input()) a_ls=list(map(int, input().split())) a=sorted(a_ls,reverse=True) ans=0 if N%2==0: ans+=a[0] for i in range((N-2)//2): ans+=(a[1+i]*2) if N%2==1: ans+=a[0] for i in range((N-1)//2): ans+=(a[1+i]*2) ans-=a[((N-1)//2)] print(ans) # 2darray [[0] * 4 for i in range(3)]
p03328
s558193049
Accepted
a, b = [int(x) for x in input().split()] print((b-a)*(b-a+1)//2 - b)
p02623
s074086242
Wrong Answer
n,m,k=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) suma=[] tmp=0 for aa in a: tmp+=aa suma.append(tmp) sumb=[] tmp=0 for bb in b: tmp+=bb sumb.append(tmp) ans=0 for i in range(n): if suma[i]<=k: for j in range(m): if suma[i]+sumb[j]<=k: ans=max(ans,i+j+2) else: break print(ans)
p03219
s309224605
Accepted
x, y = map(int, input().split()) print(x + y//2)
p02899
s923411182
Wrong Answer
import numpy as np n = int(input()) a = np.array(input().split(), int) print(str(a.argsort() + 1)[1:-1])
p02608
s924959611
Wrong Answer
def triplets_brute(n): counter = 0 upper = round(n**0.5) for x in range(1, upper+1): for y in range(1, upper+1): for z in range(1, upper+1): if x**2+y**2+z**2+x*y+y*z+z*x==n: counter += 1 return counter print(triplets_brute(int(input())))
p03262
s144090533
Accepted
import math N,X = map(int,input().split()) x = list(map(int,input().split())) y = [abs(x[i]-X) for i in range(N)] if N == 1: print(y[0]) exit(0) ans = math.gcd(y[0],y[1]) for i in range(2,N): ans = min(ans,math.gcd(y[i],ans)) print(ans)
p02862
s072448705
Accepted
X,Y=map(int,input().split()) mod = 10**9+7 if 2*X < Y or 2*Y < X:print(0) elif (X+Y) % 3 != 0:print(0) else: n = (X+Y) // 3 X,Y=X-n,Y-n factorial=[1 for i in range(X+Y+1)] for i in range(1,X+Y+1): if i==1:factorial[i]=1 else:factorial[i] = factorial[i-1]*i % mod print(factorial[X+Y]*pow(factorial[X]*factorial[Y],-1,mod)%mod)
p02676
s747091071
Accepted
K = int(input()) S = list(input()) if len(S) > K: ans = S[0:K] ans.append("...") print("".join(ans)) else: print("".join(S))
p02678
s479278031
Accepted
from collections import deque n, m = map(int, input().split()) a = [[] for _ in range(n)] for i in range(m): x, y = map(int, input().split()) a[x - 1].append(y - 1) a[y - 1].append(x - 1) c = [0] * n que = deque([]) que.append(0) while len(que) > 0: e = que.popleft() for i in a[e]: if c[i] > 0: continue c[i] = e + 1 que.append(i) print("Yes") for i in range(1, n): print(c[i])
p02615
s901515548
Accepted
n = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) ans = A[0] + sum(2 * a for a in A[1:n//2]) if n % 2 == 1: ans += A[n//2] print(ans)
p02761
s139527893
Wrong Answer
N,M= map(int,input().split()) s=[] c=[] ans=-1 for i in range(M): s_i,c_i=input().split() s.append(int(s_i)) c.append(c_i) for i in reversed(range(int("1"+"0"*(N-1)),int("9"*N)+1)): ans_bool=True for j in range(M): ans_bool=ans_bool and str(i)[s[j]-1]==str(c[j]) if ans_bool: ans=i print(ans)
p02778
s749956420
Wrong Answer
s = str(input()).lower() s.translate(str.maketrans({'a': 'x', 'b': 'x', 'c': 'x', 'd': 'x', 'e': 'x', 'f': 'x', 'g': 'x', 'h': 'x', 'i': 'x', 'j': 'x', 'k': 'x', 'l': 'x', 'm': 'x', 'n': 'x', 'o': 'x', 'p': 'x', 'q': 'x', 'r': 'x', 's': 'x', 't': 'x', 'u': 'x', 'v': 'x', 'w': 'x', 'y': 'x', 'z': 'x'})) print(s)
p03639
s222631510
Wrong Answer
N=int(input()) A=list(map(int,input().split())) a=0 b=0 for num in A: if num%2==1: a+=1 elif num%4==0: b+=1 if N==3: if a==3 or (a>=1 and b==0): print('No') else: print('Yes') else: if a<b: print('Yes') else: print('No')
p03261
s892893928
Accepted
import collections n = int(input()) li = [input() for _ in range(n)] #n行に1つずつ入力されるmojiretu ans = 'Yes' lw = li[0][0] for s in li: if lw != s[0]: ans = 'No' break else: lw = s[-1] c = collections.Counter(li) if c.most_common()[0][1] != 1: ans = 'No' print(ans)
p02778
s653880778
Wrong Answer
N=input() i=0 while i<=len(N): print("x" ,end='') i+=1
p02628
s397747605
Accepted
# coding: utf-8 # Your code here! N,K = map(int, input().split()) p=list(map(int, input().split())) P=sorted(p) print(sum(P[:K]))
p02935
s512263291
Accepted
n = int(input()) v = list(map(int,input().split())) v.sort() vlast = (v[0]+v[1]) / 2 for i in range(2, n): vlast = (vlast + v[i])/2 print(vlast)
p02768
s945084545
Accepted
M = 10**9+7 def comb(n, r): x = 1 y = 1 for i in range(r): x *= n - i x %= M y *= (i + 1) y %= M return x * pow(y, M-2, M) % M n, a, b = map(int, input().split()) print((pow(2, n, M) - comb(n, a) - comb(n, b) - 1 ) % M)
p02832
s329301539
Accepted
N = int(input()) li = [int(zz) for zz in input().split()] count = 1 ans = 0 ind = 0 while ind < N: if li[ind] == count: count += 1 ans += 1 ind += 1 if ans != 0: print(N-ans) else: print(-1)
p03487
s053608422
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) As = list(mapint()) from collections import Counter c = Counter(As) ans = 0 for num, c in c.most_common(): if c>num: ans += c-num elif c<num: ans += c print(ans)
p02768
s565442085
Wrong Answer
n,a,b=map(int,input().split()) p=10**9+7 sub=((n*(n+1))/2)%p sub=(sub*(n-1)/3)%p sub1=(a*(a-1)/2)%p sub2=(b*(b-1)/2)%p print(int((sub-sub1-sub2)%p))
p03086
s023702914
Accepted
s = list(input()) a = "" ans = 0 for c in s: if c in ("A", "C", "G", "T"): a += c else: ans = max(ans, len(a)) a = "" print(max(ans, len(a)))
p02777
s046219449
Accepted
s,t = map(str, input().split()) a,b = map(int, input().split()) u = input() if s == u: a -= 1 else: b -= 1 print(a,b)
p03035
s011528990
Accepted
# 127 A a, b = map(int, input().split()) if a >= 13: print(b) elif a >= 6: print(int(b/2)) else: print(0)
p04043
s864910416
Wrong Answer
a = input() a = [int(i)for i in a.split(" ")] print((a[0] == 5 or a[0] == 7) and (a[1] == 5 or a[1] == 7) and (sum(a) == 17))
p04029
s560982924
Accepted
# coding: utf-8 def main(): in_ninzu = int(input()) # '/'で割ると小数点付きの表示になるので’//’で商を求めると整数になる in_candy = in_ninzu * (in_ninzu + 1) // 2 print(in_candy) return 0 if __name__ == '__main__': main()
p03077
s997025928
Wrong Answer
N=int(input()) A=int(input()) B=int(input()) C=int(input()) D=int(input()) E=int(input()) min=min(A, B, C, D, E) print(-(-N//min))
p03345
s754983911
Wrong Answer
a,b,c,k = map(int, input().split()) over = 10**18 if a == b == c: print(0) exit() for i in range(k): x = b+c y = a+c z = a+b a = x b = y c = z if abs(a) > over or abs(b) > over or abs(c) > over: print("unfair") exit() print(a-b)
p03695
s197013472
Accepted
n=int(input()) A=list(map(int,input().split())) B=[0,0,0,0,0,0,0,0] red=int(0) for i in range(n): now=int(A[i]/400) if now<8: B[now]=1 else: red+=1 ans=B.count(1) if ans==0: ans=1 red-=1 print("{} {}".format(ans,ans+red))
p03548
s402848000
Accepted
x, y, z = map(int, input().split()) ans = 0 x -= z ans += x // (y + z) print(ans)
p02724
s491358159
Accepted
X =input() X=int(X) point =0 while X>=5: if X>=500: X-=500 point+=1000 elif 5<=X<500: X-=5 point+=5 print(point)
p03817
s746877277
Accepted
x = int(input()) if x <= 6: print(1) elif x <= 11: print(2) else: ans = x//11 a = x%11 if a == 0: print(ans*2) elif a <= 6: print(ans*2+1) else: print(ans*2+2)
p03997
s659137700
Accepted
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
p02987
s880994564
Wrong Answer
import sys a1=sys.stdin.readline() a2=list(a1) a3 = [i for i in a1] b=[ord(x) for x in a3] b.sort() if b[0]==b[1] and b[2]==b[3] and b[0]!=b[3]: print("Yes") else: print('No')
p02726
s357651221
Wrong Answer
from itertools import combinations n, x, y = map(int, input().split()) cnt = [0] * n for i, j in combinations(range(n), 2): dist = min(abs(j - i), abs(i - x) + abs(j - y) + 1, abs(i - y) + abs(j - x) + 1) cnt[dist] += 1 for i in range(1, n): print(cnt[i])
p03252
s942521200
Accepted
from collections import Counter def main(): S = input() T = input() s = Counter(S) t = Counter(T) a = sorted(list(s.values())) b = sorted(list(t.values())) print("Yes" if a == b else "No") if __name__ == "__main__": main()
p03103
s749161164
Wrong Answer
import numpy as np N, M = map(int, input().split()) AB = np.zeros(0, dtype=int) for i in range(N): a, b = map(int, input().split()) AB = np.concatenate([AB, np.full(b, a)]) AB = np.sort(AB) print(AB[:M].sum())
p02693
s960779231
Accepted
a = int(input()) x,y = map(int,input().split()) flag = True for i in range(x, y+1): if i % a == 0: flag = True break; else: flag = False if flag: print('OK') else: print('NG')
p03076
s143255776
Wrong Answer
n=[int(input()) for _ in range(5)] try: m=10-min([i%10 for i in n if i%10!=0]) n=[i if i%10==0 else i+(10-i%10) for i in n] print(sum(n)-m) except: print(0)
p02725
s551971400
Wrong Answer
# coding: utf-8 # Your code here! k,n = map(int,input().split()) num_list = list(map(int, input().split())) min_num = num_list[0]+num_list[-1] for i in range(0,int(len(num_list)/2)): res = num_list[-1]-k #print(num_list) num_list.pop(-1) #print(num_list) num_list.insert(0, res) #print(num_list) sum_num = abs(num_list[0])+abs(num_list[-1]) #print("sum_num") #print(sum_num) if sum_num < min_num: min_num = sum_num print(min_num)
p02701
s801454838
Accepted
n = int(input()) print(len(set([input() for _ in range(n)])))
p03286
s422696695
Accepted
from math import floor n = int(input()) s = "" if n == 0: print(0) exit() while n: s += str(n%2) n = n//2 n *= (-1) # print(n) # if n == -1: # break print(s[::-1])
p02697
s856846550
Accepted
N , M = map(int,input().split()) if N % 2 != 0: start = 1 end = N for i in range(M): print(start,end) start += 1 end -= 1 else: start = 1 end = N judge = True for i in range(M): print(start,end) start += 1 end -= 1 if (end - start) <= N // 2 and judge: start += 1 judge = False
p02917
s972697828
Wrong Answer
a=input() b=input().split() sum=0 for i in range(len(b)-1) : sum+=min(int(b[i]),int(b[i+1])) sum+=int(b[-1]) print(sum)
p03127
s374306868
Accepted
n = int(input()) A = list(map(int,input().split())) import fractions ans = A[0] for i in range(1,n): ans = fractions.gcd(ans,A[i]) print(ans)
p02958
s938302895
Accepted
def readints(): return list(map(int, input().split())) n = int(input()) p = readints() # print(sorted(p)) q = sorted(p) sum = 0 for i in range(n): if p[i] != q[i]: sum += 1 print("YES" if sum <= 2 else "NO")
p03317
s600679752
Wrong Answer
N, K = map(int, input().split()) A = list(map(int, input().split())) a_min = min(A) pos = 0 ans = 0 for pos in range(N): if A[pos] != a_min: for i in range(pos, min(pos+K-1, N)): A[i] = a_min ans += 1 print(ans)
p04029
s393157875
Accepted
N = int(input()) a = 1/2*N*(N+1) print(int(a))
p02578
s174748764
Accepted
n=int(input()) a=list(map(int,input().split())) b=a s=0 for i in range(n-1): if b[i]>a[i+1]: s+=(a[i]-a[i+1]) b[i+1]=b[i] print(s)
p02843
s249192446
Accepted
x = input() y = int(x) if y < 100: print(0) else: ans = 0 c = int(x[:len(x)-2]) for i in range(1,c+1): if 100*i <= y and y <= 105*i: ans = 1 break print(ans)
p03251
s801401154
Wrong Answer
n, m, X, Y = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) x.sort() y.sort() for z in range(x[n-1], y[0]): if X < z and z <= Y: print("No War") exit() print("War")
p02621
s054123111
Accepted
a = int(input()) print(a + (a*a) + (a*a*a))
p02699
s491059767
Wrong Answer
from sys import stdin from sys import setrecursionlimit setrecursionlimit(10 ** 7) a,b = map(int,stdin.readline().rstrip().split()) if b <= a: print("unsafe") else: print("safe")
p03479
s133832711
Accepted
x,y = map(int,input().split()) count = 1 while True: if x * 2 <= y: count+=1 x*=2 else: break print(count)
p02630
s516105669
Accepted
#!/usr/bin/env python3 N = int(input()) A = list(map(int, input().split())) Q = int(input()) BC = [map(int, input().split()) for i in range(Q)] D = {} for i in range(1, 10**5+1): D[i] = 0 for a in A: D[a] += 1 ret = sum(A) for b, c in BC: sa = c - b #minus = b * D[b] #cnt = D[b] plus = sa * D[b] D[c] += D[b] D[b] = 0 ret += plus print(ret)
p03680
s134825782
Wrong Answer
n = int(input()) a = [int(input())-1 for _ in range(n)] c = a[0] cnt = 2 while 1: c = a[c] if c == 1: print(cnt) break elif c == 0: print(-1) break else: cnt += 1
p02795
s826390318
Wrong Answer
h = int(input()) w = int(input()) n = int(input()) if(h >= w): print(n // h) else: print(n // w)
p02772
s904307792
Accepted
n = int(input()) a = list(map(int,input().split())) def is_approve(a:list): ans = False for num in a: if num % 2 == 1 : ans = True elif num % 3 == 0 or num % 5 == 0: ans = True else: ans = False break return ans if is_approve(a): print('APPROVED') else: print('DENIED')
p02947
s905711983
Wrong Answer
from collections import Counter n = int(input()) s = [str(sorted(input())) for i in range(n)] print(s) c = Counter(s) print(c) l = sum((v*(v-1)/2) for v in c.values()) print(l)
p03037
s111166171
Wrong Answer
n, m = map(int, input().split()) lr = [] for i in range(m): lr.append(list(map(int, input().split()))) lmax = 0 mmin = 10**5 for i in range(m): lmax = max(lmax, lr[i][0]) mmin = min(mmin, lr[i][1]) print(mmin - lmax + 1)
p02629
s855745262
Wrong Answer
from string import ascii_lowercase N = int(input()) def base(n): l = [] p = int(n / 26) q = n % 26 - 1 if p != 0: l = [*l, *base(p)] return [*l, ascii_lowercase[q]] print(''.join(base(N)))
p03814
s236565949
Accepted
s = input() print( s.rfind('Z') - s.find('A')+1)
p02691
s057479834
Wrong Answer
n = int(input()) ai = [int(i) for i in input().split()] li = [0]*(10**6+1) for i in range(1,n): if ai[i] >= 2*10**5: continue li[ai[i]-i+5*10**5] += 1 ans = 0 exit() for i in range(1,n): #print(i) ans += li[-ai[i-1]-(i-1)+5*10**5] if i == n: #print(i,i,i) break if ai[i] < 2*10**5: li[ai[i]-i+5*10**5] -= 1 print(ans)
p02596
s155497806
Wrong Answer
import sys x = int(input()) if x%2 == 0: print(-1) sys.exit() y = 7 i = 1 while y%x != 0: if i == 100: print(-1) sys.exit i = i + 1 y = y*10 + 7 print(i)
p03137
s326134150
Accepted
import numpy as np n,m = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() x = np.array(x) diff = x[1:]-x[:-1] low = np.argsort(diff)[::-1][n-1:] print(sum(diff[low]))
p02983
s355125971
Accepted
import itertools L,R = map(int,input().split()) if 2019 <= (R - L) + 1: print(0) exit() lst = list(range(L,R+1)) md = [x * y % 2019 for x,y in itertools.combinations(lst,2)] md.sort() print(md[0])
p02951
s769970259
Accepted
A, B, C = map(int, input().split()) print(max(C - (A - B), 0))
p02547
s720906325
Wrong Answer
n = int(input()) d = [] z = 0 for i in range(n): d1, d2 = map(int, input().split()) z = z+1 if d1==d2 else 0 d.append(z) print(max(d))
p02791
s336960438
Wrong Answer
N = int(input()) P = list(map(int, input().split())) ans = 0 min_v = N for i in range(0, N): if P[i] > min_v: continue for j in range(0, i+1): if P[i] > P[j]: break if i == j: ans += 1 min_v = i print (ans)
p03487
s213004273
Wrong Answer
#coding:utf-8 from collections import Counter N = int(input()) A = list(map(int, input().split())) c = Counter(A) ans = 0 for it in c.items(): if it[0] <= it[1]: ans += (it[1]-it[0]) else: ans += it[0] print (ans)
p03012
s220996788
Accepted
n = int(input()) w = list(map(int, input().split())) difference = [] for i in range(n): s1 = w[0:i+1] s2 = w[i+1:n] s = abs(sum(s1)-sum(s2)) difference.append(s) print(min(difference))
p03821
s281988955
Accepted
n, *AB = map(int, open(0).read().split()) c = 0 for a, b in zip(AB[::2][::-1], AB[1::2][::-1]): a += c t = a % b if t != 0: t = b - t c += t print(c)
p03449
s018135957
Wrong Answer
import numpy as np N = int(input()) A = np.array([list(map(int, input().split())) for _ in range(2)]) U = A[0][1:] D = A[1][:-1] i = -1 for i in range(N - 1): sum_U = U[i:].sum() sum_D = D[i:].sum() if sum_U < sum_D: break ans = A[0][0] + A[1][N - 1] + U[:i].sum() + D[i:].sum() print(ans)
p03672
s169551532
Accepted
s=input() n=len(s) print(max([n-i for i in range(2,n,2)if s[:(n-i)//2]==s[(n-i)//2:-i]]))
p03745
s089568481
Wrong Answer
N=int(input()) A=list(map(int,input().split())) cnt = 0 flag = 0 for i in range(N-1): #print(A[i+1]-A[i]) if A[i+1]-A[i] >= 0: if flag == 1: cnt +=0 elif flag == -1: cnt +=1 flag = 0 elif flag ==0: flag = 1 elif A[i+1]-A[i] <= 0: if flag == 1: cnt +=1 flag =0 elif flag ==-1: cnt +=1 elif flag ==0: flag = -1 print(cnt+1)
p03281
s950007497
Wrong Answer
def divisor(x): ret=[] for i in range(1,x+1): if x%i==0: ret.append(i) return len(ret) ans=0 n=int(input()) for i in range(1,n+1): if divisor(i)==8: ans+=1 print(ans)
p02720
s313778828
Wrong Answer
que=[1,2,3,4,5,6,7,8,9] k=int(input()) for i in range(k-1): q=que.pop(0) #print("q",q) m=q%10 #print("m",m,"que",que) if m==0: que.append(m*10) que.append(m*10+1) elif m==9: que.append(m*10+8) que.append(m*10+9) else: que.append(m*10+m-1) que.append(m*10+m) que.append(m*10+m+1) print(que[0])
p03761
s012364586
Accepted
n=int(input()) cnt=[10000]*26 for i in range(n): tmp=[0]*26 S=input() for j in range(len(S)): tmp[ord(S[j])-97]+=1 for j in range(26): cnt[j]=min(tmp[j],cnt[j]) li=[] for i in range(26): for j in range(cnt[i]): li.append(chr(i+97)) print(''.join(li))
p03012
s240535731
Accepted
import sys N = int(input()) array = list(map(int,input().split())) result = sum(array) for I in range(len(array)): tmp = abs(sum(array[0:I]) - sum(array[I:])) if result > tmp: result = tmp print(result)
p02963
s400348884
Accepted
from math import ceil S=int(input()) if S<=10**9: d=0 c=S else: d=ceil (S/(10**9)) c=10**9*d-S print(0,0,10**9,1,c,d)
p02601
s006766407
Accepted
A, B, C = map(int, input().split()) K = int(input()) k = 0 while True: if A < B: break else: B *= 2 k += 1 while True: if B < C: break else: C *= 2 k += 1 if k <= K: print('Yes') else: print('No')
p03071
s709414768
Accepted
a, b = map(int, input().split()) x = a + a-1 y = b + b-1 z = a + b print(max(x,y,z))
p02731
s837658967
Accepted
print('{:.10f}'.format((float(input())/3)**3))
p03435
s365766587
Accepted
a,b,c=map(int,input().split()) d,e,f=map(int,input().split()) g,h,i=map(int,input().split()) if a+e==b+d: if b+f==c+e: if d+h==e+g: if e+i==f+h: print('Yes') exit() print('No')
p02690
s070030537
Wrong Answer
import sys input = sys.stdin.readline def main(): X = int(input().rstrip()) f = 0 for a in range(73): for b in range(64): i = a ** 5 - (-b) ** 5 if i == X: print(a, -b) f = 1 break if f: break if __name__ == '__main__': main()
p03435
s284619996
Wrong Answer
c=[] for i in range(3): c.append(list(map(int,input().split()))) for i in range(2): if c[i+1][0]-c[i][0]==c[i+1][1]-c[i][1] and c[i+1][1]-c[i][1]==c[i+1][2]-c[i][2]: flg=0 else: flg=1 if flg==0: print("Yes") else: print("No")
p02772
s269575153
Accepted
N = int(input()) tuplea = tuple(map(int, input().split())) ans = 0 for n in range(N): if tuplea[n]%2 == 1: pass else: if tuplea[n]%3 == 0 or tuplea[n]%5 == 0: pass else: ans = 1 if ans == 0: print('APPROVED') else: print('DENIED')
p02861
s178139260
Wrong Answer
n = int(input()) xy = [] for i in range(n): arrat = [int(i) for i in input().split()] xy.append(arrat) ans = 0 for i in range(n): for j in range(i+1,n): ans += ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5 ans /= (n*(n-1)//2) print(ans*2)