problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03407
s830736998
Accepted
a,b,c=map(int,input().split()) if a+b>=c: print("Yes") else: print("No")
p03680
s737306304
Accepted
import itertools N = int(input()) A = [int(input()) for _ in range(N)] a = 1 for i, _ in enumerate(range(N), 1): a = A[a - 1] if a == 2: break if a == 2: print(i) else: print(-1)
p03495
s604707740
Accepted
N,K=map(int,input().split()) A=list(map(int,input().split())) m= [0 for i in range(200001) ] for i in range(N): m[A[i]] += 1 m.sort(reverse=True) ans = 0 for i in range(K,N): if ( m[i] == 0 ): break ans += m[i] print(ans)
p02572
s522550931
Wrong Answer
def resolve(): n = int(input()) a = list(map(int, input().split())) mod = 10**9+7 s = 0 sq = 0 for i in range(n): s += a[i] sq += (a[i])**2 s %= mod sq %= mod s2 = (s**2) %mod ans = s2-sq if ans < 0: ans += mod print((ans//2)%mod) resolve()
p02753
s846585491
Accepted
S = input() if S.find("A") == -1 or S.find("B") == -1: print("No") else: print("Yes")
p03475
s489329929
Accepted
N = int(input()) C, S, F = zip(*[tuple(map(int, input().split())) for _ in range(N-1)]) S = list(s for s in S) + [0] for i in range(N-1): for j in range(i, N-1): S[i] = max(S[i], S[j]) while S[i] % F[j]: S[i] += 1 S[i] += C[j] print(*S, sep="\n")
p02697
s485124593
Wrong Answer
n, m = map(int,input().split()) ans = [] for i in range(m + 1): if n % 2 == 0 and i == 0:continue if n % 2 == 1 and i == m:continue temp = (i + 1, n - i) ans.append(temp) for i in ans: print(*i)
p03086
s143109344
Accepted
a=input() b=0 c=0 for i in range(len(a)): if a[i]=="A" or a[i]=="C" or a[i]=="G" or a[i]=="T": b=b+1 if c<b: c=b if a[i]!="A" and a[i]!="C" and a[i]!="G" and a[i]!="T": b=0 print(c)
p03345
s209744385
Accepted
a,b,c,k=map(int,input().split()) print((a-b)*(-1)**k)
p02888
s304686678
Wrong Answer
n = int(input()) l = [int(_) for _ in input().split()] M = 10**3+1 le = [0] * M for i in range(n): le[l[i]] += 1 ans = 0 for a in range(1, M-2): for b in range(a, M-1): for c in range(b, min(a+b, M)): ans += (le[a] * le[b] * le[c]) print(ans)
p03221
s317453456
Accepted
import sys N,M = (int(x) for x in input().split()) li = [] for i in range(M): a,b = (int(x) for x in input().split()) li.append([i,a,b,""]) li.sort(key=lambda x: x[2]) cnt = [1]*N for i in range(M): li[i][3] = str(li[i][1]).zfill(6) + str(cnt[li[i][1]-1]).zfill(6) cnt[li[i][1]-1] += 1 li.sort(key=lambda x: x[0]) for i in range(M): print(li[i][3])
p03327
s868845300
Wrong Answer
N=int(input()) if N>=1000: print('ABD') else: print('ABD')
p02958
s638883250
Accepted
N = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(N): cnt += p[i] != i + 1 if cnt == 0 or cnt == 2: print('YES') else: print('NO')
p02603
s321444268
Wrong Answer
N = int(input()) A = [int(i) for i in input().split()] cash=1000 stock=0 for i in range(N-1): if A[i] < A[i+1]: stock=cash//A[i] cash=cash%A[i] elif A[i] > A[i+1]: cash+=A[i]*stock stock=0 cash+=A[N-1]*stock print(cash)
p02713
s639542487
Wrong Answer
# -*- coding: utf-8 -*- """ Created on Sun Apr 12 22:01:05 2020 @author: H_Hoshigi """ import math K = 200#int(input()) answer = 0 for a in range(1, K+1): for b in range(1, K+1): gcd_a_b = math.gcd(a, b) for c in range(1, K+1): answer += math.gcd(gcd_a_b, c) print(answer)
p03485
s421392192
Wrong Answer
a=[int(i) for i in input().rstrip().split()] print(round(sum(a)/len(a)))
p03494
s675097489
Wrong Answer
N = int(input()) import numpy as np A = np.array(list(map(int, input().split()))) ans = 0 while not np.any(A % 2 == 0): A = A / 2 ans += 1 print(ans)
p03759
s730949839
Accepted
a, b, c = map(int, input().split()) print('YES' if b-a == c-b else 'NO')
p02576
s939465901
Accepted
x,n,t = map(int,input().split(" ")) cnt =0 while x > 0: x -= n cnt += 1 print(cnt * t)
p02732
s205316534
Wrong Answer
from collections import Counter from scipy.misc import comb N = int(input()) A = [int(x) for x in input().split()] C = Counter(A) def banned_count(seq): for i in range(N): count = 0 C[A[i]] -= 1 for j in C.values(): if j >= 2: count += comb(j, 2) print(int(count)) C[A[i]] += 1 banned_count(A)
p03285
s786221117
Accepted
import sys N = int(input()) for i in range(N//4+1): if (N-4*i)%7 == 0: print("Yes") sys.exit() print("No")
p02847
s743867381
Wrong Answer
date = input() List = ['SAT', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SUN'] for i in range(len(List)): if date == List[i]: print(i+1)
p02879
s839458221
Accepted
x,y=map(int,input().split()) if x<10 and y<10: print(x*y) else: print(-1)
p03962
s678448128
Accepted
import sys input = lambda: sys.stdin.readline().rstrip() def main(): x = list(map(int, input().split())) print(len(set(x))) if __name__ == '__main__': main()
p02779
s222598629
Accepted
n=int(input()) a=list(map(int,input().split())) s=list(set(a)) if len(a)==len(s): print('YES') else: print('NO')
p02658
s451589628
Accepted
n = int(input()) y = list(map(int, input().split(" "))) s = 1 hoge = False for i in y: if i ==0: print(0) hoge = True def f(): s = 1 for i in y: s *= i if s>10**18: print(-1) return print(s) if not hoge: f()
p03607
s336784131
Accepted
import sys from collections import defaultdict input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) n = I() d = defaultdict(int) for i in range(n): temp = I() d[temp] += 1 ans = 0 for i in d.values(): if i % 2 == 1: ans += 1 print(ans)
p02645
s293459577
Accepted
name = input() print(name[:3])
p03448
s627155828
Accepted
A = int(input()) B = int(input()) C = int(input()) X = int(input()) ans = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): money = 500 * a + 100 * b + 50 * c if money == X: ans += 1 print(ans)
p02912
s089850264
Wrong Answer
n,m = map(int, input().split()) a = list(map(int, input().split())) import heapq a = list(map(lambda x:x*(-1), a)) heapq.heapify(a) for _ in range(m): num = heapq.heappop(a) heapq.heappush(a,num//2) a = list(a) print(sum(a)*(-1))
p03475
s558366961
Accepted
n = int(input()) train = [list(map(int, input().split())) for i in range(n-1)] for i in range(n-1): ans = 0 for j in range(i,n-1): if ans <=train[j][1]: ans = train[j][1]+ train[j][0] else: if ans%train[j][2]==0: ans += train[j][0] else: ans = train[j][0] + (ans//train[j][2]+1)*train[j][2] print(ans) print(0)
p03632
s652384997
Accepted
A, B, C, D = map(int, input().split()) ans = max(0, min(B, D) - max(A, C)) print(ans)
p03796
s608914149
Accepted
INF = 1000000007 n = int(input()) ans = 1 for i in range(1,n+1): ans = ans * i % INF print(ans)
p03448
s513543556
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): if 500*i + 100*j + 50*k == x: ans += 1 print(ans)
p04034
s394247406
Accepted
n, m = map(int, input().split()) red = {1, } l = [1 for _ in range(n)] for _ in range(m): x, y = map(int, input().split()) l[x - 1] -= 1 l[y - 1] += 1 if x in red: red.add(y) if l[x - 1] == 0: red.discard(x) print(len(red))
p03804
s856313758
Accepted
N,M=map(int,input().split()) A=[input() for i in range(N)] B=[input() for i in range(M)] judge=any([line[j:j+M] for line in A[i:i+M]]==B for i in range(N-M+1) for j in range(N-M+1)) print("Yes" if judge else "No")
p02727
s388015372
Wrong Answer
if __name__ == '__main__': X, Y, A, B, C = map(int, input().split()) p = [int(a) for a in input().split()] q = [int(a) for a in input().split()] r = [int(a) for a in input().split()] p.sort(reverse=True) q.sort(reverse=True) P = p[0:X] Q = q[0:Y] Z = min(C,X+Y) R = r[0:Z] s = P+Q+R s.sort(reverse=True) S = s[0:X+Y] ans = sum(S) print(ans)
p02848
s500157073
Accepted
n = int(input()) s = input() t = "".join([chr(ord("A") + (ord(i)-ord("A")+n)%26) for i in s]) print(t)
p02600
s464077482
Accepted
def main(): x = int(input()) ans = 10 - int(x // 200) print(int(ans)) if __name__ == '__main__': main()
p02760
s116652608
Wrong Answer
A = [list(map(int, input().split())) for i in range(3)] N = int(input()) b = [] for i in range(N): b.append(int(input())) yoko = A tate = [[], [], []] for row in A: for i in range(3): tate[i].append(row[i]) naname = [[A[0][0], A[1][1], A[2][2]]] all = yoko + tate + naname for kumi in all: chk = 0 for i in range(3): if kumi[0] in b: chk += 1 if chk == 3: print("Yes") break if chk == 0: print("No")
p02811
s267626882
Accepted
k,x = [int(x) for x in input().split()] if k*500>=x: print("Yes") else: print("No")
p03087
s485430537
Wrong Answer
N, Q = map(int, input().split()) S = input() cumulative = [0] * (N+1) for i in range(N): if S[i:i+2] == "AC": cumulative[i+2] = cumulative[i+1] + 1 for _ in range(Q): start, end = map(int, input().split()) ans = cumulative[end] - cumulative[start-1] if start > 1 and S[start-2:start] == "AC": ans -= 1 print(ans)
p02832
s044419443
Accepted
N=int(input()) A=map(int,input().split()) i=1 for a in A: if a==i: i+=1 i-=1 print(N-i if i>0 else -1)
p02819
s829297890
Accepted
x = int(input()) primes = [i for i in range(2 * x)] for i, b in enumerate(primes): if i < 2 or b == 0: continue else: m = (2 * x - 1) // i if m > 1: for j in range(2, m + 1): primes[i * j] = 0 print(min([i for i in primes if i >= x]))
p03679
s828839248
Accepted
x, a, b = map(int, input().split()) if b - a <= 0: print('delicious') elif b - a <= x: print('safe') else: print('dangerous')
p02982
s496155921
Accepted
import numpy as np N, D = map(int,input().split()) LX = [list(map(int, input().split())) for i in range(N)] cnt=0 for i in range(N-1): for j in range(i+1,N): LXP = np.array(LX[i]) LXQ = np.array(LX[j]) ans = (float(np.sqrt(sum((LXP - LXQ) ** 2)))) if ans.is_integer(): cnt += 1 print(cnt)
p04011
s221392609
Accepted
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) print(X * min(K,N) + max(N-K,0) * Y )
p03778
s921654895
Wrong Answer
a,b,c=input().split() a=int(a) b=int(b) c=int(c) if b<=c: if a+b>=c: print(0) else: print(c-b) else: if a+c>=b: print(0) else: print(b-c)
p02640
s478332714
Accepted
X, Y = map(int, input().split()) for i in range(X + 1): j = X - i if i * 2 + j * 4 == Y: print("Yes") break else: print("No")
p02759
s032095116
Accepted
N = int(input()) # N, X = [int(i) for i in input().split()] if N%2: print(N//2 + 1) else: print(N//2)
p02724
s511614212
Wrong Answer
X = int(input()) C = 0 D = 0 while True: if X > 500: C = X // 500 P = 500 * C X = X - P elif X > 5: D = X // 5 L = 5 * D X = X - L else: break total = (1000 * C) + (5 * D) print(total)
p02660
s606543274
Wrong Answer
N = int(input()) ans = 0 for i in range(2, int(N**0.5)+1): cnt = 0 while N%i == 0: N /= i cnt += 1 a = 0 b = 0 for j in range(1, cnt+1): a += j if a > cnt: break b += 1 ans += b if N == 1: print(0) elif ans == 0: print(1) else: print(ans)
p02601
s572377481
Wrong Answer
a,b,c=map(int,input().split()) k=int(input()) count=0 while a>=b: b=b*2 count+=1 con=0 while b*count>=c: c=c*2 con+=1 total=con+count if total<=k: print('Yes') else: print('No')
p02777
s311886479
Wrong Answer
target_a, target_b = list(map(str, input().split())) a, b = map(int, input().split()) target = input('') list_target_a = list(target_a) list_target_b = list(target_b) list_target = list(target) if len(list_target) == len(list_target_a): a -= 1 elif len(list_target) == len(list_target_b): b -= 1 print(a, b)
p03785
s511392646
Wrong Answer
n,c,k = [int(x) for x in input().split()] t = [int(input()) for _ in range(n)] t.sort() bus = c f_bus = 0 ans = 0 for i in range(n): if t[i] - f_bus >= k or bus == 0: ans += 1 f_bus = t[i] bus = c-1 else: bus -= 1 if bus != c: ans += 1 print(ans)
p02953
s248312211
Wrong Answer
from collections import deque N = int(input()) H = deque(map(float, input().split())) prev = H.popleft() if N == 1: print('Yes') exit() for i in range(N-2): cor = H.popleft() if prev - cor < -1: print('No') exit() prev = cor cor = H.popleft() if cor - prev < 0: print('No') exit() print('Yes')
p02602
s692686778
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")
p03803
s675857367
Accepted
# 入力 a, b = map(int, input().split()) # 処理&出力 if a == b: print('Draw') elif a == 1: print('Alice') elif b == 1: print('Bob') elif a > b: print('Alice') elif b > a: print('Bob')
p02725
s732760008
Accepted
k, n = map(int, input().split()) a = list(map(int, input().split())) root = [] ans = 0 for i in range(0, n-1): x = a[i+1] - a[i] root.append(x) y = a[0] + k - a[n-1] root.append(y) for i in root: ans += i ans -= max(root) print(ans)
p02862
s487901762
Accepted
def comb(n, m, p=10**9+7): if n < m: return 0 if n < 0 or m < 0: return 0 m = min(m, n-m) top = bot = 1 for i in range(m): top = top*(n-i) % p bot = bot*(i+1) % p bot = pow(bot, p-2, p) return top*bot % p x, y = map(int, input().split()) j = 2*x-y if j % 3: print(0) exit() j //= 3 i = x - 2*j if i < 0 or j < 0: print(0) exit() ans = comb(i+j, i) print(ans)
p02607
s222376363
Accepted
N = int(input()) A = list(map(int,input().split())) An = 0 for i in range(N): if (i+1)%2 == 1: if A[i]%2 == 1: An +=1 print(An)
p02970
s295241551
Accepted
n,d= map(int,input().split()) k = 2 * d + 1 print( (n+k-1)//k)
p02899
s161975674
Accepted
N=int(input()) A=list(map(int,input().strip().split())) B=[-1 for n in range(N)] for n in range(len(A)): B[A[n]-1]=n+1 print(" ".join(list(map(str,B))))
p02760
s613055132
Accepted
a=[] for i in range(3): *x,=map(int,input().split()) a+=x n=int(input()) b=[] for i in range(n): b.append(int(input())) ans=[False for _ in range(9)] for i in b: for j in a: if i==j: ans[a.index(i)]=True if all(ans[0:3]) or all(ans[3:6]) or all(ans[6:9]): print("Yes") elif all(ans[0:7:3]) or all(ans[1:8:3]) or all(ans[2:9:3]): print("Yes") elif all(ans[0:5:4]) or all(ans[2:7:2]): print("Yes") else: print("No")
p02726
s934451673
Accepted
import sys import os def file_input(): f = open('ABC160/input.txt', 'r') sys.stdin = f def main(): #file_input() # int(input()) N,X,Y=map(int, input().split()) out=[0]*(N-1) for i in range(1,N): for j in range(i+1,N+1): out[min(j-i,abs(j-Y)+1+abs(X-i),abs(j-X)+1+abs(i-Y))-1]+=1 [print(x) for x in out] if __name__ == '__main__': main()
p02613
s082936193
Accepted
n = int(input()) c0 = 0 c1 = 0 c2 = 0 c3 = 0 for _ in range(n): s = input() if s == 'AC': c0 += 1 elif s == 'WA': c1 += 1 elif s == 'TLE': c2 += 1 elif s == 'RE': c3 += 1 print('AC x', c0) print('WA x', c1) print('TLE x', c2) print('RE x', c3)
p02577
s154459735
Accepted
N = input() Ans = 0 for i in range(len(N)): Ni = int(N[i]) Ans = (Ans+Ni)%9 if Ans != 0: print('No') else: print('Yes')
p02660
s027216378
Accepted
from collections import defaultdict import math N = int(input()) d = defaultdict(int) for i in range(2, int(math.sqrt(N)) + 1): while N % i == 0: d[i] += 1 N //= i if N > 1: d[N] = 1 ans = 0 for v in d.values(): k = 1 while k <= v: ans += 1 v -= k k += 1 print(ans)
p03076
s014422699
Wrong Answer
from decimal import Decimal, ROUND_HALF_UP # input cook_time = [] append = cook_time.append for i in range(5): append(int(input())) # check cook_time.sort(key=lambda x: int(Decimal(x).quantize(Decimal("1E1"), rounding=ROUND_HALF_UP)) - x) res = 0 for c in cook_time: if res % 10 != 0: res = int(Decimal(res).quantize(Decimal("1E1"), rounding=ROUND_HALF_UP)) print(c, res) res += c print(res)
p03986
s917783888
Accepted
x = input() t = 0 s = 0 for i in x: if i == 'S': t += 1 else: if t > 0: t -= 1 else: s += 1 print(s+t)
p02793
s665095812
Wrong Answer
n = int(input()) a = list(map(int, input().split())) mod = 10*9+7 from fractions import gcd l = a[0] for i in range(n): l = l*a[i]//gcd(l,a[i]) b = [0]*n ans = 0 for i in range(n): b[i] = l//a[i] ans += b[i]%mod print(ans)
p02717
s985562681
Accepted
a,b,c = [int(s) for s in input().split(" ")] a,b = b,a a,c = c,a print("{} {} {}".format(a,b,c))
p03163
s553853390
Wrong Answer
import copy N,W=map(int,input().split()) Wlist=[] Vlist=[] for i in range(N): w,v=map(int,input().split()) Wlist+=[w] Vlist+=[v] dp0=[0 for p in range(W+1)] dp1=[0 for p in range(W+1)] dp1[Wlist[0]]=Vlist[0] for i in range(1,N): wi=Wlist[i] for j in range(W): if j+wi<=W: dp1[j+wi]=max(dp0[j]+Vlist[i],dp1[j+wi]) dp1[j]=max(dp0[j],dp1[j]) dp0=copy.copy(dp1) print(max(dp1))
p03673
s325461360
Accepted
from collections import deque n = int(input()) a = list(map(int, input().split())) d = deque() for i in range(n): if n % 2 == (i + 1) % 2: d.appendleft(a[i]) else: d.append(a[i]) print(*d)
p02866
s616573271
Accepted
from collections import Counter N = int(input()) D = list(map(int, input().split())) mod = 998244353 c = Counter(D) m = max(c.keys()) if D[0] == 0 and c[0] == 1: ans = 1 for i in range(1, m+1): ans *= c[i-1]**c[i] % mod ans %= mod print(ans) else: print(0)
p03719
s456933996
Accepted
A, B, C = map(int, input().split()) if C >= A and C <= B: print("Yes") else: print("No")
p03617
s907937154
Accepted
Q, H, S, D = map(int, input().split()) N = int(input()) ans = (N//2) * min(8 * Q, 4 * H, S * 2, D) + (N % 2) * min(4 * Q, 2 * H, S) print(ans)
p02866
s225839232
Accepted
n = int(input()) d = list(map(int,input().split())) m = max(d) if(d[0] != 0 or m >= n): print(0) else: s = [0] * (m+1) for i in d:s[i] += 1 if(0 in s or s[0] != 1): print(0) else: t = 1 for i in range(1,m+1): t *= s[i-1]**s[i] t %= 998244353 print(t)
p02881
s393630735
Accepted
import numpy as np N = int(input()) A = [] i = 2 a = int() b = int() ans = 10**12+1 for i in range(2,int(np.sqrt(N))+1): if N%i ==0: A.append(i) if len(A) == 0: print(N-1) else: for j in range(len(A)): a = A[j]-1 b = (N/A[j])-1 if a+b <= ans: ans = a+b print(int(ans))
p03799
s312091199
Accepted
n,m=map(int,input().split()) print(n+(m-n*2)//4 if m>n*2 else m//2)
p02785
s117620378
Wrong Answer
N,K=map(int,input().split()) L=list(map(int,input().split())) L=sorted(L) print(sum(L[:-K]))
p02642
s257967858
Wrong Answer
N = int(input()) num_list = list(map(int, input().split())) count=0 for i in range(N): for j in range(N): if num_list[i] % num_list[j]==0: count = count + 1 break count = count - N print(N-count)
p03206
s916215549
Accepted
N = int(input()) if N == 25: print('Christmas') elif N == 24: print('Christmas Eve') elif N == 23: print('Christmas Eve Eve') else: print('Christmas Eve Eve Eve')
p03493
s757627148
Accepted
s = input() count = 0 for i in range(len(s)): if s[i]=='1': count += 1 print(count)
p03759
s756514975
Wrong Answer
a,b,c=map(int,input().split()) if abs(a-b)==abs(c-b): print('YES') else: print('NO')
p02658
s667220290
Accepted
N = int(input()) arr = list(map(int, input().split())) ans = arr[0] if 0 in arr: print(0) exit() for i in range(1,N): ans *= arr[i] if ans > 10**18: print(-1) exit() print(ans)
p02792
s111163743
Accepted
N = int(input()) num =[[0] * 10 for _ in range(10)] for n in range(1, N+1): s = str(n) a, b = map(int, [s[0], s[-1]]) num[a][b] += 1 ans = 0 for a in range(1, 10): for b in range(1, 10): ans += num[a][b] * num[b][a] print(ans)
p02996
s931971550
Accepted
from sys import stdin import sys import math from functools import reduce import functools import itertools from collections import deque,Counter,defaultdict from operator import mul import copy # ! /usr/bin/env python # -*- coding: utf-8 -*- import heapq sys.setrecursionlimit(10**6) # INF = float("inf") INF = 10**18 import bisect import statistics mod = 10**9+7 # mod = 998244353 N = int(input()) A = [] for i in range(N): A.append(list(map(int, input().split()))) A = sorted(A, key=lambda x: x[1]) t = 0 for i in range(N): t += A[i][0] if t > A[i][1]: print("No") sys.exit() print("Yes")
p03719
s318006906
Accepted
a, b, c = map(int, input().split()) if c >= a and c <= b: print('Yes') else: print('No')
p02624
s512152146
Wrong Answer
import math N = int(input()) ans = 0 A = [1 for i in range(N + 2)] k = 2 A[1] = 0 while k <= math.sqrt(N): for i in range(k,N + 1,k): q = i p = 1 while q % k == 0: q /= k p += 1 A[i] *= p while A[k] != 1: k += 1 for i in range(1,N + 1): if A[i] <= 1: A[i] += 1 ans += i * A[i] print(ans)
p03241
s643134729
Wrong Answer
from math import sqrt from bisect import bisect_left N,M = map(int,input().split()) t = M #約数全列挙 sep = [1] for i in range(2,int(sqrt(M))+2,1): if M % i ==0: count = 0 if M % i == 0: if N <= i and i <= t: t = i if N <= M//i and M//i <= t: t = M//i print(M//t)
p02555
s124615794
Accepted
s = int(input()) mod = 10 ** 9 + 7 dp = [1, 0, 0] for _ in range(s - 2): dp.append((dp[-1] + dp[-3]) % mod) print(dp[s])
p03339
s167264396
Accepted
n = int(input()) s = input() cnt_R = s.count('E') cnt_L = 0 INF = 10**18 ans = INF for x in s: if x == 'W': ans = min(ans, cnt_L+cnt_R) cnt_L += 1 else: cnt_R -= 1 ans = min(ans, cnt_L+cnt_R) print(ans)
p03285
s047924567
Wrong Answer
x = int(input()) flag = False for ia in range(0, int(x/4)): for ib in range(0, int(x/4)): if 4 * ia + 7 * ib == x: flag = True break if flag: break if flag: print("Yes") else: print("No")
p02732
s404552443
Wrong Answer
n = int(input()) a = list(map(int,input().split())) answer = 0 answer1 = 0 for i in range(max(a)): answer += a.count(i + 1) * (a.count(i + 1) -1) // 2 for k in range(n): if a.count(a[k]) > 2: answer1 = answer - (a.count(a[k]) - 1) print(answer1)
p02813
s615876493
Accepted
def c_count_order(): from itertools import permutations N = int(input()) P = tuple(int(i) for i in input().split()) Q = tuple(int(i) for i in input().split()) rank = {perm: k for k, perm in enumerate(permutations(range(1, N + 1), N), 1)} return abs(rank[P] - rank[Q]) print(c_count_order())
p03001
s371493706
Accepted
W, H, x, y = map(int, input().split()) print("{0} {1}".format(H * W / 2, int(x + x == W and y + y == H)))
p02918
s301885111
Wrong Answer
n, k = map(int,input().split()) s = input() press = [] temp = s[0] cnt = 0 for string in s: if temp == string: cnt += 1 else: press.append(cnt) temp = string cnt = 1 press.append(cnt) if len(press) < 3 * k: print(n-1) exit() ans = 2 * k for i in press: ans += i - 1 print(ans)
p03163
s855593187
Accepted
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, lim = map(int, readline().split()) WV = np.array(read().split(), np.int64) W = WV[::2] V = WV[1::2] # weight -> value dp = np.zeros(lim + 1, np.int64) for w, v in zip(W, V): np.maximum(dp[w:], dp[:-w] + v, out=dp[w:]) print(dp.max())
p04012
s221247845
Wrong Answer
w = input() beau = {} for i in range(len(w)): if not w[i] in beau: beau[w[i]] = 1 else: beau[w[i]] += 1 num = sum(list(map(lambda x: x%2,list(beau.values())))) if num == 0: print('YES') else: print('NO')