problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02918
s257888642
Accepted
N,K = map(int,input().split()) S = list(input()) ans = 0 k = 0 c = 0 for i in range(N-1): if S[i] != S[i+1]: if c < K: if k == 0: k += 1 else: ans += 2 c += 1 k = 0 else: ans += 1 if k == 1 and c < K: ans += 1 print(ans)
p04043
s922444808
Wrong Answer
word = list(input()) #print(word) ['5', '5', '7'] a=0 b=0 for i in range(3): if word[i]==str(5): a=a+1 for i in range(3): if word[i]==str(7): b=b+1 if a==2 and b==1: print("YES") else: print("NO")
p03639
s658587121
Accepted
N = int(input()) A = list(map(int, input().split())) num_four = 0 num_two = 0 num_odd = 0 for i in range(N): if A[i] % 4 == 0: num_four += 1 elif A[i] % 2 == 0: num_two += 1 else: num_odd += 1 # print(num_four, num_two, num_odd) if num_two != 0: ans = 'Yes' if num_four + 1 >= num_odd + 1 else 'No' else: ans = 'Yes' if num_four + 1 >= num_odd else 'No' print(ans)
p03971
s931383808
Accepted
n,a,b = map(int , input().split()) s = input() Judgment = 0 rank = 0 overseas=0 for num in range(n): if s[num] == 'a' and rank < a+b: print('Yes') rank = rank+1 elif s[num] == 'b' and rank < a+b and overseas < b: print('Yes') rank = rank +1 overseas = overseas + 1 else: print('No')
p02772
s883052979
Accepted
N = int(input()) doc = [int(x) for x in input().split() if int(x) % 2 == 0] for i in doc: if i % 3 != 0 and i % 5 != 0: print('DENIED') exit() print('APPROVED')
p03038
s766783628
Accepted
import sys import heapq input = sys.stdin.readline n,m = map(int, input().split()) A = list(map(int,input().split())) d = [list(map(int,input().split())) for _ in range(m)] d.sort(key=lambda x:-x[1]) total = sum(A) heapq.heapify(A) for i in range(m): for j in range(d[i][0]): tmp = heapq.heappushpop(A, d[i][1]) if tmp < d[i][1]: total += (d[i][1] - tmp) else: break print(total)
p03711
s272032765
Accepted
x,y=input().split() a={"1","3","5","7","8","10","12"} b={"4","6","9","11"} print("Yes" if {x,y}<=a or {x,y}<=b else "No")
p02909
s573296856
Accepted
#python3 from itertools import cycle def main(): s = input() if s == 'Sunny': print('Cloudy') elif s == 'Cloudy': print('Rainy') else: print('Sunny') main()
p03324
s738117968
Accepted
[D,N] = list(map(int,input().split())) if N!=100: print(100**D*N) else: print(100**D*(N+1))
p02802
s732914461
Wrong Answer
N,M=map(int,input().split()) wa=0 ac=0 already=[] for i in range(M): P,S=input().split() if S=="WA" and already.count(P)==0: wa=wa+1 if S=="AC" and already.count(P)==0: ac=ac+1 already.append(P) else: pass if ac==0: print(0,0) else: print(ac,wa)
p03035
s175648573
Accepted
A, B = map(int,input().split()) if A >= 13: print(B) elif A >= 6: print(B // 2) else: print(0)
p03478
s449013590
Wrong Answer
n, a, b = map(int, input().split()) i = 1 count = 0 for i in range(n+1): if(a <= i and b >= i): count += 1 print(count)
p02754
s453098849
Accepted
N ,A ,B = map(int,input().split()) r = N % (A + B) Q = N // (A + B) ans = (Q * A + min(r,A)) print(ans)
p03438
s836666469
Accepted
N = int(input()) a_list = list(map(int, input().split())) b_list = list(map(int, input().split())) margin = 0 # b側で加算可能な回数 for a,b in zip(a_list, b_list): if a == b: continue elif a < b: margin -= (b-a)//2 else: margin += a-b if margin <= 0: print('Yes') else: print('No')
p03711
s621646716
Accepted
x, y = map(int, input().split()) g = [set([1, 3, 5, 7, 8, 10, 12]), set([4, 6, 9, 11]), set([2])] for s in g: if x in s and y in s: print('Yes') break else: print('No')
p02823
s964352952
Accepted
n,a,b = map(int,input().split()) if (b-a)%2==0: print(int((b-a)//2)) else: print(int(min(a-1,n-b)+1+(b-1-a)//2))
p02700
s303443452
Wrong Answer
A, B, C, D = list(map(int, input().split())) while True: if A - D <= 0: print('No') break else: print('Yes') break
p03767
s342333864
Accepted
n = int(input()) a = [int(i) for i in input().split()] a.sort(reverse=True) ans = 0 for i in range(n): ans += a[i*2+1] print(ans)
p03379
s071361282
Wrong Answer
N = int(input()) X = list(map(int, input().split())) X = sorted(X) # print('X', X) # print('median candidate', X[N // 2 - 1], X[N // 2]) for i in X: if i <= X[N // 2 - 1]: print(X[N // 2]) else: print(X[N // 2 - 1])
p03986
s472536811
Accepted
x = input() cs = 0 ct = 0 prev = "" n = len(x) cnt = 0 for i in range(n): if x[i] =="S": cs+=1 elif x[i] =="T": if cs>0: ct+=1 else: cs = 0 ct = 0 if cs>0 and ct>0: cnt+=1 cs-=1 ct-=1 print(n-cnt*2)
p03013
s860736840
Wrong Answer
n, m = map(int, input().split()) a = [int(input()) for _ in range(m)] mod = 10**9 + 7 def check(arr): for i in range(m-1): if a[i] + 1 == a[i+1]: return 0 dp = [0 for _ in range(n+1)] dp[0] = 0 dp[1] = 1 for i in range(2, n+1): if i in a: continue dp[i] += dp[i-1] + dp[i-2] dp[i] %= mod #print(dp) return dp[n] print(check(n))
p02628
s608551885
Accepted
n,k = map(int,input().split()) p = list(map(int,input().split())) p.sort() ans = 0 for i in range(k): ans += p[i] print(ans)
p03657
s732786415
Accepted
# A,B,A+Bのいずれかが3の倍数になるか A, B = map(int, input().split()) if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 ==0: print('Possible') else: print('Impossible')
p02972
s418894122
Accepted
N = int(input()) a = list(map(int, input().split())) b = [0] * (N + 1) for i in range(N, 0, -1): if sum(b[::i]) % 2 != a[i-1]: b[i] = 1 s = sum(b) print(sum(b)) if s != 0: for i in range(N+1): if b[i] == 1: print(i, end=" ")
p03760
s500102598
Wrong Answer
o=input() e=input() print("".join([o[i]+e[i] for i in range(len(o)-1)]),end="") print(o[-1],end="") if len(o) != len(e): print(e[-1])
p02861
s889976988
Accepted
from itertools import permutations from math import sqrt def dist(A,B): p=A[0]-B[0] q=A[1]-B[1] return sqrt(p*p+q*q) def f(n): if n==0: return 1 return f(n-1)*n N=int(input()) P=[] for _ in range(N): x,y=map(int,input().split()) P.append((x,y)) T=permutations(P,N) D=0 for H in T: S=0 for k in range(N-1): S+=dist(H[k],H[k+1]) D+=S print(D/f(N))
p04030
s561384051
Accepted
s = list(input()) n = len(s) ans = [] for i in range(n): if s[i] == '0': ans.append('0') if s[i] == '1': ans.append('1') if s[i] == 'B': if ans: ans.pop() print("".join(ans))
p03632
s254553397
Accepted
a, b, c, d = map(int, input().split()) ans = 0 if b <= c or d <= a: ans = 0 else: ans = min(d, b) - max(a, c) print(ans)
p03698
s287746914
Accepted
# coding: utf-8 S=list(input()) if len(S)==len(set(S)): print("yes") else: print("no")
p02690
s937599987
Wrong Answer
x=int(input()) for a in range(x,0,-1): b=(a**5-x) if b<0: b=-(round(abs(b)**(1/5),7)) if b.is_integer(): b=int(b) print("{} {}".format(a,b)) exit() else: b=(round(abs(b)**(1/5),7)) if b.is_integer(): b=int(b) print("{} {}".format(a,b)) exit()
p03625
s657515933
Accepted
n = int(input()) a = list(map(int,input().strip().split())) import collections c = sorted(collections.Counter(a).items(), reverse=True) leng_1 = 0 for leng,count in c: if count >=4: if leng_1 != 0: print(leng_1 * leng) exit() else: print(leng**2) exit() elif count >=2: if leng_1 != 0: print(leng_1*leng) exit() else: leng_1 = leng print(0)
p03543
s695358667
Accepted
N = input() if (N[0] == N[1] == N[2]) or (N[1] == N[2] == N[3]): print('Yes') else: print('No')
p02683
s992195058
Accepted
import numpy as np def dfs(n,a,s): if n==0: return -1 if (a >= X).all()==False else s #print(a+A[n-1]) x=dfs(n-1,a+A[n-1],s+C[n-1]) y=dfs(n-1,a,s) return y if x==-1 else x if y==-1 else min(x,y) N,M,X=map(int,input().split()) C=[] A=[] for i in range(N): c,*tmp=map(int,input().split()) A.append(np.array(tmp)) C.append(c) #print(A) print(dfs(N,np.array([0]*M),0))
p03639
s311512055
Accepted
n = int(input()) a = list(map(int,input().split())) ju = 0 for i in range(n): if(a[i]%4==0): ju +=1 elif(a[i]%2!=0): ju -= 1 if(n%2==1): ju += 1 if(ju>=0): print("Yes") else: print("No")
p03815
s551635958
Wrong Answer
x=int(input()) ans=(x//11)*2 x%=11 if 0<x<=6: ans+=1 else: ans+=2 print(ans)
p02661
s299490976
Wrong Answer
n = int(input()) a = [] b = [] for _ in range(n): atmp, btmp = map(int, input().split()) a.append(atmp) b.append(btmp) a.sort() b.sort() if n % 2 == 1: pos = n // 2 print(b[pos] - a[pos] + 1) else: pos = n // 2 - 1 a1 = a[pos] a2 = a[pos + 1] b1 = b[pos] b2 = b[pos + 1] medmin = b1 + a1 medmax = b2 + a2 print(medmax - medmin + 1)
p02696
s972579040
Wrong Answer
from math import floor a, b, n = [int(x) for x in input().split()] for x in range(0, n+1): value = floor(a*x/b) - a * floor(x/b) print(value)
p03150
s762697436
Accepted
S=input() ans='NO' # print(S.find('k')) if S.find('k')==0 and S.rfind('eyence')==len(S)-6: ans='YES' elif S.find('ke')==0 and S.rfind('yence')==len(S)-5: ans='YES' elif S.find('key')==0 and S.rfind('ence')==len(S)-4: ans='YES' elif S.find('keye')==0 and S.rfind('nce')==len(S)-3: ans='YES' elif S.find('keyen')==0 and S.rfind('ce')==len(S)-2: ans='YES' elif S.find('keyenc')==0 and S.rfind('e')==len(S)-1: ans='YES' print(ans)
p03038
s161079583
Accepted
from operator import itemgetter N, M = list(map(int, input().split())) A = [[1, a] for a in list(map(int, input().split()))] BC = [list(map(int, input().split())) for i in range(M)] q = sorted(A+BC, key=itemgetter(1), reverse=True) ans = 0 i = 0 while N: n = min(q[i][0], N) ans += q[i][1] * n N -= n i += 1 print(ans)
p03419
s981000850
Accepted
N, M = map(int, input().split()) # 偶数回裏返す->表 # 奇数回裏返す->裏 # 四隅->4回->表 # 四隅以外の外枠->6回->表 # 内側->9回->裏 # 1マスの場合 if N == 1 and M == 1: print(1) exit(0) # 1行又は1列の場合->両端以外 if N == 1 or M == 1: print(max(N, M)-2) exit(0) # 内側のカードの枚数を求める print((N-2)*(M-2))
p03359
s450077005
Accepted
a, b = map(int, input().split()) if b >= a: print(a) else: print(a-1)
p03495
s026982380
Accepted
from collections import Counter n, k = map(int, input().split()) a = [int(an) for an in input().split()] ans = 0 set_a = set(a) num_of_types = len(set_a) if num_of_types > k: cnt = Counter(a) ans = sum(sorted(cnt.values())[: num_of_types - k]) print(ans)
p03250
s255841668
Accepted
a,b,c=sorted(map(int,input().split())) print(a+c*10+b)
p02719
s054321329
Accepted
N,K=map(int,input().split()) if N%K != 0: if abs(K-N%K)<N: print(K-N%K) else: print(N) else: print(0)
p03557
s136310550
Accepted
from bisect import ( bisect_left, bisect_right ) def main(): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() c.sort() ans = 0 for target in b: ans += bisect_left(a, target) * (len(c) - bisect_right(c, target)) print(ans) main()
p03038
s398861890
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) d = [] for i in A: d.append((i, 1)) for i in range(M): B, C = map(int, input().split()) d.append((C, B)) d.sort() d.reverse() i = 0 ans = 0 for j, k in d: if i + k >= N: ans += j * (N - i) break i += k ans += j * k print(ans)
p04019
s887888991
Wrong Answer
S = input() print("Yes" if any([all(["N" in S, "S" in S]), all(["W" in S, "E" in S])]) else "No")
p02712
s026264388
Accepted
N = int(input()) a = [] for i in range(1, N + 1): if i % 3 == 0 or i % 5 == 0: pass else: a.append(i) print(sum(a))
p03481
s380780749
Accepted
x, y = map(int, input().split()) i = 0 while x * (2 ** i) <= y: i += 1 print(i)
p02690
s324204681
Wrong Answer
def main(): N = int(input()) for a in range(0, 101, 1): for b in range(-101, a+1, 1): val = a**5 - b**5 if(val == N): print(str(a) + " " + str(b)) return if __name__ == "__main__": main()
p03817
s945691342
Accepted
X = int(input()) div11 , mod = divmod(X,11) div6, mod = divmod(mod,6) num = 1 if mod > 0 else 0 ans = div11 * 2 + div6 + num print(ans)
p02720
s948827965
Accepted
k=int(input()) from collections import deque cnt=1 q=deque([1,2,3,4,5,6,7,8,9]) while cnt<k: tmp=q.popleft() if tmp%10!=0: q.append(tmp*10+tmp%10-1) q.append(tmp*10+tmp%10) if tmp%10!=9: q.append(tmp*10+tmp%10+1) cnt+=1 print(q.popleft())
p02972
s087998431
Wrong Answer
#134_D n=int(input()) a=[0]+list(map(int,input().split())) b=[0 for _ in range(n+1)] for i in range(n,0,-1): if i<=n//2: b[i]=a[i] else: b[i]=sum([a[k] for k in range(2*i,n,i)]) print(sum(b)) if sum(b)>0: ans=[] for i in range(1,n+1): if b[i]==1: ans.append(i) print(*ans)
p02577
s697386809
Accepted
num = str(input()) s = 0 for i in num: s+=int(i) if(s%9==0): print("Yes") else: print("No")
p03360
s179494567
Wrong Answer
def main(): a, b, c = map(int, input().split()) k = int(input()) abc = [a, b, c] ma = max(a, b, c) ans = 0 for num in abc: if num == ma: for i in range(k): num *= 2 ans += num else: ans += num print(ans) if __name__ == "__main__": main()
p03943
s851737784
Accepted
a, b, c = map(int, input().split()) if a == b + c: print('Yes') elif b == a + c: print('Yes') elif c == a + b: print('Yes') else: print('No')
p02602
s242396153
Accepted
N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(K, N): if A[i] > A[i - K]: print('Yes') else: print('No')
p03103
s653332577
Wrong Answer
n,m=list(map(int,input().split())) d={} for _ in range(n): a, b = list(map(int, input().split())) d[a]=b sd=dict(sorted(d.items())) result=0 ans=0 for i in sd: for j in range(sd[i]): ans+=i result+=1 if result == m: print(ans) exit()
p03774
s568114372
Wrong Answer
n,m=map(int,input().split()) ab=[list(map(int, input().split())) for i in range(n)] cd=[list(map(int, input().split())) for j in range(m)] for i in range(n): l=[] for j in range(m): dist=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]) l.append(dist) print(l) goal = l.index(min(l))+1 print(goal)
p02946
s455199365
Accepted
import sys sys.setrecursionlimit(10**6) k, x = map(int, input().split()) start = x+1-k end = x+k ans = [i for i in range(start, end)] print(*ans)
p04029
s762080873
Accepted
n=int(input()) sum=0 for i in range(n): sum+=(i+1) print(sum)
p02553
s089603176
Wrong Answer
a,b,c,d=input().split() if int(a)<0 and int(c)<0: if int(a)*int(c)<int(b)*int(d): print(int(b)*int(d)) else: print(int(a)*int(c)) elif int(a)<0: print(int(b)*int(d)) elif int(c)<0: print(int(b)*int(d)) elif int(a)>0 and int(c)>0: print(int(b)*int(d)) elif int(a)<0 and int(b)<0: print(int(b)*int(c)) elif int(c)<0 and int(d)<0: print(int(a)*int(d))
p03331
s149210819
Accepted
n=int(input()) ans=10**5 for a in range(1,n): b=n-a aa=list(str(a)) bb=list(str(b)) tmp=0 for k in (aa+bb): tmp+=int(k) ans=min(ans,tmp) print(ans)
p03681
s805351177
Accepted
n, m = map(int, input().split()) inf = 10**9+7 ans = 0 if abs(n-m) >= 2: pass else: ans = 1 for i in range(1, n+1): ans *= i ans %= inf for i in range(1, m+1): ans *= i ans %= inf if n == m: ans *= 2 ans %= inf print(ans)
p03971
s884371177
Accepted
N,A,B = map(int,input().split()) S = input() total = 0 b = 0 answer = [] for s in S: bl = False if s == 'a': if total < A+B: bl = True total += 1 elif s == 'b': if total < A+B and b < B: bl = True total += 1 b += 1 answer.append('Yes' if bl else 'No') print(*answer, sep='\n')
p02682
s989185540
Wrong Answer
a,b,c,k = map(int,input().split()) if a+b>=k: print(a) else: print(a-(k-a))
p02818
s175877237
Accepted
taka, aoki, num = map(int, input().split()) if taka <= num: num -= taka taka = 0 if aoki <= num: aoki = 0 print(taka, aoki) elif aoki > num: aoki -= num print(taka, aoki) if taka > num: taka -= num print(taka, aoki)
p02761
s653039018
Wrong Answer
n, m = map(int, input().split()) scList = [list(map(int, input().split())) for _ in range(m)] num = ["-" for _ in range(n)] flag = True for i in range(m): s = scList[i][0] - 1 c = scList[i][1] if (num[s] != "-" and num[s] != str(c)) or (s == 0 and c == 0): flag = False break num[s] = str(c) if not flag: print("-1") else: ans = "".join(num) ans = ans.replace("-", "0") if ans[0] == "0": ans = "1" + ans[1:] print(ans)
p03161
s203272585
Accepted
def chmin(a, b): if a > b: return b else: return a N, K = map(int, input().split()) h = list(map(int, input().split())) dp = [float("inf")]*N dp[0] = 0 for i in range(N - 1): #ジャンプ地点 for j in range(1, min(K + 1, N - i)): #ジャンプ距離 dp[i+j] = chmin(dp[i + j], dp[i] + abs(h[i + j] - h[i])) print(dp[N - 1])
p03548
s338943699
Wrong Answer
x, y, z = map(int, input().split()) n = z cnt = 0 while n <= x: n += y + z cnt += 1 print(cnt)
p03285
s972838145
Accepted
n = int(input()) a = 25 b = 15 cnt = 0 for i in range(a + 1): for j in range(b + 1): if 4*i + 7*j == n: cnt += 1 if cnt >= 1: print('Yes') else: print('No')
p03827
s707229557
Accepted
N=int(input()) S=str(input()) x,ans=0,0 for i in range(N): if S[i]=="I": x+=1 elif S[i]=="D": x-=1 if ans<x: ans=x print(ans)
p03557
s848676501
Wrong Answer
from bisect import bisect_right N = int(input()) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans = 0 for c in C: i = bisect_right(B, c) for b in B[:i]: j = bisect_right(A, b) ans += j print(ans)
p02996
s438337797
Accepted
n = int(input()) b = [] for i in range(n): x,y = map(int,input().split()) b.append([y,x]) b.sort() ans = 'Yes' t = 0 for i in range(n): t += b[i][1] if t>b[i][0]: ans='No' print(ans)
p02879
s509439233
Accepted
a, b= map(int, input().split()) if 1 <= a <= 9 and 1 <= b <= 9: print(a * b) else: print(-1)
p03838
s877929710
Accepted
x, y = map(int, input().split()) ans = 0 if x >= 0 and y >= 0: if y >= x: ans = y - x else: ans = abs(y-x) + 2 elif x >= 0 and y < 0: ans = abs(abs(y)-abs(x)) + 1 elif x < 0 and y >= 0: ans = abs(abs(y)-abs(x)) + 1 else: if y >= x: ans = abs(y-x) else: ans = abs(y-x) + 2 if y == 0: ans -= 1 print(ans)
p02818
s773917149
Accepted
a,b,c=map(int,input().split()) aa=max(0,a-c) print(aa,max(0,a+b-aa-c))
p02784
s970759839
Wrong Answer
h, n = map(int, input().split()) an = list(map(int, input().split())) if sum(an) > h: print('No') else: print('Yes')
p02765
s035645933
Wrong Answer
[n, r] = map(int, input().rstrip().split(' ')) if n > 10: print(r) else: print(r - 100 * (10 - n))
p03208
s218439878
Wrong Answer
N,K=map(int,input().split()) t=[0]*N for i in range(N): t[i]=int(input()) t.sort(key=int) ans=10**5 for i in range(N-K+1): ans=min(ans,t[i+K-1]-t[i]) print(ans)
p03612
s895192723
Wrong Answer
n = int(input()) p = list(map(int,input().split())) count = 0 for i in range(n-1): if p[i] == i+1: tmp = p[i] p[i] = p[i+1] p[i+1] = tmp count += 1 print(count)
p03557
s477191975
Accepted
import bisect n=int(input()) A=sorted(list(map(int,input().split()))) B=list(map(int,input().split())) C=sorted(list(map(int,input().split()))) lc=len(C) ans=0 for b in B: ma = bisect.bisect_left(A, b) mc = lc-bisect.bisect_right(C, b) ans += ma*mc print(ans)
p02597
s787741007
Wrong Answer
n = int(input()) c = input() wc = c.count('W') rc = c.count('R') print(min(c[:rc].count('W'), c[wc:].count('R')))
p03861
s257448798
Wrong Answer
def resolve(): a, b, x = map(int, input().split()) count = culc(b, x) - culc(a, x) if a % 2 == 0 and b % 2 == 0: count += 1 print(count) def culc(num, x): if num == 0: return -1 else: return num // x + 1 if __name__ == '__main__': resolve()
p03274
s533382098
Wrong Answer
n,k = map(int,input().split()) s = list(map(int,input().split())) if k == 1 and 0 in s: print(0) exit() if (n-k)<=1: print(abs(s[0]-s[-1])+min(abs(s[0]),abs(s[-1]))) exit() a = 10**9 for i in range(n-k): m = abs(s[i]-s[i+k-1])+min(abs(s[i]),abs(s[i+k-1])) if m<a: #print(s[i],s[i+k-1]) a=m print(a)
p03611
s241135544
Accepted
n = int(input()) a = list(map(int,input().split())) b = [] for i in range(n): b += [a[i],a[i]+1,a[i]-1] import collections c = collections.Counter(b) print(c.most_common()[0][1])
p02712
s819013532
Accepted
n = int(input()) ans = 0 for i in range(1, n+1): if (i % 3) == 0: continue if (i % 5) == 0: continue ans += i print(ans)
p02595
s897342192
Accepted
import math n,d=map(int,input().split()) cnt=0 for i in range(n): x,y = map(int,input().split()) sq = (x**2) + (y**2) res = math.sqrt(sq) if res<=d: cnt=cnt+1 print(cnt)
p03345
s598028511
Accepted
A,B,C,K = map(int,input().split()) limit = 10 ** 18 if K % 2 == 0: ans = (A - B) else: ans = (B - A) if ans < limit: print(ans) else: print("Unfair")
p03696
s143863356
Accepted
N = int(input()) S = input() l, r = 0, 0 for s in S: if s == '(': r += 1 else: if r > 0: r -= 1 else: l += 1 print('(' * l + S + ')' * r)
p03011
s343301072
Wrong Answer
linha = input() menor = 101 segundoMenor = 101 for x in linha.split(): if int(x) < menor: menor = int(x) for x in linha.split(): if int(x) == menor: pass elif int(x) < segundoMenor: segundoMenor = int(x) print(menor + segundoMenor)
p04043
s855274926
Accepted
a = map(int,input().split()) list_a = list(a) list_a.sort() if list_a == [5, 5, 7]: print("YES") else: print("NO")
p03680
s159025837
Accepted
n = int(input()) a = [int(input()) for _ in range(n)] if 2 not in a: print(-1) quit() else: t = a.index(2) s = 1 count = 0 while count <= 10**6: s = a[s-1] count += 1 if s == 2: print(count) quit() print(-1)
p03971
s433717312
Accepted
N,A,B=map(int,input().split()) S=input() passer=0 passb=0 for p in S: if p =="c": print("No") if p=="a": if passer < A+B: print("Yes") passer+=1 else: print("No") if p=="b": if passer <A+B and passb <B: print("Yes") passer+=1 passb+=1 else: print("No")
p02963
s636227061
Accepted
import sys import math read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): S = int(input()) x1 = math.ceil(S ** 0.5) x2 = x1 ** 2 - S print(0, 0, x1, 1, x2, x1) if __name__ == '__main__': main()
p02547
s118300528
Wrong Answer
# -*- coding: utf-8 -*- a = int(input()) xy = [map(int, input().split()) for _ in range(a)] x, y = [list(i) for i in zip(*xy)] flag = 0 for i in range(a): if (x[i] == y[i]): flag = flag+1 else: flag = 0 if flag >= 3: print("Yes") else: print("No")
p03309
s298106798
Wrong Answer
import sys import math def input(): return sys.stdin.readline()[:-1] def mi(): return map(int, input().split()) def ii(): return int(input()) def main(): N = ii() A = list(mi()) s = sum(A[i]-i-1 for i in range(N))/N print(sum(abs(A[i]-i-1-math.floor(s)) for i in range(N))) if __name__ == '__main__': main()
p03971
s433356716
Accepted
n, a, b = map(int,input().split()) s_list = list(input()) judge=[] count_tot = 0 count_inter = 0 for s in s_list: if s == 'a': if count_tot < a+b: judge.append('Yes') count_tot += 1 continue elif s == 'b': if count_tot < a+b and count_inter < b: judge.append('Yes') count_tot += 1 count_inter += 1 continue judge.append('No') for result in judge: print(result)
p03471
s888292300
Accepted
N, Y = map(int,input().split()) x, y, z = -1, -1, -1 k = 0 for i in range(N+1): for j in range(0,N-i+1): k = N - i - j if 10000*i + 5000*j + 1000*k == Y : x, y, z = i, j, k break print(x, y, z)
p03633
s937223964
Accepted
N = int(input()) S = [] for _ in range(N): S.append(int(input())) import fractions def lcm(x, y): return (x * y) // fractions.gcd(x, y) result=1 for num in S: result = lcm(result,num) print(result)