problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02829
s932305929
Accepted
#!/usr/bin/env python3 import sys def solve(A: int, B: int): print(6//A//B) 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() A = int(next(tokens)) # type: int B = int(next(tokens)) # type: int solve(A, B) if __name__ == '__main__': main()
p03695
s452701408
Wrong Answer
n=int(input()) a=list(map(int,input().split())) color=[] free=0 count=0 Sans,Mans=0,0 for i in a: if i//400<8 and i//400 not in color: color.append(i//400) Sans+=1 elif i>=3200: free+=1 #Mans=Sans if free+Sans>8: Mans=8 else: Mans=Sans+free if Sans==0: Sans=1 print(Sans,Mans)
p03206
s801585450
Accepted
d=int(input());print("Christmas"+(25-d)*" Eve")
p02706
s340455893
Wrong Answer
def q2(): N, M = (int(i) for i in input().split()) A = [int(i) for i in input().split()] sum_A = sum(A) if N > sum_A: ans = N - sum_A else: ans = 0 print(ans) if __name__ == '__main__': q2()
p03407
s605622909
Accepted
A, B, C = map(int,input().split()) if (A+B) >= C : print("Yes") else: print("No")
p03565
s446423910
Accepted
S = input() T = input() if len(S) < len(T): print('UNRESTORABLE') exit() ans = 'z'*51 for i in range(len(S)-len(T)+1): s = S[i:i+len(T)] for a,b in zip(s,T): if a==b or a=='?': continue break else: cand = S[:i] + T + S[i+len(T):] ans = min(ans, cand.replace('?','a')) print('UNRESTORABLE' if ans=='z'*51 else ans)
p04034
s770156359
Wrong Answer
n, m = map(int, input().split()) xy = [tuple(map(int, input().split())) for _ in range(m)] gray = [False] * n gray[0] = True ball = [1] * n for x, y in xy: x -= 1; y -= 1 if ball[x] > 0: ball[x] -= 1 ball[y] += 1 if gray[x]: gray[y] = True ans = 0 for i in range(n): if gray[i] and ball[i] > 0: ans += 1 print(ans)
p03607
s864273777
Accepted
n = int(input()) a = [int(input()) for _ in range(n)] d = {} for i in a: if i not in d: d[i] = 0 d[i] +=1 elif i in d: if d[i] == 0: d[i] +=1 else: d[i] -=1 l =[] for i in d.keys(): if d[i] != 0: l.append(d[i]) print(len(l))
p02748
s747947624
Accepted
A,B,M = [int(zz) for zz in input().split()] lia = [int(zz) for zz in input().split()] lib = [int(zz) for zz in input().split()] ans = min(lia)+min(lib) for _ in range(M): x,y,c = [int(zz) for zz in input().split()] ans = min(ans,lia[x-1]+lib[y-1]-c) print(ans)
p02817
s184581399
Accepted
print("".join(input().split()[::-1]))
p02694
s653788468
Accepted
input_line = int(input()) deposit = 100 i = 0 while deposit < input_line: deposit = int(deposit * 1.01) i += 1 print(i)
p02607
s285009842
Accepted
n=int(input()) l=[int(i) for i in input().split()] c=0 for i in range(n): if (i+1)%2==1 and l[i]%2==1: c+=1 print(c)
p02700
s451851215
Wrong Answer
import math a,b,c,d=map(int,input().split()) print("Yes") if math.ceil(c/a)>=math.ceil(a/d) else print("No")
p02759
s543973654
Accepted
import numpy as np import math as m def main(**kwargs): r = int(n / 2 + 0.5) return r if __name__ == "__main__": cin = np.array(input().split(" ")).astype("int") n, *_ = cin cout = main(n=n) print(cout)
p02583
s366896684
Accepted
from collections import Counter from itertools import combinations N = int(input()) if N == 0: print(0) else: L = [int(s) for s in input().split()] set_L = Counter(L) uniq_L = set_L.keys() res = 0 if len(uniq_L) < 3: print(res) else: for Li, Lj, Lk in combinations(uniq_L, 3): if Li + Lj > Lk and Li + Lk > Lj and Lj + Lk > Li: res += set_L[Li] * set_L[Lj] * set_L[Lk] print(res)
p02661
s638326457
Wrong Answer
from math import ceil, floor N = int(input()) A, B = [], [] for i in range(N): _a, _b = [int(x) for x in input().split()] A.append(_a) B.append(_b) A.sort() B.sort() min_mid, max_mid = 0, 0 if N % 2 != 0: mid = int((N-1)/2) min_mid, max_mid = A[mid], B[mid] else: mid = int(N / 2) min_mid = floor((A[mid-1] + A[mid]) / 2) max_mid = ceil((B[mid-1] + B[mid]) / 2) res = str(max_mid - min_mid + 1) print(res)
p02594
s165454763
Accepted
x = int(input()) if x >= 30: print('Yes') else: print('No')
p03633
s633677906
Wrong Answer
from fractions import gcd from functools import reduce n = int(input()) l = list(int(input()) for _ in range(n)) def lcm_base(x,y): return x*y/gcd(x,y) def lcm_list(t): return reduce(lcm_base,t) print(int(lcm_list(l)))
p03105
s120392090
Accepted
a,b,c=map(int,input().split()) print(min(b//a,c))
p03062
s811868070
Wrong Answer
n = int(input()) a = list(map(int, input().split())) b = [abs(i) for i in a] if (sum([i < 0 for i in a]) + sum([i == 0 for i in a]))% 2 == 0: print(sum(b)) else: b = [abs(i) for i in a] a0 = a.pop(0) af = a.pop() print(sum(b) - min(abs(a0), abs(af)) * 2)
p03160
s034064665
Wrong Answer
def chmin(a, b): if a > b: return b return a def main(): N = int(input()) hs = [i for i in map(int, input().split())] dp = [1e5]*100010 dp[0] = 0 for i in range(1, N): dp[i] = chmin(dp[i], dp[i-1] + abs(hs[i]-hs[i-1])) if i > 1: dp[i] = chmin(dp[i], dp[i-2] + abs(hs[i]-hs[i-2])) print(dp[N-1]) if __name__ == '__main__': main()
p02696
s324487320
Wrong Answer
import sys import math def IL(): return map(int,sys.stdin.readline().rstrip().split()) def Main(): a,b,n = IL() x = min(b,n) print(math.floor(a*x/b)-a*math.floor(x/b)) return if __name__=='__main__': Main()
p03854
s317208659
Accepted
#!/usr/bin/env python # coding: utf-8 # In[1]: S = input() # In[4]: f = True s_reversed = S[::-1] words = ['maerd', 'remaerd', 'esare', 'resare'] while s_reversed: length = len(s_reversed) for i in [7,6,5]: while s_reversed[:i] in words: s_reversed = s_reversed[i:] if length == len(s_reversed): print("NO") f = False break if f: print("YES") # In[ ]:
p02779
s243999250
Accepted
N = int(input()) A = list(map(int, input().split(" "))) A.sort() same = False for i in range(N - 1): if A[i] == A[i + 1]: same |= True print('NO' if same else 'YES')
p03262
s105649881
Accepted
import fractions N, X = list(map(int,input().split())) x = list(map(int,input().split())) x.append(X) x = sorted(x) difs=[] for i in range(N): difs.append(x[i+1] - x[i]) if i == 0: ans = difs[0] continue ans = fractions.gcd(ans, difs[i]) print(ans)
p03329
s310341329
Accepted
N = int(input()) Cash = sorted([1]+[6**T for T in range(1,7)]+[9**T for T in range(1,6)]) DPList = [0]*(N+1) for TN in range(1,N+1): DPList[TN] = min(DPList[TN-TC]+1 if TN>=TC else 1000000 for TC in Cash) print(DPList[N])
p02888
s460548131
Wrong Answer
#(0)入力環境 import bisect#listをsortしたまま要素を挿入できる n = int(input()) l = sorted(list(map(int,input().split()))) #(1)考察 #aとbの二重ループのなかで最後の一つは二分探索で高速に ans = 0 for i in range(n - 1): for j in range(i + 1, n): ans += bisect.bisect_left(l,l[i] + l[j]) - (j + 1) print(ans) print(ans)
p02838
s528428118
Accepted
#!/usr/bin/env python def main(): n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 ret = 0 magni = 1 for j in range(60): bin_cnt = [0, 0] for i in range(n): a[i], b = divmod(a[i], 2) bin_cnt[b] += 1 x, y = bin_cnt ret += x * y * magni % mod magni = magni * 2 % mod ret %= mod print(ret) if __name__ == '__main__': main()
p03427
s339974528
Accepted
N = input() ans = 0 if N[1:] == "9" * (len(N) - 1): ans = int(N[0]) + (9 * (len(N) - 1)) else: ans = int(N[0]) + 9 * (len(N) - 1) - 1 print(ans)
p02729
s785452499
Wrong Answer
N, M = map(int, input().split()) print(N*M-M)
p03759
s679443014
Accepted
a, b, c = map(int, input().split()) print("YES" if b - a == c - b else "NO")
p02572
s231778312
Accepted
n = int(input()) A = list(map(int, input().split())) M = 10**9 + 7 S = sum(A) S2 = sum(map(lambda x: x**2, A)) print(((S**2 - S2)// 2)%M)
p03910
s932190534
Wrong Answer
n = int(input()) if n % 2 == 0: print(n // 2) print(1) print(n // 2 - 1) else: print(n // 2 + 1) print(n - (n // 2 + 1))
p02866
s521052658
Accepted
from collections import Counter P = 998244353 N = int(input()) D = [int(x) for x in input().split()] def solve(): if D[0] != 0: return 0 total = 1 max_d = max(D) counter = Counter(D) if counter[0] != 1: return 0 for i in range(max_d + 1): if i not in counter: return 0 if i > 1: total *= (counter[i - 1] ** counter[i] % P) total %= P return total print(solve())
p03556
s072532359
Wrong Answer
N = int(input()) for i in range(1, N): if i*i > N: print((i-1)*(i-1)) exit() print(0)
p02882
s343736554
Accepted
import math a,b,x = map(int, input().split()) if x==a**2*b: print(0) exit() if a**2*b/2<=x: ans = 90-math.degrees(math.atan(a**3/2/(a**2*b-x))) else: ans = 90-math.degrees(math.atan(2*x/a/b**2)) print(ans)
p02912
s423983849
Accepted
import heapq n,m = map(int,input().split()) a = list(map(lambda x: int(x)*(-1),input().split())) a.sort(reverse=True) heapq.heapify(a) for i in range(m): x = -heapq.heappop(a) x //= 2 heapq.heappush(a,-x) print(-sum(a))
p02924
s994243185
Accepted
n=int(input()) print(n*(n-1)//2)
p03251
s278136804
Wrong Answer
[n,m,x,y] = [int(i) for i in input().split()] xs = [int(i) for i in input().split()] ys = [int(i) for i in input().split()] checker = 0 for i in range(x+1,y+1): #print(max(xs),i,min(ys)) if max(xs) < i and min(ys) >= i: checker = 1 if checker: print("No war") else: print("War")
p03126
s109837143
Accepted
N, M, *_ = map(int, open(0).read().split()) A = [] K_i = 0 for i in range(N): K = _[K_i] A.append(_[K_i+1 : K_i+1+K]) K_i += K + 1 ans = 0 for m in range(1, M+1): for k, a_i in enumerate(A, start=1): if m not in a_i: break if k == len(A): ans += 1 print(ans)
p03862
s580871622
Wrong Answer
n,x=map(int,input().split()) a=list(map(int,input().split())) s=[0]*(n-1) for i in range(n-1): s[i]=a[i]+a[i+1] ans=0 for i in range(n-2): if s[i]>x: t=s[i]-x s[i+1]-=t s[i]=x ans+=t if s[n-2]>x: ans+=s[n-2]-x print(ans)
p03221
s147554705
Accepted
N, M = map(int, input().split()) PY = [list(map(int, input().split())) + [i] for i in range(M)] PY.sort(key=lambda x: (x[0], x[1])) prev_p, i = PY[0][0], PY[0][2] out = [None] * len(PY) out[i] = str(prev_p).zfill(6) + str(1).zfill(6) cnt = 1 for p, y, idx in PY[1:]: if p != prev_p: cnt = 0 cnt += 1 prev_p = p out[idx] = str(p).zfill(6) + str(cnt).zfill(6) for x in out: print(x)
p02705
s159252938
Accepted
import math r = int(input()) print(math.pi*r*2)
p02911
s915800729
Wrong Answer
N, K, Q = map(int, input().split()) S = [K-Q]*N for i in range(Q): A = int(input()) S[A-1] += 1 C = [str(i+1) for i, s in enumerate(S) if s > 0] print("\n".join(C))
p03379
s902822611
Accepted
n = int(input()) x = list(map(int,input().split())) a = x[:] a.sort() kijun = a[n//2] a1 = a[n//2] a2 = a[n//2-1] for i in x: if i < kijun: print(a1) else: print(a2)
p02862
s038930659
Accepted
def solve(): x, y = map(int, input().split()) n = (2*y-x) / 3 m = (2*x-y) / 3 mod = 10**9+7 if n < 0 or m < 0 or (x+y)% 3 != 0: return 0 cmb = 1 n = int(n) m = int(m) cnt = 0 for i in range(n): cnt += 1 cmb *= n+m-i cmb *= pow(i+1, mod-2, mod) cmb %= mod return cmb print(solve())
p03437
s172933764
Accepted
x, y = map(int,input().split()) print([x, -1][x%y==0])
p02838
s697903425
Accepted
n=int(input()) a=list(map(int,input().split())) mod=10**9+7 ans=0 for i in range(60): x=1<<i o=len([0 for j in a if j&x]) ans+=x*o*(n-o) ans%=mod print(ans)
p02691
s519042060
Accepted
n = int(input()) A = list(map(int, input().split())) d = {} ans = 0 for i in range(n): if i-A[i] in d: ans += d[i-A[i]] if A[i]+i not in d: d[A[i]+i] = 1 else: d[A[i]+i] += 1 print(ans)
p03433
s563773549
Accepted
N=int(input()) A=int(input()) if (N%500) <= A : print("Yes") else: print("No")
p02682
s063122102
Wrong Answer
a,b,c,d = map(int,input().split()) ans = 0 if a >= d: ans = d elif (a + b) >= d: ans = a elif (a + b + c) >= d: ans = a - (d - (a+b)) else: ans = a - c if ans <= 0: ans = 0 print(ans)
p02742
s534166885
Wrong Answer
h, w = (int(x) for x in input().split()) if w%2 == 0: odd_row = w // 2 even_row = odd_row else: odd_row = w // 2 + 1 even_row = odd_row - 1 total = (h//2)*even_row + (h-h//2)*odd_row print(total)
p03264
s324071035
Accepted
def solve(): K = int(input()) a = K // 2 b = K - a print(a * b) if __name__ == '__main__': solve()
p02820
s952015763
Accepted
N, K = map(int, input().split()) R, S, P = map(int, input().split()) T = input() win = {"r": "p", "s": "r", "p": "s"} point = {"r": R, "s": S, "p": P} taka = [] ans = 0 for i in range(N): if i >= K: if win[T[i]] == taka[i - K]: taka.append("*") else: taka.append(win[T[i]]) ans += point[win[T[i]]] else: taka.append(win[T[i]]) ans += point[win[T[i]]] print(ans)
p02958
s850546685
Wrong Answer
N = int(input()) p = input().split() p = [int(num) for num in p] if p == sorted(p): print("Yes") else: q = sorted(p) t = 0 for i in range(N): if p[i] == q[i]: t += 1 if t == 2: print("Yes") else: print("No")
p02910
s080679296
Wrong Answer
s = input() x = len(s) - 1 m = 0 n = 1 c = 0 while m <= x: if s[m] == 'R': c += 1 m += 2 while n <= x: if s[n] == 'L': c += 1 n += 2 if c == 0: print('Yes') else: print('No')
p02753
s777611391
Wrong Answer
s = input() if s == "AAA": yn = "Yes" elif s == "BBB": yn = "Yes" else: yn = "No" print(yn)
p02628
s102707169
Wrong Answer
n,k=map(int,input().split()) l=list(map(int,input().split())) l.sort() s=0 print(sum(l[0:3]))
p03860
s224335302
Accepted
s = input().split() ans = "A" + s[1][0] + "C" print(ans)
p03285
s062535123
Accepted
# ABC105 B def main(): n = int(input()) res = 'No' for i in range(100 // 4): for j in range((100-i) // 7): if 4 * i + 7 * j == n: res = 'Yes' break print(res) if __name__ == '__main__': main()
p03545
s299903951
Accepted
def a(s,i): if i == l-1: if eval(s)==7: print(s+"=7") exit() return a(s+"+"+N[i+1],i+1) a(s+"-"+N[i+1],i+1) N = input() l = len(N) a(N[0],0)
p02727
s578837706
Wrong Answer
X,Y,A,B,C=map(int, input().split()) plist=list(map(int, input().split())) qlist=list(map(int, input().split())) rlist=list(map(int, input().split())) plist.sort(reverse=True) qlist.sort(reverse=True) rlist.sort(reverse=True) redlist = plist[:X] greenlist = qlist[:Y] RandG = redlist+greenlist RandG.sort() for i in range(min(X,Y,C)+2): if i > min(X,Y,C): break if sum(RandG[:i])>sum(rlist[:i]): break maxdeli = sum(RandG[i-1:]) + sum(rlist[:i-1]) print(maxdeli)
p03637
s633375649
Accepted
n = int(input()) a = list(map(int, input().split())) four = 0 two = 0 for i in range(n): if a[i] % 4 == 0: four += 1 elif a[i] % 2 == 0: two += 1 if 2 * four + 1 >= n: print("Yes") elif 2 * four + two >= n: print("Yes") else: print("No")
p03254
s830604454
Wrong Answer
N, x = map(int, input().split()) a = list(map(int, input().split())) sorted_a = sorted(a) cont = 0 for i in range(N): if x >= sorted_a[i]: cont += 1 x = x - sorted_a[i] if x != 0: cont = cont -1 print(cont)
p02702
s126563194
Accepted
s = input() n = 0 ans = 0 m = [0]*2019 m[0] = 1 for i, j in enumerate(reversed(s)): n = (n+int(j)*pow(10, i, 2019))%2019 m[n] += 1 for i in m: ans += i*(i-1)//2 print(ans)
p02683
s423003928
Accepted
def solve(string): import numpy from itertools import product n, m, x, *ca = map(int, string.split()) ca = numpy.array(ca).reshape((-1, m + 1)).T c, a = ca[0], ca[1:] ans = n * 10**5 + 1 for b in product([0, 1], repeat=n): b = numpy.array(b) if (a @ b.T).min() >= x: ans = min(ans, c @ b.T) return str(ans if ans <= n * 10**5 else -1) if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip()))
p03160
s293558113
Accepted
N = int(input()) h = list(map(int,input().split())) inf = float("inf") dp = [inf]*N dp[0] = 0 #initial situation dp[1] = abs(h[1]-h[0]) for i in range(2,N): dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2])) print(dp[N-1])
p03479
s610477693
Wrong Answer
x, y = map(int, input().split()) nx = x*2 i = 2 while nx*2 <= y: nx = nx*2 i += 1 print(i)
p02866
s445637590
Accepted
import sys from collections import Counter n = int(input()) D = list(map(int,input().split())) if D[0] != 0 or D.count(0) != 1: print(0) sys.exit() D = Counter(D) L = sorted(D.items()) pk = 0 pv = 1 ans = 1 for i,j in L: if i == 0: continue if i != pk+1: print(0) break ans *= pv**j ans %= 998244353 pk = i pv = j else: print(ans)
p02621
s482840099
Accepted
A=int(input()) print(A+A*A+A*A*A)
p02596
s806378293
Wrong Answer
k = int(input()) x = 7 e = 10 for i in range(10000000): # print(x) if x == 0: print(i + 1) exit() x = (x * e + 7) % k print("-1")
p03998
s868956098
Wrong Answer
A = input() B = input() C = input() l = [A,B,C] i = [1,0,0] p = 0 while i[p] != len(l[p]): card = l[p][i[p]] if card == "a": i[0] += 1 p = 0 if card == "b": i[1] += 1 p = 1 if card == "c": i[2] += 1 p = 2 print(["A","B","C"][p])
p03438
s450356947
Accepted
n = int(input()) ai = [int(i) for i in input().split()] bi = [int(i) for i in input().split()] sita = 0 ue = 0 for i in range(n): if ai[i] >= bi[i]: sita += ai[i] - bi[i] else: ue += (bi[i] - ai[i]+1) // 2 #print(sum(bi),sum(ai),ue,sita) if sum(bi) - sum(ai) - max(ue,sita) >= 0: print('Yes') else: print('No')
p02695
s380343128
Wrong Answer
import itertools n, m, q = map(int, input().split()) num_lists = [list(map(int, input().split())) for _ in range(q)] A = list(range(1, m+1)) ans = 0 for a in itertools.product(A, repeat=n): point = 0 for num_list in num_lists: if num_list[2] == a[num_list[1] - 1] - a[num_list[0] - 1]: point += num_list[3] ans = max(ans, point) print(ans)
p02959
s094000685
Wrong Answer
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) # 勇者iが倒せるモンスター数Ciは Ci <= min(A_i+A_i+1, B_i) # 各々の勇者が倒せる数だけ倒す貪欲法で行く C = [0]*N for i in range(N): C[i] += min(A[i],B[i]) C[i] += min(A[i+1],B[i]-min(A[i],B[i])) A[i+1] = A[i+1]-min(A[i]-B[i],0) print(sum(C))
p03994
s716953467
Accepted
s = list(input()) k = int(input()) for i in range(len(s)): if ord("z")-ord(s[i])+1<=k: k -= (ord("z")-ord(s[i])+1)%26 s[i] = "a" if k: s[-1] = chr((ord(s[-1])+k-ord("a"))%26+ord("a")) print("".join(s))
p03241
s797016672
Accepted
n,m=map(int,input().split()) num=m//n def make_divisors(n): divisors=[] for i in range(1,int(n**0.5)+1): if n%i==0: divisors.append(i) if i!=n//i: divisors.append(n//i) return divisors make=make_divisors(m) make.sort() import bisect ans=bisect.bisect_right(make,num) print(make[ans-1])
p03109
s251909494
Wrong Answer
y, m, d = map(int, input().split('/')) if m <= 4: print("Heisei") else: print("TBT")
p02963
s106633534
Accepted
s = int(input()) x1 = 0 a = 10**9 c = 1 y1 = 0 b = 0 d = 0 t = s//(10**9) if s%10**9==0: d = s//10**9 print(x1,y1,a,b,c,d) exit() d = t+1 b = 10**9-s%(10**9) print(x1,y1,a,b,c,d)
p04030
s602289883
Wrong Answer
s=list(input()) res=[] for i in s: if i=="b": res=res[:-1] else: res.append(i) print("".join(res))
p03556
s621328272
Accepted
print(int(int(input())**0.5)**2)
p03105
s861402109
Accepted
a,b,c = map(int,input().split()) if(b >= a * c): print(c) else: print(b // a)
p02547
s998941842
Accepted
N=int(input()) flag=0 count=0 for i in range(N): d1,d2=map(int,input().split()) if(d1==d2): count+=1 else: count=0 if(count==3): flag=1 break if(flag==1): print("Yes") else: print("No")
p03836
s570556980
Accepted
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) a,b,c,d = inpl() x = c-a y = d-b res = '' res += 'U' * y + 'R' * x res += 'D' * y + 'L' * x res += 'L' + 'U' * (y+1) + 'R' * (x+1) + 'D' res += 'R' + 'D' * (y+1) + 'L' * (x+1) + 'U' print(res)
p03645
s228814879
Wrong Answer
import numpy as np n,m = map(int, input().split()) from_start = np.array([]) to_end = np.array([]) for _ in range(m): temp = [] temp = list(map(int, input().split())) if temp[0]==1: from_start = np.append(from_start, temp[1]) elif temp[1]==n: to_end = np.append(to_end, temp[0]) if from_start in to_end: print('POSSIBLE') else: print('IMPOSSIBLE')
p02695
s139512281
Wrong Answer
N, M, Q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(Q)] ans = [] import itertools for A in itertools.combinations_with_replacement(range(1, M+1), N): tmp = 0 print(A) for a, b, c, d in abcd: if A[b-1] - A[a-1] == c: tmp += d ans.append(tmp) print(max(ans))
p03449
s819273158
Wrong Answer
n = int(input()) dp = [[0 for i in range(n)] for i in range(2)] a1 = list(map(int, input().split())) a2 = list(map(int, input().split())) dp[0][0] = a1[0] for i in range(1, n): dp[0][i] = dp[0][i - 1] + a1[i] dp[1][0] = a2[0] for i in range(1, n): dp[1][i] = max(dp[0][i] + a2[i], dp[1][i - 1] + a2[i]) if n == 1: print(a1[0] + a2[0]) else: print(dp[1][-1])
p03665
s856483586
Accepted
N, P = map(int, input().split()) odd = sum([int(i) % 2 for i in input().split()]) even = N-odd if odd == 0: if P == 0: print(2**even) else: # P==1 print(0) else: print(2**even * (2**odd//2))
p03623
s565699790
Accepted
x,a,b=map(int,input().split()) if abs(a-x)>abs(b-x): print('B') else: print('A')
p03206
s386592122
Accepted
d=int(input()) print('Christmas Eve Eve Eve' if d<23 else ('Christmas Eve Eve' if d<24 else ('Christmas Eve' if d<25 else 'Christmas')))
p02768
s339279939
Accepted
def ncr(n,r,z): x=1 y=1 for i in range(min(r,n-r)): x=(x*(n-i))%z y=(y*(i+1))%z y=pow(y,z-2,z) return x*y%z n,a,b=map(int,input().split()) mod=10**9+7 A=ncr(n,a,mod) B=ncr(n,b,mod) ans=pow(2,n,mod)-1-A-B while ans<0: ans+=mod print(ans)
p02630
s356749021
Accepted
from sys import stdin from sys import setrecursionlimit from collections import Counter setrecursionlimit(10 ** 7) n = int(input()) a = list(map(int,stdin.readline().rstrip().split())) su = sum(a) q = int(input()) cc = Counter(a) for _ in range(q): b,c = map(int,input().split()) cc[c] += cc[b] su += c*cc[b]-b*cc[b] cc[b] -= cc[b] print(su)
p03150
s827473501
Accepted
S=input() N=len(S) if S=="keyence": print("YES") exit() for i in range(N): for j in range(i,N): tmp="" for k in range(N): if i<=k and k<=j: continue tmp=tmp+S[k] if tmp=="keyence": print("YES") exit() print("NO")
p02860
s044269411
Accepted
n = int(input()) if n % 2 == 1: print("No") exit() s = input() if n % 2 == 0: if s[n//2:] == s[:n//2]: print("Yes") else: print("No")
p02603
s157569013
Wrong Answer
n=int(input()) a=list(map(int, input().split())) delta_a = [0] * (n-1) for i in range(n-1): delta_a[i] = a[i+1] - a[i] stock = 0 money = 1000 for i in range(n-1): if delta_a[i] > 0 and (delta_a[i-1] < 0 or i == 0): stock = money // a[i] money = money % a[i] elif delta_a[i] < 0 and delta_a[i-1] >= 0 and stock != 0: money += stock * a[i] stock = 0 if stock != 0: money += stock * a[n-1] print(money)
p02760
s878642759
Accepted
import numpy as np a = [] a.append([int(x) for x in input().split()]) a.append([int(x) for x in input().split()]) a.append([int(x) for x in input().split()]) n = int(input()) b = [] for i in range(n): b.append(int(input())) ans = 'No' for i in range(3): if set(np.array(a)[:, i]) <= set(b) or set(np.array(a)[i, :]) <= set(b): ans = 'Yes' if set([a[0][0], a[1][1], a[2][2]]) <= set(b) or set([a[2][0], a[1][1], a[0][2]]) <= set(b): ans = 'Yes' print(ans)
p02607
s914268756
Accepted
N,*A=map(int,open(0).read().split());print(len([i for i in A[::2]if i%2]))
p03623
s071389893
Accepted
x,a,b=map(int,input().split()) if abs(x-a)>abs(x-b): print("B") else: print("A")
p03624
s325968460
Accepted
S=input() cnt=[0]*26 for i in S: cnt[ord(i)-97]+=1 for i in range(26): if(cnt[i]==0): print(chr(i+97)) exit() print("None")
p02629
s352389952
Wrong Answer
N=int(input()) alp=["a","b","c","d","e","f","g","h","i", "j","k","l","m","n","o","p","q","r", "s","t","u","v","w","x","y","z"] S="" while N>0: Q=N%26 N=N//26 S+=alp[Q-1] print(S[::-1])