problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03077
s327513257
Accepted
N = int(input()) A = int(input()) B = int(input()) C = int(input()) D = int(input()) E = int(input()) import math x = math.ceil(N / (min(A, B, C, D, E))) ans = 5 + (x - 1) print(ans)
p02912
s950138533
Wrong Answer
import heapq n,m=map(int,input().split()) a=list(map(lambda x:int(x)*(-1),input().split())) heapq.heapify(a) for i in range(m): max=heapq.heappop(a) heapq.heappush(a,max//2) print(sum(a)*(-1))
p03475
s734108405
Wrong Answer
N = int(input()) csf = [list(map(int, input().split())) for i in range(N - 1)] for i in range(N): ans = 0 for j in range(i, N - 1): c, s, f = csf[j] if ans <= s: ans += s - ans + c else: while ans < s: ans += f ans += c print(ans)
p03438
s242952982
Accepted
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c,d=0,0 for i in range(n): if a[i]>b[i]: c+=a[i]-b[i] else: d+=(b[i]-a[i])//2 if d>=c: print("Yes") else: print("No")
p02911
s171193226
Accepted
N,K,Q = map(int,input().split()) #n人にk点を配った情報を作成 point = [K] * N #各クイズごとに正解者に+1点を与える for i in range(Q): score = int(input()) score = score -1 point[score] += 1 #クイズが終わった後の得点を調べて結果を出力していく for i in range(N): if point[i] <= Q: print("No") else: print("Yes")
p02570
s651986453
Wrong Answer
data = input("put:") data = data.split() print("Yes") if int(data[0]) / int(data[2]) <= int(data[1]) else print("No")
p03261
s269352114
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n = int(input()) words = [] for _ in range(n): w = input().strip() if w in words: print('No') sys.exit(0) if len(words) == 0: words.append(w) continue if words[-1][-1] != w[0]: print('No') sys.exit(0) else: words.append(w) print('Yes')
p03284
s016878447
Wrong Answer
def resolve(): n, k = map(int, input().split()) print(n % k) resolve()
p02676
s950935845
Wrong Answer
K=int(input()) S=input() sbreak=list(S) news=[] if len(sbreak)<=K: print(S) else: for num in sbreak: news.append(num) if num==sbreak[K-1]: break s=''.join(news) print(s+'...')
p02646
s970045199
Accepted
a,v = map(int, input().split()) b,w = map(int, input().split()) t = int(input()) if a<b: new_a = a + v*t new_b = b + w*t if new_a >= new_b: print("YES") elif new_a < new_b: print("NO") elif a>b: new_a = a - v*t new_b = b - w*t if new_a <= new_b: print("YES") elif new_a > new_b: print("NO")
p03645
s293027237
Wrong Answer
N, M =map(int, input().split()) sa = set() ag = set() for i in range(M): a,b = map(int, input().split()) if a == 1: sa.add(b) if b == N: sa.add(a) print('POSSIBLE' if len(sa&ag) else 'IMPOSSIBLE')
p03371
s690529565
Wrong Answer
a, b, c, x, y = (map(int, input().split())) candi = [] for i in range(100001): candi.append(c*i+max(0,(x-i//2))*a+max(0,(y-i//2))*b) print(min(candi))
p03625
s741833480
Accepted
from collections import Counter N = int(input()) A = list(map(int, input().split())) ans = 0 counter = Counter(A) keys = sorted(counter.keys(), reverse=True) flag = False for k in keys: if ans == 0 and counter[k] >= 4: ans = k*k flag = True break elif ans == 0 and counter[k] >= 2: ans = k elif ans != k and counter[k] >= 2: ans = ans * k flag = True break if flag: print(ans) else: print(0)
p03943
s566578258
Accepted
l = sorted(map(int, input().split())) print(["No","Yes"][l[2]*2==sum(l)])
p02576
s706087614
Accepted
import math N, X, T = map(int, input().split()) print(math.ceil(N/X) * T)
p03679
s330333312
Wrong Answer
def main(): num = list(map(int,input().split())) if num[2]-num[1]<=0: print('delicious') elif num[0] >num[2]-num[1]: print('safe') else: print('dangerous') main()
p03456
s488933813
Accepted
import math a,b = input().split() c = int(a+b) root = int(math.sqrt(c)) if root*root == c: print("Yes") else: print("No")
p03698
s354759271
Accepted
s=input() ss=set(list(s)) if len(ss)==len(s): print('yes') else: print('no')
p03493
s206736995
Accepted
a = int(input()) count = 0 b = a / 100 reserch_1 = b // 1 if (reserch_1 == 1): a = a - 100 count = count + 1 c = a /10 reserch_2 = c // 1 if (reserch_2 == 1): a = a - 10 count =count + 1 reserch_3 = a // 1 if(reserch_3 == 1): count =count + 1 print(count)
p02793
s624363894
Accepted
import fractions from functools import reduce m = 0 sum = 0 n = int(input()) List = list(map(int, input().split())) def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) m = lcm_list(List) for i in List: sum += m // i print(sum % (10**9 + 7))
p03095
s215237976
Accepted
from collections import Counter n = int(input()) s = input() mod = 10 ** 9+7 a = Counter(s) ans = 1 for v in a.values(): ans *= (v+1) print((ans-1)%mod)
p03448
s296363052
Accepted
A = int(input()) B = int(input()) C = int(input()) X = int(input()) cnt = 0 for i in range(A + 1): for j in range(B + 1): for k in range(C + 1): if (500 * i + 100 * j + 50 * k == X): cnt += 1 print(cnt)
p03745
s448866194
Wrong Answer
n = int(input()) l = list(map(int,input().split())) if n == 1: print(1) exit() if l[-1] >= l[-2]: l += [float('Inf')] else: l += [-float('Inf')] ans = 1 i = 1 while i <= n - 1: if l[i-1] <= l[i] and l[i] <= l[i+1]: i += 1 elif l[i-1] >= l[i] and l[i] >= l[i+1]: i += 1 else: ans += 1 i += 2 print(ans)
p02665
s579697037
Wrong Answer
import math def main(): N = int(input()) A = list(map(int, input().split())) B = [1] * (N) B.append(0) sumA = sum(A) ans = 0 if N == 0 and A[0] != 1: print(-1) return for i in range(1,N): sumA -= A[i] B[i] = min(2 * B[i-1] - A[i], sumA) if B[i] < 0: print(-1) return print(sum(A+B)) if __name__ == "__main__": main()
p02548
s825480034
Accepted
n = int(input()) count = 0 for i in range(1,n): count += (n-1)//i print(count)
p03696
s374772651
Accepted
n=int(input()) s=input() cntl=0 for i in range(n-1,-1,-1): if s[i]==")": cntl+=1 elif s[i]=="(" and cntl>0: cntl-=1 sl="("*cntl cntr=0 for i in range(n): if s[i]=="(": cntr+=1 elif s[i]==")" and cntr>0: cntr-=1 sr=")"*cntr print(sl+s+sr)
p02917
s534946893
Accepted
N = int(input()) B = list(map(int,input().split())) A = [B[0]] + [min(B[i],B[i-1]) for i in range(1,N-1)] + [B[-1]] print(sum(A))
p02727
s741804421
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())) lis=p+q+r lis.sort(reverse=True) ans=0 for i in range(x+y): ans+=lis[i] print(ans)
p03796
s230126958
Wrong Answer
n = int(input()) ans = 1 for i in range(n): ans *= i+1 ans = ans%10000007 print(ans)
p02748
s266444748
Accepted
from sys import stdin A, B, M = (int(x) for x in stdin.readline().rstrip().split()) ai = [int(x) for x in stdin.readline().rstrip().split()] bj = [int(x) for x in stdin.readline().rstrip().split()] minimum = min(ai) + min(bj) for i in range(M): x, y, c = (int(x) for x in stdin.readline().rstrip().split()) price = ai[x-1] + bj[y-1] - c if price < minimum: minimum = price print(minimum)
p02946
s387563712
Wrong Answer
K,X = map(int,input().split()) a=X-K+1 b=X+K-1 for i in range(a,b): print(i)
p03720
s900287779
Accepted
# ALC005 B N, M = map(int, input().split()) road_list = [] for _ in range(M): a, b = map(int, input().split()) road_list.append(a) road_list.append(b) for _ in range(1, N+1): print(road_list.count(_))
p03778
s027262614
Wrong Answer
w,a,b = map(int, input().split()) if a<=b<=a+w: print(0) exit() if b<=a<=b+w: print(0) exit() ans1=b-a-w ans2=a-b-w print(min(ans1,ans2))
p03043
s710162965
Wrong Answer
N, K = map(int, input().split()) qs = 0 for i in range(1, N+1): if i > K: qs += 1/N elif i <= K: q = 1/N while i <= K: q *= 1/2 i *= 2 qs += q print(qs)
p02684
s819760522
Accepted
n,k = map(int,input().split()) a = list(map(int,input().split())) dic = {} for key, a in zip(range(1, n+1), a): dic[key] = a log = [-1]*(n+1) next = dic[1] step = 1 log[next] = step k -= 1 while k: next = dic[next] step += 1 k -= 1 if log[next] != -1: k %= log[next] - step else: log[next] = step print(next)
p02801
s473578071
Wrong Answer
s = input() a = 'abcdefghijklmnopqrstuvwxyz' ans = 0 for i in range(len(a)): if a[i]=='s': ans=i break print(a[ans])
p03359
s297404941
Accepted
a, b = map(int, input().split()) if a <= b: print(a) else: print(a - 1)
p02777
s785643158
Accepted
S,T = input().split() A,B = input().split() A = int(A) B = int(B) U = input() if S == U: A -= 1 if T == U: B -= 1 print(A," ",B)
p03774
s318317219
Accepted
n,m = map(int,input().split()) ab = [[int(i) for i in input().split()] for _ in range(n)] cd = [[int(i) for i in input().split()] for _ in range(m)] for stu in ab: mind = float("inf") for i,cp in enumerate(cd,1): d = sum(map(abs,(stu[0]-cp[0],stu[1]-cp[1]))) if mind > d: ans = i mind = d else: print(ans)
p02731
s126926547
Accepted
l = int(input()) print((l*l*l)/27)
p02842
s171638269
Wrong Answer
# N=1079 N=int(input()) ans=int(round((N*100/108)+0.5)) if (ans*1.08)//1 == N: print(ans) else: print(":(")
p03962
s081402551
Accepted
print(len(set(input().split())))
p03449
s411642124
Wrong Answer
N=int(input()) p=[0] q=[0] A1=list(map(int,input().split())) A2=list(map(int,input().split())) for i in range(N): p.append(p[i]+A1[N-i-1]) q.append(q[i]+A2[i]) ans=0 for j in range(N): ans=max(ans,p[j+1]+q[j+1]) print(ans)
p02700
s556226200
Wrong Answer
a, b, c, d=map(int, input().split()) flag = False for i in range(101): a = a-d if a <= 0: flag = True break c = c-b if True: print("No") else: print("Yes")
p02819
s179032113
Accepted
x=int(input()) while True: for i in range(2,x): if x%i == 0: x += 1 break else: print(x) break
p02700
s805828824
Accepted
a,b,c,d = map(int,input().split()) while a>0 and c>0: c-=b a-=d if c<=0: print("Yes") else: print("No")
p02584
s681026033
Accepted
X, K, D = map(int, input().split()) s = (abs(X) // D) t = abs(abs(X) - D*s) u = abs(abs(X) - D*(s+1)) if abs(X) > (K*D): print(abs(X) - K*D) else: if (K-s) % 2 == 0: print(t) else: print(u)
p02659
s450893785
Wrong Answer
from decimal import * a,b=map(float, input().split(" ")) b *= 100 print((int)(a*b)/100+0.001)
p02556
s756449676
Accepted
N = int(input()) XY = [] for i in range(N): XY.append(list(map(int,input().split()))) ZW = [] for i in range(N): ZW.append([XY[i][0]-XY[i][1],XY[i][0]+XY[i][1]]) out = [] ZW.sort(key=lambda x:x[0]) out.append(abs(ZW[0][0]-ZW[N-1][0])) ZW.sort(key=lambda x:x[1]) out.append(abs(ZW[0][1]-ZW[N-1][1])) print(max(out))
p02678
s488366996
Accepted
n,m = map(int,input().split()) d = [[] for i in range(n)] for i in range(m): a,b = map(int,input().split()) d[a-1].append(b-1) d[b-1].append(a-1) ans = [-1]*n ans[0] = 0 from collections import deque q = deque([0]) while q: u = q.popleft() for v in d[u]: if ans[v]==-1: ans[v] = u q.append(v) print('Yes') for i in ans[1:]: print(i+1)
p02873
s523335382
Accepted
S = input() bf = '' idx = [] bdiff = 0 diff = 0 rlt = 0 for i in range(len(S)): if bf != S[i]: idx.append(i) bf = S[i] idx.append(len(S)) for i in range(len(idx)-1): diff = idx[i+1] - idx[i] rlt += diff*(diff+1)//2 if S[idx[i]] == '>': if bdiff < diff: rlt -= bdiff else: rlt -= diff bdiff = diff print(rlt)
p02707
s171134777
Wrong Answer
import collections N = int(input()) A = input().split() clist = collections.Counter(A) for i in range(1,N): j = str(i) print(clist['i'])
p02633
s164688233
Accepted
from math import gcd x = int(input()) y = x * 360 // gcd(x, 360) print(y//x)
p02623
s023023114
Accepted
n,m,k=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) a,b=[0],[0] for i in range(n): a.append(a[i]+A[i]) for i in range(m): b.append(b[i]+B[i]) j,ans=m,0 for i in range(n+1): if a[i]>k: break while b[j] > k-a[i]: j-=1 ans=max(ans,i+j) print(ans)
p03360
s465218525
Accepted
# -*- coding: utf-8 -*- import math import itertools import sys import copy # 入力 #A, B, C, D = map(int, input().split()) #L = list(map(int, input().split())) #N = int(input()) L = list(map(int, input().split())) K = int(input()) L.sort(reverse=True) sum = L[0] for _ in range(K) : sum *= 2 sum += L[1] sum += L[2] print (sum)
p03150
s960417842
Accepted
S=input() t="keyence" for i in range(1,7): if S[:i]==t[:i] and S[-(7-i):]==t[i:]: print('YES') exit() print('NO')
p03637
s794464842
Accepted
n = int(input()) a = list(map(int, input().split())) ans1 = 0 ans2 = 0 ans3 = 0 for i in range(n): if a[i] % 4 == 0: ans1 += 1 elif a[i] % 2 == 0: ans2 += 1 else: ans3 += 1 if ans1 + 1 == ans3 and ans2 == 0: print("Yes") elif ans1 >= ans3: print("Yes") else: print("No")
p04019
s714586753
Wrong Answer
s = input() if s.count("N") == s.count("S") and s.count("E") == s.count("W"): print("Yes") else: print("No")
p03359
s399077692
Wrong Answer
a, b = map(int, input().split()) if b > a: print(a-1) else: print(a)
p03146
s109068284
Accepted
def f(n): if n%2 == 0: return n//2 else: return 3*n + 1 s = int(input()) ans = [s] cnt = 0 while True: ans.append(f(s)) if f(s) == 4: cnt += 1 if cnt == 2: break s = f(s) for i in range(len(ans)-1): for j in range(i+1, len(ans)): if ans[i] == ans[j]: print(j+1) break else: continue break
p03592
s707267962
Accepted
#!/usr/bin/env python3 n, m, k = map(int, input().split()) for i in range(n + 1): for j in range(m + 1): if m * i + j * n - 2 * i * j == k: print("Yes") exit() print('No')
p03427
s968721591
Accepted
N = int(input()) for i in range(17): if 10**i <=N <10**(i+1): m=i+1 break for j in range(0,10): if (10**(m-1))*j + 10**(m-1)-1 <=N< (j+1)*(10**(m-1))+10**(m-1)-1: a = j break print(a+9*(m-1))
p02660
s170650597
Accepted
n=int(input()) r=int(n**0.5+1) ans=0 for i in range(2,r): e=0 while n%i==0: n//=i e+=1 k=1 while e>=k: e-=k ans+=1 k+=1 if n!=1: ans+=1 print(ans)
p03998
s950035422
Accepted
import collections h,t= {p: collections.deque(list(raw_input())) for p in 'abc'},'a' while(h[t]): t = h[t].popleft() print t.upper()
p03745
s547386783
Accepted
N = int(input()) A = list(map(int, input().split())) flag = None #True:増加 False:減少 temp = A[0] result = 1 for a in A: if a == temp: continue if flag == None: if a > temp: flag = True else: flag = False elif (flag and a < temp) or (not flag and a > temp): flag = None result += 1 temp = a print(result)
p03162
s421799690
Accepted
n = int(input()) l = [list(map(int, input().split())) for i in range(n)] a, b, c = [list(i) for i in zip(*l)] dp = [[0, 0, 0] for i in range(n+1)] for i in range(n): dp[i+1][0] = max(dp[i][1]+a[i], dp[i][2]+a[i]) dp[i+1][1] = max(dp[i][0]+b[i], dp[i][2]+b[i]) dp[i+1][2] = max(dp[i][0]+c[i], dp[i][1]+c[i]) print(max(dp[-1][0], dp[-1][1], dp[-1][2]))
p02689
s948177138
Accepted
import sys N, M = map(int, sys.stdin.readline().split()) H = list(map(int, sys.stdin.readline().split())) AB = [list(map(int, sys.stdin.readline().split())) for i in range(M)] ans = [1] * N for i in range(M): a, b = AB[i] if H[a - 1] < H[b -1]: ans[a -1] = 0 elif H[a - 1] > H[b - 1]: ans[b - 1] = 0 else: ans[a - 1] = 0 ans[b - 1] = 0 print(ans.count(1))
p02701
s812575796
Accepted
N = int(input()) myset = set([]) for i in range(N): S = input() myset.add(S) print(len(myset))
p02775
s302640186
Accepted
N = input() n = len(N) a = int(N[0]) b = 11-int(N[0]) for i in range(n-1): a1 = min(a+int(N[i+1]), b+int(N[i+1])) b1 = min(a+11-int(N[i+1]), b+9-int(N[i+1])) a = a1 b = b1 print(min(a,b))
p03327
s874628035
Wrong Answer
n=int(input()) if n<=999: print("ABC"+str(n)) else: a=str(n%1000+1) if len(a)==1: print("ABD00"+a) elif len(a)==2: print("ABD0"+a) else: print("ABD"+a)
p02646
s108741756
Accepted
A,V=map(int,input().split()) B,W=map(int,input().split()) T=int(input()) if A==B: print('YES') else: if A>B: if A-(V*T)<=B-(W*T): print('YES') else: print('NO') else: if A+(V*T)>=B+(W*T): print('YES') else: print('NO')
p03071
s288352859
Accepted
# ABC124A a, b = map(int, input().split()) a, b = max(a, b), min(a, b) if a >= b + 1: print(2 * a - 1) else: print(2 * a)
p03371
s170854328
Accepted
a,b,c,x,y = map(int,input().split()) res = 9999999999999 for i in range(0, 200002, 2): na = x - i//2 nb = y - i//2 na = 0 if na < 0 else na nb = 0 if nb < 0 else nb res = min(res, c * i + a*na + b*nb) print(res)
p03592
s392161727
Accepted
import sys N, M, K = list(map(int, input().split())) for i in range(N + 1): for j in range(M + 1): if (M - j) * i + (N - i) * j == K: print('Yes') sys.exit() print('No')
p03487
s075517654
Accepted
from collections import Counter n = int(input()) a = Counter(list(map(int, input().split()))) ans = 0 for x,y in a.items(): if y<x: ans += y else:ans += y-x print(ans)
p03796
s579876547
Accepted
mod=10**9+7 N=int(input()) ans=1 for i in range(1,N+1): ans*=i ans%=mod print(ans)
p02718
s856734967
Wrong Answer
i1 = input() i2 = input() # i1 = "4 1" # i2 = "5 4 2 1" list1 = [int(s) for s in i1.split()] list2 = [int(s) for s in i2.split()] n = list1[0] m = list1[1] total = sum(list2) # 選べる count = 0 for a in range(n): if (list2[a]/total >= 1/(4*m)): count += 1 if count == m: print("Yes") else: print("No")
p02987
s549369084
Wrong Answer
s=input() t=[] for i in range(4): if s[i] in t: t.append(t[i]) if len(t)==2: print("Yes") else: print("No")
p02843
s102661238
Accepted
X = int(input()) dp = [0] * 110000 dp[100] = 1 dp[101] = 1 dp[102] = 1 dp[103] = 1 dp[104] = 1 dp[105] = 1 for i in range(X + 1): dp[i + 100] = max(dp[i], dp[i + 100]) dp[i + 101] = max(dp[i], dp[i + 101]) dp[i + 102] = max(dp[i], dp[i + 102]) dp[i + 103] = max(dp[i], dp[i + 103]) dp[i + 104] = max(dp[i], dp[i + 104]) dp[i + 105] = max(dp[i], dp[i + 105]) print(dp[X])
p02546
s904510391
Accepted
from sys import stdin readline = stdin.readline def i_input(): return int(readline().rstrip()) def i_map(): return map(int, readline().rstrip().split()) def i_list(): return list(i_map()) def main(): S = readline().rstrip() ans =S + "s" if S[-1] != "s" else S + "es" print(ans) if __name__ == "__main__": main()
p03625
s037569111
Accepted
from collections import defaultdict Lineger_Dict = defaultdict(int) N = int(input()) N_List = list(map(int,input().split())) for i in N_List: Lineger_Dict[i] += 1 Rec = sorted([k for k,v in Lineger_Dict.items() if v >= 2] + [k for k,v in Lineger_Dict.items() if v >= 4]) if len(Rec) < 2: print(0) else: print(Rec[-1]*Rec[-2])
p02971
s466216525
Wrong Answer
N=int(input()) a=[int(input()) for i in range(N)] sw=True b=sorted(a,reverse=True) for j in range(N-1): if b[j]>b[j+1]: max2=b[j+1] max1=b[j] sw=False break if sw==True: max1=b[0] for k in range(N): print(max1) else: for k in range(N): if a[k]==max1: print(max2) else: print(max1)
p03109
s503184750
Wrong Answer
S = input() y = S[0:4] m = S[5:7] d = S[8:10] if y < "2019": print("Heisei") elif (y == "2019") and (m < "4"): print("Heisei") elif (y == "2019") and (m == "4") and (d <= "30"): print("Heisei") elif (y == "2019") and (m == "4") and (d > "30"): print("TBD") elif (y == "2019") and (m >= "5"): print("TBD") elif (y > "2019"): print("TBD")
p02576
s273172689
Wrong Answer
a,b,c=list(map(int,input().split())) d=a//b print(int(d*c))
p03545
s224888556
Accepted
a,b,c,d=input() for i in range(2**3): ls = ["+","+","+"] for j in range(3): if (i >> j) & 1: ls[j] = "-" if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7: print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7") break
p04019
s495170477
Accepted
S=input() ecount=0 wcount=0 ncount=0 scount=0 flag=1 for i in range(len(S)): if S[i]=="E": ecount=ecount+1 elif S[i]=="W": wcount=wcount+1 elif S[i]=="N": ncount=ncount+1 else: scount=scount+1 if (ncount>0)or(scount>0): if (ncount*scount==0): flag=0 if (wcount>0)or(ecount>0): if (wcount*ecount==0): flag=0 if flag==0: print("No") else: print("Yes")
p02951
s700143618
Accepted
A,B,C = map(int,input().split()) print(max(C-(A-B),0))
p03785
s539424441
Accepted
_, c, k, *lst = map(int, open(0).read().split()) lst.sort() res = 1 tmpt = lst[0] tmpc = 0 for i in lst: tmpc += 1 if not (tmpc <= c and i - tmpt <= k): res += 1 tmpc = 1 tmpt = i print(res)
p03407
s465475478
Accepted
a, b, c = map(int, input().split()) print('Yes' if (a + b) >= c else 'No')
p02596
s626412048
Accepted
import sys input = sys.stdin.readline K=int(input().rstrip('\n')) if K % 2 ==0: print(-1) else: now = 7 check = 0 for i in range(1,K+1): if now % K ==0: print(i) check += 1 break else: now = now%K now = now*10 now += 7 if check ==0: print(-1)
p02854
s158894429
Accepted
n = int(input()) arr = list(map(int,input().split())) tot = sum(arr) temp = 0 ans = 1e18 for i in range(n): temp += arr[i] rest = tot-temp cost = abs(rest-temp) if cost < ans: ans = cost print(ans)
p03107
s028114766
Accepted
S = input() ans = min(S.count("0"), S.count("1")) * 2 print(ans)
p02848
s986034381
Accepted
def main(): N = int(input()) S = input() ans = '' for i in range(len(S)): o = (ord(S[i]) - 65 + N)%26 + 65 ans += chr(o) print(ans) if __name__ == "__main__": main()
p02935
s272022469
Accepted
import functools def new_ingredient(x, y): return (x + y) / 2 def main(): n = int(input()) v = [int(x) for x in input().split()] v.sort() max_value = functools.reduce(new_ingredient, v) print(max_value) if __name__ == "__main__": main()
p02729
s015380372
Wrong Answer
def main(): n,m = map(int,input().split()) print(n * (n - 1) / 2 + m * (m - 1) / 2) main()
p02747
s831406663
Wrong Answer
S = input() if len(S) == 2: if S == 'hi': print('Yes') else: print('No') else: flag = 0 i = 0 while i < len(S)-1: if S[i:i+2] == 'hi': flag = 1 else: flag = 0 break i += 2 if flag == 1: print('Yes') else: print('No')
p02732
s955287128
Accepted
N = int(input()) A = list(map(int, input().split())) from collections import defaultdict c = defaultdict(int) cm = set() c2 = list() num = 0 for i in range(N): c[A[i]] += 1 cm.add(A[i]) for i in list(cm): num += c[i]*(c[i]-1)//2 for i in range(N): ans = num - c[A[i]] + 1 c2.append(ans) for cs in c2: print(cs)
p03281
s419715851
Accepted
#coding:utf-8 n = int(input()) ans = 0 #n以下のすべての奇数について全探索 for i in range(1, n+1, 2): count = 0 for j in range(1, i+1): if i % j == 0: count += 1 if count == 8: ans += 1 print(ans)
p03799
s128115921
Wrong Answer
n, m = map(int, input().split()) if n * 2 > m: print(n) else: print((m - 2*n) // 4 + n)
p03693
s624460516
Wrong Answer
r,g,b=map(int,input().split()) n=100*r+10*g+b if n%4==0: print("Yes") else: print("No")