problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03331
s205097065
Wrong Answer
n=int(input()) ans=10e5 for a in range(2,n//2+1): b=n-a ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)])) print(int(ans))
p03012
s036127431
Accepted
N = int(input()) W = list(map(int, input().split())) count = abs(sum(W[:1]) - sum(W[1:])) for T in range(2, N): if count > abs(sum(W[:T]) - sum(W[T:])): count = abs(sum(W[:T]) - sum(W[T:])) print(count)
p02659
s496863956
Wrong Answer
a,b = map(float, input().split()) c = b.as_integer_ratio() d = int(c[0]) e = int(c[1]) print(int(a*d/e))
p02727
s196622760
Accepted
import heapq x,y,a,b,c = map(int,input().split()) p_list = list(map(int,input().split())) q_list = list(map(int,input().split())) r_list = list(map(int,input().split())) p_target = heapq.nlargest(x, p_list) q_target = heapq.nlargest(y, q_list) r_target = heapq.nlargest(c, r_list) p_target.extend(q_target) p_target.extend(r_target) p_target.sort(reverse=True) print(sum(p_target[:x+y]))
p03495
s485926800
Accepted
import collections n,k = map(int,input().split()) a = list(map(int,input().split())) c = sorted(list(collections.Counter(a).values())) print(sum(c[:-k]))
p02665
s080178925
Wrong Answer
from itertools import accumulate N,*A=map(int, open(0).read().split()) if N==0: print(1) exit() if A[0]!=0: print(-1) exit() R=[0]*(N+1) R[0]=1 ans=0 for i in range(N): R[i]-=A[i] if R[i]<0: print(-1) exit() R[i+1]=min(R[i]*2,10**10) B=list(accumulate(A[::-1]))[::-1] ans+=sum(min(R[i]+A[i],B[i])for i in range(N+1)) print(ans)
p03759
s129730846
Accepted
A, B, C = list(map(int,input().split())) if B-A == C-B: print('YES') else: print('NO')
p03106
s884803224
Accepted
A,B,K=[int(x) for x in input().split(' ')] lis=[] blis=[] count=0 sm=min([A,B]) bm=max([A,B]) for i in range(1,sm+1): if sm/i == sm//i: lis.append(i) for i in lis: if bm/i == bm//i: blis.append(i) blis=list(set(blis)) blis.sort() blis.reverse() print(blis[K-1]) #8 12 2
p03693
s610849035
Accepted
a,b,c = map(int,input().split()) temp = b*10+c if temp%4 == 0: print("YES") else: print("NO")
p04019
s630267090
Accepted
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): s = input() ok = [{"N", "S"}, {"E", "W"}, {"N", "S", "E", "W"}] if set(s) in ok: print("Yes") else: print("No") if __name__ == '__main__': main()
p03835
s146574425
Wrong Answer
k, s = map(int, input().split()) ans = 0 for x in range(k+1)[::-1]: y = min(s-x, k) z = s-x-y if z > k: break ans += y - z + 1 print(ans)
p02743
s997453075
Accepted
import sys from math import ceil, floor, sqrt from collections import deque, Counter, defaultdict from fractions import gcd from decimal import Decimal input = lambda: sys.stdin.readline().rstrip() def eprint(s): sys.stderr.write('DEBUG: {}'.format(s)) return def main(): a,b,c = map(int, input().split()) if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt(): print('Yes') else: print('No') return if __name__ == '__main__': main()
p02571
s034456481
Accepted
S = list(input()) T = list(input()) out=[] for i in range(len(S)-len(T)+1): cnt=0 for j in range(len(T)): if S[i+j] != T[j]: cnt+=1 out.append(cnt) print(min(out))
p02935
s789465920
Accepted
n=int(input()) v=list(map(int,input().split())) v.sort() ans=v[0] for i in v: ans=(ans+i)/2 print(ans)
p02957
s012864500
Accepted
a,b=map(int,input().split()) print((a+b)//2 if (a+b)%2 == 0 else "IMPOSSIBLE")
p02972
s828888928
Accepted
import sys input = sys.stdin.readline N = int(input()) a = list(map(int,input().split())) #box = [0]*(N+1) for i in range(N,0,-1): k=2 temp=a[i-1] #print(123,i,ball) while i*k<=N: if a[i*k-1]==1: temp = (temp+1)%2 k+=1 a[i-1] = temp #print(box) M=0 b=[] for i in range(1,N+1): if a[i-1]==1: M+=1 b.append(i) print(M) [print(x) for x in b]
p03448
s806465205
Accepted
a = int(input()) b = int(input()) c = int(input()) x = int(input()) ans = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): total = i * 500 + 100 * j + 50 * k if total == x: ans += 1 print(ans)
p03627
s071083573
Accepted
n = int(input()) a = list(map(int,input().split())) cnt = {} for x in a: if x not in cnt:cnt[x] = 1 else:cnt[x] +=1 res = [] for key in cnt: v = cnt[key] if v>=2: res.append(key) if v >=4:res.append(key) res.sort(reverse = True) if len(res) < 2:ans=0 else: ans = res[0]*res[1] print(ans)
p02900
s576803226
Accepted
def prime_factorize(n): a = [1] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a A, B = map(int, input().split()) cds = set(prime_factorize(A)) & set(prime_factorize(B)) print(len(cds))
p02994
s311941705
Accepted
n,l=map(int,input().split()) num=1+l-1 number=[] for _ in range(n): number.append(num) num+=1 if 0 in number: print(sum(number)) else: if all(i<0 for i in number): print(sum(number)-max(number)) else: print(sum(number)-min(number))
p02879
s362743124
Accepted
A,B = map(int,input().split()) if A <= 9 and B <= 9: print(A*B) else: print(-1)
p02760
s449720738
Accepted
A = [] for _ in range(3): A.append(list(map(int, input().split()))) B = [] while True: try: B.append(int(input())) except: break; for i in range(3): if (A[0][i] in B and A[1][i] in B and A[2][i] in B) or (A[i][0] in B and A[i][1] in B and A[i][2] in B): print("Yes") import sys; sys.exit() if (A[0][0] in B and A[1][1] in B and A[2][2] in B) or (A[0][2] in B and A[1][1] in B and A[2][0] in B): print("Yes") import sys; sys.exit() print("No")
p02688
s643968215
Accepted
N, K = [int(x) for x in input().split()] snuke_list = [] for i in range(K): d = int(input()) snuke_list.extend([int(x) for x in input().split()]) print(N - len(set(snuke_list)))
p03548
s896373659
Wrong Answer
x, y, z = map(int, input().split()) ans = 0 for i in range(z, 10**5): if (x-i) % (y+i) == 0: ans = (x-i) // (y+i) break print(int(ans))
p03623
s982338150
Accepted
x,a,b=map(int,input().split()) print(['A','B'][abs(x-a)>abs(x-b)])
p02630
s023039085
Wrong Answer
import numpy as np n = int(input()) A = list(map(int,input().split())) q = int(input()) BC = [list(map(int,input().split())) for _ in range(q)] A = np.array(A) def main(A,BC): for bc in BC: A = np.where(A==bc[0],bc[1],A) print(max(A)) if __name__ == '__main__': main(A,BC)
p04044
s889595389
Accepted
#B n,l=map(int,input().split()) s=[] for i in range(n): s.append(input()) s.sort() for i in s: print(i,end="")
p03612
s178731794
Accepted
N = int(input()) P = list(map(lambda a: int(a) - 1, input().split())) ans = 0 for i in range(N): p = P[i] if p == i: if i < N - 1: P[i], P[i + 1] = P[i + 1], P[i] ans += 1 print(ans)
p02595
s134454640
Wrong Answer
import math count=0 n, d =map(int,input().split()) for i in range(n): x, y = map(int,input().split()) ans = math.sqrt(x**2 + y**2) if ans>=d: count+=1 print(count)
p03719
s264290562
Wrong Answer
A,B,C = map(int, input().split()) if C > A and C < B: print('Yes') else: print('No')
p03997
s272305046
Accepted
A = int(input()) B = int(input()) C = int(input()) print(int((A+B)*C/2))
p03836
s781480581
Wrong Answer
sx, sy, tx, ty = map(int, input().split()) x = tx - sx y = ty - sy ans = '' if x >= 0: ans += 'R'*x else: ans += 'L'*-x if y >= 0: ans += 'U'*y else: ans += 'D'*-y if x >= 0: ans += 'L'*x else: ans += 'R'*-x if y >= 0: ans += 'D'*y else: ans += 'U'*-y cycle = ans ans += 'UR' ans += cycle ans += 'DL' print(ans)
p02615
s192047048
Wrong Answer
n = int(input().strip()) a = [int(x) for x in input().strip().split(' ')] a = sorted(a, reverse=True) sum = a[0] for i in range(0,n-2): sum += min(a[i],a[i+1]) print(sum)
p02701
s144553255
Wrong Answer
N = int(input()) S = [] for i in range(N): S.append(input()) print(len(S))
p03438
s109450486
Accepted
N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) diff = [a[i] - b[i] for i in range(N)] plus = sum(filter(lambda x: x > 0, diff)) minus_even = sum(filter(lambda x: x < 0 and x % 2 == 0, diff)) minus_odd = sum(x + 1 for x in diff if x < 0 and x % 2 == 1) # print(plus) if plus * 2 + minus_even + minus_odd > 0: print('No') else: print('Yes')
p03250
s488308204
Accepted
class Solution: def solve(self, A: int, B: int, C: int) -> str: s = sorted([A, B, C]) return s[0] + s[1] + 10*s[2] if __name__ == '__main__': # standard input A, B, C = map(int, input().split()) # solve solution = Solution() print(solution.solve(A, B, C))
p02933
s182869810
Accepted
INT = lambda: int(input()) INTM = lambda: map(int,input().split()) STRM = lambda: map(str,input().split()) STR = lambda: str(input()) LIST = lambda: list(map(int,input().split())) LISTS = lambda: list(map(str,input().split())) def do(): a=INT() s=STR() if a<3200: print('red') else: print(s) if __name__ == '__main__': do()
p02697
s529801022
Wrong Answer
n, m = map(int, input().split()) if n % 2: n -= 1 for i in range(m): print(i+1, n-i) else: for i in range(m): if i == m-1: print(i+1, n-i-1) else: print(i+1, n-i)
p03150
s436653660
Accepted
s = input() n = len(s) k = 'keyence' for i in range(7): if s[i] != k[i]: break else: i += 1 tmp = i for i in range(7): if s[n - i - 1] != k[6 - i]: break else: i += 1 if i + tmp >= 7: print('YES') else: print('NO')
p02754
s482908981
Accepted
N, num_of_blue, num_of_red = map(int, input().split()) num_of_repetition = (N // (num_of_blue + num_of_red)) remainder_s = N % (num_of_blue + num_of_red) count_b = num_of_blue * num_of_repetition + min(num_of_blue, remainder_s) print(count_b)
p03086
s704815452
Wrong Answer
S = input() ans = 0 cnt = 0 for i in S: if i in ("A","C","G","T"): cnt += 1 else: ans = max(ans,cnt) cnt = 0 print(ans)
p02546
s669693614
Wrong Answer
x=input() print(x+'s' if x[len(x)-1]!='s' else x[0:len(x)-1]+"es")
p03264
s182249613
Wrong Answer
K = int(input()) if K%2 ==0: print(int(K/2+1)) elif K%2 !=0: print(int((K+1)/2))
p02786
s080185566
Accepted
import math h = int(input()) n = int(math.log2(h)) a = 2 r = 2 S = (a*(r**n)-a) // (r-1) print(S + 1)
p02595
s969131324
Wrong Answer
N, D = map(int, input().split()) A = 0 for point in range(N): p, q = map(int, input().split()) dis = q**2 + q**2 if(dis <= D**2): A += 1 print (A)
p02993
s688790703
Wrong Answer
n = str(input()) print('Good' if len(set(n))==4 else 'Bad')
p03827
s418235982
Accepted
n=int(input()) s=input() ans=0 tmp=0 for i in range(n): if s[i]=="I": tmp+=1 ans=max(ans,tmp) else: tmp-=1 print(ans)
p03862
s879433213
Accepted
def main(): n, x, *a = map(int, open(0).read().split()) a = [0] + a ans = 0 tmp = 0 for i, j in zip(a, a[1:]): i -= tmp if (i + j - x) > 0: c = (i + j - x) ans += c tmp = c else: tmp = 0 print(ans) if __name__ == '__main__': main()
p02660
s095970193
Accepted
def f(exponent): #reurns how many times a prime raised to exponent can be used lo,hi = 1, exponent + 1 while(lo < hi): med = (lo + hi)/2 if med * (med + 1)/2 > exponent: hi = med else: lo = med +1 return lo -1 def answer(n): if n == 1: return 0 res = 0 for d in range(2, int(n ** 0.5) + 2): if n % d == 0: e = 0 while(n%d == 0): e +=1 n/=d res+= f(e) if n > 1: res += 1 return res print answer(int(raw_input()))
p03493
s887727173
Wrong Answer
s = input() print('1'.count(s))
p02783
s726116691
Wrong Answer
H, A = map(int, input().split()) print(H // A + 1)
p02688
s957954146
Wrong Answer
def main(): s = list(map(int,input().split())) n = [0]*s[0] for k in range(1,s[1],1): d = int(input()) a = list(map(int,input().split())) #print(a) for i in range(0,d,1): #print(a[i]) n[a[i]-1] = 1 #print(n) sum=0 #print(n) for k in range(0,s[0],1): if(n[k]==0): sum = sum+1 print(sum) main()
p02866
s098169023
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) Ds = list(mapint()) mod = 998244353 from collections import Counter c = Counter(Ds) if Ds[0]!=0: print(0) elif c[0]>1: print(0) else: ans = 1 for i in range(1, N): ans *= pow(c[i-1], c[i], mod) ans %= mod print(ans)
p02744
s111896345
Accepted
n = int(input()) def calc(x_list): tmp = [] for x in x_list: m = max(x) for alpha in range(ord('a'), ord(m) + 2): tmp.append(x + chr(alpha)) if len(tmp[-1]) < n: tmp = calc(tmp) return tmp ans = calc(['a']) ans.sort() if n >= 2: print(*ans, sep="\n") else: print('a')
p03778
s584286104
Wrong Answer
w,a,b = map(int,input().split()) if b < a: print(a-b) elif a <= b <= a+w: print("0") elif a+w < b: print(b - (a+w))
p02684
s657822602
Accepted
from collections import defaultdict N, K = map(int, input().split()) A = [int(x) - 1 for x in input().split()] cur = 0 step = 0 d = defaultdict(int) d[0] = step li = [] while True: cur = A[cur] li.append(cur) if d[cur] != 0: break step += 1 d[cur] = step pre = li[:d[cur]] loop = li[d[cur]:] if K <= len(pre): print(pre[K - 1] + 1) else: K -= len(pre) + 1 print(loop[K % (len(loop))] + 1)
p03469
s045583128
Wrong Answer
ds=str(input()) ds=ds.replace("2017","2018")
p02843
s389637902
Accepted
x = int(input()) x_ = divmod(x, 100) if 5*x_[0] >= x_[1]: print(1) else: print(0)
p02813
s600134847
Accepted
import itertools import math n = int(input()) p = list(map(int, input().split())) q = list(map(int, input().split())) lst = [] for i in range(1, n+1): lst.append(i) a = list(itertools.permutations(lst)) p_c = a.index(tuple(p)) q_c = a.index(tuple(q)) print(int(math.fabs(q_c-p_c)))
p03127
s266191978
Accepted
from fractions import gcd n = int(input()) a_list = [int(x) for x in input().split()] ans = a_list[0] for i in range(1, n): ans = gcd(ans, a_list[i]) print(ans)
p03043
s063769769
Wrong Answer
N, K = map(int,input().split()) ans = 0 if N >= K: ans += (N - K + 1) / N L = K-1 else: L = N for i in range(1,L+1,1): ans_i = 0 score = i c = 0 while score <= K: score = score * 2 c += 1 rate = (1 / N)*((1/2)** c) ans += rate #print(ans) print(ans)
p02606
s008125185
Accepted
L,R,d = map(int,input().split()) ans=0 for i in range(L,R+1): if (i%d == 0): ans+=1 print(ans)
p03274
s987899827
Accepted
n,k = map(int,input().split()) num_list = list(map(int,input().split())) ans = 10e12 for i in range(n-k+1): left = num_list[i] right = num_list[i+k-1] if (right <= 0) and (left <= 0): tmp = abs(left) elif (right >= 0) and (left <= 0): tmp = min(abs(right) , abs(left)) + abs(right) + abs(left) elif (right >= 0) and (left >= 0): tmp = abs(right) if tmp < ans: ans = tmp print(ans)
p02784
s376484853
Accepted
#!/usr/bin/env python3 n, m, *a = map(int, open(0).read().split()) if sum(a) >= n: print('Yes') else: print('No')
p02606
s007603994
Wrong Answer
l,r,d = map(int,input().split()) mod = l % d cnt = 0 for i in range(mod+l,r+1,d): cnt += 1 print(cnt)
p03639
s654771688
Accepted
n = int(input()) a = list(map(int,input().split())) nums = {0:0,1:0,2:0,3:0} for i in range(n): num = a[i] % 4 nums[num] += 1 if nums[2] % 2 == 0: if nums[1] + nums[3] - 1 <= nums[0]: print("Yes") else: print("No") elif nums[2] % 2 == 1: if nums[1] + nums[3] <= nums[0]: print("Yes") else: print("No")
p02777
s880383701
Wrong Answer
s,t = input().split() a,b = map(int, input().split()) u = input() if u == s: a+=1 else: b+=1 print(a,b)
p03319
s743313174
Accepted
N,K=map(int,input().split()) A=list(map(int,input().split())) #最終的にすべて同じ値になるなら、最小値のほうから攻めるべき #早いソートにしたほうがいいかも。2部探索とか mini_index=A.index(1) if N<=K: print(1) else: length=K count=1 while(True): length+=K-1 count+=1 if length>=N: print(count) break
p03038
s536673147
Wrong Answer
from heapq import heappush,heappop N,M = list(map(int,input().split())) A = list(map(int,input().split())) change = [list(map(int,input().split())) for _ in range(M)] def tempchange(l,change): for i in range(M): B,C = change[i][0],change[i][1] for j in range(B): a = heappop(l) dif = C - a if dif > 0: heappush(l,C) else: heappush(l,a) return sum(l) #A.sort(reverse = True) change.sort(key = lambda x:x[1],reverse =True) print(tempchange(A,change))
p02838
s848103882
Wrong Answer
import numpy as np n,*a=map(int,open(0).read().split()) mod=10**9+7 a=np.array(a) b0=np.array([0 for i in range(60)]) b1=np.array([0 for i in range(60)]) for i in range(60): c=len(a[a&1==1]) b1[i]=c b0[i]=n-c a>>=1 ans=0 for i in range(60): ans+=(b0[i]*b1[i]*pow(2,i,mod)) ans%=mod print(ans)
p03835
s562295120
Accepted
[K,S] = list(map(int,input().split())) count=0 for X in range(K+1): for Y in range(K+1): Z = S - X - Y if Z in range(K+1): count+=1 print(count)
p02742
s644310322
Accepted
# B - Bishop H, W = map(int, input().split()) ans = W * (H//2) if H&1: ans += (W+1)//2 if H == 1 or W == 1: ans = 1 print(ans)
p03659
s808884060
Wrong Answer
from itertools import accumulate N = int(input()) A = tuple(accumulate(map(int, input().split()))) x = A[-1] y = A[0] ans = abs(x - y - y) for a in A: ans = min(ans, abs(x - a - a)) print(ans)
p02772
s997121288
Wrong Answer
n = int(input()) a = list(map(int, input().split())) flag = False for i in range(n): if a[i] % 2 == 0: if a[i] % 3 == 0 or a[i] % 5 == 0: flag = True else: flag = False break if flag: print("APPROVED") else: print("DENIED")
p03719
s764803543
Accepted
a,b,c = map(int,input().split()) if a <= c <= b: print('Yes') else: print('No')
p02640
s431872804
Wrong Answer
import sys import numpy as np import math from collections import deque from functools import reduce # input = sys.stdin.readline x, y = map(int, input().split()) x2 = y // 2 xe = y // 4 if (x <= x2 and x >= xe): print("Yes") else: print("No")
p02641
s582194568
Accepted
import numpy as np X, N = map(int, input().split()) if N == 0: print(X) else: l = list(map(int, input().split())) app = [x for x in range(X - int(N / 2) - 1, X + int(N / 2) + 1) if x not in l] print(app[np.argmin([abs(x - X) for x in app])])
p02663
s036967941
Wrong Answer
h1,m1,h2,m2,k=map(int,input().split()) h3=abs(h2-h1) print(h3*60-k)
p03796
s481397063
Accepted
ans=1 for i in range(1,int(input())+1): ans=ans*i%(10**9+7) print(ans)
p03495
s337495843
Accepted
import collections n,k=map(int,input().split()) a=list(map(int,input().split())) a_counter=collections.Counter(a) a_count=a_counter.most_common() answer = 0 # print(a_counter) for i in range(k, len(a_count)): # print(a_count[i]) answer += a_count[i][1] print(answer)
p02646
s794765007
Wrong Answer
AV = list(map(int,input().split())) BW = list(map(int,input().split())) T = int(input()) A = AV[0] V = AV[1] B = BW[0] W = BW[1] for i in range(T): if A <= B: B += W A += V else: B -= W A -= V if abs(A) >= abs(B): print('Yes') else: print('No')
p03998
s701656440
Accepted
a=[input(),input(),input()] now=0 while a[now]: y=a[now][0];a[now]=a[now][1:];now=ord(y)-ord('a') print("ABC"[now])
p03073
s173023270
Accepted
s = input() n = len(s) s0 = "01" * (n//2) s1 = "10" * (n//2) if n % 2 == 1: s0 += "0" s1 += "1" a0 = 0 a1 = 0 for i in range(n): if s[i] != s0[i]: a0 += 1 if s[i] != s1[i]: a1 += 1 print(min(a0, a1))
p03711
s541467780
Accepted
k = [1,3,1,2,1,2,1,1,2,1,2,1] N,M = map(int,input().split()) if k[N-1] == k[M-1]: print("Yes") else: print("No")
p02697
s219375029
Accepted
n,m=map(int, input().split()) if m%2==1: for i in range(m//2): print(i+1,m-i) for i in range(m//2+1): print(m+i+1,2*m+1-i) else: for i in range(m//2): print(i+1,m+1-i) for i in range(m//2): print(m+i+2,2*m+1-i)
p03835
s261339696
Accepted
K, S = map(int, input().split()) count = 0 for x in range(K+1): for y in range(K+1): z = S - x - y if 0 <= z <= K: count += 1 print(count)
p02922
s452484746
Accepted
import math a,b=map(int,input().split()) print(math.ceil((b-1)/(a-1)))
p02707
s447527827
Accepted
n=int(input()) d={i:0 for i in range(1,n+1)} l=list(map(int,input().split())) for i in range(1,n): d[l[i-1]]+=1 for i in d: print(d[i])
p02792
s716158185
Accepted
N = int(input()) count = [[0] * 10 for _ in range(10)] ans = 0 for i in range(1,N + 1): a, b = int(str(i)[0]), int(str(i)[-1]) count[a][b] += 1 for i in range(1,10): for j in range(10): ans += count[i][j] * count[j][i] print(ans)
p03804
s962457918
Accepted
N,M=map(int,input().split()) A = [str(input()) for _ in range(N)] B = [str(input()) for _ in range(M)] k=N//M + N%M def macthing(y,x): flag=0 for p in range(M): if A[y+p][x:x+M]!=B[p]: flag=1 break if flag==0: return True else: return False for i in range(k): for j in range(k): if macthing(i,j): print('Yes') exit() print('No')
p02756
s982429451
Wrong Answer
S=input() Q=int(input()) def rev(s): l = len(s) return s[-1]+s[1:l-1]+s[0] s=S[0] for i in range(Q): T = input().split() if T[0]=='1': s=rev(s) elif T[0]=='2': F,C=T[1],T[2] if F=='1': s=str(C)+s else: s=s+str(C) print(s)
p02775
s254326037
Accepted
n = "0" + input() n = list(map(int, list(n))) n.reverse() pay = 0 turi = 0 pls = 0 for i in range(len(n)): val = n[i] + pls pls = 0 if val < 5: pay += val elif val == 5: pay += val if n[i + 1] >= 5: pls = 1 else: turi += 10 - val pls = 1 ans = pay + turi print(ans)
p02993
s103572089
Wrong Answer
number = input() check = False for i in range(len(number)-1): if i == len(number)-2: break elif number[i] == number[i+1]: check = True if check == True: print("Bad") else: print("Good")
p03673
s209499189
Wrong Answer
import collections n = int(input()) a = list(map(str, input().split())) b = collections.deque() for i in range(n): if i % 2 == 0: b.append(a[i]) else: b.appendleft(a[i]) print(" ".join(b))
p02900
s268131145
Wrong Answer
import fractions A, B = map(int, input().split()) i = fractions.gcd(A, B) C = [] for j in range(2, int(i**0.5)+1): while True: if i%j == 0: i //= j C.append(j) else: break print(len(set(C))+1)
p03086
s499895857
Wrong Answer
import sys input = sys.stdin.readline def read(): S = input().strip() return S, def solve(S): alphabets = ['A', 'C', 'G', 'T'] max_count = 0 count = 0 for s in S: if s in alphabets: count += 1 else: max_count = max(max_count, count) count = 0 return max_count if __name__ == '__main__': inputs = read() print(solve(*inputs))
p03345
s129091203
Accepted
A, B, C, K = map(int, input().split()) if K%2 == 0: print(A-B) else: print(B-A)
p03565
s513083146
Wrong Answer
import re import sys def main(): s = sys.stdin.readline().rstrip().replace("?", ".") t = sys.stdin.readline().rstrip() n = len(s) m = len(t) ans = 0 for i in range(n, n - m + 1, -1): tmp = s[i - m : i] if re.fullmatch(tmp, t): s = re.sub(tmp, t, s) ans = 1 break if ans == 1: print(s.replace(".", "a")) else: print("UNRESTORABLE") if __name__ == "__main__": main()
p03457
s367169401
Accepted
N = int(input()) P = [list(map(int, input().split())) for i in range(N)] P.insert(0,[0,0,0]) ans = "Yes" for i in range(N): norm = abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2]) move = (P[i+1][0]-P[i][0]) - norm if ((move%2 != 0) or (move < 0)): ans = "No" break print(ans)
p02767
s222854405
Accepted
N=int(input()) X=list(map(int,input().split())) def P(n): return sum([(X[i]-n)**2 for i in range(0,N)]) l=[P(i) for i in range(1,101)] print(min(l))