problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02554
s877004506
Accepted
n=int(input()) x=pow(10,n,10**9+7)-2*pow(9,n,10**9+7)+pow(8,n,10**9+7) print(x%(10**9+7))
p02714
s552560644
Accepted
n = int(input()) s = input() count_r = s.count("R") count_g = s.count("G") count_b = s.count("B") sum = count_r * count_g * count_b minus = 0 for i in range(n-2): for j in range(2, n-i+1, 2): if i+j <= n-1: tem = [s[i], s[i+j//2], s[i+j]] if tem[0] != tem[1] and tem[0] != tem[2] and tem[1] != tem[2]: minus += 1 print(sum - minus)
p02693
s501748953
Accepted
n = int(input()) a,b = map(int,input().split()) dif = b//n-a//n if dif == 0 and b%n != 0 and a%n !=0 : print("NG") else: print("OK")
p02854
s466700085
Wrong Answer
def main(): section_num = int(input()) length = list(map(int, input().split())) sums = [sum(length[:section_num // 2]), sum(length[section_num // 2:])] answer = abs(sums[0] - sums[1]) sums[0] += length[section_num // 2] sums[1] -= length[section_num // 2] answer = min(answer, abs(sums[0] - sums[1])) print(answer) if __name__ == '__main__': main()
p03605
s101425192
Accepted
#https://atcoder.jp/contests/abc073/tasks/abc073_a if "9" in str(input()): print("Yes") else: print("No")
p03377
s378776098
Wrong Answer
a, b, x = map(int, input().split()) if x < a + b: print("YES") else: print("NO")
p02659
s205396366
Accepted
from decimal import Decimal a,b = input().split() print(int(Decimal(a) * Decimal(b)))
p03105
s063455322
Accepted
A, B, C = map(int, input().split()) ans = min(B // A, C) print(ans)
p03379
s235637377
Wrong Answer
N=int(input()) X=sorted(list(map(int,input().split()))) for i in range(N): if i<(N//2): print(X[N//2]) else: print(X[N//2-1])
p03773
s930206485
Accepted
import sys input = sys.stdin.readline a,b=map(int,input().split()) print((a+b)%24)
p03478
s845364567
Accepted
#ANS-3 input_N,A,B = input().split() A = int(A) B = int(B) count = 0 for i in range(int(input_N)+1): sum_all = 0 i_str = str(i) for j in range(len(i_str)): sum_all += int(i_str[j]) if A<=sum_all: if sum_all<=B: count += i print(count)
p02583
s114220198
Accepted
from itertools import combinations def triangle(l_tuple): if len(set(l_tuple)) == 3: if l_tuple[0] + l_tuple[1] > l_tuple[2] and l_tuple[1] + l_tuple[2] > l_tuple[0] and l_tuple[2] + l_tuple[0] > l_tuple[1]: return True return False n = int(input()) l = list(map(int, input().split())) l_comb = list(combinations(l, 3)) cnt = 0 for i in l_comb: if triangle(i): cnt += 1 print(cnt)
p04030
s792142968
Wrong Answer
# -*- coding : utf-8 -*- S = str(input()) w = "" if len(S) == 0: if S[0] == "B": w = "" else : w = w + S[0] else: if S[0] == "B": w = "" else : w = w + S[0] for i in range(1,len(S)): if S[i] == "B": if w == "": w = "" else : w = w.rstrip(S[i-1]) else: w = w + S[i] print(w)
p02665
s915001681
Wrong Answer
N = int(input()) A = list(map(int, input().split())) last = A[-1] count = last root = 1 for i in range(N): if i+1 == N and root-A[i] > A[i+1]: root = last + A[i] elif root-A[i] > (last + A[i+1]): root = (last + A[i+1]) + A[i] count+=root root = (root-A[i])*2 if root < A[i+1]: print(-1) break else: print(count)
p02708
s777778312
Accepted
N, K = map(int, input().split()) ans = 0 mod = 10 ** 9 + 7 def sum_num(n): return (n*(n+1))//2 for k in range(K, N+1): min_sum = sum_num(k-1) max_sum = sum_num(N) - sum_num(N-k) # print(k, min_sum, max_sum) ans += max_sum - min_sum + 1 ans += 1 ans %= mod print(int(ans))
p02724
s488857558
Accepted
X = int(input()) print(X//500*1000 + (X-X//500*500)//5*5)
p02747
s928574211
Accepted
s = input() h = 'hi' if s == h or s == h * 2 or s == h * 3 or s == h * 4 or s == h * 5: print('Yes') else: print('No')
p03624
s630725980
Accepted
S = input() lll = "abcdefghijklmnopqrstuvwxyz" for i in range(26): if lll[i] in S: pass else: print(lll[i]) exit() print("None")
p03711
s480519872
Accepted
x, y = map(int, input().split()) a = [4, 6, 9, 11] b = [1, 3, 5, 7, 8, 10, 12] if x == 2 or y == 2: print('No') elif x in a and y in a: print('Yes') elif x in b and y in b: print('Yes') else: print('No')
p02916
s403223123
Accepted
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) sum=0 for i in range(n): sum+=b[a[i]-1] if i>0 and a[i]==a[i-1]+1: sum+=c[a[i-1]-1] print(str(sum))
p02847
s810716271
Accepted
s = input() ls =["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"] t = ls.index(s) print(7-t)
p02701
s424098438
Accepted
N = int(input()) X = set([input() for _ in range(N)]) print(len(X))
p03087
s568316334
Accepted
n, q = map(int, input().split()) s = input() """ナイーブ for i in range(q): l, r = map(int, input().split()) print(s[l-1:r].count("AC")) """ # 前処理+全探索 # 区間なので累積和を疑う t = [0]*n count = 0 for i in range(n-1): t[i] = count if s[i] + s[i+1] == "AC": count += 1 t[i+1] = count #print(t) for i in range(q): l, r = map(int, input().split()) ans = t[r-1] - t[l-1] print(ans)
p02596
s290857378
Wrong Answer
k = int(input()) c = 0 a = [0]*(k+1) a[0] = 7%k if k%2 == 0 or k%5 == 0: print('-1') elif 7%k == 0: print('1') else: for i in range(1,k): c += 1 a[i+1] = (10*a[i] + 7)%k if a[i+1] == 0: break print(c)
p02742
s603848061
Wrong Answer
import math H,W = list(map(int,input().split())) ans = 0 if H * W % 2 == 0: ans = H * W / 2 elif H == 1 or W == 1: ans = 1 else: ans = ((H-1) * W / 2) + math.ceil(W/2) print(int(ans))
p03860
s502229592
Wrong Answer
s= list(map(str,input().split())) print('A' + ''+ s[0] + '' +'C')
p02970
s816946775
Accepted
N,D=map(int, input().split()) print((N+D*2)//(D*2+1))
p03131
s898214826
Accepted
K,A,B = map(int,input().split()) if B-A < 3: print(1+K) exit() ans = 1 N = K - (A-1) if N >= 2: ans += A-1 ans += (B-A)*(N//2) + N%2 else: ans += K print(ans)
p03475
s643702000
Wrong Answer
N = int(input()) ans = [0 for i in range(N)] for i in range(N-1): c, s, f = map(int, input().split()) for j in range(i+1): if ans[j]>=s: x = int((ans[j]-s)/f) ans[j] = s+f*x+c else: ans[j] = s+c for i in range(N): print(ans[i])
p02780
s344700514
Accepted
N, K = map(int, input().split()) pN = list(map(int, input().split())) ex_p = [(pi+1)/2 for pi in pN] cum_p = [ex_p[0]] for i in range(1,N): cum_p.append(cum_p[i-1]+ex_p[i]) max_ex = cum_p[K-1] for i in range(1,N-K+1): if max_ex < cum_p[K+i-1] - cum_p[i-1]: max_ex = cum_p[K+i-1] - cum_p[i-1] print(max_ex)
p03719
s180227761
Accepted
A,B,C=map(int,input().split());print(['Yes','No'][C<A or C>B])
p02882
s083911314
Wrong Answer
from math import pi, tan EPS = 0.0000000001 def f(a, b, theta): if theta >= pi * 0.5: return 0.0 elif tan(theta) >= b / a: return a * b**2 * 0.5 / tan(theta) else: return a**2 * b - a**2 *b * 0.5 * tan(theta) a, b, x = map(int, input().split()) l = 0 r = pi * 0.5 while r - l >= EPS: mid = (l + r) * 0.5 if f(a, b, mid) >= x: l = mid else: r = mid print("{:.10f}".format(l / pi * 180))
p03076
s833160906
Wrong Answer
import copy li=[int(input()) for i in range(5)] ans=10**9 temp=0 for j in li: temp = j li2 = copy.copy(li) li2.remove(j) for k in li2: temp += k + (10 - (k % 10)) ans = min(ans, temp) print(ans)
p03136
s568179162
Accepted
n = int(input()) a = list(map(int,input().split())) p,q = max(a), sum(a) - max(a) if p < q: print('Yes') else: print('No')
p03565
s023146187
Wrong Answer
import re s2 = input().replace('?','.') t = input() a = len(s2) b = len(t) l = [] for i in range(a-b+1): if re.match(s2[i:i+b], t) is not None: s3 = s2.replace(s2[i:i+b], t, 1).replace('.','a') l.append(s3) if not l: print('UNRESTORABLE') else: print(sorted(l)[0])
p03160
s852977513
Wrong Answer
N = int(input()) h = list(map(int,input().split())) cost = [100000]*N cost[0] = 0 for i in range(N-1): num = cost[i] + abs(h[i+1]-h[i]) if cost[i+1] > num: cost[i+1] = num if i > 0: num2 = cost[i-1] + abs(h[i+1]-h[i-1]) if cost[i+1] > num2: cost[i+1] = num2 print(cost[N-1])
p02613
s430249367
Accepted
n=int(input()) ac=0 wa=0 tle=0 re=0 for i in range(n): a=input() if a=='AC': ac+=1 elif a=='WA': wa+=1 elif a=='TLE': tle+=1 else: re+=1 print('AC x '+str(ac)) print('WA x '+str(wa)) print('TLE x '+str(tle)) print('RE x '+str(re))
p03821
s246980843
Accepted
n = int(input()) a = [] b = [] for j in range(n): l = list(map(int, input().split())) a.append(l[0]) b.append(l[1]) c = 0 for i in range(n-1, -1, -1): if (a[i]+c) % b[i] != 0: c += (b[i] - (a[i]+c) % b[i]) print(c)
p02888
s649449360
Wrong Answer
N = int(input()) L = list(map(int,input().split())) L.sort() print(L) from bisect import bisect_left ans = 0 for i in range(N): for j in range(i+1, N): sum = L[i]+L[j] count = bisect_left(L, sum) print(count) ans += max(0, count-j-1) print(ans) print(ans)
p02725
s459673311
Accepted
K,N = map(int,input().split()) A = list(map(int,input().split())) a = [] for i in range(N-1): a.append( A[i+1] - A[i]) a.append(K-A[N-1] + A[0]) Am = max(a) print(K-Am)
p02947
s829464146
Wrong Answer
import collections N=int(input()) S=[list(input()) for i in range(N)] x=[] for i in S: a=collections.Counter(i) a=sorted(a) x.append(a) x=list(map(list,set(map(tuple,x)))) print(N-len(x)+1)
p02693
s236634961
Accepted
k = int(input()) a, b = input().split(' ') a = int(a) b = int(b) result = 'NG' for i in range(a, b + 1 ): n = i % k if n == 0: result = 'OK' break print(result)
p02754
s779935881
Accepted
n, a, b = map(int, input().split()) if n%(a+b) >= a: print(n//(a+b)*a+a) else: print(n//(a+b)*a+n%(a+b))
p03103
s905665035
Accepted
n,m = map(int,input().split()) a = [0]*n for i in range(n): a[i] = list(map(int,input().split())) sortsecond = lambda val : val[0] a.sort(key=sortsecond) count = 0 for i in range(n): if a[i][1] <= m: count += a[i][1]*a[i][0] m -= a[i][1] else: count += m*a[i][0] break print(count)
p03827
s555295328
Wrong Answer
n=int(input()) s=input() x=0 L=[] for i in range(n): if s[i]=="I": x+=1 elif s[i]=="D": x-=1 L.append(x) print(max(L))
p03145
s464569277
Accepted
#!/usr/bin/env python3 a, b, c = map(int, input().split()) print(a*b//2)
p03861
s054590923
Accepted
a, b, x = map(int, input().split()) print(b//x - (a-1)//x )
p03131
s341958181
Wrong Answer
row_data = input().split() trial_data = int(row_data[0]) change_coin = int(row_data[1]) change_buiscuit = int(row_data[2]) if change_coin - change_buiscuit >= -1: print(int(trial_data+1)) else: residual = trial_data - change_coin + 1 if residual % 2 == 0: if residual <= 1: print(int(change_buiscuit)) else: print(int(((residual-2)/2) * (change_buiscuit - change_coin) + change_buiscuit)) else: if residual <= 1: print(int(change_buiscuit + 1)) else: print(int(((residual-3)/2) * (change_buiscuit - change_coin)+ change_buiscuit + 1))
p02766
s198165423
Wrong Answer
n,k = map(int,input().split()) ans = 0 for i in range(10**9): if n >=2: n = n//k ans +=1 else: break print(ans+1)
p04011
s582672410
Accepted
N,K,X,Y = [int(input()) for i in range(4)] if N>K: total = N*X- (N-K)*(X-Y) print(total) else: total = N*X print(total)
p03815
s475514666
Wrong Answer
import math N = int(input()) if N <= 6: ans = 1 elif N <= 11: ans = 2 elif N % 11 == 0: ans = N / 11 else: ans = (math.floor(N / 11) * 2) + 1 print(ans)
p04005
s953862073
Accepted
a,b,c = map(int, input().split()) res = a*b*c res = min(res, abs(a*b*(c//2) - a*b*(c-c//2))) res = min(res, abs(a*(b//2)*c - a*(b-b//2)*c)) res = min(res, abs((a//2)*b*c - (a-a//2)*b*c)) print(res)
p03386
s778715128
Wrong Answer
A, B, K = map(int, input().split()) L = list(range(A, min(B+1, A+K+1))) + list(range(max(A, B-K+1), B+1)) L_no_duplication = set(L) print(*sorted(L_no_duplication), sep="\n")
p02818
s084982799
Accepted
#!/usr/bin/env python3 def main(): A, B, K = map(int, open(0).read().split()) if (A > K): print(A - K, B) elif (B - (K - A) >= 0): print(0, B - (K - A)) else: print(0, 0) main()
p02645
s516404171
Accepted
def A(): s = input() print(s[:3]) A()
p02787
s366226369
Accepted
H,N=map(int,input().split()) dp=[10**12 for _ in range(H+1)] dp[0]=0 for i in range(N): h,n=map(int,input().split()) for j in range(H+1): dp[j]=min(dp[j],dp[max(0,j-h)]+n) print(dp[H])
p02744
s269846519
Accepted
n = int(input()) alpha_dict = {} for i,c in enumerate(range(ord('A'),ord('Z')+1)): alpha_dict[i] = str(chr(c)).lower() ans = [] def dfs(s, mx, ans): if len(s) == n: ans += [s] return else: for i in range(mx+1): dfs(s+alpha_dict[i], max(i+1, mx), ans) dfs("", 0, ans) ans = sorted(ans) for a in ans: print(a)
p02718
s949920074
Accepted
N,M = map(int,input().split()) A = list(map(int,input().split())) s = sum(A) t = 0 for x in A: if 4*M*x >= s: t += 1 print("Yes" if t >= M else "No")
p02699
s607548463
Wrong Answer
S, W = map(int, input().split()) if S/2 <= W: print("{}".format("unsafe")) else: print("{}".format("safe"))
p03543
s290205148
Accepted
import sys ss=input().strip() ans=["000","111","222","333","444","555","666","777","888","999"] for a in ans: if a in ss: print("Yes") sys.exit() print("No")
p02556
s387298905
Accepted
def main(): N = int(input()) X, Y = [], [] for _ in range(N): x, y = map(int, input().split()) X.append(x - y) Y.append(x + y) return max(max(X) - min(X), max(Y) - min(Y)) print(main())
p03264
s932631544
Accepted
K=int(input()) if K%2==0: print((K//2)**2) else: print((K//2)*(K//2+1))
p03160
s825337002
Accepted
N=int(input()) H=list(map(int,input().split())) dp=[0]*N dp[1]=abs(H[1]-H[0]) for i in range(N-2): dp[i+2]=min(dp[i+1]+abs(H[i+2]-H[i+1]),dp[i]+abs(H[i+2]-H[i])) print(str(dp[N-1]))
p03433
s856910118
Accepted
def resolve(): N = int(input()) A = int(input()) print("Yes" if N % 500 <= A else "No") if '__main__' == __name__: resolve()
p03211
s548436821
Wrong Answer
s = input() min_ = 10**18 for i in range(len(s)-2): min_ = min(min_, abs(753 - int(s[i:i+3])))
p03479
s900118657
Accepted
x,y=map(int,input().split()) answer = 0 a=x while True: answer += 1 a*=2 if a>y: break print(answer)
p03827
s264314027
Accepted
n =int(input()) s = input() x,ans =0,0 for i in s: if i =="I": x +=1 ans =max(x,ans) else: x-=1 ans =max(x,ans) print(ans)
p04005
s944513970
Accepted
a, b, c = map(int, input().split()) mi = min(min(a, b), c) ma = max(max(a, b), c) r = (a + b + c) - mi - ma ans = (mi * r) * 1 if ma % 2 == 1 else 0 print(ans)
p02748
s327908778
Wrong Answer
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) aaa = min(a) bbb = min(b) for k in range(M): x, y, c = map(int, input().split()) ans = min((aaa + bbb), ((a[x - 1] + b[y - 1]) - c)) print(ans)
p02862
s791376584
Accepted
X,Y =map(int,input().split()) mod = 10**9+7 cnt = 0 for p in range(X//2+1): if Y == 2*X-3*p: A = 1 for a in range(p): A *= (X-p)-a A %= mod B = 1 for b in range(1,p+1): B *= b B %= mod cnt +=( A*pow(B,mod-2,mod) )% mod print(cnt)
p02628
s235135118
Accepted
N, K = map(int,input().split()) mylist = list(map(int,input().split())) mylist.sort() print(sum(mylist[:K]))
p03862
s113441990
Accepted
n,x=map(int,input().split()) a=list(map(int,input().split())) ans=0 for i in range(n-1): if a[i]>x: ans+=a[i]-x a[i]=x if a[i]+a[i+1]>x: ans+=a[i]+a[i+1]-x a[i+1]-=a[i]+a[i+1]-x print(ans)
p03252
s198131460
Accepted
S=list(input()) T=list(input()) slist=[None]*26 flag=True for i in range(len(S)): if slist[ord(S[i])-97] == None and T[i] not in slist: slist[ord(S[i])-97] = T[i] elif slist[ord(S[i])-97] != T[i]: flag = False break else: slist[ord(S[i])-97] = T[i] if flag: print("Yes") else: print("No")
p02594
s122312972
Accepted
a=input() if int(a) >= 30: print("Yes") else: print("No")
p02791
s835418743
Accepted
N = int(input()) P = list(map(int, input().split())) ans = 0 min_num = N for i in range(N): if P[i] <= min_num: ans += 1 min_num = P[i] print(ans)
p03998
s514387435
Accepted
a,b,c=list(input()),list(input()),list(input()) a,b,c=list(reversed(a)),list(reversed(b)),list(reversed(c)) x="a" while True: if x=="a": if not a: print("A") break x=a.pop(-1) elif x=="b": if not b: print("B") break x=b.pop(-1) elif x=="c": if not c: print("C") break x=c.pop(-1)
p02748
s123383323
Accepted
a,b,m = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) ans = min(A)+min(B) for _ in range(m): x,y,c = map(int,input().split()) ans = min(ans,A[x-1]+B[y-1]-c) print(ans)
p02719
s792160150
Accepted
n,k=map(int,input().split()) x=n%k print(min(x,k-x))
p03323
s203909530
Wrong Answer
N,D=map(int, input().split()) print(100**D*N)
p03252
s342530935
Wrong Answer
s = input() t = input() go = [] back = [] g = [] b = [] def has_duplicates(seq): return len(seq) != len(set(seq)) for i in range(len(s)): go.append(s[i]+t[i]) back.append(t[i]+s[i]) go_l = set(go) back_l = set(back) go = list(go_l) back = list(back_l) print(go) print(back) for i in range(len(go)): g.append(go[i][0]) b.append(back[i][0]) print(g) print(b) ansg = has_duplicates(g) ansb = has_duplicates(b) if ansg == True or ansb == True: print("No") else: print("Yes")
p03208
s098320653
Accepted
n, k, *a = map(int, open(0).read().split()) a.sort() for i in range(n-1): a[n-i-1] = abs(a[n-i-1]-a[n-i-2]) a[0] = 0 for i in range(n-1): a[i+1] += a[i] mn = 1e18 for i in range(n-k+1): mn = min(mn, a[i+k-1]-a[i]) print(mn)
p03657
s493568729
Wrong Answer
a, b = [int(x) for x in input().split()] print("Possible" if (a + b) % 3 == 0 else "Impossible")
p03137
s823003449
Accepted
n,m = map(int,input().split()) x = list(map(int,input().split())) x.sort() if n >= m: print(0) exit() sub = [0]*(m-1) for i in range(m-1): sub[i] = x[i+1]-x[i] sub.sort() ass = 0 for i in range(m-n): ass += sub[i] print(ass)
p03352
s081905423
Accepted
icase=0 if icase==0: bpmax=0 x=int(input()) for b in range(1,32): for p in range(2,10): bp=b**p if bp<=x: bpmax=max(bpmax,bp) else: break print(bpmax)
p03797
s012649143
Accepted
#!/usr/bin/env python n, m = map(int, input().split()) ans = 0 cc = m//2 if n >= cc: ans = cc else: ans = (n+cc)//2 print(ans)
p02571
s489340446
Wrong Answer
s = input() t = input() ans = len(t) for num in range(len(t)): if (t[:len(t) - num] in s): ans = num break print(num)
p02584
s922955296
Accepted
x,k,d = map(int,input().split()) x = abs(x) i = int(x / d) if k < i: print(x - k * d) exit() if (k - i) % 2 == 0: print(x - i * d) exit() print(abs(x - (i + 1) * d))
p02847
s004017490
Accepted
w = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'] S = input() res = abs(w.index("SUN") - w.index(S)) if res == 0: res = 7 print(res)
p02947
s484847333
Accepted
import sys read_=sys.stdin.buffer.readline N=int(read_()) ans_d={} ans=0 for i in range(N): s=''.join(sorted(input())) if s in ans_d: ans+=ans_d[s] ans_d[s]+=1 else: ans_d[s]=1 print(ans)
p02663
s580015512
Wrong Answer
H_1, M_1, H_2, M_2, K = map(int, input().split()) time =(H_2 * 60 + M_2)-(H_1 * 60 + M_1) a = time // K if a == 0 : print(0) exit(0) if time % K == 0: a = a-1 print(a*K)
p03035
s246017193
Accepted
a, b = map(int, input().split()) if a <=5: print(0) elif a<= 12: print(b//2) else: print(b)
p03221
s524963851
Accepted
from bisect import bisect_left as bt n,m = map(int,input().split()) dm,ct = [[] for _ in range(n+1)],[] for _ in range(m): a,b = map(int,input().split()) dm[a].append(b); ct.append((a,b)) for i in range(1,n+1): dm[i].sort() for c in ct: v,f = str(c[0]),str(bt(dm[c[0]],c[1])+1) print('0'*(6-len(v))+v+'0'*(6-len(f))+f)
p03107
s432722932
Accepted
S = input() c0 = S.count("0") c1 = S.count("1") ans = min(c0, c1) * 2 print(ans)
p02911
s890577445
Accepted
n, k, q = map(int, input().split()) a = [int(input()) for _ in range(q)] #参加者のポイント p = [k - q] * n for i in a: p[i - 1] += 1 for i in p: if i > 0: print("Yes") else: print("No")
p03408
s580744407
Wrong Answer
n = int(input()) d = {} for _ in range(n): s = input() if s not in d.keys(): d[s] = 0 d[s] += 1 m = int(input()) for _ in range(m): s = input() if s in d.keys(): d[s] -= 1 d = sorted(d.items(), key=lambda x:x[1]) if d[-1][1] == - (m - 1): print(0) else: print(d[-1][1])
p02995
s051596649
Wrong Answer
from fractions import gcd A, B, C, D = map(int, input().split()) U = B - A + 1 U_c = U // C U_d = U // D U_cd = U // (C * D // gcd(C, D)) ans = U - (U_c + U_d - U_cd) if A % 4 == 0 or B % 4 == 0: ans -= 1 print(ans)
p03161
s841848006
Accepted
n, k = map(int, input().split()) h = list(map(int, input().split())) dp = [0 for i in range(n)] for i in range(1, n): m = 10**10 index = i-1 num = k while index >= 0 and num: m = min(m, dp[index]+abs(h[index]-h[i])) index-=1 num-=1 dp[i] = m print(dp[n-1])
p03386
s954809137
Accepted
A, B, K = map(int, input().split()) hoge = [A + i for i in range(K) if A + i <= B] huga = [B - i for i in range(K) if A <= B - i] for x in sorted(set(hoge+huga)): print(x)
p02608
s311854915
Accepted
N = int(input()) ans = [0] * (N+1) for x in range(1, 10**2): for y in range(1, 10**2): for z in range(1, 10**2): try: ans[(x+y+z)**2 - (x*y+y*z+z*x)] += 1 except: pass for i in range(1, N+1): print(ans[i])
p03419
s390842569
Wrong Answer
h,w = map(int,input().split()) if (w < 3 and h < 3): print(0) else: print(max(1,h-2)*max(1,w-2))