problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03680
s062291883
Accepted
n = int(input()) al = [int(input()) for _ in range(n)] pos = 0 for i in range(n): pos = al[pos] - 1 if (pos == 1): print(i+1) exit() print(-1)
p03481
s026397945
Wrong Answer
X,Y = map(int,input().split()) a = 1 x = X mul = min(X,2) cnt = 1 for i in range(10000): x *= mul if x>=Y: cnt+=i break print(cnt)
p03438
s267858993
Accepted
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt1 = 0 cnt2 = 0 for i in range(n): if a[i] > b[i]: cnt1 += a[i] - b[i] elif a[i] < b[i]: cnt2 += -(-(b[i] - a[i]) // 2) if (b[i] - a[i]) % 2 == 1: cnt1 += 1 if cnt1 <= cnt2: print("Yes") else: print("No")
p03106
s700704084
Accepted
a, b, k = list(map(int, input().split())) l = [] for i in range(100): if a%(i+1) == 0 and b%(i+1) == 0: l.append(i+1) print(l[-(k)])
p02909
s890410129
Accepted
S = input() if S == "Sunny": print("Cloudy") elif S == "Cloudy": print("Rainy") else: print("Sunny")
p02675
s575310150
Accepted
n = int(input()) a = n % 10 if (a == 3): print("bon") elif (a == 2 or a == 4 or a == 5 or a == 7 or a == 9) : print("hon") else: print("pon")
p04020
s100156892
Accepted
n = int(input()) A = [int(input()) for _ in range(n)] ans = 0 for i in range(n-1): p,r = divmod(A[i], 2) A[i] = r ans += p if A[i]*A[i+1]: A[i+1] -= 1 ans += 1 print(ans+A[-1]//2)
p02630
s790852912
Wrong Answer
N = int(input()) A = list(map(int, input().split())) Q = int(input()) B = [list(map(int,input().split())) for i in range(Q)] for i in B: for j in range(len(A)): if A[j] > i[0]: break if A[j] == i[0]: A[j] = i[1] print(sum(A))
p03795
s458922201
Accepted
n = int(input()) bonus = n % 15 bonus = (n - bonus) / 15 bonus = round(bonus) print((n * 800) - (bonus * 200))
p03061
s056368054
Accepted
from fractions import gcd n = int(input()) a = list(map(int, input().split())) sf = [a[0]] * n for i in range(1, n): sf[i] = gcd(sf[i - 1], a[i]) sb = [a[n - 1]] * n for i in range(n - 2, -1, -1): sb[i] = gcd(sb[i + 1], a[i]) ans = 1 for i in range(n): if i == 0: ans = max(ans, sb[1]) elif i == n - 1: ans = max(ans, sf[n - 2]) else: ans = max(ans, gcd(sf[i - 1], sb[i + 1])) print(ans)
p03472
s962559157
Wrong Answer
N,H = map(int,input().split()) A=[] B=[] for i in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) maxA = max(A) B.sort(reverse=True) #(時間軸後ろから考えて)攻撃力がでかい方から投げつけ。 # 残りHP/maxA の切り上げ nage = 0 ans = (H+maxA-1)//maxA#投げなし for i in range(N): nage+=B[i] ans = min(ans, (i+1) + (H-nage+maxA-1)//maxA) print(ans)
p03106
s508320314
Accepted
a,b,k = map(int,input().split()) m = [] for i in range(min(a,b),0,-1): if a%i == 0 and b%i == 0: m.append(i) print(m[k-1])
p03836
s213062959
Accepted
sx, sy, tx, ty = map(int, input().split()) x = tx - sx y = ty - sy ans = 'U'*y + 'R'*x ans += 'D'*y + 'L'*x ans += 'L' + 'U'*(y+1) + 'R'*(x+1) + 'D' ans += 'R' + 'D'*(y+1) + 'L'*(x+1) + 'U' print(ans)
p02988
s168389344
Accepted
def main(): n = int(input()) P = list(map(int, input().split())) count = 0 p1 = P[0] p2 = P[1] for i in range(2, n): p3 = P[i] if p1 < p2 < p3 or p1 > p2 > p3: count += 1 p1 = p2 p2 = p3 print(count) main()
p02601
s342917510
Accepted
A, B, C = [int(s) for s in input().split()] K = int(input()) i = 0 while B <= A: B = 2 * B i += 1 j = 0 while C <= B: C = 2 * C j += 1 if i + j <= K: print('Yes') else: print('No')
p02730
s913653158
Wrong Answer
import math s = input() n = len(s) zen_c = 0 kou_c = 0 z = math.floor((n-1)/2) k = math.floor((n+2)/2) zenhan = s[0:z] kouhan = s[k:n] zen_l = len(zenhan)-1 kou_l = len(kouhan)-1 for i in range(0, zen_l): if zenhan[i] == zenhan[zen_l-i] and i != (zen_l-i): zen_c = 1 for i in range(0, kou_l): if kouhan[i] == kouhan[kou_l-i]: kou_c = 1 if zenhan == kouhan: print('Yes' if zen_c == 1 and kou_c == 1 else 'No') else: print('No')
p02748
s645332682
Accepted
[a,b,m] = [int(i) for i in input().split()] a_p = [int(i) for i in input().split()] b_p = [int(i) for i in input().split()] ans = 10**9+7 for i in range(m): [x,y,c] = [int(i) for i in input().split()] tmp = a_p[x-1] + b_p[y-1] - c if tmp < ans: ans = tmp print(min(ans,min(a_p)+min(b_p)))
p02682
s484426965
Accepted
A, B, C, K = map(int, input().split()) S = min(A, K) - max(0, K-A-B) print(S)
p03001
s332663323
Accepted
w,h,x,y=map(int,input().split()) if 2*x==w and 2*y==h: a=1 else: a=0 print(w*h/2,a)
p03137
s380897944
Accepted
n, m = map(int, input().split()) list_X = list(map(int, input().split())) list_X.sort() list_Y = [] for i in range(m-1): list_Y.append(list_X[i+1]-list_X[i]) list_Y.sort() if n >= m: print(0) else: print(sum(list_Y[:m-n]))
p03994
s544901186
Wrong Answer
s = input() k = int(input()) l = [26 - (ord(c) - ord('a')) % 26 for c in s] for i in range(len(s) - 1): if k >= l[i]: k -= l[i] s = s[:i] + 'a' + s[i + 1 :] k %= 26 s = s[:-1] + chr(ord('a') + (ord(s[-1]) - ord('a') + k) % 26) print(s)
p02729
s912651814
Accepted
N,M = map(int,input().split()) print(N*(N-1)//2+M*(M-1)//2)
p02553
s470751956
Accepted
a, b, c, d = map(int, input().split()) result = a*c result = max(result, a*d) result = max(result, b*c) result = max(result, b*d) print(result)
p03131
s812344894
Wrong Answer
K,A,B=map(int,input().split()) bis=1 if K==1: bis+=1 elif A>=B-1 or K-A+1<=0: bis+=K else: if (K-(A-1))%2==0: bis=A+(B-A)*(K-(A-1))//2 else: bis=A+(B-A)*(K-(A-1))//2+1 print(int(bis))
p03250
s909268636
Accepted
a = list(map(int,input().split())) ans = int(1e10) a.sort() print(a[0] + a[1] + 10*a[2])
p03774
s448395458
Wrong Answer
n, m = map(int, input().split()) a, b, c, d = [0] * n, [0] * n, [0] * m, [0] * m for i in range(n): a[i], b[i] = map(int, input().split()) for i in range(m): c[i], d[i] = map(int, input().split()) for i in range(n): min_dist, min_c = abs(a[0]-c[0]) + abs(b[0]-d[0]), 0 for j in range(m): dist = abs(a[i]-c[j]) + abs(b[i]-d[j]) if dist < min_dist: min_dist = dist min_c = j print(min_c+1)
p03061
s131177622
Accepted
from math import gcd #================================================ N=int(input()) A=list(map(int,input().split())) F=[0]*N G=[0]*N F[0]=A[0] G[-1]=A[-1] for i in range(1,N): F[i]=gcd(F[i-1],A[i]) G[-(i+1)]=gcd(G[-i],A[-(i+1)]) F=[0]+F+[F[-1]] G=[G[0]]+G+[0] M=0 for i in range(N): M=max(M,gcd(F[i],G[i+2])) print(M)
p03030
s293794103
Wrong Answer
N = int(input()) SP = [] for _ in range(N): S,P = input().split() SP.append([S,-int(P)]) sort_SP = sorted(SP) for i in SP: print(sort_SP.index(i)+1)
p02820
s192268393
Accepted
n, k = map(int, input().split()) r, s, p = map(int, input().split()) t = input() ret = 0 for i in range(k): last = 'x' for c in t[i::k]: if last != c: ret += p if c == 'r' else r if c == 's' else s last = c else: last = 'x' print(ret)
p03861
s665730945
Accepted
a, b, x = map(int, input().split()) print(b//x - a//x + (a%x == 0))
p03673
s835539387
Accepted
n = int(input()) a = list(map(int, input().split())) s = [a[i] for i in range(0,n,2)] t = [a[i] for i in range(1,n,2)[::-1]] if n % 2 == 0: print(*t, end=' ') print(*s) else: # print(s,t) print(*s[::-1], end=' ') print(*t[::-1])
p02939
s750091850
Accepted
S = input() ans = ["-1"] t = "" for c in S: t += c if t != ans[-1]: ans.append(t) t = "" print(len(ans)-1)
p03971
s509991100
Accepted
n,a,b=map(int,input().split()) ca,cb=0,0 s=input() for i in range(n): if s[i]=="a": if ca<a+b: print("Yes") ca+=1 else: print("No") elif s[i]=="b": if ca<a+b and cb<b: print("Yes") ca+=1;cb+=1 else: print("No") else: print("No")
p02665
s904220051
Accepted
from itertools import accumulate N, *A = map(int, open(0).read().split()) S = list(accumulate(A)) ans = 1 cur = 1 for a, s in zip(A, S): if (cur := min(2 * (cur - a), S[-1] - s)) < 0: print(-1) quit() ans += cur print(ans)
p02687
s702942168
Accepted
#!/usr/bin/env python3 import sys def solve(S: str): print("ABC" if S == "ARC" else "ARC") return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() S = next(tokens) # type: str solve(S) if __name__ == '__main__': main()
p03814
s615052057
Accepted
s = str(input()) for i in range(len(s)): if s[i] == "A": start = i + 1 break for j in range(len(s)): if s[j] == "Z": end = j + 1 print(end - start + 1)
p02597
s125423828
Accepted
n = int(input()) c = list(input()) r_cnt = c.count('R') w_cnt = c.count('W') cnt = 0 for i in range(r_cnt): if c[i] == 'R': continue else: cnt += 1 print(cnt)
p03456
s809033569
Accepted
a, b =input().split() s = int(a + b) ans = 'No' for i in range(317): if i ** 2 == s: ans = 'Yes' break print(ans)
p03544
s876488511
Wrong Answer
import sys import math import itertools n = int(input()) l0=2 l1 = 1 l = l0 + l1 for i in range(n-2): l0 = l1 l1 = l l = l0 + l1 print(l)
p03545
s047976349
Accepted
l = list(input()) for i in range(8): s = int(l[0]) b = bin(i)[2:].zfill(3) op = ["", "", ""] for j in range(len(b)): if b[j] == "0": s += int(l[j+1]) op[j] = "+" else: s -= int(l[j+1]) op[j] = "-" if s == 7: print(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]+"=7") break
p02935
s073263652
Wrong Answer
n=int(input()) lst=list(map(int, input().split())) ''' lst=sorted(lst, reverse=True) new=[lst[i]*(1/2)**(i+1) for i in range(n-1)] print(sum(new)+lst[-1]*(1/2)**(n-1)) ''' total=0 for i in range(n-1): total+=lst[i]*(1/2)**(i+1) print(total+lst[-1]*(1/2)**(n-1))
p02724
s435285386
Accepted
x = int(input()) fivehundred = (x//500)*1000 five = ((x%500)//5) * 5 print(fivehundred + five)
p02694
s879804877
Wrong Answer
X = input() X = int(X) cash = 100 count = 0 while cash < X: cash*=1.01 count += 1 print(count)
p02723
s891447688
Wrong Answer
s = input() print("Yes" if s[2] == s[3] and s[4] == s[5] else "NO")
p02831
s742911236
Accepted
# import bisect # import copy import fractions # import math # import numpy as np # from collections import Counter, deque # from itertools import accumulate,permutations, combinations,combinations_with_replacement,product def resolve(): A,B=map(int,input().split()) print(A*B//fractions.gcd(A,B)) resolve()
p03136
s458368210
Accepted
N=int(input()) L=(int, input().split())[1] for i in range(N): L[i] = int(L[i]) a=sum(L) b=max(L) c=a-b if c>b: print("Yes") else: print("No")
p02639
s148495306
Accepted
x = list(input().split()) for i in range(5): x[i] = int(x[i]) if x[i] == 0: print(i+1)
p02622
s060022560
Accepted
s=input() t=input() count=0 for i in range(len(s)): if s[i]!=t[i]: count+=1 print(count)
p02665
s037128429
Accepted
n=int(input()) a=list(map(int,input().split())) can_root=1 ls=[1] for i in range(n): if can_root<a[i]: print(-1);exit() can_root=(can_root-a[i])*2 ls.append(can_root) if can_root < a[-1]:print(-1);exit() ans=a[-1] start=a[-1] for i in range(n)[::-1]: start+=a[i] ans+=min(ls[i],start) print(ans)
p02571
s764727717
Wrong Answer
S = input() T = input() max_count = 0 for start in range(len(T)): for end in range(start, len(T)): if T[start] == S[start]: if T[start:end+1] in S[start:-(len(T)-end)]: max_count = max(max_count, len(T[start:end+1])) answer = len(T) - max_count print(answer)
p03043
s489031744
Accepted
n,k=map(int,input().split()) ans=0 for i in range(1,n+1): tp=i coin=0 while k>tp: tp*=2 coin+=1 ans+=(1/n)*(1/2**coin) print(ans)
p03659
s685515129
Accepted
N = int(input()) A = list(map(int,input().split())) S1 = A[0] S2 = sum(A)-A[0] B = [abs(S1-S2)] for i in range(N-2): S1 += A[i+1] S2 -= A[i+1] B.append(abs(S1-S2)) print(min(B))
p03319
s594213316
Accepted
# import sys # input = sys.stdin.readline import collections import itertools def main(): n, k = input_list() a = input_list() b = n - 1 x = k - 1 ans = b // x if b % x == 0: print(ans) else: print(ans + 1) def input_list(): return list(map(int, input().split())) def input_list_str(): return list(map(str, input().split())) if __name__ == "__main__": main()
p03219
s488976703
Accepted
# -*- coding: <encoding name> -*- X, Y = map(int,input().split()) print(X + Y // 2)
p02994
s029410304
Accepted
N, L = map(int, input().split()) l = [L+i-1 for i in range(1,N+1)] min = l[0] for i in range(N): if abs(min) > abs(l[i]): min = l[i] print(sum(l)-min)
p02711
s777034052
Accepted
#k = int(input()) #s = input() #a, b = map(int, input().split()) #l = list(map(int, input().split())) n = input() if "7" in n: print ("Yes") else: print ("No")
p03971
s332165275
Accepted
N,A,B=map(int,input().split()) S=str(input()) M=A+B K=0 Foreign=0 for j in S: if j=="c": print("No") else: if j=="a": K+=1 if K<=M: print("Yes") else: print("No") else: Foreign+=1 if Foreign<=B: K+=1 if K<=M: print("Yes") else: print("No") else: print("No")
p03416
s424131771
Accepted
A, B = map(int, input().split()) def kaibun(num) : num_str = str(num) for i in range((len(num_str)+1)//2) : if num_str[i] != num_str[-(i+1)] : return False return True ans = 0 for i in range(A,B+1) : if kaibun(i) == True : ans += 1 print(ans)
p03293
s255122315
Accepted
S = input() T = input() for i in range(len(S)): if S[-i:]+S[:-i] == T: print('Yes') exit() print('No')
p03345
s038631034
Accepted
''' Created on 2020/08/17 @author: harurun ''' import sys pin=sys.stdin.readline pout=sys.stdout.write perr=sys.stderr.write mod=1000000000000000000 A,B,C,K=map(int,pin().split()) if abs(A-B)>mod: print("Unfair") elif K%2==0: print(A-B) else: print(B-A)
p03944
s443321345
Accepted
W, H, N = map(int, input().split()) minx, maxx = 0, W miny, maxy = 0, H for _ in range(N): x, y, a = map(int, input().split()) if a == 1: minx = max(x, minx) elif a == 2: maxx = min(x, maxx) elif a == 3: miny = max(y, miny) elif a == 4: maxy = min(y, maxy) width = max(0, maxx-minx) height = max(0, maxy-miny) print(width*height)
p03086
s221163897
Accepted
def abc122_b(): s = input() acgt = ['A', 'C', 'G', 'T'] check = [1 if s[i] in acgt else 0 for i in range(len(s))] result = 0 for i in range(len(check)): for j in range(i, len(check)): if check[i : j + 1].count(0) == 0: if result < len(check[i:j + 1]): result = len(check[i:j + 1]) print(result) if __name__ == '__main__': abc122_b()
p03434
s231043811
Accepted
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readline().split())) inf = float('inf') mod = 10**9 + 7 n = ri() li = sorted(rl(), reverse=True) a = 0 b = 0 for i in range(n): if i & 1 == 0: a += li[i] else: b += li[i] print(a-b)
p03545
s025187500
Accepted
ABCD = input() ans = '' def dfs(i, s): global ans s += ABCD[i] if i == 3: if eval(s) == 7: ans = s return i += 1 dfs(i, s+'+') dfs(i, s+'-') dfs(0, '') print(ans+'=7')
p04011
s457952002
Wrong Answer
n = int(input()) k = int(input()) x = int(input()) y = int(input()) ans = 0 for i in range(n): if i <= k: ans += x else: ans += y print(ans)
p02691
s790568181
Accepted
N = int(input()) A = [int(x) for x in input().split(' ')] left = [0] * N right = [0] * N for i, a in enumerate(A): if i - a >=0: right[i-a] += 1 if i + a < N: left[i + a] += 1 #print(right) #print(left) ans = 0 for l, r in zip(left, right): ans += l*r print(ans)
p03478
s915097860
Wrong Answer
N, A, B = input().split() count=0 for i in range(int(N)): if int(A) <= sum(map(int, N)) <= int(B): count+=1 print(count)
p03087
s440211457
Wrong Answer
n, q = map(int, input().split()) s = input() L = [0]*len(s) for i in range(1,len(s)): L[i] = L[i-1] if s[i-1] == "A" and s[i] == "C": L[i] += 1 for _ in range(q): l, r = map(int, input().split()) print(L[r-1]-L[l]+1)
p03730
s067489805
Wrong Answer
import sys a,b,c = map(int,input().split()) sum = 0 for i in range(1,100): sum += a*i if (sum)%b == c: print("YES") sys.exit() print("NO")
p03986
s407031662
Accepted
A=list(input()) from collections import deque que=deque() for i in A: if i=="T": if que==deque(): que.append("T") elif que[-1]=="T": que.append("T") else: que.pop() else: que.append("S") print(len(que))
p03371
s176387936
Accepted
A, B, C, X, Y = map(int, input().split()) ans = 1000000007 for i in range(max(X, Y) + 1): i_C = 2 * i i_A = max(0, X - i) i_B = max(0, Y - i) # ans = min(ans, A * i_A + B * i_B + C * i_C) print(ans)
p02582
s721755307
Accepted
line = input() rain_day = 0 k = 0 for wether in line: #当日雨 if wether == "R": rain_day += 1 #当日晴れ、前日は雨 elif rain_day != 0: k = rain_day rain_day = 0 #当日晴れ、前日も晴れ else: pass if k > rain_day: print(k) else: print(rain_day)
p02946
s972213203
Accepted
K,X = map(int,input().split()) L = [] for i in range(X-K+1,X+K): L.append(i) [print(i,end=' ') for i in L]
p02833
s643091272
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) if n % 2 == 1: print(0) else: n //= 2 ans = 0 while n: n //= 5 ans += n print(ans)
p02859
s694616360
Accepted
#!/usr/bin/python3 # -*- coding:utf-8 -*- def main(): r = int(input()) print(r**2) if __name__=='__main__': main()
p04020
s336122439
Wrong Answer
import sys stdin = sys.stdin import itertools mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) N = ni() A = list() for _ in range(N): A.append(ni()) cnt = 0 s = sum(A) for i in range(N-1): #print(A) ccnt = (A[i] + A[i+1]) //2 A[i+1] -= max(0, ccnt*2 - A[i]) A[i] = max(0, A[i]-ccnt*2) cnt += ccnt #print(A) #print(cnt) print((s - sum(A))//2)
p03387
s588906363
Accepted
a,b,c=map(int,input().split()) aa,bb,cc=a%2,b%2,c%2 def check(a,b,c): max_=max(a,b,c) ans=((max_-a)//2)+((max_-b)//2)+((max_-c)//2) return ans if aa==bb==cc: print(check(a,b,c)) else: if aa==bb and aa!=cc: print(check(a+1,b+1,c)+1) elif cc==bb and aa!=cc: print(check(a,b+1,c+1)+1) else: print(check(a+1,b,c+1)+1)
p03012
s150107768
Wrong Answer
import numpy as np N = int(input()) W = input().split() for i in range(N): W[i] = int(W[i]) min_w= 100000 for i in range(N-2): w1 = W[:i+1] w2 = W[i+1:] w1 = np.array(w1) w2 = np.array(w2) print(w1) print(w2) min_w = min(min_w, abs(np.sum(w2)-np.sum(w1))) print(min_w)
p03264
s762256507
Accepted
n=int(input()) print((n//2)*((n+2-1)//2))
p02675
s152068589
Accepted
n = input()[-1] if n in '24579': print('hon') elif n in '0168': print('pon') else: print('bon')
p03371
s168527198
Wrong Answer
a,b,c,x,y=list(map(int,input().split())) ans=0 if 2*c*max(x,y)<=a*x+b*y: ans+=2*c*max(x,y) elif a+b>2*c: ans+=2*c*min(x,y) if x>y: ans+=a*(x-y) else: ans+=b*(y-x) else: ans+=a*x+b*y print(ans)
p03720
s523478156
Wrong Answer
a,b=map(int,input().split()) c=[input() for i in range(b)] sum=0 d=[] for k in range(1,a+1): for j in range(b): sum=sum+c[j].split()[0].count(str(k))+c[j].split()[1].count(str(k)) d.append(sum) sum=0 for m in d: print(m)
p02660
s105553152
Accepted
import math N=int(input()) ans=0 arr=[] tmp=1 #print(int(math.sqrt(N))+5) for i in range(int(math.sqrt(N))+5): tmp=1 while N % ((i+2)**tmp) == 0: N=N / ((i+2)**tmp) #print((i+2)**tmp) ans+=1 tmp+=1 while N % (i+2) == 0: N = N // (i+2) if N > 1 : ans+=1 print(ans)
p03329
s620195522
Wrong Answer
list=[1, 1, 1, 1, 1] for i in range(1, 7): list.append(6**i) for j in range(1, 7): list.append(9**j) sorted(list, reverse=True) N=int(input()) count=0 for i in list: if i < N: N=N-i count+=1 if i == N: count+=1 print(count)
p03665
s163179615
Wrong Answer
from scipy.special import comb n, p, *A = map(int, open(0).read().split()) odd = sum(a%2 for a in A) even = n - odd if p: s = 0 for i in range(1, odd, 2): s += comb(odd, i, exact=True) s *= pow(2, even) print(s) else: s = 0 for i in range(0, odd, 2): s += comb(odd, i, exact=True) s *= pow(2, even) print(s)
p02989
s579297407
Wrong Answer
def count_up(d, cut): ABC = len([1 for i in d if i < cut]) ARC = len(d) - ABC if ABC == ARC: return True return False N = int(input()) d = list(map(int, input().split())) counter = 0 for i in range(max(d)): if count_up(d, i): counter += 1 print(counter)
p03243
s504296229
Wrong Answer
N = int(input()) NList = [] x = N for i in range(3): NList.append(x % 10) x = x // 10 NList.sort() for i in range(3): if N <= NList[i] * 111: print(NList[i] * 111) break
p02866
s916519240
Accepted
N = int(input()) D = list(map(int, input().split())) ans = 0 if not D[0] == 0 or not D.count(0) == 1: print(0) else: co = [0] * (max(D)+1) for i in D: co[i] += 1 ans = 1 for i in range(2, max(D)+1): ans = ans * (co[i-1]**co[i]) % 998244353 print(ans)
p02888
s592863397
Accepted
import sys from bisect import bisect_left, bisect_right n, *l = map(int, sys.stdin.read().split()) l.sort() ans = 0 for i in range(n-2): for j in range(i+1, n-1): # i: 1番目に長い棒 j: 2番目に長い棒 # 3番目に長い棒の条件 -> jよりも短く a<b+cよりa-bより大きい cnt = (n - 1) - j - bisect_right(l, l[-(i+1)] - l[-(j+1)]) if cnt > 0: ans += cnt print(ans)
p03862
s277749660
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, x, *a = map(int, read().split()) memo = 0 cnt = 0 if a[0] > x: cnt += a[0] - x a[0] = x for i in range(n - 1): if a[i + 1] > x: cnt += a[i + 1] - x a[i + 1] = x v = a[i] + a[i + 1] - memo if v > x: memo = v - x else: memo = 0 cnt += memo print(cnt)
p03251
s929844298
Accepted
N,M,X,Y=map(int,input().split()) x=max(list(map(int,input().split()))) y=min(list(map(int,input().split()))) if max(X,x)+1<=min(y,Y): print("No War") else: print("War")
p03251
s223714878
Accepted
n,m,x,y=map(int,input().split()) xs=list(map(int,input().split())) ys=list(map(int,input().split())) x_=max(xs) y_=min(ys) for z in range(x_+1,y_+1): if x<z<=y: print('No War') exit() print('War')
p02789
s120756975
Wrong Answer
def test_cases(N, M): if N==M: return 'Yes' else: return 'No'
p03150
s770999288
Accepted
S = input() for i in range(len(S)-1): for j in range(i,len(S)): memo = S[:i]+S[j:] #print(memo) if memo == 'keyence': print('YES') exit() print('NO')
p03944
s579175508
Wrong Answer
w,h,n=map(int,input().split()) a=[[int(i)for i in input().split()]for j in range(n)] S=[[0,w],[0,h]] for i in a: if i[2]==1: S[0][0]=i[0] if i[2]==2: S[0][1]=i[0] if i[2]==3: S[1][0]=i[1] if i[2]==4: S[1][1]=i[1] ans=max(0,(S[0][1]-S[0][0]))*max(0,(S[1][1]-S[1][0])) print(ans)
p03611
s637558528
Accepted
from collections import Counter n = int(input()) a = list(map(int, input().split())) new_list = list() for x in range(n): num = a[x] num_plus = num + 1 num_minus = num - 1 new_list.append(num_plus) new_list.append(num_minus) new_list.append(num) d = dict(Counter(new_list)) print(max(d.values()))
p03456
s431842449
Accepted
a, b = input().split() if (int(a + b) ** 0.5).is_integer(): print("Yes") else: print("No")
p02813
s551071081
Accepted
import itertools n = int(input()) p = tuple(map(int, input().split())) # 横入力 q = tuple(map(int, input().split())) # 横入力 seq = [0]*n for i in range(1,n+1): seq[i-1] = i nnn = list(itertools.permutations(seq, n)) print(abs(nnn.index(q) - nnn.index(p)))
p02597
s262432966
Wrong Answer
n = int(input()) s = input() res = 2000000 for i in range(1,n): w = s.count('W',0,i) r = s.count('R',i) if (max(r,w) < res): res = max(r,w) print(str(res))
p02772
s794428348
Wrong Answer
N = int(input()) A = list(map(int, input().split())) count = 0 for i in A: if i//3 == 0 or i//5 == 0: count += 1 else: count += 0 if count == N: print('APPROVED') else: print('DENIED')