problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02953
s815814071
Accepted
def main(): n=int(input()) H=list(map(int,input().split())) now=H[0]-1 if n==0: print('Yes') return for h in H[1:]: if now > h: print('No') return elif now == h: now = h else: now = h -1 print('Yes') main()
p02848
s937911131
Wrong Answer
N = int(input()) S = input() A = '' for i in range(len(S)): if ord(S[i])+N <= 90: A += chr(ord(S[i])+N) print(A) else: A += chr(ord(S[i])+N-26) print(A) print(A)
p02677
s793541611
Accepted
import math [A, B, H, M] = list(map(int, input().split())) a = 2 * math.pi / 12 * (H + M / 60) b = 2 * math.pi / 60 * M c = a - b answer = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(c)) print(answer)
p03328
s163291793
Accepted
a, b = map(int, input().split()) x = [i *(i + 1) // 2 for i in range(1, 1000)] for i in range(999): if a < x[i] and x[i] - a == x[i+1] - b: print(x[i] - a) break
p02602
s014674767
Accepted
def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) ans = [] for i in range(k, n): if a[i] > a[i-k]: ans.append("Yes") else: ans.append("No") for s in ans: print(s) if __name__ == "__main__": main()
p02732
s385479610
Accepted
from collections import Counter def choose(n, r): x, y = 1, 1 for i in range(r): x *= n - i y *= i + 1 return x // y N = int(input()) *a, = map(int, input().split()) ctr = Counter(a) b = 0 for cnt in ctr.values(): b += choose(cnt, 2) ret = [] for x in a: cnt = ctr[x] res = b - choose(cnt, 2) + choose(cnt - 1, 2) ret.append(res) print(*ret, sep='\n')
p04012
s668536652
Accepted
from collections import Counter w = list(input()) w = Counter(w) flag = True for k, v in w.items(): if v % 2 != 0: flag = False break print("Yes" if flag else "No")
p02988
s772337276
Accepted
n = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(2, n): l = [p[i - 2], p[i - 1], p[i]] m = sorted(l) if l[1] == m[1]: cnt += 1 print(cnt)
p02630
s892960903
Accepted
import collections n = int(input()) a = list(map(int, input().split())) q = int(input()) query = [list(map(int, input().split())) for _ in range(q)] s = sum(a) a = collections.Counter(a) for b, c in query: s = s + (c - b) * a[b] a[b], a[c] = 0, a[c] + a[b] print(s)
p03241
s919178193
Accepted
n,m = map(int,input().split()) div = [] for i in range(1,int(m**0.5)+1): if m%i == 0: div.append(i) div.append(m//i) div.sort(reverse=True) for x in div: if m//x >= n: print(x) break
p02665
s126471939
Accepted
n = int(input()) al = list(map(int,input().split())) sum_a = sum(al) potential = 1 ans = 0 for a in al: ans += min(sum_a, potential) sum_a -= a potential = 2 * (potential - a) if potential < 0: print(-1) exit() print(ans)
p02916
s887284310
Wrong Answer
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) ans = sum(b) for i in range(n-1): print(ans) if a[i+1] == a[i] + 1: ans += c[i-1] print(ans)
p03861
s581071453
Accepted
a, b, x = [int(i) for i in input().split()] def ret(n): if n>=0: return n//x+1 else: return 0 print(ret(b)-ret(a-1))
p02582
s275561102
Accepted
S =input() cnt = 0 cntmax = 0 for i in range(3): if S[i] == 'R': cnt+= 1 cntmax = max(cntmax, cnt) else: cnt =0 print(cntmax)
p03416
s242275699
Accepted
A,B=map(int,input().split()) num=0 for i in range(A,B+1): N=str(i) if N==N[::-1]: num+=1 print(num)
p03524
s387310886
Accepted
s = input() A = s.count("a") B = s.count("b") C = s.count("c") if max(A,B,C) - min(A,B,C) <= 1: print("YES") else: print("NO")
p03487
s806980247
Wrong Answer
n=int(input());a=input().split();d={} for i in a: if i not in d: d[i]=min(a.count(i),abs(int(i)-a.count(i))) print(sum([i for i in d.values()]))
p02552
s130214737
Accepted
x = int(input()) print(x * -1 + 1)
p02797
s289365093
Accepted
N, K, S = map(int, input().split()) print(" ".join([str(S)] * K + [str(S+1)] * (N-K)) if S<10**9 else " ".join([str(S)] * K + ['1'] * (N-K)))
p03852
s490912836
Accepted
c = input() if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u': print('vowel') else: print('consonant')
p02693
s496326700
Wrong Answer
import random import math LI = lambda: list(map(int,input().split())) MI = lambda: map(int,input().split()) yes = lambda: print("Yes") no = lambda: print("No") I = lambda: list(input()) J = lambda x: "".join(x) II = lambda: int(input()) SI = lambda: input() #---khan17---template t = II() a,b = MI() boo = False for i in range(a,b+1): if a%t == 0: boo = True break print("OK" if boo else "NG")
p02690
s035372739
Accepted
import sys def Ii():return int(sys.stdin.buffer.read()) def Mi():return map(int,sys.stdin.buffer.readline().split()) def Li():return list(map(int,sys.stdin.buffer.readline().split())) x = Ii() for i in range(121): for j in range(-119,120): if x == i**5 - j**5: print(i,j) exit(0)
p03419
s607832470
Accepted
n,m = map(int,input().split()) ans=0 if n==1 and m==1: print(1) elif n==1 or m==1: print(n*m-2) else: print(n*m-2*(n+m)+4)
p03282
s527309512
Accepted
s=input() k=int(input()) for i in range(k): if not s[i]=='1': print(s[i]) break else: print(s[k-1])
p02860
s481145810
Accepted
N=int(input()) s=input() if N%2==1: print("No") else: m=int(N/2) s1=s[:m] s2=s[m:] if s1==s2: print("Yes") else: print("No")
p03239
s301078723
Accepted
n, t = map(int, input().split()) ct = [list(map(int, list(input().split()))) for i in range(n)] ct.sort(key=lambda x: x[0]) for i in range(n): if ct[i][1] <= t: print(ct[i][0]) exit() if i == n - 1: print("TLE")
p02755
s095952656
Accepted
A,B = [int(i) for i in input().split()] flag=0 for i in range(1,1050): if int(i*0.08)==A and int(i*0.1)==B: ans = i flag=1 break if flag==1: print(ans) else: print(-1)
p02765
s190304265
Accepted
def main(): import sys input = sys.stdin.readline N, R = map(int,input().split()) if N >= 10: print(R) elif N < 10: print(R + 100 * (10 - N)) if __name__ == "__main__": main()
p02911
s730046082
Wrong Answer
import numpy as np n,k,q = map(int,input().split()) a =np.array([k]*n) a-=q for i in range(q): a[int(input())-1]+=1 for i in range(n): if i>0: print("Yes") else: print("No")
p04044
s880021830
Accepted
n, l = map(int, input().split()) s_l = [ str(input()) for _ in range(n) ] s_l = sorted(s_l) print(''.join(s_l))
p03360
s994390335
Wrong Answer
a=list(map(int,input().split())) a=sorted(a) k=int(input()) g=2 for i in range(1,k+1): f=a[2]*g a[2]=f g=g+2 c=a[0]+a[1]+a[2] print(c)
p02755
s287423704
Accepted
A, B = map(int, input().split()) _MAX_PRICE = 1001 for n in range(1, _MAX_PRICE): if int(n * 0.08) == A and int(n * 0.1) == B: print(n) exit() print(-1)
p02888
s631254459
Accepted
import bisect n = int(input()) ll = list(map(int, input().split())) ll.sort() ans = 0 for i in range(n-2): e1 = ll[i] for j in range(i+1, n-1): e2 = ll[j] ans += bisect.bisect_left(ll[j+1:], e1+e2) print(ans)
p02916
s742960152
Accepted
n= int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) ans=0 for i in range(0,n): ans += b[a[i]-1] if i>=1: if a[i]==a[i-1]+1: ans+=c[a[i]-2] print(ans)
p03071
s737872204
Accepted
a,b = map(int, input().split()) if a<b: a,b = b,a if a==b: print(a*2) else: print(a+a-1)
p02760
s578315483
Accepted
a = [] for _ in range(3): a += list(map(int, input().split())) n = int(input()) b = {int(input()): None for _ in range(n)} r = [(ai in b) for ai in a] combs = [ [0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6], ] if any([all([r[c] for c in comb]) for comb in combs]): print('Yes') else: print('No')
p03799
s004916941
Accepted
N,M=map(int,input().split()) ans = 0 if M >= 2 * N: ans = N M -= N * 2 ans += M // 4 else: ans = M //2 print(ans)
p03077
s523377751
Wrong Answer
n=int(input()) t=[int(input()) for _ in range(5)] k=n//min(t) if k<1:k=1 print(k+4)
p02759
s191373001
Wrong Answer
n = int(input()) s = n//2 t = n%2 if t ==1: print(s+1) if t ==0: print(s+1)
p03448
s349216236
Wrong Answer
def solve(a, b, c, x): return sum( x == 500 * i + 100 * j + 50 * k for i in range(1, a + 1) # 500円 for j in range(1, b + 1) # 100円 for k in range(1, c + 1) # 50円 ) _a = int(input()) _b = int(input()) _c = int(input()) _x = int(input()) print(solve(_a, _b, _c, _x))
p03555
s707385613
Wrong Answer
S1 = list(input()) S2 = list(input()) flag = 0 for i in range(3): if S1[i] != S2[2-i]: flag = 1 if flag: print('No') else: print('Yes')
p03835
s723912856
Accepted
k,s = map(int,input().split()) ans = 0 if(s == 0): print(1) exit() elif(s == 3*k): print(1) exit() for i in range(0,k+1): for j in range(0,k+1): z = s - i - j if(z >= 0 and z <= k): ans += 1 print(ans)
p03105
s528927405
Wrong Answer
a, b, c = map(int, input().split()) cnt = 0 while True: if a <= b: b -= a cnt += 1 else: print(0) exit() if cnt == c or b <= 0: print(cnt) exit()
p02689
s423895939
Wrong Answer
N,M = map(int,input().split()) H = list(map(int,input().split())) data = set([int(i) for i in range(1,N+1)]) tmp = set() for _ in range(M): A,B = map(int,input().split()) tmp.add(B) # print(data) # print(tmp) print(len(data-tmp))
p03387
s440192604
Accepted
a = list(map(int,input().split())) a = sorted(a) a,b,c = a[0],a[1],a[2] ca = c-a cb = c-b if ca % 2 == 0 and cb % 2 == 0: print(ca //2 + cb //2) elif ca % 2 == 1 and cb % 2 == 1: print(((ca-1) // 2) + ((cb-1) // 2) + 1) elif ca % 2 == 1 and cb % 2 == 0: print((cb // 2) + 1 + ((ca+1) // 2)) elif cb % 2 == 1 and ca % 2 == 0: print((ca // 2) + 1 + ((cb+1) // 2))
p03543
s746296673
Accepted
a, b, c, d = input() print("Yes" if a == b == c or b == c == d else "No")
p02843
s693836124
Accepted
x = int(input()) dp = [False] * (x+1) dp[0] = 1 for i in range(0, x+1): if dp[i]: try: dp[i + 100] = True dp[i + 101] = True dp[i + 102] = True dp[i + 103] = True dp[i + 104] = True dp[i + 105] = True except: pass if dp[x]: print(1) else: print(0)
p02831
s308969593
Accepted
import fractions A,B = map(int,input().split()) def lcm(x, y): return (x * y) // fractions.gcd(x, y) print(lcm(A, B))
p03038
s815603339
Accepted
import bisect n, m = list(map(int, input().split(' '))) aaa = list(map(int, input().split(' '))) aaa = sorted([-a for a in aaa])[::-1] len_aaa = len(aaa) cccbbb = [] for i in range(m): b, c = list(map(int, input().split(' '))) cccbbb.append((-c, b)) cccbbb = sorted(cccbbb) ccc = [] for c, b in cccbbb: ccc += [c] * b if len(ccc) > len_aaa: break ans = 0 for i in range(len_aaa): c = ccc[i] if i < len(ccc) else 0 ans += min(aaa[i], c) print(abs(ans))
p03427
s110330913
Accepted
s = input() digit = len(s) first_num = int(s[0]) a = 0 a = 9*(digit-1) + int(s[0]) - 1 b = 0 for i in s: b += int(i) print(max(a, b))
p02744
s838564600
Wrong Answer
from string import ascii_lowercase N = int(input()) ans = ['a'] for i in range(1, N): ans2 = [] for a in ans: for b in ascii_lowercase[:i + 1]: ans2 += [a + b] ans = ans2 print('\n'.join(ans))
p03160
s131455956
Accepted
n = int(input()) h = [int(x) for x in input().split()] h.insert(0, -1) dp = [-1] * (n+1) dp[1] = 0 dp[2] = abs(h[1] - h[2]) for i in range(3, n+1): dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2])) print(dp[n])
p02583
s763655037
Accepted
N = int(input()) L = list(map(int, input().split())) # SL = list(set(L)) SL = L SL.sort() anss = set() for ix in range(len(SL)): for jx in range(ix+1,len(SL)): for ux in range(jx+1,len(SL)): if SL[ix] != SL[jx] != SL[ux] and SL[ix]+SL[jx] > SL[ux]: anss.add((ix+1, jx+1, ux+1)) print(len(anss))
p03448
s203341110
Accepted
import sys import copy import math import itertools import numpy as np A=int(input()) B=int(input()) C=int(input()) X=int(input()) cnt = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): if a*500+b*100+c*50==X: cnt+=1 print(cnt)
p02756
s795595845
Wrong Answer
s = input() q = int(input()) a = "" b = "" for i in range(q): l = list(input().split()) if len(l) == 1: a, b = b, a else: if l[1] == "1": s = a + s a = l[2] if b == "": b = s s = "" else: s = s + b b = l[2] if a == "": a = s s = "" print(a+s+b)
p03041
s127807080
Accepted
a,b=map(int,input().split()) c=input() n=c[b-1] n=n.lower() c=list(c) c[b-1]=n c=''.join(c) print(c)
p03457
s513838874
Accepted
def boolean(a,b): D = abs(a[0] - b[0]) -abs(a[1] - b[1]) - abs(a[2] - b[2]) if(D >= 0 and D %2 == 0): return 0 else: return 1 N = int(input()) txy=[0 for i in range(N+1)] txy[0]=[0,0,0] for i in range(N): a=list(map(int,input().split())) txy[i+1]=a ans = "Yes" for i in range(1,N + 1): if(boolean(txy[i-1],txy[i])): ans = "No" break print(ans)
p02714
s040099652
Accepted
import sys import collections N = int(input()) S = [ch for ch in input()] counter = collections.Counter(S) if len(counter.keys()) != 3: print(0) sys.exit() total = 1 for k, v in counter.items(): total *= v for i in range(len(S)): l, r = i - 1, i + 1 while 0 <= l and r < len(S): if len(set([S[i], S[l], S[r]])) == 3: total -= 1 l -= 1 r += 1 print(total)
p02706
s856104217
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) if N >= sum(A): print(N - sum(A)) else: print('-1')
p02923
s724188012
Accepted
def main(): n = int(input()) h = [int(x) for x in input().split()] tmp = 0 ans = 0 for i in range(n-1): if h[i] >= h[i+1]: tmp+=1 ans = max(tmp, ans) else: tmp=0 print(ans) main()
p03778
s183631559
Wrong Answer
w, a, b = map(int, input().split()) if w >= abs(a-b): print(0) elif a > b: print(b+w-a) elif b > a: print(a+w-b)
p04044
s168010575
Accepted
n,l = map(int,input().split()) s = [input() for i in range(n)] s.sort() print("".join(s))
p02571
s566440173
Accepted
s=input() t=input() mx=0 for i in range(len(s)-len(t)+1): sm=0 for j in range(len(t)): if s[i+j]==t[j]: sm+=1 mx=max(sm,mx) print(len(t)-mx)
p03679
s691165444
Wrong Answer
a,b,c=map(int,input().split()) if b>c: print('delicious') elif a>=c-b: print('safe') else: print('dangerous')
p02880
s421817488
Accepted
a = int(input()) b = [i * j for i in range(1, 10) for j in range(1, 10)] print("Yes" if a in b else "No")
p03721
s537904691
Wrong Answer
n, k = map(int, input().split()) a_list = [] for i in range(n): a, b = map(int, input().split()) a_list.append([a, b]) a_list.sort(key=lambda x: x[0]) print(a_list) for i in range(n): k -= a_list[i][1] if k <= 0: print(a_list[i][0]) break
p02582
s718879225
Wrong Answer
S = input() m = 0 c = 0 for s in S: if s == 'R': c += 1 else: c == 0 m = max(m, c) print(m)
p02713
s158163604
Accepted
# coding: utf-8 import math n = int(input()) ans = 0 for i in range(n): for j in range(n): x=math.gcd(i+1,j+1) for k in range(n): ans += math.gcd(x,k+1) print(ans)
p02603
s548669044
Accepted
_,a=open(0) *a,=map(int,a.split()) x=1000 for i,j in zip(a,a[1:]):x+=x//i*(j-i)*(i<j) print(x)
p02607
s120830258
Wrong Answer
n = int(input()) A = list(map(int, input().split())) ans = 0 if len(A) > 2: for a in A[::2]: if a % 2 == 1: ans += 1 print(ans)
p02690
s864903667
Accepted
dat = {} for i in range(0, 500): for j in range(0, 500): res = i ** 5 - j ** 5 dat[res] = [i, j] res = i ** 5 + j ** 5 dat[res] = [i, -j] tmp = int(input()) if tmp in dat: print(dat[tmp][0], dat[tmp][1])
p03012
s421007414
Accepted
n=int(input()) w=list(map(int,input().split())) s=[w[0]] sum=sum(w) ans=sum for i in range(1,n): temp=s[i-1]+w[i] s.append(temp) ans=min(ans,abs(sum-2*s[i])) print(ans)
p03041
s545366004
Accepted
n,k = map(int,input().split()) S = list(input()) S[k-1] = S[k-1].lower() print("".join(S))
p03043
s641317727
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, k = map(int, read().split()) ans = 0 for i in range(1, n + 1): cnt = 0 check = i while k > check: check *= 2 cnt += 1 if cnt == 0: ans += 1 / n else: ans += 0.5 ** cnt * (1 / n) print(ans)
p02848
s392980223
Accepted
n = int(input()) res = [] for i in input(): a = ord(i) + n if a > 90: res.append(chr(a % 90 + 64)) else: res.append(chr(a)) print("".join(res))
p02854
s249511522
Wrong Answer
from itertools import accumulate N = int(input()) A = list([int(x) for x in input().split()]) count = 0 ironbar = list(accumulate(A)) i = 0 j = len(A) - 1 while i + 1 < j: left = ironbar[i] right = ironbar[j] - ironbar[i] if left > right: j = (i+j) // 2 elif left < right: i = (i+j) // 2 else: print(0) exit() left = ironbar[i] right = ironbar[j] - ironbar[i] print(abs(left-right))
p03107
s179840371
Accepted
s = input() b = 0 w = 0 for i in range(len(s)): if(s[i] == '0'): b = b+1 if(s[i] == '1'): w = w+1 print(2*min(b,w))
p02767
s833912391
Accepted
n = int(input()) s = input().split() sum = 0 for i in range(n): sum += int(s[i]) a = float(sum)/float(n) if int(a)+0.5 <= a: a = int(a)+1 else: a = int(a) ans = 0 for i in range(n): ans += (int(s[i])-a)**2 print(ans)
p02953
s746791941
Accepted
n=int(input()) #n,m=map(int,input().split()) #t=int(input()) hl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] flag="Yes" for i in range(n-2,-1,-1): righth=hl[i+1] cur=hl[i] if cur<=righth: pass elif cur==righth+1: hl[i]=cur-1 else: flag="No" break print(flag)
p02765
s647326229
Accepted
N , R =map(int, input().split()) if N <=10: print(R + 100 * ( 10 - N)) else: print(R)
p02711
s591746272
Accepted
n = list(map(int, input())) if n[0] == 7: print("Yes") elif n[1] == 7: print("Yes") elif n[2] == 7: print("Yes") else: print("No")
p03605
s595564477
Wrong Answer
X = str(input()) if '9' in X: print('YES') else: print('NO')
p02860
s387884082
Wrong Answer
n = int(input()) s = input() a = 0 if n%2 == 0: for i in range (n//2): if s[i] == s[n//2-1+i]: continue else: a = 1 break else: a = 1 print('Yes' if a==0 else 'No')
p03345
s826658213
Wrong Answer
a,b,c,k = map(int,input().split()) count = 0 if k == 0: if abs(a-b) >= 10**8: print('Unfair') else: print(a-b) exit() while count == k: a1 = a b1 = b c1 = c a = b1 + c1 b = a1 + c1 c = a1 + b1 count += 1 if abs(a-b) >= 10**8: print('Unfair') else: print(a-b)
p02917
s503355178
Accepted
# coding: utf-8 N = int(input()) B = list(map(int, input().split())) A = B A.insert(0, B[0]) for i in range(1, N - 1): if A[i] > A[i+1]: A[i] = A[i+1] print(sum(A))
p03637
s763906961
Wrong Answer
n, *a = map(int, open(0).read().split()) f = 0 t = 0 for i in a: if i % 4 == 0: f += 1 elif i % 2 == 0: t += 1 if 2*f + t >= len(a): print('Yes') quit() elif 2*f + t + 1 == len(a) and f != 0: print('Yes') else: print('No')
p02552
s132025019
Accepted
x = int(input()) if x==0: print(1) else: print(0)
p02836
s180829513
Accepted
def actual(s): N = len(s) count_operation = 0 for i in range(N): head = s[i] tail = s[N - 1 - i] if head != tail: count_operation += 1 return int(count_operation / 2) s = input() print(actual(s))
p03637
s593554265
Accepted
n = int(input()) a = list(map(int, input().split())) m4 = 0 m2 = 0 for i in range(len(a)): if (a[i] % 4 == 0): m4 += 1 elif (a[i] % 2 == 0): m2 += 1 if (m4*2+m2 >= len(a) or m4*2+1 >= len(a)): print("Yes") else: print("No")
p03773
s773589290
Accepted
a, b = map(int, input().split()) ans = (a+b)%24 print(ans)
p02683
s021987217
Wrong Answer
n,m,x = map(int,input().split()) ca = [list(map(int,input().split())) for _ in range(n)] true_buy = float("inf") for i in range(2**n): buy = [] buy_sum = 0 for j in range(n): if (i>>j) & 1: buy.append(ca[j]) buy_sum += ca[j][0] for k in range(m): gain = 0 for l in range(len(buy)): gain += buy[l][k] if gain < x: buy_sum = float("inf") true_buy = min(buy_sum,true_buy) if true_buy == float("inf"): print(-1) else: print(true_buy)
p03163
s341352660
Accepted
N,W=map(int,input().split()) MV=[list(map(int, input().split())) for _ in range(N)] dp=[0]*(W+1) for w,v in MV: for tw in range(W,w-1,-1): dp[tw]=max(dp[tw],dp[tw-w]+v) #print(dp,tw) print(max(dp))
p02595
s911038266
Accepted
import math N, D = map(int, input().split()) count = 0 xy = [map(int, input().split()) for _ in range(N)] x, y = [list(i) for i in zip(*xy)] for i in range(N): if math.sqrt(x[i] * x[i] + y[i] * y[i]) <= D: count += 1 print(count)
p02924
s234307740
Wrong Answer
N = int(input()) print(int(1/2*N*(N-1)))
p03835
s343662496
Accepted
K, S = map(int, input().split()) c = 0 for x in range(K + 1): for y in range(x + 1): if x + y > S: break z = S - x - y if z >= 0 and z < y + 1: if x != y and x!= z and y!= z: c += 6 elif x == y and x == z and y == z: c += 1 else: c += 3 print(c)
p03061
s160616727
Accepted
from math import gcd n, *a = map(int, open(0).read().split()) l = [0] * n r = [0] * n for i in range(n - 1): l[i + 1] = gcd(l[i], a[i]) for i in range(n - 1, 0, -1): r[i - 1] = gcd(r[i], a[i]) print(max(gcd(l[i], r[i]) for i in range(n)))
p03474
s237096711
Accepted
import sys input = sys.stdin.readline A, B = [int(x) for x in input().split()] S = input().rstrip() if S[A] != "-": print("No") sys.exit() if "-" in S[:A] or "-" in S[A+1:]: print("No") sys.exit() print("Yes")
p02603
s167335699
Accepted
n = int(input()) a = list(map(int,input().split())) money = 1000 for i in range(1,n): if a[i-1] < a[i]: money = money%a[i-1]+a[i]*(money//a[i-1]) print(money)
p02678
s651425721
Accepted
N,M=map(int,input().split()) G=[] for i in range(0,N): G.append([]) for i in range(0,M): a,b=map(int,input().split()) a-=1 b-=1 G[a].append(b) G[b].append(a) q=[] sign=[-1]*N sign[0]=0 q.append(0) while q: x=q.pop(0) for nv in G[x]: if sign[nv]==-1: sign[nv]=x q.append(nv) print("Yes") for i in range(1,N): print(sign[i]+1)
p02663
s305974542
Accepted
a,b,c,d,k = map(int,input().split()) h = c-a mn = d-b time = h*60+mn ans = time-k print(ans)