problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02607
s303388198
Accepted
n = int(input()) s = list(map(int,input().split())) a = 0 for i in range(n): if i%2 == 0 and s[i]%2 ==1: a+=1 print(a)
p02995
s632107664
Accepted
a, b, c, d = map(int, input().split()) big = max(c, d) small = min(c, d) lcm = 0 for i in range(1, 10 ** 8): surplus = big % small if surplus == 0: lcm = c * d // small break big = small small = surplus c_num = b // c - (a - 1) // c d_num = b // d - (a - 1) // d cd_num = b // lcm - (a - 1) // lcm num = b - a + 1 #print(num, c_num, d_num, cd_num, lcm) ans = num - (c_num + d_num - cd_num) print(ans)
p02948
s959116199
Accepted
import heapq n, m = map(int, input().split()) ab = [list(map(int, input().split())) for i in range(n)] ab.sort(key=lambda x:x[0]) counter = 0 content = 0 ans = 0 h = [] heapq.heapify(h) for i in range(m): while counter < n and ab[counter][0]==i+1: heapq.heappush(h,-ab[counter][1]) counter+=1 content+=1 if content != 0: ans-=heapq.heappop(h) content-=1 print(ans)
p02694
s914920003
Wrong Answer
import math K = int(input()) n_pre = math.log(K/100, 1.01) print(math.ceil(n_pre))
p03150
s170327422
Wrong Answer
s = list(input()) ans = list("keyence") x = 0 for c in s: if c == ans[x]: x += 1 if x == 7: print("YES") exit() print("NO")
p03645
s287700831
Accepted
n,m = [int(x) for x in input().split()] ab = [] for _ in range(m): tmp = [int(x) for x in input().split()] ab.append(tmp) start = [x[1] for x in ab if x[0] == 1] goal = [x[0] for x in ab if x[1] == n] ans = "IMPOSSIBLE" if len(set(start) & set(goal)) > 0: ans = "POSSIBLE" print(ans)
p03106
s349738633
Accepted
A,B,K=map(int,input().split()) ans=0 n=100 while True: if A%n==0 and B%n==0: ans+=1 if ans==K: print(n) exit() n-=1
p03665
s005973272
Wrong Answer
n, p = map(int, input().split()) a = [1 if i%2==0 else 0 for i in map(int,input().split())] sum_a = sum(a) if p==0: print(n*(n-1)//2-sum_a*(n-sum_a)+1) else: print(sum_a*(n-sum_a))
p03146
s094798368
Accepted
X = int(input()) list=[X] count=1 while count <= 1000000: if X%2 == 0: X=X/2 else: X=3*X+1 count+=1 if list.count(X) ==1: print(count) break list.append(X)
p02597
s730020733
Accepted
N = int(input()) c = list(input()) if 'R' in c and 'W' in c: R = int(c.count('R')) c[0:R] = [] print(c.count('R')) else: print(0)
p02838
s378851996
Accepted
n = int(input()) a = list(map(int, input().split())) cnt = [[0] * 2 for _ in range(61)] for i in range(61): mask = 1 << i for j in range(n): if mask & a[j] >= 1: cnt[i][1] += 1 elif mask & a[j] == 0: cnt[i][0] += 1 else: continue ans = 0 mod = 10**9 + 7 for i in range(61): ans += cnt[i][1] * cnt[i][0] * pow(2, i, mod) ans %= mod print(ans)
p02631
s999243572
Wrong Answer
N = int(input()) A_list = [int(e) for e in input().split()] all_A_xor = A_list[0] #print(A_list[0],bin(A_list[0])) for i in range(1,N): #print(A_list[i],bin(A_list[i])) all_A_xor ^= A_list[i] #print(all_A_xor,bin(all_A_xor)) ans = [A^all_A_xor for A in A_list] print(ans)
p03035
s735697181
Accepted
A, B=map(int, input().split()) if A<=5: print(0) elif 6<=A<=12: print(B//2) else: print(B)
p02642
s430286697
Wrong Answer
n=int(input()) a=[int(x) for x in input().split()] a.sort() p=[] q=0 for c in a: t=0 for d in p: if c%d==0: t=1 break if t==0: q+=1 p.append(c) print(q)
p03623
s263981934
Accepted
def main(): import sys #input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations #from itertools import accumulate, product from bisect import bisect_left,bisect_right from math import floor, ceil #from operator import itemgetter #mod = 1000000007 x,a,b = map(int, input().split()) if abs(x-a)>abs(x-b): print('B') else: print('A') if __name__ == '__main__': main()
p03474
s782213169
Accepted
a,b = map(int,input().split()) s = list(input()) t1 = s[:a] t2 = s[a] t3 = s[a+1:] t1 = ''.join(t1) t3 = ''.join(t3) def is_int(s): try: int(s) return True except ValueError: return False if is_int(t1) == True and is_int(t3) == True and t2 == '-': print('Yes') else: print('No')
p03487
s145181152
Wrong Answer
n = int(input()) a = list(map(int, input().split())) count = [0 for i in range(n+1)] tmp = 0 for i in a: if i > n: tmp+=1 else: count[i] += 1 ans = 0 for i in range(n+1): ans += min(abs(count[i] - i), count[i]) print(ans+tmp)
p03254
s285284499
Wrong Answer
N,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() count = 0 if x < a[0]: print(0) exit() for i in range(N): if x >= a[i]: x = x - a[i] count += 1 else: break if x > 0: print(count - 1) else: print(count)
p03434
s925054907
Wrong Answer
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) print(a) Alice=[] Bob=[] for i in range(n): if i%2==0: Alice.append(a[i]) else: Bob.append(a[i]) #print('Alice',Alice) #print('Bob',Bob) print((sum(Alice))-(sum(Bob)))
p03759
s760637965
Accepted
def main(): A, B, C = map(int, input().split()) if B - A == C - B: print('YES') else: print('NO') main()
p02603
s839709192
Accepted
n = int(input()) a = list(map(int,input().split())) cm = 1000 p1 = p2 = a[0] for i in range(1,n): #print(i,a[i],p1,p2) if(a[i]>=p2): p2 = a[i] elif(a[i]<p2): cm += (cm//p1)*(p2-p1) p1 = p2 = a[i] cm += (cm//p1)*(p2-p1) print(cm)
p02748
s561392634
Accepted
S = input().split() #冷蔵庫 A = int(S[0]) #電子レンジ B = int(S[1]) #割引券 M = int(S[2]) a = list(map(int,input().split())) b = list(map(int,input().split())) total_mini = min(a) + min(b) for i in range(M): m = list(map(int,input().split())) amount = a[m[0]-1] + b[m[1]-1] - m[2] if total_mini > amount: total_mini = amount print(total_mini)
p03779
s013395852
Wrong Answer
x = int(input()) f = True ans = 0 if x%2!=0: ans += 1 while f: ans+=1 a = x//2 if a < 1: f = False x = a print(ans)
p03076
s842857874
Accepted
d=[] for i in range(5): s=int(input()) if s%10 == 0: d.append((s,s,s%10)) else: d.append((s,s+(10-s%10),10-s%10)) d.sort(key=lambda d:d[2]) result=0 result=sum(d[i][1] for i in range(len(d)-1)) + d[-1][0] print(result)
p03778
s195234496
Accepted
W,a,b = map(int, input ().split ()) if a < b: A,B = W+a,b if A >= B: print (0) else: print (B-A) else: A,B = a,W+b if B >= A: print (0) else: print (A-B)
p03035
s281893836
Accepted
import os, sys, re, math (A, B) = [int(n) for n in input().split()] price = 0 if A <= 5 else B // 2 if A <= 12 else B print(price)
p02766
s543277833
Wrong Answer
s = input().split() N = int(s[0]) K = int(s[1]) i=1 while N > K **(i-1): if N < K**i: print(i) elif N == K**i: print(i+1) i += 1
p04045
s295374149
Accepted
nk = list(map(int, input().split())) N = nk[0] K = nk[1] d = input().split() a = True for i in range(N, 90001): a = True for j in d: if str(i).count(j) > 0: a = False break if a: print(i) break
p02684
s241015082
Wrong Answer
N, K = map(int, input().split()) A = [0] + list(map(int, input().split())) s = [0] * (N+1) p = 1 h = [] while True: h.append(p) s[p] = 1 p = A[p] if s[p] != 0: break last = h.index(p) leng = len(h) - last rem = (K - last) % leng print(h[last:][rem])
p03243
s676832942
Accepted
N=input() L=len(N) if int(N[0]*L)>=int(N): print(int(N[0]*L)) else: print(int((N[0])*L)+111)
p03838
s531900808
Accepted
def main(): x,y = map(int, input().split()) if y>=x: print(min(y-x,abs(y+x)+1)) else: print(min(abs(y+x)+1,abs(y-x)+2)) if __name__ == '__main__': main()
p02911
s435249127
Accepted
n,k,q=map(int,input().split()) ans=[k-q]*n h=[] for i in range(q): h.append(int(input())) for j in h: ans[j-1]+=1 for k in ans: if k>=1: print('Yes') else: print('No')
p02556
s754487299
Accepted
import numpy as np N = int(input()) xy = [list(map(int, input().split())) for _ in range(N)] xy45 = [[xy[i][0] - xy[i][1], xy[i][0] + xy[i][1]] for i in range(N)] xy45 = np.array(xy45) print(max(max(xy45[:, 0]) - min(xy45[:, 0]), max(xy45[:, 1]) - min(xy45[:, 1])))
p02756
s911463838
Accepted
s = list(input()) q = int(input()) a = [] f = False #さかさま for i in range(q): x = list(input().split()) if x[0]=='1': f = not f else: if f: if x[1]=='1': s.append(x[2]) else: a.append(x[2]) else: if x[1]=='1': a.append(x[2]) else: s.append(x[2]) a.reverse() s = a+s if f:s.reverse() print(''.join(s))
p02833
s819911826
Accepted
import math N = int(input()) if N % 2 == 1: print(0) else: div10 = N // 10 sum_val = div10 if sum_val > 0: count_5 = math.floor(math.log(div10, 5)) for i in range(count_5): sum_val += div10 // pow(5, i + 1) print(sum_val)
p03030
s096355431
Wrong Answer
n = int(input()) res = [] for i in range(n): city, value = input().split() value = int(value) res.append([city, value, i]) res_s = sorted(res, key = lambda x: (x[0], x[1])) for i in range(n): res_s[i].append(i) ans = sorted(res_s, key = lambda x: x[2]) for i in range(n): print(ans[i][3])
p03592
s386099621
Accepted
n,m,k= map(int, input().split()) for i in range(n+1): for j in range(m+1): x=i*m+j*n-2*(i*j) if k==x: print('Yes') exit() print('No')
p02796
s157891441
Accepted
import sys import heapq input = sys.stdin.readline n = int(input()) query = [] for i in range(n): x, l = map(int, input().split()) query.append([x+l, x-l]) # 貪欲 heapq.heapify(query) finish, start = heapq.heappop(query) time = finish count = 1 while len(query) > 0: finish, start = heapq.heappop(query) if start >= time: time = finish count += 1 else: continue print(count)
p03077
s888401175
Accepted
N=int(input()) A=list(int(input()) for _ in range(5)) mini=min(A) print(int((N-1)/mini)+5)
p03417
s978355857
Accepted
N, M = map(int, input().split()) min_NM = min(N,M) max_NM = max(N,M) if min_NM == 1 and max_NM == 1: print(1) elif min_NM == 1: print(max_NM-2) else: if min_NM == 2: print(0) else: ans = (N-2)*(M-2) print(ans)
p04019
s131984469
Wrong Answer
S = input() if 'N' in S: if not 'S' in S: print('No') exit() if 'S' in S: if not 'N' in S: print('No') exit() if 'E' in S: if not 'W' in S: print('No') exit() if 'W' in S: if not 'E' in S: print('No') exit() print('YES')
p02731
s050005766
Wrong Answer
l = int(input()) def f(x,y): z = l-x-y if z<1 or z>l: print(x,y,z) return -1 return x*y*z def fp(x,y): dx = y*(l-x-y) - x*y dy = x*(l-x-y) - x*y return dx,dy x = 1.0 y = 1.0 while True: dx,dy = fp(x,y) if dx<10**-8 and dy<10**-8: print(f(x,y)) exit() x += dx * 10**-4 y += dy * 10**-4
p03317
s496896776
Wrong Answer
import math n, k = map(int, input().split()) aa = tuple(map(int, input().split())) p = 0 for i in range(n): if aa[i] == 1: p = i break x = 0 k -= 1 x += math.ceil(p / k) x += math.ceil((n - p - 1) / k) print(x)
p03038
s138013137
Wrong Answer
N,M = map(int,input().split()) A = list(map(int,input().split())) BC = [(A[i], 1) for i in range(N)] for _ in range(M): B, C = map(int, input().split()) BC.append((C,B)) BC = sorted(BC,reverse = True) ans = 0 a = 0 count = N for c,b in BC: print(b,c) lamb = min(count,b) ans += c * lamb count -= lamb print(ans)
p02989
s325213023
Accepted
n = int(input()) ls = list(map(int,input().split())) ls.sort() a = ls[n // 2] - ls[(n // 2) - 1] print(a)
p03721
s135842635
Accepted
N,M = map(int,input().split()) dic = {} for _ in range(N): a, b = map(int,input().split()) if a in dic: dic[a] += b else: dic[a] = b List = sorted(dic) ans = 0 i = 0 while M > 0: M -= dic[List[i]] ans = List[i] i += 1 print(ans)
p02767
s158892425
Accepted
# coding:utf-8 N = int(input()) X = [el for el in map(int, input().split(' '))] ans = 2 ** 63 - 1 for point in range(100): tmp = 0 for x in X: tmp += (x - point) ** 2 if ans > tmp: ans = tmp print(ans)
p03971
s970892410
Wrong Answer
p = 0 n, a, b = map(int, input().split()) for i in input(): if i == "a" and p > a+b: p += 1 print("Yes") elif i == "b" and p > a+b and f > a+b: f += 1 print("Yes") else: print("No")
p03208
s173509645
Wrong Answer
n, k = map(int,input().split()) h =[int(input()) for i in range(n)] h.sort() ans = 100000000 for i in range(len(h)-k+1): if h[i+k-1] - h[i] < ans: ans = h[i+k-1] - h[i] if ans == 0: break print(ans)
p02717
s830881515
Wrong Answer
A = 1 B = 2 C = 3 A,B,C, = B,C,A print(A,B,C)
p02789
s612207537
Accepted
N, M = map(int, input().split()) if M >= N: print("Yes") else: print("No")
p03951
s208924333
Wrong Answer
N=int(input()) s=input() t=input() overlap1=0 for i in range(N): if s[i]==t[N-i-1]: overlap1+=1 else: break overlap2=0 for i in range(N): if t[i]==s[N-i-1]: overlap2+=1 else: break print(N if s==t else 2*N-max(overlap1,overlap2))
p02720
s557761311
Accepted
def d_lunlun_number(): from collections import deque K = int(input()) queue = deque(range(1, 10)) ans = -1 for _ in range(K): ans = queue.popleft() lsd = ans % 10 # least significant digit if lsd != 0: queue.append(10 * ans + (lsd - 1)) queue.append(10 * ans + lsd) if ans % 10 != 9: queue.append(10 * ans + (lsd + 1)) return ans print(d_lunlun_number())
p02630
s779090442
Accepted
n = int(input()) a = [int(i) for i in input().split()] q = int(input()) ans = sum(a) numbers = [0]*(10**5+1) for v in a: numbers[v] += 1 for _ in range(q): b,c = [int(i) for i in input().split()] nb = numbers[b] ans += (c-b)*nb print(ans) numbers[b] = 0 numbers[c] += nb
p02665
s703085159
Accepted
n = int(input()) a = list(map(int, input().split())) sita_maxi = [0 for i in range(n+1)] sita_maxi[n] = a[n] for i in range(n-1, -1, -1): sita_maxi[i] = sita_maxi[i+1] + a[i] if a[0] > 1: print(-1) exit() lst = [1] for i in range(1, n+1): lst.append(min((lst[i-1]-a[i-1])*2, sita_maxi[i])) if lst[-1] < a[i]: print(-1) exit() print(sum(lst))
p02818
s382246370
Accepted
# coding: utf-8 # Your code here! A,B,K=map(int,input().split()) if A<=K: K-=A A=0 if B<=K: print(0, end=' ') print(0) else: B-=K print(A,end=' ') print(B) else: A-=K print(A,end=' ') print(B)
p03163
s569960541
Accepted
N, W = map(int, input().split()) goods = [list(map(int, input().split())) for _ in range(N)] dp = [[0 for _ in range(W+1)] for _ in range(N+1)] for i in range(N): for w in range(W+1): if w-goods[i][0] >= 0: dp[i+1][w] = max(dp[i+1][w], dp[i][w-goods[i][0]] + goods[i][1]) dp[i+1][w] = max(dp[i+1][w], dp[i][w]) print(dp[-1][-1])
p03761
s670964591
Accepted
import numpy as np n = int(input()) l = [[0] * (ord('z') - ord('a') + 1) for _ in range(n)] for i in range(n): S = input() for s in S: idx = ord(s) - ord('a') l[i][idx] += 1 l = np.array(l) l = np.rot90(l, -1) ans = '' for j in range(len(l)): num = min(l[j]) ans += chr(ord('a') + j) * num print(ans)
p02835
s509936499
Wrong Answer
# -*- coding:utf-8 -*- s = input() count = 0 for i in range(len(s)): a = s[i] b = s[::-1][i] if a != b: count += 1 print(int(count/2))
p03795
s023330481
Wrong Answer
N = int(input()) x = N * 800 y = (x // 15) * 200 print(x - y)
p02684
s399832802
Accepted
n,k=map(int,input().split()) loop_=[1] l_set=set() lst=list(map(int,input().split())) tar=None for i in range(k): num=lst[loop_[-1]-1] if num in l_set: tar=num break else: loop_.append(num) l_set.add(num) if tar==None: print(loop_[k]) exit() loop__=loop_[loop_.index(tar):] num=k+1-len(loop_) try: print(loop__[num%len(loop__)-1]) except: print(1)
p03284
s423644441
Accepted
a,b=map(int,input().split()) print("10"[a%b==0])
p03103
s208571511
Wrong Answer
N, M = map(int,input().split()) AB = {} for i in range(N): A, B = map(int,input().split()) AB[A]=B AB = sorted(AB.items(),key = lambda x:x[0]) cost = 0 for a,b in AB: cost += (min(max(M,0),b))*a M-=b if M<=0: break print(cost)
p02777
s523990133
Accepted
S, T = input().split() A, B = map(int, input().split()) U = input() if S == U: print(A - 1, B) else: print(A, B - 1)
p02720
s275517303
Wrong Answer
n = int(input()) if n <= 9: print(n) n -= 9 t = n % 3 cnt = 0 while True: n //= 3 cnt += 1 if n < 3: break if t == 0: print(n*10 + n+1) else: print((n+1)*10 + (n+1)-(2-t))
p02723
s291423022
Accepted
s=input() if s[2]==s[3] and s[4]==s[5]: print("Yes") else: print("No")
p03281
s488123055
Accepted
def divisor(n): i = 1 table = [] while i * i <= n: if n % i == 0: table.append(i) table.append(n//i) i += 1 table = list(set(table)) return table def main(): n = int(input()) ans = 0 for i in range(1, n+1): if i % 2 != 0 and len(divisor(i)) == 8: ans += 1 print(ans) if __name__ == "__main__": main()
p03723
s636250679
Wrong Answer
#!/usr/bin/env python a, b, c = map(int, input().split()) if a == b == c: print(-1) exit() ans = 0 while True: ta = a tb = b tc = c a = (tb+tc)//2 b = (tc+ta)//2 c = (ta+tb)//2 ans += 1 if a%2 == 1 or b%2 == 1 or c%2 == 1: print(ans) exit()
p04045
s959252319
Wrong Answer
a = input('') b = input('') num = b.split(' ') price = int(a.split(' ')[0]) f = False for i in range(price, 10000): for j in range(len(str(i))): if str(i)[j] in num: break else: break print(i)
p02819
s800044508
Accepted
x = int(input()) while True: flg = True for i in range(2,x): if x % i == 0: flg = False break if flg == True: break x += 1 print(x)
p02861
s911839909
Wrong Answer
import itertools N=int(input()) XY=[] for i in range(N): x,y=map(int,input().split()) XY+=[[x,y]] ALL=list(itertools.permutations(XY)) print(ALL) ans=10**9 d=0 for i in ALL: for k in range(N-1): d2=((i[k][0]-i[k+1][0])**2+(i[k][1]-i[k+1][1])**2)**(1/2) d+=d2 ans=d/len(ALL) print(ans)
p03329
s501626062
Accepted
import numpy as np N=int(input()) six=[1] nine=[] for i in range(1,N): six.append(6**i) nine.append(9**i) if 6**i>N: break six=np.array(six) nine=np.array(nine) L=np.concatenate([six,nine]) now=N count=0 dp=np.ones(N+L.max()+1)*10**9 dp[1]=1 dp[0]=0 #dp[i+1] iをちょうど引き出すのに必要な最小回数 for i in range(1,N): dp[i+1]=(dp[i-L+1]+1).min() print(int(dp[N])) #print(len(L))
p02772
s282431306
Accepted
import sys n = int(input()) a = [num for num in map(int, input().split())] # print(n) # print(a) for item in a: if item % 2 == 1: continue if item % 3 == 0 or item % 5 == 0: continue print('DENIED') sys.exit() print('APPROVED')
p03254
s473092179
Wrong Answer
n,m=map(int,input().split()) a=list(map(int,input().split())) a.sort() s=0 while s<n-1: if m>=a[s]: m-=a[s] s+=1 else:break print(s)
p03761
s261333313
Accepted
# coding: utf-8 N = int(input()) d = {} alp = "abcdefghijklmnopqrstuvwxyz" cnt = {} for s in alp: cnt[s] = 0 for i in range(N): d[i] = {} s = input() for j in range(len(alp)): d[i][alp[j]] = 0 for j in range(len(s)): d[i][s[j]] += 1 for s in alp: l = [] for k in d.keys(): l.append(d[k][s]) cnt[s] = min(l) ans = "" # print(cnt) for a in alp: ans += a * cnt[a] print(ans)
p02801
s104537211
Wrong Answer
a = input() alpha = ["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"] for i in alpha: if a == alpha: print(alpha[i+1]) break
p03659
s191478830
Wrong Answer
n = int(input()) a = sorted(list(map(int, input().split()))) r = sum(a) l = 0 sub = 10 ** 19 + 101 for i in range(n): r -= a[i] l += a[i] # print(l, r,sub) if n == 2: print(abs(r - l)) exit() elif abs(r - l) > sub: print(tmp) exit() else: sub = min(sub, abs(r - l)) tmp = abs(r - l)
p02766
s731799780
Accepted
n,k=map(int,input().split()) cnt=0 while n: cnt+=1 n//=k print(cnt)
p02780
s651661397
Wrong Answer
N,K=input().split() n,k=int(N),int(K) p=list(input().split()) for i in range (len(p)): p[i]=int(p[i]) pre=[0 for i in range (n+1)] q=[0 for i in range (n-k+100)] pre[0]=p[0] for i in range(n): pre[i+1]=pre[i]+p[i] for i in range(1,n-k+1): q[i]=pre[i+k]-pre[i] ans=max(q) print ((ans + k) / 2)
p03380
s687448425
Accepted
N = int(input()) A = sorted(list(map(int, input().split()))) import math n = A.pop() P_dif_A = sorted([[abs(a-n/2), a] for a in A]) r = P_dif_A[0][1] print(n, r)
p02712
s692573828
Wrong Answer
N = int(input()) ans = 0 for i in range(N): if i % 15 == 0: pass elif i % 3 == 0: pass elif i % 5 == 0: pass else: ans += i print(ans)
p03804
s022600165
Accepted
n,m = map(int, input().split()) As = [list(input()) for i in range(n)] Bs = [list(input()) for i in range(m)] for i in range(n-m+1): for j in range(n-m+1): cut = [] for k in range(m): cut.append(As[j+k][i:i+m]) # print(i,j,cut) if cut == Bs: print("Yes") exit() print("No")
p02633
s030856204
Accepted
X = int(input()) def gcd(a, b): if a == 0: return b else: return gcd(b%a, a) print(360*X//gcd(X, 360)//X)
p02660
s422786683
Accepted
n=int(input()) s=[] for i in range(2,int(n**0.5)+1): if n%i==0: p=0 while(n%i==0): p+=1 n//=i s.append(p) if n>1: s.append(1) #1print(s) ans=0 for i in s: r=1 while(i>0): if i<r: break i-=r r+=1 ans+=1 print(ans)
p02744
s806606269
Accepted
N=int(input()) global key key="abcdefghij" def normal(N): if N==1: return ["a"] else: new=[] lis=normal(N-1) for s in lis: i=0 while key[i] in s: new.append(s+key[i]) i+=1 new.append(s+key[i]) return new lis=normal(N) for s in lis: print(s)
p02678
s561869867
Accepted
from collections import deque n,m = map(int,input().split()) adj = [[] for _ in range(n)] for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 adj[a].append(b) adj[b].append(a) que = deque() dist = [-1]*n ans = [0]*n que.append(0) while len(que) != 0: now = que.popleft() for to in adj[now]: if dist[to] != -1: continue dist[to] = dist[now]+1 que.append(to) ans[to]=now print("Yes") for i in range(1,n): print(ans[i]+1)
p03127
s230195363
Wrong Answer
# C - Monsters Battle Royale N = int(input()) A = list(int(x) for x in input().split()) A.sort() ans = A[0] for i in range(1, N): tmp = A[i]%ans if tmp != 0: ans = tmp else: continue print(ans)
p03720
s182786517
Wrong Answer
N, M = map(int, input().split()) a = [] b = [] for i in range(M): a1 , b1 = [int(i) for i in input().split()] a.append(a1) b.append(b1) nm = a+b ans = [0 for i in range(N)] for j in range(0,(len(nm))): i = nm[j] ans[i-1] += 1 print(ans)
p03785
s569095413
Accepted
n,c,k=map(int,input().split()) t=[0 for i in range(n)] for i in range(n): t[i]=int(input()) t.sort() ans=0 cnt=1 bef=t[0] for i in range(1,n): if cnt==c: ans+=1 cnt=1 bef=t[i] elif bef+k>=t[i] and cnt<c: cnt+=1 else: ans+=1 cnt=1 bef=t[i] if i==n-1: ans+=1 print(ans)
p04005
s807238236
Accepted
A,B,C = map(int,input().split()) if A*B*C % 2 == 0: print(0) else: print(min(min(A*B,B*C),C*A))
p02957
s823987163
Accepted
a, b = map(int, input().split()) if abs(a+b)%2 == 0: print(abs(a+b)//2) else: print('IMPOSSIBLE')
p02767
s059324933
Wrong Answer
n = int(input()) address = list(map(int, input().split())) sort_address = sorted(address) sum = 0 sum_min = 100000 for i in range(sort_address[0], sort_address[-1] + 1): for j in sort_address: sum += (i - j)**2 if sum < sum_min: sum_min = sum sum = 0 print(sum_min)
p03131
s391547384
Accepted
#temprate from sys import setrecursionlimit setrecursionlimit(10**6) from collections import Counter def inputlist(): return [int(j) for j in input().split()] #temprate K,A,B = inputlist() if A >= B: print(K + 1) exit() tmp = K - (A - 1) if tmp < 0: print(K + 1) exit() cnt = tmp // 2 amari = tmp % 2 ans = cnt * B - (cnt - 1) * A + amari ans = max(ans, K + 1) print(ans)
p03331
s349859109
Accepted
ans=float("INF") n=int(input()) s=0 for i in range(1,n//2+1): ans=min(sum(list(map(int,list(str(i)))))+sum(list(map(int,list(str(n-i))))),ans) print(ans)
p03565
s836442751
Wrong Answer
import numpy as np S = input() T = input() m = len(S) n = len(T) for i in range(m-n, -1, -1): if np.prod([s in [t, '?'] for s, t in zip(S[i:i+m], T)]): ans = S[:i] + T + S[i+m-1:] ans = ans.replace('?', 'a') break else: ans = 'UNRESTORABLE' print(ans)
p03264
s058781058
Accepted
k = int(input()) n = k // 2 if k % 2 == 0: print(n**2) else: print(n * (n + 1))
p02993
s130001219
Accepted
S = input() for i in range(3): if S[i] == S[i + 1]: print('Bad') quit() print('Good')
p03943
s008717353
Accepted
a, b, c = map(int,input().split()) l = [a,b,c] l.sort() if l[0] + l[1] == l[2]: print("Yes") else: print("No")
p02973
s286516242
Wrong Answer
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) As = [-int(input()) for _ in range(N)] from bisect import bisect_left lis = [1] for a in As: if a>=lis[-1]: lis.append(a) else: lis[bisect_left(lis, a)-1] = a print(len(lis))
p02712
s087759572
Wrong Answer
def main(): N = int(input()) res = 0 for i in range(N): if i % 3 != 0 and i % 5 != 0: res += i print(res) if __name__ == "__main__": main()