problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03161
s391338459
Accepted
import numpy as np n, k = map(int, input().split()) h = np.array(input().split(), dtype=np.int64) dp = np.zeros(n, dtype=np.int64) for i in range(1, n): l = max(0, i-k) dp[i] = np.min(np.abs(h[i] - h[l:i]) + dp[l:i]) print(dp[-1])
p02713
s848606297
Accepted
from math import gcd def main(): #startline------------------------------------------- k = int(input()) ans = 0 for i in range(1,k+1): for j in range(1,k+1): for l in range(1,k+1): ans += gcd(gcd(i,j),l) print(ans) if __name__ == "__main__": main() #endline===============================================
p03861
s776600902
Wrong Answer
a, b, x = map(int, input().split()) cnt = 0 for i in range(1, int(1e18)): if a <= x*i and x*i <= b: cnt += 1 elif b <= x*i: break print(cnt)
p03319
s898454165
Wrong Answer
n, k = map(int, input().split()) a = list(map(int, input().split())) i = a.index(1) ans = (min(i, n - k) + k - 2) // (k - 1) + (max(n - 1 - i, k - 1) + k - 2) // (k - 1) print(ans)
p03994
s691799129
Accepted
S = input() K = int(input()) ord_a = ord('a') ord_z = ord('z') k = K Ans = list(S) for i, s in enumerate(S[:-1]): ord_s = ord(s) dif = ord_z - ord_s + 1 # print(i, k, dif) if s == 'a': Ans[i] = 'a' elif dif <= k: Ans[i] = 'a' k -= dif else: pass Ans[-1] = chr(ord_a + (ord(Ans[-1]) + k - ord_a)%26) print(''.join(Ans))
p02641
s394884344
Wrong Answer
xn=input().split() x=int(xn[0]) n=int(xn[1]) data=input().split() for i in range(100): for d in data: if int(d) != x-i: print(int(d)) break elif int(d) != x+i: print(int(d)) break else: continue break
p02760
s048800239
Accepted
import numpy as np A = np.array(sum((input().split() for _ in range(3)), []), dtype=np.int8) N = int(input()) for _ in range(N): np.multiply(A, A != int(input()), out=A) A.resize(3, 3) print("YNeos"[np.trace(A) and np.trace(np.rot90(A)) and A.sum(axis=0).all() and A.sum(axis=1).all()::2])
p03997
s493971265
Wrong Answer
a = int(input()) b = int(input()) h = int(input()) print((a + b) / 2 * h)
p03126
s918563456
Accepted
n,m=map(int,input().split()) a=[0]*m b=[list(map(int,input().split())) for _ in range(n) ] for i in range(n): c=b[i][0] for j in range(1,c+1): a[b[i][j]-1]+=1 print(a.count(n))
p02684
s538692220
Wrong Answer
n, k = map(int,input().split()) a = list(map(int,input().split())) s = 0 seen = [False for _ in range(n)] d = [] while not seen[s]: seen[s] = True d.append(s) s = a[s]-1 noncyi = d.index(s) cyi = len(d) - noncyi if k < noncyi: print(d[k-1]) else: k -= noncyi print(d[noncyi + k%cyi]+1)
p02772
s201489584
Accepted
n=int(input()) a = list(map(int,input().split())) even=[el for el in a if el % 2==0] try: for a in even: if a % 3 == 0 or a % 5 == 0: flg = 1 else: raise except: print('DENIED') else: print('APPROVED')
p02618
s551745007
Accepted
D=int(input()) C=list(map(int,input().split())) import numpy as np L=np.zeros(26,dtype=np.int) ans=[] for d in range(D): L+=1 X=L*C xi=X.argmax() S=list(map(int,input().split())) si=np.argmax(S) if si==xi: ans.append(si+1) L[si]=0 elif S[si]-C[xi]>X[xi]: ans.append(si+1) L[si]=0 else: ans.append(xi+1) L[xi]=0 for a in ans: print(a)
p02773
s579771966
Wrong Answer
N = int(input()) S = [] for i in range(N): S.append(input()) S.sort() T = {S[0]:1} for j in range(1,N): if S[j] not in T: T[S[j]] = 1 else: T[S[j]] += 1 T_sorted = sorted(T.items(),key = lambda x:-x[1]) maxT = T_sorted[0][1] print(T_sorted) for k in range(len(T_sorted)): if T_sorted[k][1] != maxT: break print(T_sorted[k][0])
p02663
s622894503
Wrong Answer
h1, m1, h2, m2, k = map(int, input().split()) H = (h2-h1)*60 M = abs(m1-m2) print(H-M-k)
p03625
s951310898
Accepted
N = int(input()) A = [int(x) for x in input().split()] pair = [] unpair = set() for a in A: if a in unpair: pair.append(a) unpair.remove(a) else: unpair.add(a) pair.sort() pair.reverse() if len(pair) <= 1: ans = 0 else: ans = pair[0] * pair[1] print(ans)
p02678
s184446198
Wrong Answer
print("No")
p02953
s921756265
Accepted
N = int(input()) H = list(map(int, input().split())) ans = 'Yes' _max = 0 for i in H: if _max < i - 1: _max = i - 1 if _max > i: ans = 'No' print(ans)
p02958
s354111647
Accepted
#整数の入力 A = int(input()) #スペース区切りの整数の入力リスト S_list = list(map(int, input().split())) A_list = [] for i in range(A): A_list.append(i+1) S_list[i] = int(S_list[i]) counter = 0 for i in range(A): if(A_list[i] != S_list[i]): counter = counter + 1 if((counter == 0)or(counter == 2)): print("YES") else: print("NO")
p02646
s602603466
Accepted
import math import itertools import collections import bisect import heapq def IN(): return int(input()) def sIN(): return input() def MAP(): return map(int,input().split()) def LMAP(): return list(map(int,input().split())) def TATE(n): return [input() for i in range(n)] MOD = 10**9 + 7 a,v = MAP() b,w = MAP() t = IN() if b > a: if a+v*t >= b+w*t: print('YES') else: print('NO') else: if a-v*t <= b-w*t: print('YES') else: print('NO')
p03624
s999076770
Accepted
S = input() s = set([c for c in S]) x = 'abcdefghijklmnopqrstuvwxyz' for a in s: x = x.replace(a, '') if len(x) == 0: print('None') else: print(x[0])
p02693
s571862063
Accepted
K = int(input()) A,B = map(int,input().split()) flag = 0 for i in range(A,B+1): if i % K == 0: flag = 1 break if flag == 1: print("OK") else: print("NG")
p03001
s002128785
Accepted
W, H, x, y = map(int, input().split()) area = W*H/2 if x == W/2 and y == H/2: print(area, 1) else: print(area, 0)
p03659
s758110570
Accepted
N = int(input()) a = list(map(int, input().split())) sa = a[:] for i in range(N-1): sa[i+1] += sa[i] diff = float('inf') for i in range(N-1): if abs(sa[i] - (sa[-1] - sa[i])) < diff: diff = abs(sa[i] - (sa[-1] - sa[i])) print(diff)
p03778
s168384833
Wrong Answer
a,b,c = map(int,input().split()) ab = abs(a-b) if ab <= c: print(0) else: print(ab-c)
p03435
s222802155
Wrong Answer
C11, C12, C13 = map(int, input().split()); C21, C22, C23 = map(int, input().split()); C31, C32, C33 = map(int, input().split()); # a1 = 0と仮定して他を調整する b1 = C11; b2 = C12; b3 = C13; a2 = C21 - b1; a3 = C31 - b1; if (a2 >= 0 and a2 <= 100 and C22 == a2 + b2 and C23 == a2 + b3 and a3 >= 0 and a3 <= 100 and C32 == a3 + b2 and C33 == a3 + b3): print("Yes"); else: print("No");
p03767
s002097213
Accepted
n = int(input()) a = sorted(map(int, input().split())) ans = 0 for i in range(n, 3 * n, 2): ans += a[i] print(ans)
p03386
s910152067
Wrong Answer
A, B, K = map(int, input().split()) if A + B <= K * 2: for i in range(A, B + 1): print(i) else: for i in range(A, A + K): print(i) for i in range(B - K + 1, B + 1): print(i)
p02606
s139951632
Accepted
import sys L, R , d = map(int, input().split()) ans = 0 for i in range(L,R + 1): if R < d: break if ( i % d ) == 0: ans += 1 print(ans)
p02951
s742510588
Accepted
A,B,C=map(int,input().split()) a=A-B b=C-a if b<=0: print(0) else: print(b)
p03103
s635766716
Accepted
n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] sorted_ab = sorted(ab, key=lambda x: x[0]) i,ans,cnt = 0,0,0 while cnt < m: ans += sorted_ab[i][0]*min(m-cnt,sorted_ab[i][1]) cnt += min(m-cnt,sorted_ab[i][1]) i+=1 print(ans)
p02623
s656098789
Accepted
from itertools import accumulate from bisect import bisect n, m, k = map(int, input().split()) (*a,) = accumulate(map(int, input().split())) (*b,) = accumulate(map(int, input().split())) a = (0,) + tuple(i for i in a if i <= k) b = tuple(i for i in b if i <= k) print(max(i + bisect(b, k - a[i]) for i in range(len(a))))
p03557
s973401061
Wrong Answer
import bisect 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() d=0 for i in B: d+=bisect.bisect_right(A,i+0.1)*(N-bisect.bisect_left(C,i-0.1)) print(d)
p03069
s006347283
Wrong Answer
import sys ## io ## def IS(): return sys.stdin.readline().rstrip() def II(): return int(IS()) def MII(): return list(map(int, IS().split())) from collections import Counter #======================================================# def main(): n = II() s = IS() cnt_b = 0 cnt_w = s.count('.') cnt = 2*10**5 for si in s: if si == '#': cnt_b += 1 else: cnt_w -= 1 cnt = min(cnt, cnt_b+cnt_w) print(cnt) if __name__ == '__main__': main()
p02783
s009735794
Accepted
h, a = list(map(int, input().split())) print((h+a-1)//a)
p02909
s305212435
Accepted
S = input() pred = "" if S == "Sunny": pred = "Cloudy" elif S == "Cloudy": pred = "Rainy" elif S == "Rainy": pred = "Sunny" print(pred)
p03485
s381534474
Accepted
a=list(map(int,input().split())) print(-(-sum(a)//2))
p03150
s908508196
Wrong Answer
import sys, re input = sys.stdin.readline S = input() if S == 'keyence' or re.fullmatch(r'[a-z]+keyence', S) or re.match(r'k[a-z]+eyence', S) or re.match(r'ke[a-z]+yence', S) or re.match(r'key[a-z]+ence', S) or re.match(r'keye[a-z]+nce', S) or re.match(r'keyen[a-z]+ce', S) or re.match(r'keyenc[a-z]+e', S) or re.fullmatch(r'keyence[a-z]+', S): print('YES') else: print('NO')
p04012
s526351980
Accepted
from collections import Counter s = input() ans = [False if i%2 else True for i in Counter(s).values()] print("Yes" if all(ans) else "No")
p03730
s549338952
Accepted
A, B, C = map(int, input().split()) count=0 for i in range(101): if A*(i+1)%B==C: print("YES") break else: count=count+1 if count==101: print("NO")
p02713
s213296085
Wrong Answer
import fractions from functools import reduce import itertools k = int(input()) l = list(range(1, k + 1)) ans = 0 for v in itertools.product(l, repeat=3): ans += min(list(v)) print(ans)
p03943
s664704961
Accepted
a = list(map(int, input().split())) a.sort() if a[0]+a[1] == a[2]: print('Yes') else: print('No')
p03359
s650427997
Accepted
a, b = map(int,input().split()) print(a-1 if a>b else a)
p02718
s049129693
Accepted
#python3 def main(): n, m = map(int, input().split()) a = [int(i) for i in input().split()] s = sum(a) x = s/(4*m) c = 0 for i in range(n): if x > a[i]: c += 1 k = n-c if k >= m: print('Yes') else: print('No') main()
p03087
s205396546
Wrong Answer
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline n,q = map(int, input().split()) s = input().rstrip() lr = [list(map(int, input().split())) for _ in range(q)] cnt = [0] * (n) for i in range(0, n - 1): if s[i] == 'A' or s[i + 1] == 'C': cnt[i + 1] = cnt[i] + 1 else: cnt[i + 1] = cnt[i] for i in range(q): ll = lr[i][0] - 1 rr = lr[i][1] - 1 print(cnt[rr] - cnt[ll])
p03434
s810374336
Wrong Answer
N = int(input()) A = list(map(int,input().split())) A = sorted(A,reverse = True) A.insert(N,0) print(A) ans = 0 for i in range(0,N,2): ans += (A[i] - A[i+1]) print(A[i],A[i+1]) print(ans)
p02953
s791377434
Accepted
N = int(input()) H = list(map(int, input().split())) f = True H[0] -= 1 for i in range(1, N): if H[i - 1] > H[i]: f = False break elif H[i - 1] < H[i]: H[i] -= 1 print("Yes" if f else "No")
p02663
s569387307
Accepted
h1,m1,h2,m2,k = map(int,input().split()) time = (h2 - h1) * 60 + (m2 - m1) print(time - k)
p02797
s722517272
Wrong Answer
import math n,k,s=[int(i) for i in input().split()] ans="" a=str(s//2) b=str(math.ceil(s/2)) for i in range(n): if i==0: ans+=a elif i==1: ans+=b elif i>k: if(s==10**9): ans+=str(10**9-1) else: ans+=str(10**9) elif i%2==0: ans+=a elif i%2==1: ans+=b ans+=" " print(ans[:-1])
p03681
s550649355
Wrong Answer
import math N,M=map(int,input().split()) p=10**9 +7 ans=(math.factorial(N)+math.factorial(M))*2 % p print(ans)
p02583
s813600135
Accepted
n = int(input()) l = list(map(int, input().split())) l = sorted(l) count = 0 for i in range(2, n): for j in range(1, i): for k in range(j): if l[j] + l[k] > l[i] and l[i] != l[j] != l[k]: count += 1 print(count)
p02756
s832730289
Accepted
S = input() Q = int(input()) arr1 = [] arr2 = [] count = 1 for _ in range(Q): q = input() if q == "1": count *= -1 else: _, f, c = map(str, q.split()) if f == "1": arr1.append(c) if count == 1 else arr2.append(c) else: arr2.append(c) if count == 1 else arr1.append(c) if count == 1: ans = "".join(arr1[::-1]) + S + "".join(arr2) else: ans = "".join(arr2[::-1]) + S[::-1] + "".join(arr1) print(ans)
p03557
s619174900
Accepted
import bisect 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 i in range(N): l = bisect.bisect_left(A, B[i]) r = N - bisect.bisect_right(C, B[i]) ans += l * r print(ans)
p02814
s024252139
Accepted
from fractions import gcd N, M = map(int, input().split()) a = list(map(int, input().split())) k = a[0] for i in range(1, N): k = (a[i]*k) // gcd(a[i], k) if k > M*2: print(0) exit(0) k = int(k) ans = (M - (k // 2)) // k if M >= (k // 2): flag = True for i in range(N): if (k // a[i]) % 2 == 0: print(0) exit(0) if flag: ans += 1 print(int(ans))
p03284
s363940539
Accepted
a,b = map(int,input().split()) if a % b == 0: print(0) else: print(1)
p02835
s001666509
Accepted
a1, a2, a3 = map(int, input().split()) A = a1 + a2 + a3 if A >= 22: print("bust") else: print("win")
p03220
s239176443
Accepted
import numpy as np n = int(input()) t, a = map(int, input().split()) h = np.array(list(map(int, input().split()))) A = list(map(lambda x: abs(a-(t-x*0.006)), h)) [idx] = [i for i, x in enumerate(A) if x == min(A)] print(idx+1)
p02829
s037613804
Wrong Answer
A = int(input()) B = int(input()) if A == 1 and B == 2: print('3') elif A == 2 and B == 3: print('1') else: print('2')
p03778
s734185776
Accepted
(W,a,b) = map(int,input().split()) if a+W<b: print(b-(a+W)) elif b+W<a: print(a-(b+W)) else: print(0)
p02601
s954997194
Accepted
A,B,C = map(int,input().split()) K = int(input()) c = 0 while A >= B: B *= 2 c += 1 while B >= C: C *= 2 c += 1 if c <= K: print("Yes") else: print("No")
p02705
s199126147
Accepted
r = int(input()) print(r*2*3.14159265)
p03095
s885621899
Wrong Answer
N = int(input()) S = input() M = 10**9 + 7 cash = set() from collections import Counter cs = Counter(S) ans = 1 for key, val in cs.items(): ans *= (val + 1) %M ans -= 1 print(ans)
p03555
s819746607
Accepted
s_1 = input() s_2 = input() ans = "YES" if s_1[0] != s_2[2] or s_1[1] != s_2[1] or s_1[2] != s_2[0]: ans = "NO" print(ans)
p02726
s483897462
Accepted
node_num, l_connected_node, g_connected_node = [int(n) for n in input().rstrip().split()] l_connected_node-=1 g_connected_node-=1 count=[0]*node_num for i in range(node_num-1): for j in range(i+1, node_num): count[min(j-i, abs(i-l_connected_node)+abs(j-g_connected_node)+1)]+=1 for x in range(1, node_num): print(count[x])
p02693
s363490724
Wrong Answer
import sys lines = sys.stdin.readlines() K = int(lines[0]) X = lines[1].split(' ') print(X) A = X[0] B = X[1] n = int(int(A)/int(K)) m = int(int(B)/int(K)) if m-n >0: print('OK') else: print('NG')
p03997
s670834329
Accepted
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
p03779
s778302575
Wrong Answer
def get_index(n): i=1 while True: if n<piramid(i): return i-1 i+=1 def piramid(n): return n*(n+1)//2 n=int(input()) index=get_index(n) print(min(index+n-piramid(index),index+2+piramid(index+1)-n))
p02633
s760348944
Accepted
x = int(input()) n = 1 while (x*n)%360!=0: n+=1 print(n)
p02833
s346883865
Wrong Answer
N=int(input()) five=5 two=2 F=0 T=0 if N%2==1: print(0) else: N = int(N/2) T += N while five < N: F += int(N//five) five *= 5 print(int(F))
p03351
s567492115
Accepted
# 絶対値はabs関数 a,b,c,d=map(int,input().split()) if abs(a-b)<=d and abs(b-c)<=d or abs(a-c)<=d: print('Yes') else: print('No')
p02843
s338920816
Accepted
n=int(input()) maxketa = n//100 if n <= maxketa*100+5*maxketa: print(1) else: print(0)
p03317
s199511593
Accepted
import math N, K = map(int, input().split()) A = list(map(int, input().split())) ans = 0 print(math.ceil((N-1)/(K-1)))
p03493
s898398678
Accepted
S = input() count = 0 for i in range(3): if S[i] == '1': count += 1 print(count)
p02786
s157622068
Accepted
h =int(input()) count =0 while(h>0): h = int(h/2) count+=1 ans=0 for i in range(count): ans += 2**i print(ans)
p02753
s146865191
Accepted
# import sys import math import numpy as np import itertools p=input() if p=='AAA' or p == 'BBB': print("No") else: print("Yes")
p04005
s524103707
Wrong Answer
def main(): ABC = list(map(int,input().split())) tmp = [0,0,0] cube = ABC[0]*ABC[1]*ABC[2] for i in range(3): base = cube/ABC[i] tmp[i] = abs((ABC[i]//2*base)-((ABC[i]-ABC[i]//2)*base)) print(int(min(tmp))) if __name__ == '__main__': main()
p03062
s872201615
Wrong Answer
n = int(input()) a = list(map(int,input().split())) for i in range(n-1): if a[i] < 0: if a[i] + a[i+1] <= 0: a[i],a[i+1] = (-1)*a[i],(-1)*a[i+1] print(sum(a))
p02819
s656087878
Accepted
A =int(input()) def Primenumber(i): if i == 2: return 2 for j in range(2,(i//2)+1): if i % j == 0: return Primenumber(i+1) elif j == i//2: return i print(Primenumber(A))
p03434
s749253726
Accepted
#ABC088 m = int(input()) a = sorted(list(map(int,input().split())),reverse=True) p = 0 q = 0 for i in range(len(a)//2): p += a[2 * i] q += a[2 * i + 1] if len(a) % 2 != 0: p += a[-1] print(p-q)
p02547
s252309306
Accepted
## coding: UTF-8 N = int(input()) D = [list(map(int, input().split())) for _ in range(N)] #print(N, D) ans = "No" renzoku = 0 for i in range(N): if(D[i][0] == D[i][1]): renzoku += 1 if(renzoku >= 3): ans = "Yes" else: renzoku = 0 print(ans)
p02553
s891436167
Accepted
a, b, c, d = list(map(int,input().split())) print(max(a * c, a * d, b * c, b * d))
p02935
s600294712
Accepted
N = int(input()) V = sorted([float(v) for v in input().split()]) while len(V) > 1: if len(V) > 2: pick = V[0:2] V = [sum(pick)/2] + V[2:] else: V = [sum(V)/2] print(V[0])
p03136
s671239393
Wrong Answer
n = int(input()) l = list(map(int, input().split())) print("Yes" if max(l) < sum(l) else "No")
p03487
s760642767
Accepted
from collections import Counter n=int(input()) a=Counter(input().split()) ans=0 for i,j in a.items(): i=int(i) if i>j: ans+=j elif i<j: ans+=j-i print(ans)
p02629
s222167281
Accepted
n = int(input()) def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) print(num2alpha(n).lower())
p02689
s231848070
Accepted
N, M = map(int, input().split()) H_list = list(map(int, input().split())) N_list = [0] * N for _ in range(M): A, B = map(int, input().split()) if H_list[A-1] >= H_list[B-1]: N_list[B-1] = 1 if H_list[A-1] <= H_list[B-1]: N_list[A-1] = 1 print(N_list.count(0))
p02784
s807203398
Accepted
H, N = map(int, input().split()) A = map(int, input().split()) print("Yes" if sum(A) >= H else "No")
p03474
s648356192
Accepted
a,b = map(int, input().split()) s = list(input()) if len(s) != a+b+1: print("No") else: for i in range(a): if s[i] == "-": print("No") exit() if s[a] != "-": print("No") exit() for j in range(a+1,a+b+1): if s[j] == "-": print("No") exit() print("Yes")
p03665
s008114469
Accepted
n, p = map(int, input().split()) A = list(map(int, input().split())) for a in A: if a % 2 != 0: break else: if p == 1: print(0) exit() if p == 0: print(2**n) exit() ans = 2**(n-1) print(ans)
p02835
s844265522
Accepted
A=[int(s) for s in input().split()] print("bust" if sum(A)>=22 else "win")
p02641
s231518848
Wrong Answer
X,N = map(int,input().split()) p = list(map(int,input().split())) if N == 0: print(X) else: count = 0 ans = 0 while True: count +=1 if X-count not in p: ans = X-count break elif X+count not in p: ans = X+count break print(ans)
p03681
s274745366
Accepted
# ABC065c import sys import math input = sys.stdin.readline sys.setrecursionlimit(10**6) n, m = map(int, input().split()) MOD = 10**9+7 if not (n == m or n == m-1 or n == m+1): print(0) exit(0) if n == m: print(math.factorial(n) % MOD * math.factorial(n) % MOD * 2 % MOD) exit(0) print(math.factorial(n) % MOD*math.factorial(m) % MOD)
p03262
s122639603
Accepted
f=lambda:map(int,input().split()) _,x=f() m=[abs(i-x) for i in f()] from fractions import * a=m.pop() for i in m: a=gcd(a,i) print(a)
p03625
s381196834
Accepted
from collections import Counter n = int(input()) A = list(map(int, input().split())) c = Counter(A) pair = [] # print(c) for x, cnt in c.items(): pair += [x] * (cnt//2) # print(pair) pair.sort() ans = 0 if len(pair) >= 2: ans = pair[-1] * pair[-2] print(ans)
p02801
s999448511
Wrong Answer
x=input("alphabet:") print(chr(ord(x)+1))
p04045
s111678254
Accepted
# /usr/bin/env python3 # https://atcoder.jp/contests/abc042/tasks/arc058_a n, k = input().split() d = input().split() while True: if len(set(n) & set(d)) == 0: print(n) break n = str(int(n) + 1)
p02640
s848891850
Accepted
X, Y = map(int,input().split()) turu=X kame=0 Flag=False while turu>=0: total=4*turu+2*kame if total==Y: Flag=True break else: turu+=-1 kame+=1 print("Yes" if Flag is True else "No")
p03471
s888967837
Accepted
def main(): N, Y = map(int, input().split()) for i in range(0, N+1): for j in range(0, N+1): if N-i-j < 0: continue if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y: print(i, j, (N-i-j)) return print(-1, -1, -1) main()
p03013
s654691846
Accepted
N,M = map(int,input().split()) MOD = 10**9+7 dp = [0] * (N+1) dp[1] = 1 for _ in range(M): dp[int(input())] = -1 if N<2: print(dp[N]) exit() if dp[2] != -1: dp[2] = 1 for i in range(N+1): if dp[i] == -1: continue if i-1>=0 and dp[i-1] != -1: dp[i] += dp[i-1] if i-2>=0 and dp[i-2] != -1: dp[i] += dp[i-2] dp[i] %= MOD print(dp[N])
p02578
s806655689
Accepted
N = int(input()) A = list(map(int, input().split())) sum = 0 for i in range(N)[1:]: if A[i-1]>A[i]: sum += A[i-1]-A[i] A[i] = A[i-1] print(sum)
p03994
s902676477
Accepted
def c2a(c): return (26 - ord(c) + ord("a")) % 26 s = input() k = int(input()) l = len(s) ans = "" for i, e in enumerate(s, 1): if i == l: code = (ord(e) - ord("a") + k) % 26 + ord("a") c = chr(code) else: cnt = c2a(e) if cnt <= k: c = "a" k -= cnt else: c = e ans += c print(ans)