problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02719
s770529415
Accepted
from functools import reduce from fractions import gcd import math import bisect import itertools import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline INF = float("inf") def main(): N, K = map(int, input().split()) print(min(N%K, K - N%K)) if __name__ == '__main__': main()
p03069
s769570412
Accepted
from itertools import accumulate N = int(input()) S = input() black = [0] * N white = [0] * N for i in range(N): if S[i] == "#": black[i] = 1 else: white[i] = 1 black = list(accumulate(black, initial=0)) white = list(accumulate(white, initial=0)) ans = float("inf") for i in range(N + 1): ans = min(ans, black[i] + white[N] - white[i]) print(ans)
p03073
s720026009
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) s = list(map(int, input().strip())) ans1 = 0 ans2 = 0 for i, v in enumerate(s): if v != (i % 2): ans1 += 1 else: ans2 += 1 print(min(ans1, ans2))
p03145
s449460201
Accepted
ab, bc, ca = map(int, input().split()) print(int(ab * bc / 2))
p03944
s496906449
Accepted
w, h, n = map(int, input().split()) b = 0 l = 0 for i in range(n): x, y, a = map(int, input().split()) if a == 1: l = max(l, x) elif a == 2: w = min(w, x) elif a == 3: b = max(b, y) else: h = min(h, y) print(max(h - b, 0)*max(w - l, 0))
p02584
s772648909
Accepted
x,k,d = map(int,input().split()) x = abs(x) n = x//d #print(k-n,(abs(x-d*k)),(abs(x-(x//d)*d-d)),abs(x-(x//d)*d)) if n >= k: print(abs(x-d*k)) elif n < k: if (k-n)%2 == 1: print((abs(x-(x//d)*d-d)))#,abs(x-(x//d)*d))) else: print(abs(x-(x//d)*d)) #print(min(abs(x%d),abs(x%d-d)))
p03146
s368575505
Wrong Answer
s = int(input()) lis = [s] def func(n): if n%2 == 0: return n//2 else: return 3*n+1 while func(s) !=4: s = func(s) lis.append(s) print(len(lis)+4)
p02697
s633519491
Wrong Answer
N, M = map(int, input().split()) if N % 2 == 0: N += 2 else: N += 1 ans = [[] for _ in range(N)] K = 0 for i, n in enumerate(range(1, N // 2)): ans[i].append(n) K += 1 for i, n in enumerate(range(N // 2, N - 1)): ans[K - 1 - i].append(n) for a in ans[:M]: print(*a)
p02701
s251273820
Wrong Answer
def main(): n = int(input()) s = [] ans = 0 for i in range(n): si = input() if si in s: break else: ans += 1 s.append(si) print(ans) main()
p03821
s628257501
Accepted
num = (int)(input()) button = [] for i in range(num): button.append(list(map(int, input().split(" ")))) count = 0 for i in range(num - 1, -1, -1): button[i][0] += count tasu = button[i][1] - (button[i][0] % button[i][1]) if button[i][0] % button[i][1] != 0 else 0 #print(tasu, count) count += tasu print(count)
p02687
s088153636
Accepted
S = input() if S=='ABC': print('ARC') else: print('ABC')
p02756
s078020927
Wrong Answer
from collections import deque s = input() r = False d = deque() d.append(s) q = int(input()) for i in range(q): t = input() if t == "1": r = not r else: t, f, c = list(t.split()) f = False if f=="1" else True if r == f: d.appendleft(c) else: d.append(c) if r: d.reverse() print("".join(d))
p03317
s120967178
Accepted
import math, sys from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from copy import deepcopy from functools import lru_cache from heapq import heapify, heappop, heappush from itertools import accumulate, combinations, permutations input = sys.stdin.readline mod = 10**9 + 7 ns = lambda: input().strip() ni = lambda: int(input().strip()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) n, k = nm() a = nl() print(math.ceil((n - 1) / (k - 1)))
p02924
s157581873
Accepted
n = int(input()) print(n * (n - 1) // 2)
p02627
s670492724
Accepted
# -*- coding: utf-8 -*- print(['A', 'a'][ord(input()) >= 97])
p02696
s367676491
Accepted
a,b,n = map(int, raw_input().split(' ')) m = 0 print min(b-1,n) * a /b """ for t in range(0, min(b,n) + 1): print t*a/b m = max(m,t * a / b) #print int(t * a / b) print m """
p03759
s005649513
Wrong Answer
a,b,c = map(int,input().split()) if b-a == c-b: print("Yes") else: print("No")
p02687
s909194901
Accepted
if __name__=='__main__': s = input() t = 'ABC' if s == 'ARC' else 'ARC' print(t)
p03836
s956588703
Accepted
a,b,c,d = map(int, input().split()) ans="" first = (c-a)*"R"+(d-b)*"U" second = (c-a)*"L"+(d-b)*"D" third = "D"+(c-a+1)*"R"+(d-b+1)*"U"+"L" fourth = "U"+(c-a+1)*"L"+(d-b+1)*"D"+"R" ans=first+second+third+fourth print(ans)
p03073
s289171826
Wrong Answer
import sys input = sys.stdin.readline def read(): S = input().strip() return S, def solve(S): N = len(S) ans = [0, 0] # 偶数番目、奇数眼目の1の個数 for i in range(N): if S[i] == "1": ans[i % 2] += 1 return min(ans[0]+N//2+N%2-ans[1], N//2-ans[0]+ans[1]) if __name__ == '__main__': inputs = read() print(solve(*inputs))
p02994
s412933202
Accepted
N, L = map(int, input().split()) if L >= 0: print(sum([L+i-1 for i in range(2, N+1)])) else: apple = [L+i-1 for i in range(1, N+1)] apple.pop(min(N-1, -L)) print(sum(apple))
p02708
s659913191
Wrong Answer
n, k = map(int, input().split()) MOD = 1e9+7 s = [0] * (n+2) s[1] = (n+1) for i in range(2,n+2): s[i] = (s[i-1] + ( i * (n-i+1) + 1 )) % MOD if s[i] < 0: s[i] %= MOD print(int(s[n+1] - s[k-1]))
p03219
s560643205
Wrong Answer
x,y=map(int,input().split()) print(x + y/2)
p03565
s646340461
Accepted
import sys S = input() T = input() match_list = [] for i in range(len(S)-len(T)+1): is_match = True for j in range(len(T)): if S[i+j] != T[j] and S[i+j] != '?': is_match = False break if is_match: match_list.append(i) if not match_list: print("UNRESTORABLE") sys.exit() ans = S[:max(match_list)] + T if len(S) > len(ans): ans += S[len(ans):] print(ans.replace('?', 'a'))
p02642
s909035103
Wrong Answer
N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) ans = 0 for i, a in enumerate(A): flag = True for j in A[i + 1:]: if a % j == 0: flag = False break if A[i] == A[i - 1]: if A[i] % A[i - 1] == 0: flag = False if flag: ans += 1 print(ans)
p03210
s407868090
Accepted
X = input() if X in "753": print("YES") else: print("NO")
p02627
s268350772
Accepted
if str(input()).isupper(): print('A') else: print('a')
p03695
s888244881
Accepted
import sys import bisect n = int(input()) a_ls = [int(i) for i in sys.stdin.readline().split()] ls = [i * 400 - 1 for i in range(1, 9)] _set = set() n_max = 0 for a in a_ls: ind = bisect.bisect_left(ls ,a) if ind == 8: n_max += 1 else: _set.add(ind) _min = max(len(_set), 1) print(_min, len(_set) + n_max)
p03778
s967633354
Wrong Answer
w, a, b = map(int, input().split()) if b + w > w + a > b: print(0) elif a + w < b: print(b - a - w) elif b + w < a: print(a - b - w)
p04043
s294214122
Accepted
list = input().split() list.sort() if ''.join(list) == '557': print('YES') else: print('NO')
p02642
s410861629
Accepted
N = int(input()) A = list(map(int, input().split())) max_a = max(A) + 1 counter = [0 for _ in range(max_a)] for i in A: for j in range(i, max_a, i): counter[j] += 1 res = 0 for a in A: if counter[a] == 1: res += 1 print(res)
p03672
s041260433
Accepted
def main(): S = input() N = len(S) for i in range(1, N+1): t = S[:-i] if len(t) % 2 == 1: continue M = len(t) if t[:M//2] == t[M//2:]: return print(M) if __name__ == '__main__': main()
p03611
s609427472
Accepted
n=int(input()) a=list(map(int,input().split())) a.sort() ans=[-1,0] i=0 while i<=n-1: res=0 cnt=0 while i+res<=n-1 and a[i+res]-a[i]<=2: if a[i+res]==a[i]: cnt+=1 res+=1 if res>ans[1]: ans[1]=res ans[0]=i i+=cnt print(ans[1])
p02801
s696004763
Accepted
C=input() print(chr(ord(C)+1))
p02760
s139352263
Accepted
#!/usr/bin/env python3 def func(a, i): return {a[0]:i, a[1]:i+1, a[2]:i+2} A = {} for i in range(3): A.update(func(input().split(), 3*i)) N = int(input()) b = [A.get(input(), -1) for _ in range(N)] bingo = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]] for i in bingo: if set(i) <= set(b): print("Yes") break else: print("No")
p03565
s375802569
Wrong Answer
sdash = input() n = len(sdash) t = input() s = ['*'] * n isNotUsed = True for i in range(len(t), n+1): if sdash[-i] == t[0] and isNotUsed: for j in range(len(t)): s[-i+j] = t[j] isNotUsed = False elif sdash[-i] == '?': s[-i] = 'a' else: s[-i] = sdash[-i] if isNotUsed: print('UNRESTORABLE') else: s = ''.join(s) s.replace('*', 'a') print(s)
p03696
s674272553
Accepted
n = int(input()) s = list(input()) ans = '' cnt = 0 for c in s: ans += c if c == ')': cnt -= 1 else: cnt += 1 if cnt < 0: ans = '(' + ans cnt = 0 cnt = 0 for c in s[::-1]: if c == ')': cnt += 1 else: cnt -= 1 if cnt < 0: ans += ')' cnt = 0 print(ans)
p02695
s405148686
Wrong Answer
import itertools n,m,q=map(int, input().split()) arr=[[0]*4 for i in range(q)] for i in range(q): arr[i][0],arr[i][1],arr[i][2],arr[i][3]=map(int, input().split()) ans=0 for i in itertools.product([k for k in range(1,m+1)],repeat=n): score=0 for j in range(q): tmp1=i[arr[j][1]-1] tmp0=i[arr[j][0]-1] if tmp1-tmp0==arr[j][2]: score+=arr[j][3] if ans<score: ans=score print(ans)
p02754
s075098751
Accepted
n,a,b=map(int,input().split()) m=n%(a+b) s=n//(a+b) if m<=a: print(a*s+m) else: print(a*s+a)
p04012
s201246165
Accepted
s = input() cnt = {} for l in s : cnt.setdefault(l,0) cnt[l] += 1 flag = True for v in cnt.values(): if v % 2 == 1: flag = False break if flag : print('Yes') else : print('No')
p02989
s761122486
Wrong Answer
import sys input=sys.stdin.readline n=int(input()) L=list(map(int,input().split())) L.sort() num=L[n//2]-L[n//2-1] print(num if num!=1 else 0)
p03659
s374115113
Wrong Answer
n=int(input()) A=list(map(int,input().split())) goukei=sum(A) for i in range(1,n): A[i]+=A[i-1] ans=100000000000 for j in range(n): ans=min(ans,abs(A[j]-(goukei-A[j]))) print(ans)
p03254
s360012888
Wrong Answer
n,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() b = [] num = a[0] i = 1 while num <= x: num += a[i] if x - a[i] > 0: x -= a[i] b.append(a[i]) i += 1 else: b.append(max(0,a[i])) break print(a) print(b) print(num) ans = 0 for i in range(min(len(a),len(b))): if a[i] == b[i]: ans += 1 print(ans)
p02677
s550865205
Accepted
A, B, H, M = map(int, input().split()) import math sita = min(abs(30*H-11*M/2), 360-abs(30*H-11*M/2)) # print(sita) # print(math.cos(math.radians(sita))) print((A**2 + B**2 - 2*A*B*math.cos(math.radians(sita)))**(1/2))
p02817
s029827835
Accepted
a, b = input().split() print(b + a)
p03106
s174694216
Wrong Answer
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque from decimal import * def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': a,b,k = map(int, input().split()) count = 0 for i in range(1,101): if a % i ==0 and b % i ==0: count +=1 if count == k: print(i) break
p03836
s833015161
Wrong Answer
sx, sy, gx, gy = map(int, input().split()) print("U"*(gy-sy)+"R"*(gx-sx)+"D"*(gy-sy)+"L"*(gx-sx)+"L"+"U"*(gy-sy+1)+"R"*(gx-sx+1)+"D"+"R"+"D"*(gy-sy+1)+"L"*(gx-sx+1)+"D")
p03062
s077328361
Wrong Answer
N = int(input()) a = list(map(int, input().split())) dp = [[0] * 2 for _ in range(N+1)] dp[0][0] = 0 dp[0][1] = -10**18 for i in range(1, N): dp[i][0] = max(dp[i-1][0]+a[i-1], dp[i-1][1]-a[i-1]) dp[i][1] = max(dp[i-1][0]-a[i-1], dp[i-1][1]+a[i-1]) print(max(dp[N-1][0], dp[N-1][0]))
p03328
s500353238
Accepted
a, b = list(map(int, input().split())) d = b - a print(d * (d+1) // 2 - b)
p03329
s257551121
Accepted
n = int(input()) dp = [i for i in range(n+1)] # dp table 最初は全て1円で払う for j in range(1, n+1): power = 1 while power <= j: dp[j] = min(dp[j], dp[j - power] + 1) power *= 6 power = 1 while power <= j: dp[j] = min(dp[j], dp[j - power] + 1) power *= 9 print(dp[n])
p03644
s232256968
Accepted
import math n = int(input()) print(2**int(math.log2(n)))
p03252
s555112962
Wrong Answer
S = input() T = input() dictionary = {} ans = "Yes" for i in range(len(S)): if T[i] in dictionary: if dictionary[T[i]] == S[i]: continue else: ans = "No" else: dictionary[T[i]] = S[i] print(ans)
p03994
s200737105
Accepted
S = input() K = int(input()) Ans = [] for s in S[:-1]: if s == 'a': Ans.append('a') continue if (123 - ord(s)) <= K: Ans.append('a') K -= 123 - ord(s) else: Ans.append(s) K %= 26 if ord(S[-1]) + K >= 123: Ans.append(chr(ord(S[-1]) + K - 26)) else: Ans.append(chr(ord(S[-1]) + K)) print(''.join(Ans))
p03220
s543298703
Accepted
#!/usr/bin/env python3 n = int(input()) t,a = map(int,input().split()) h = list(map(int,input().split())) best = 10**6 ans = 0 for i in range(n): if best > abs((t-h[i]*0.006)-a): best = abs((t-h[i]*0.006)-a) ans = i+1 print(ans)
p02784
s162908819
Accepted
#B H,N=map(int,input().split()) A=list(map(int,input().split())) if sum(A)>=H: print('Yes') else: print('No')
p02658
s022247322
Wrong Answer
import numpy as np sub = input() input = input().split(" ") nl = list() for ele in input: nl.append(int(ele)) res = np.prod(nl) if res >= 1000000000000000000: print("-1") else: print(res)
p02897
s357373413
Wrong Answer
N=int(input()) if N%2==0: print(1/2) elif N==1: print(1.0000000000) else: print(0.6000000000)
p02946
s209572887
Accepted
import sys input = lambda: sys.stdin.readline().rstrip() input_nums = lambda: list(map(int, input().split())) def main(): K, X = input_nums() a = [x for x in range(K*2-1)] m = a[len(a)//2] d = m - X print(*[x - d for x in a]) if __name__ == '__main__': main()
p04044
s565257671
Accepted
n,l = map(int,input().split()) A =[input() for _ in range(n)] print("".join(sorted(A)))
p03494
s059273375
Wrong Answer
N = int(input()) args = list(map(int, input().split())) c = 0 for arg in args: cc =int(arg / 2) if cc > c: c = cc print(c)
p02756
s945139878
Accepted
s = input() q = int(input()) appendix = [[], []] reverse = False for _ in range(q): query = input().split() if query[0] == '1': reverse ^= True else: f = bool(int(query[1]) - 1) appendix[int(f ^ reverse)].append(query[2]) if reverse: print(''.join(appendix[1][::-1]) + s[::-1] + ''.join(appendix[0])) else: print(''.join(appendix[0][::-1]) + s + ''.join(appendix[1]))
p03433
s320841250
Wrong Answer
N, A = [int(input()) for i in range(2)] if (N%500) < A: print('Yes') else: print('No')
p03001
s754231220
Wrong Answer
w,h,x,y = map(int,input().split()) men1 = min(h*x,h*(w-x)) men2 = min(w*y,w*(h-y)) print("{} {}".format(float(max(men1,men2)),1 if men1 == men2 else 0))
p03041
s435734409
Accepted
N, K = map(int, input().split()) S = list(input()) S[K - 1] = chr(ord(S[K - 1]) + 32) print("".join(S))
p02963
s858447522
Accepted
s = int(input()) n = 1000000000 x = (n-s%n)%n y = (s+x)//n print(*[1,n,y,x,0,0])
p03161
s942187040
Accepted
N, K = map(int, input().split()) h = [0] + list(map(int, input().split())) dp = [10**10] * (N+1) dp[0] = dp[1] = 0 for i in range(1, N+1): for k in range(1, K+1): if i + k <= N: dp[i+k] = min(dp[i+k], dp[i]+abs(h[i] - h[i+k])) print(dp[N])
p02595
s709798198
Accepted
N,D=map(int,input().split()) X=[tuple(map(int,input().split())) for i in range(N)] print(sum([1 for x,y in X if (x**2+y**2)**0.5<=D]))
p02817
s740198231
Accepted
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline s, t = map(str, input().decode().split()) print(t, s, sep='') if __name__ == "__main__": setrecursionlimit(10000) main()
p03062
s756591629
Accepted
import sys n=int(input()) A=list(map(int,input().split())) count=0 for elem in A: if elem < 0: count+=1 if count%2==0: for i in range(len(A)): A[i]=abs(A[i]) print(sum(A)) sys.exit() else: tmp=1000000000000 for elem in A: tmp=(min(tmp,abs(elem))) for i in range(len(A)): A[i]=abs(A[i]) print(sum(A)-2*tmp)
p02713
s989773166
Accepted
from math import gcd K = int(input()) #K = 200 sum = 0 for a in range (1, K+1): for b in range(1, K+1): for c in range(1, K+1): sum += gcd(gcd(a, b), c) print(sum)
p03860
s573568294
Accepted
print('A{}C'.format(input().split()[1][0]))
p03721
s526116739
Accepted
n,k=map(int,input().split()) l=[0]*(10**5+1) for i in range(n): a,b=map(int,input().split()) l[a]+=b inc=0 for i in range(10**5+1): inc+=l[i] if inc>=k: print(i) break
p03778
s122491105
Accepted
w,a,b=map(int,input().split()) print(max(abs(a-b)-w,0))
p02912
s139862177
Accepted
from heapq import ( heapify, # 優先度付きキューの生成 heappop, heappush, heappushpop, heapreplace ) N, M = map(int, input().split()) # 最小値が返ってくるので-1倍する A = [-i for i in map(int,input().split())] heapify(A) for _ in range(M): s = -heappop(A) s //= 2 heappush(A, -s) print(-sum(A))
p02766
s297195541
Accepted
n, k = map(int, input().split()) i = 0 while (n >= k): n = n / k i = i + 1 if (n != 0): i = i + 1 print(i)
p02882
s958447625
Accepted
import math a, b, x = map(int, input().split()) s = a*a*b if x*2 <= s: tan = (a * b * b) / (2 * x) else: tan = (2 * (a * a * b - x)) / (a * a * a) sita = math.degrees(math.atan(tan)) print(sita)
p02688
s546045640
Wrong Answer
n,k = [int(ch) for ch in input().split()] snuckList = [] for i in range(n): snuckList.append(i+1) for i in range(k): snuck = int(input()) snackList = input() if snuck in snuckList: snuckList.remove(snuck) print(len(snuckList))
p03657
s054573741
Wrong Answer
a, b = map(int, input().split()) if (a % 3 == 0) or (b % 3 == 0) or ((a + b) % 3 == 0): print('Yes') else: print('No')
p02801
s689706071
Accepted
c = input() ans = chr(ord(c) + 1) print(ans)
p03698
s340716118
Accepted
s=list(input()) t=list(set(s)) print("yes" if len(s)==len(t) else "no")
p02633
s658413784
Accepted
X = int(input()) for k in range(1, 361): if k * X % 360 == 0: print(k) break
p03359
s394507503
Wrong Answer
a, b = map(int, input().split()) r = a-1 if b-a>0: r+=1 print(r)
p02755
s579683414
Accepted
def tax(a, b): for i in range(1,1010): if int(i*0.08) == a and int(i*0.1) == b: print(i) return print(-1) return a, b = map(int, input().strip().split()) tax(a,b)
p03698
s354927018
Accepted
# ABC063 from collections import Counter S = input() count = Counter(S) for cnt in count.values(): if cnt != 1: print('no') exit() else: print('yes')
p02600
s762348434
Accepted
x = int(input()) if 400 <= x < 600: a = 8 elif 600 <= x < 800: a = 7 elif 800 <= x < 1000: a = 6 elif 1000 <= x < 1200: a = 5 elif 1200 <= x < 1400: a = 4 elif 1400 <= x < 1600: a = 3 elif 1600 <= x < 1800: a = 2 else: a = 1 print(a)
p04030
s851435622
Accepted
S=list(input()) for i in range(10): try: j=S.index('B') except: break if j!=0: del S[j-1:j+1] else: del S[j] print(''.join(S))
p02918
s247815671
Accepted
n,k = map(int, raw_input().split()) s = raw_input() cd = 0 d = None for l in s: if d != l: cd +=1 d = l score = 0 for u,v in zip(s,s[1:]): if u == v: score +=1 if cd > 2: t = min(k,((cd - 2)+1)/2) k -= t score += 2 * t cd -= 2 * t if cd == 2 and k: score +=1 cd -= 1 print score
p02819
s066659129
Accepted
# coding: utf-8 import math def prime(X): if X == 1: return False for i in range(2, int(math.sqrt(X)) + 1): if X % i == 0: return False return True X = int(input()) while prime(X) == False: X += 1 print(X)
p02761
s882456935
Wrong Answer
n,m=map(int,input().split()) ans=[-1]*n frag=1 for i in range(m): s,c=map(int,input().split()) s-=1 if ans[s]==-1: ans[s]=c elif ans[s]!=c: frag=0 if ans[0]==0: frag=0 elif ans[0]==-1: ans[0]=1 for i in range(1,n): if ans[i]==-1: ans[i]=0 if frag: print(int(''.join(map(str,ans)))) else: print(-1)
p03804
s868215521
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): result = True for k in range(M): for l in range(M): if b[k][l] != a[i+k][j+l]: result = False if result: print('Yes') exit() print('No')
p03062
s552456448
Accepted
N = int(input()) A = list(map(int, input().split())) abs_min = 10 ** 9 minus = 0 total = 0 for x in A: if x < 0: minus += 1 x = - x if abs_min > x: abs_min = x total += x if minus % 2 == 0: print(total) else: print(total - abs_min * 2)
p02719
s527956428
Accepted
N, K = map(int, input().split()) print(min(N % K,abs(N % K-K)))
p03645
s217626203
Accepted
n, m = map(int, input().split()) c = {tuple(map(int, input().split())) for _ in [None]*m} for i in range(2, n): if {(1, i), (i, n)} <= c: print("POSSIBLE") exit() print("IMPOSSIBLE")
p02775
s597241886
Accepted
n = input() a = 0 b = 2 for s in n: v = int(s) a_ = min(a + v, b + v) b_ = min(a + 10 - v + 1, b + 10 - v + 1 - 2) a = a_ b = b_ print(min(a, b))
p03437
s544513301
Accepted
X,Y=map(int,input().split()) if(X%Y==0): print(-1) exit() print(X)
p03377
s644078329
Accepted
a, b, x = map(lambda x: int(x), input().split()) t = x - a if t < 0: print('NO') else: if t < b: print('YES') else: print('NO')
p03011
s352452544
Accepted
P,Q,R=map(int,input().split()) print(min(P+Q,Q+R,R+P))
p03475
s426611054
Accepted
#!/usr/bin/env python3 from itertools import product, permutations, combinations from bisect import bisect_right,bisect_left N=int(input()) times = [list(map(int, input().split())) for i in range(N-1)] for start in range(N-1): current = start + 1 elapsed = times[start][1] + times[start][0] while current < N-1: if elapsed < times[current][1]: elapsed = times[current][1] if elapsed % times[current][2] != 0: elapsed = times[current][2] * (elapsed // times[current][2] + 1) elapsed += times[current][0] current += 1 print(elapsed) print(0)
p02700
s956204110
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')
p03281
s724156703
Accepted
n = int(input()) if n >= 195: print(5) elif n >= 189: print(4) elif n >= 165: print(3) elif n >= 135: print(2) elif n >= 105: print(1) else: print(0)