Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p02786
a=int(input()) n = str(bin (a)) print(n,2**(len(n)-2)-1)
a=int(input()) n = str(bin (a)) print(2**(len(n)-2)-1)
[ "call.arguments.change" ]
590,339
590,340
u487594898
python
p02786
h = int(input()) n = 0 l = [] for i in range(42): l.append(2**i) for i in range(1,41): if l[i]<=h<l[i+1]: ans=sum(l[:i+1]) print(ans)
h = int(input()) n = 0 l = [] ans = 1 for i in range(42): l.append(2**i) for i in range(1,41): if l[i]<=h<l[i+1]: ans=sum(l[:i+1]) print(ans)
[ "assignment.add" ]
590,341
590,342
u007263493
python
p02786
h=int(input()) n=len(list(bin(h)))-1 print(2**n-1)
h=int(input()) n=len(list(bin(h)))-2 print(2**n-1)
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
590,343
590,344
u747220349
python
p02786
H = int(input()) # nが0になるまで何回割れるか def divCount(n, cnt = 0): if n <= 1: return cnt return divCount(n / 2, cnt + 1) attackCount = 0 for i in range(0, divCount(H)+1): attackCount += pow(2, i) print(attackCount)
H = int(input()) # nが0になるまで何回割れるか def divCount(n, cnt = 0): if n <= 1: return cnt return divCount(int(n / 2), cnt + 1) attackCount = 0 for i in range(0, divCount(H)+1): attackCount += pow(2, i) print(attackCount)
[ "call.arguments.add", "call.arguments.change", "function.return_value.change" ]
590,355
590,356
u068210419
python
p02786
h = int(input()) count = 0 n = 1 while (h > 1): h = int(h / 2) count += 1 n += 2 ** count print(n) print(h)
h = int(input()) count = 0 n = 1 while (h > 1): h = int(h / 2) count += 1 n += 2 ** count print(n)
[ "call.remove" ]
590,359
590,360
u530786533
python
p02786
from math import log2,ceil h = int(input()) print(2**ceil(log2(h))-1)
from math import log2,floor h = int(input()) print(2**(floor(log2(h))+1)-1)
[ "misc.opposites", "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change", "call.add" ]
590,363
590,364
u095094246
python
p02786
import sys sys.setrecursionlimit(10**6) from math import floor,ceil,sqrt,factorial,log from heapq import heappop, heappush, heappushpop from collections import Counter,defaultdict,deque from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from bisect import bisect_left,bisect_right from copy import deepcopy from operator import itemgetter from math import gcd mod = 10 ** 9 + 7 #整数input def ii(): return int(sys.stdin.readline().rstrip()) #int(input()) def mii(): return map(int,sys.stdin.readline().rstrip().split()) def limii(): return list(mii()) #list(map(int,input().split())) def lin(n:int): return [ii() for _ in range(n)] def llint(n: int): return [limii() for _ in range(n)] #文字列input def ss(): return sys.stdin.readline().rstrip() #input() def mss(): return sys.stdin.readline().rstrip() def limss(): return list(mss()) #list(input().split()) def lst(n:int): return [ss() for _ in range(n)] def llstr(n: int): return [limss() for _ in range(n)] h=ii() num = 1 cnt=0 while h >0: if h >1: h = ceil(h/2) cnt+=num num*=2 else: h-=1 cnt+=num print(cnt)
import sys sys.setrecursionlimit(10**6) from math import floor,ceil,sqrt,factorial,log from heapq import heappop, heappush, heappushpop from collections import Counter,defaultdict,deque from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from bisect import bisect_left,bisect_right from copy import deepcopy from operator import itemgetter from math import gcd mod = 10 ** 9 + 7 #整数input def ii(): return int(sys.stdin.readline().rstrip()) #int(input()) def mii(): return map(int,sys.stdin.readline().rstrip().split()) def limii(): return list(mii()) #list(map(int,input().split())) def lin(n:int): return [ii() for _ in range(n)] def llint(n: int): return [limii() for _ in range(n)] #文字列input def ss(): return sys.stdin.readline().rstrip() #input() def mss(): return sys.stdin.readline().rstrip() def limss(): return list(mss()) #list(input().split()) def lst(n:int): return [ss() for _ in range(n)] def llstr(n: int): return [limss() for _ in range(n)] h=ii() num = 1 cnt=0 while h >0: if h >1: h = floor(h/2) cnt+=num num*=2 else: h-=1 cnt+=num print(cnt)
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
590,375
590,376
u404290207
python
p02786
import math H = int(input()) count = 1 while True: if H == 1: break H = math.ceil(H/2) count += 1 print(2**count-1)
import math H = int(input()) count = 1 while True: if H == 1: break H = math.floor(H/2) count += 1 print(2**count-1)
[ "misc.opposites", "assignment.value.change", "identifier.change" ]
590,387
590,388
u357949405
python
p02786
N=int(input()) def sep_to_1(n): sep_mon=n count=0 mons_num=1 sum_sep_count=0 while sep_mon!=1: count+=1 # print("stage",count) sep_mon=sep_mon//2 sum_sep_count+=mons_num mons_num=2*mons_num # print("sep_mon",sep_mon) # print("mons_num",mons_num) # print("sum_sep_count",sum_sep_count) return sum_sep_count print(sep_to_1(N)+N)
N=int(input()) def sep_to_1(n): sep_mon=n count=0 mons_num=1 sum_sep_count=0 while sep_mon!=1: count+=1 # print("stage",count) sep_mon=sep_mon//2 sum_sep_count+=mons_num mons_num=2*mons_num # print("sep_mon",sep_mon) # print("mons_num",mons_num) # print("sum_sep_count",sum_sep_count) return sum_sep_count+mons_num print(sep_to_1(N))
[ "expression.operation.binary.remove" ]
590,389
590,390
u417014669
python
p02786
h = int(input()) double = 0 for i in range(h, 1, -1): if h == 1: break h = h // 2 double += 1 print(double + 1) total = 0 for i in range(double + 1): total += pow(2, i) print(total)
h = int(input()) double = 0 for i in range(h, 1, -1): if h == 1: break h = h // 2 double += 1 total = 0 for i in range(double + 1): total += pow(2, i) print(total)
[ "call.remove" ]
590,391
590,392
u762275701
python
p02786
H = int(input()) cnt = 0 n = math.floor(math.log2(H)) ans = 0 for i in range(n+1): cnt += int(math.pow(2,i)) print(cnt)
import math H = int(input()) cnt = 0 n = math.floor(math.log2(H)) ans = 0 for i in range(n+1): cnt += int(math.pow(2,i)) print(cnt)
[]
590,393
590,394
u909375661
python
p02786
h = input() h = int(h) count = 0 attack = 0 if h > 1: while h > 1: h = h / 2 count = count + 1 for i in range(0, count): attack = attack + (2**i) print(attack) else: print(1)
h = input() h = int(h) count = 0 attack = 0 if h > 1: while h >= 1: h = h / 2 count = count + 1 for i in range(0, count): attack = attack + (2**i) print(attack) else: print(1)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
590,395
590,396
u994527877
python
p02786
h = int(input()) res = 0 i = 1 while h > 0: h = h//2 res = res + i i*2 print(res)
h = int(input()) res = 0 i = 1 while h > 0: h = h//2 res = res + i i *= 2 print(res)
[ "assignment.compound.arithmetic.replace.add", "expression.operator.arithmetic.replace.remove", "expression.operation.binary.change" ]
590,397
590,398
u005318559
python
p02786
n = input() n = int(n) count = 0 attack = 0 if n > 1: while n > 1: n = n / 2 count = count + 1 for i in range(0, count): attack = attack + (2**i) print(attack) else: print("1")
n = input() n = int(n) count = 0 attack = 0 if n > 1: while n >= 1: n = n / 2 count = count + 1 for i in range(0, count): attack = attack + (2**i) print(attack) else: print("1")
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
590,399
590,400
u139282395
python
p02786
def a(H): global ans global dic if H // 2 in dic: add = 2 * ans + 1 ans = add dic[H] = add else: a(H//2) a(H//2) H = int(input()) dic = {} dic[1] = 1 ans = 1 a(H) print(ans)
def a(H): global ans global dic if H // 2 in dic: add = 2 * ans + 1 ans = add dic[H] = add else: a(H//2) a(H//2) H = int(input()) dic = {} dic[1] = 1 ans = 1 if H != 1: a(H) print(ans)
[ "control_flow.branch.if.add" ]
590,409
590,410
u151531137
python
p02786
def a(H): global ans global dic if H // 2 in dic: add = 2 * ans + 1 ans = add dic[H] = add else: a(H//2) a(H//2) H = int(input()) dic = {} dic[1] = 1 ans = 1 a(H) print(ans)
def a(H): global ans global dic if H // 2 in dic: add = 2 * ans + 1 ans = add dic[H] = add else: a(H//2) a(H//2) H = int(input()) dic = {} dic[1] = 1 ans = 1 if H != 1: a(H) print(ans)
[ "control_flow.branch.if.add" ]
590,411
590,410
u151531137
python
p02786
import math h = int(input()) i = 0 c = 0 while h != 0: c += 2**i if h > 1: h = math.ceil(h/2) else: h = 0 i += 1 print(c)
import math h = int(input()) i = 0 c = 0 while h != 0: c += 2**i if h > 1: h = math.floor(h/2) else: h = 0 i += 1 print(c)
[ "misc.opposites", "assignment.value.change", "identifier.change" ]
590,412
590,413
u620755587
python
p02786
from functools import lru_cache h = int(input()) count = 0 while n==1: n = h//2 count +=1 @lru_cache(maxsize=100000) def f(n): if n < 1: return 3 else: return f(n - 1)*2 + 1 print(f(count))
from functools import lru_cache h = int(input()) count = 0 while h > 1: h = h//2 count +=1 @lru_cache(maxsize=100000) def f(n): if n < 1: return 1 else: return f(n - 1)*2 + 1 print(f(count))
[ "assignment.variable.change", "identifier.change", "literal.number.integer.change", "function.return_value.change" ]
590,438
590,439
u699089116
python
p02786
H=int(input()) ans = 0 print(H) while H > 1: if H%2 == 0: H = H/2 ans += 1 else: H = (H-1)/2 ans += 1 N = 2**ans def fight(k): if k == 1: return 1 else: return 2*fight(k/2)+1 print(fight(N))
H=int(input()) ans = 0 while H > 1: if H%2 == 0: H = H/2 ans += 1 else: H = (H-1)/2 ans += 1 N = 2**ans def fight(k): if k == 1: return 1 else: return 2*fight(k/2)+1 print(fight(N))
[ "call.remove" ]
590,452
590,453
u829008868
python
p02786
h = int(input().split()) print(2 ** (len(bin(h)) - 2) - 1)
h = int(input()) print(2 ** (len(bin(h)) - 2) - 1)
[ "call.remove" ]
590,454
590,455
u686230543
python
p02786
h = int(input()) c = 0 while h >= 2: h /= 2 c += 1 count = 1 for i in range(1,c+1): count = count + 2*i print(count)
h = int(input()) c = 0 while h >= 2: h /= 2 c += 1 count = 1 for i in range(1,c+1): count = count + 2**i print(count)
[ "assignment.value.change", "expression.operation.binary.change" ]
590,463
590,464
u969211566
python
p02786
H = int(input()) ans = 0 n = 1 def calc(h,n): a = h//2 if a==1: n += 2 else: n += 2*calc(a,n) return n if H == 1: print(1) else: ans = calc(H,n) print(ans)
H = int(input()) n = 1 def calc(h,n): a = h//2 if a==1: n += 2 else: n += 2*calc(a,n) return n if H == 1: print(1) else: ans = calc(H,n) print(ans)
[ "assignment.remove" ]
590,465
590,466
u434872492
python
p02786
from sys import stdin import math n = int(stdin.readline().rstrip()) i = 0 while True: if 2**i >= n: break i += 1 point = 0 for j in range(i): point += 2**j print(point)
from sys import stdin import math n = int(stdin.readline().rstrip()) i = 0 while True: if 2**i > n: break i += 1 point = 0 for j in range(i): point += 2**j print(point)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
590,478
590,479
u987164499
python
p02786
h = int(input()) lhb = len(format(h, "b")) print(2 ** lhb - 1 + lhb)
h = int(input()) lhb = len(format(h, "b")) print(2 ** lhb - 1)
[ "expression.operation.binary.remove" ]
590,486
590,487
u081193942
python
p02786
h = int(input()) lhb = len(format(h, "b")) print(2 * lhb - 1)
h = int(input()) lhb = len(format(h, "b")) print(2 ** lhb - 1)
[ "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
590,488
590,487
u081193942
python
p02786
h = int(input()) n = 0 while 2**n < h: n += 1 print(2**n-1)
h = int(input()) n = 0 while 2**n <= h: n += 1 print(2**n-1)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
590,493
590,494
u825769322
python
p02786
n=int(input()) for i in range(50): if n<2**i: break print(i) out=0 for k in range(i): out+=2**k print(out)
n=int(input()) for i in range(50): if n<2**i: break #print(i) out=0 for k in range(i): out+=2**k print(out)
[ "call.remove" ]
590,501
590,502
u916637712
python
p02786
h = input() cnt = 0 while h > 0: h = h // 2 cnt = cnt + 1 print(pow(2, cnt) - 1)
h = int(input()) cnt = 0 while h > 0: h = h // 2 cnt = cnt + 1 print(int(pow(2, cnt) - 1))
[ "call.add", "call.arguments.change" ]
590,505
590,506
u387147192
python
p02787
H, N = map(int,input().split()) M = [] for k in range(N): M.append(list(map(int,input().split()))) dp = [10**9]*(H+1) dp[0] = 0 for A, B in M: for k in range(A+1): dp[k] = min(dp[k],B) for k in range(A+1,H+1): dp[k] = min(dp[k],dp[k-A]+B) print(dp[H])
H, N = map(int,input().split()) M = [] for k in range(N): M.append(list(map(int,input().split()))) dp = [10**9]*(10**5) dp[0] = 0 for A, B in M: for k in range(A+1): dp[k] = min(dp[k],B) for k in range(A+1,H+1): dp[k] = min(dp[k],dp[k-A]+B) print(dp[H])
[]
590,545
590,546
u620084012
python
p02787
import sys input = sys.stdin.readline() H,N = map(int,input().split()) spells = [list(map(int,input().split())) for i in range(N)] INF = 10**10 dp = [INF]*(H+1) dp[0] = 0 for use in spells: damage = use[0] mp = use[1] for i in range(1,H+1): dp[i] = min(dp[max(0,i-damage)] + mp, dp[i]) print(dp[-1])
import sys input = sys.stdin.readline H,N = map(int,input().split()) spells = [list(map(int,input().split())) for i in range(N)] INF = 10**10 dp = [INF]*(H+1) dp[0] = 0 for use in spells: damage = use[0] mp = use[1] for i in range(1,H+1): dp[i] = min(dp[max(0,i-damage)] + mp, dp[i]) print(dp[-1])
[ "call.arguments.change" ]
590,598
590,599
u623687794
python
p02787
h,n=map(int,input().split()) a,b=[],[] for i in range(n): aa,bb=map(int,input().split()) a.append(aa) b.append(bb) inf=float("inf") dp=[[inf]*(h+1) for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(h): dp[i+1][j]=min(dp[i+1][j],dp[i][j]) dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])]) print(dp[n][h])
h,n=map(int,input().split()) a,b=[],[] for i in range(n): aa,bb=map(int,input().split()) a.append(aa) b.append(bb) inf=float("inf") dp=[[inf]*(h+1) for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(h+1): dp[i+1][j]=min(dp[i+1][j],dp[i][j]) dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])]) print(dp[n][h])
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
590,603
590,604
u970197315
python
p02787
import sys def main(): input = sys.stdin.buffer.readline h, n = map(int, input().split()) a = [0] * n b = [0] * n for i in range(n): a[i], b[i] = map(int, input().split()) max_a = max(a) # dp[j]:jダメージ与える魔力の最小値 dp = [1e9] * (h + max_a + 1) dp[0] = 0 for i in range(n): for j in range(1, h + max_a + 1): dp[j] = min(dp[j], min(dp[max(j - a[i], 0) : j]) + b[i]) print(min(dp[h:])) if __name__ == "__main__": main()
import sys def main(): input = sys.stdin.buffer.readline h, n = map(int, input().split()) a = [0] * n b = [0] * n for i in range(n): a[i], b[i] = map(int, input().split()) max_a = max(a) # dp[j]:jダメージ与える魔力の最小値 dp = [1e9] * (h + max_a + 1) dp[0] = 0 for i in range(n): for j in range(1, h + max_a + 1): dp[j] = min(dp[j], dp[max(j - a[i], 0)] + b[i]) print(min(dp[h:])) if __name__ == "__main__": main()
[ "call.remove", "call.arguments.change" ]
590,637
590,638
u331327289
python
p02787
def chmin(dp, i, *x): dp[i] = min(dp[i], *x) INF = float("inf") # dp[i] := min 消耗する魔力 to H -= i h, n = map(int, input().split()) dp = [INF]*-~h for _ in [None]*n: a, b = map(int, input().split()) for j in range(h + 1): chmin(dp, min(j + a, h), dp[j] + b) print(dp[h])
def chmin(dp, i, *x): dp[i] = min(dp[i], *x) INF = float("inf") # dp[i] := min 消耗する魔力 to H -= i h, n = map(int, input().split()) dp = [0] + [INF]*h for _ in [None]*n: a, b = map(int, input().split()) for j in range(h + 1): chmin(dp, min(j + a, h), dp[j] + b) print(dp[h])
[ "assignment.change" ]
590,668
590,669
u373047809
python
p02787
H,N = map(int,input().split()) magic = [list(map(int,input().split())) for i in range(N)] INF = 10**10 #print(magic) dp = [INF for i in range(H+AM+1)] dp[0] = 0 for i in range(1,H+1): for j in range(N): if magic[j][0] > i: dp[i] = min(dp[i],magic[j][1]) else: dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i]) ans = INF print(dp[H])
H,N = map(int,input().split()) magic = [list(map(int,input().split())) for i in range(N)] INF = 10**10 dp = [INF for i in range(H+1)] dp[0] = 0 for i in range(1,H+1): for j in range(N): if magic[j][0] > i: dp[i] = min(dp[i],magic[j][1]) else: dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i]) print(dp[H])
[ "expression.operation.binary.remove" ]
590,692
590,693
u747602774
python
p02787
H,N = map(int,input().split()) magic = [list(map(int,input().split())) for i in range(N)] INF = 10**10 #print(magic) dp = [INF for i in range(H+AM+1)] dp[0] = 0 for i in range(1,H+1): for j in range(N): if magic[j][0] > i: dp[i] = min(dp[i],magic[j][1]) else: dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i]) ans = INF print(dp[H])
H,N = map(int,input().split()) magic = [list(map(int,input().split())) for i in range(N)] INF = 10**10 #print(magic) dp = [INF for i in range(H+1)] dp[0] = 0 for i in range(1,H+1): for j in range(N): if magic[j][0] > i: dp[i] = min(dp[i],magic[j][1]) else: dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i]) ans = INF print(dp[H])
[ "expression.operation.binary.remove" ]
590,692
590,694
u747602774
python
p02787
H, N = map(int, input().split()) inf = float('inf') dp = [inf] * (H + 1) dp[0] = 0 for i in range(N): A, B = map(int, input().split()) for j in range(H): t1 = j + A if t1 > H: t1 = H t2 = dp[t1] if t2 == inf: continue t2 += B if t2 < dp[t1]: dp[t1] = t2 print(dp[H])
H, N = map(int, input().split()) inf = float('inf') dp = [inf] * (H + 1) dp[0] = 0 for _ in range(N): A, B = map(int, input().split()) for i in range(H): t1 = i + A if t1 > H: t1 = H t2 = dp[i] if t2 == inf: continue t2 += B if t2 < dp[t1]: dp[t1] = t2 print(dp[H])
[ "identifier.change", "assignment.value.change", "expression.operation.binary.change", "variable_access.subscript.index.change" ]
590,734
590,735
u347640436
python
p02787
#個数が無制限のナップザックの問題(ただし、上限に注意)です(どの魔法を順番に選べば良いなどの制約がないのでナップザックDPを選択しました。)。 #dpの配列にはi番目の要素にモンスターの体力をi減らすために必要な最小の魔力を保存します。 #この配列は個数制限がないことに注意してinfではない要素のみを順に更新していけば良いです。 #また、最終的にモンスターの体力を最小の魔力で0以下にすれば良いので、モンスターの体力をh以上減らせる最小の魔力を求めれば良いです。 h,n=map(int,input().split()) a,b=[],[] for i in range(n): a_sub,b_sub=map(int,input().split()) a.append(a_sub) b.append(b_sub) inf=10000000000000 ma=max(a)#ダメージの最大値 dp=[inf]*(h+ma)#与えるダメージの最大値を考慮したDP dp[0]=0#初期値 for i in range(h+1+ma):# 与えるダメージ合計:0ーH+1+maまで if dp[i] == inf:#更新してきて、ダメージiになる組み合わせが存在しない場合は飛ばす continue for j in range(n): #N個の魔法を試す ni = i + a[j] #今の状態から新しく与えた場合のダメージ合計 if ni<h+ma:#オーバーキルの範囲を超えるなら、無視 dp[ni] = min(dp[ni], dp[i] + b[j]) #ダメージniを与えるのにより小さい魔力で実現できる場合は更新 print(min(dp[h:]))
#個数が無制限のナップザックの問題(ただし、上限に注意)です(どの魔法を順番に選べば良いなどの制約がないのでナップザックDPを選択しました。)。 #dpの配列にはi番目の要素にモンスターの体力をi減らすために必要な最小の魔力を保存します。 #この配列は個数制限がないことに注意してinfではない要素のみを順に更新していけば良いです。 #また、最終的にモンスターの体力を最小の魔力で0以下にすれば良いので、モンスターの体力をh以上減らせる最小の魔力を求めれば良いです。 h,n=map(int,input().split()) a,b=[],[] for i in range(n): a_sub,b_sub=map(int,input().split()) a.append(a_sub) b.append(b_sub) inf=10000000000000 ma=max(a)#ダメージの最大値 dp=[inf]*(h+1+ma)#与えるダメージの最大値を考慮したDP dp[0]=0#初期値 for i in range(h+1+ma):# 与えるダメージ合計:0ーH+1+maまで if dp[i] == inf:#更新してきて、ダメージiになる組み合わせが存在しない場合は飛ばす continue for j in range(n): #N個の魔法を試す ni = i + a[j] #今の状態から新しく与えた場合のダメージ合計 if ni<h+ma:#オーバーキルの範囲を超えるなら、無視 dp[ni] = min(dp[ni], dp[i] + b[j]) #ダメージniを与えるのにより小さい魔力で実現できる場合は更新 print(min(dp[h:]))
[ "assignment.change" ]
590,757
590,758
u753386263
python
p02787
import sys input = sys.stdin.readline H, N = map(int, input().split()) dp = [float("inf")] * (H + 1) dp[H] = 0 for _ in range(N): a, b = map(int, input().split()) for x in range(H + 1): dp[max(0, x - a)] = min(dp[max(0, x - a)], dp[x] + b) print(dp[0])
import sys input = sys.stdin.readline H, N = map(int, input().split()) dp = [float("inf")] * (H + 1) dp[H] = 0 for _ in range(N): a, b = map(int, input().split()) for x in range(H, -1, -1): dp[max(0, x - a)] = min(dp[max(0, x - a)], dp[x] + b) print(dp[0])
[ "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change", "call.arguments.add" ]
590,840
590,841
u141610915
python
p02787
H,N =map(int, input().split()) a = [] M = 0 for i in range(N): t = list(map(int, input().split())) a.append(t) M = max(M,t[0]) dp = [10000]*(H+1+M) dp[0] = 0 for i in range(H): for j,k in a: dp[i+j] = min(dp[i+j],dp[i]+k) print(min(dp[H:]))
H,N =map(int, input().split()) a = [] M = 0 for i in range(N): t = list(map(int, input().split())) a.append(t) M = max(M,t[0]) dp = [100000000]*(H+1+M) dp[0] = 0 for i in range(H): for j,k in a: dp[i+j] = min(dp[i+j],dp[i]+k) print(min(dp[H:]))
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
590,866
590,867
u785578220
python
p02787
f=lambda:map(int,input().split()) h,n=f() dp=[0]+[10**9]*h for i in range(n): a,b=f() for j in range(h+1): dp[j]=min(dp[j],dp[j-a]+b) print(dp[h])
f=lambda:map(int,input().split()) h,n=f() dp=[0]+[10**9]*h for i in range(n): a,b=f() for j in range(h+1): dp[j]=min(dp[j],dp[max(j-a,0)]+b) print(dp[h])
[ "call.add", "call.arguments.add" ]
590,868
590,869
u133936772
python
p02787
h, n = map(int, input().split()) AB = [tuple(map(int, input().split())) for i in range(n)] A = [a for a, b in AB] B = [b for a, b in AB] inf = 10**10 # DP[i][j]=i個以内で体力j以上削るための消費魔力の最小値 DP = [[inf for j in range(h+1)] for i in range(n+1)] DP[0][0] = 0 for i in range(n): for j in range(h+1): DP[i+1][j] = min(DP[i][j], DP[i][max(0, j-A[i])]+B[i]) print(DP[n][h])
h, n = map(int, input().split()) AB = [tuple(map(int, input().split())) for i in range(n)] A = [a for a, b in AB] B = [b for a, b in AB] inf = 10**10 # DP[i][j]=i個以内で体力j以上削るための消費魔力の最小値 DP = [[inf for j in range(h+1)] for i in range(n+1)] DP[0][0] = 0 for i in range(n): for j in range(h+1): DP[i+1][j] = min(DP[i][j], DP[i+1][max(0, j-A[i])]+B[i]) print(DP[n][h])
[ "assignment.change" ]
590,902
590,903
u997641430
python
p02787
H,N=map(int,input().split()) A=[] B=[] for _ in range(N): a,b=map(int,input().split()) A.append(a) B.append(b) inf=float('inf') component=[0] for i in range(H): component.append(inf) DP=[] for j in range(N+1): DP.append(copy.copy(component))#DPは(N+1)×(H+1) for k in range(1,N+1):#k番目の魔法 for l in range(1,H+1):#体力H DP[k][l]=min(DP[k-1][l],DP[k][max(0,l-A[k-1])]+B[k-1]) print(DP[N][H])
H,N=map(int,input().split()) A=[] B=[] for _ in range(N): a,b=map(int,input().split()) A.append(a) B.append(b) inf=float('inf') component=[0] for i in range(H): component.append(inf) DP=[] for j in range(N+1): DP.append(component)#DPは(N+1)×(H+1) for k in range(1,N+1):#k番目の魔法 for l in range(1,H+1):#体力H DP[k][l]=min(DP[k-1][l],DP[k][max(0,l-A[k-1])]+B[k-1]) print(DP[N][H])
[ "call.remove", "call.arguments.change" ]
590,928
590,929
u523545435
python
p02787
H,N=map(int,input().split()) C=[0 for i in range(H+(10**4)+1)] d=0 for i in [0]*N: A,B=map(int,input().split()) for i in range(H+A+1): if A==i : C[i]=B elif A<i : if C[i]==0 and C[i-A]>0: C[i]=C[i-A]+B elif C[i-A]>0: C[i]=min(C[i],C[i-A]+B) d=max(d,A) e=10**9 for i in range(H+1,H+d+1): if C[i]>0: e=min(C[i],e) print(e)
H,N=map(int,input().split()) C=[0 for i in range(H+(10**4)+1)] d=0 for i in [0]*N: A,B=map(int,input().split()) for i in range(H+A+1): if A==i : C[i]=B elif A<i : if C[i]==0 and C[i-A]>0: C[i]=C[i-A]+B elif C[i-A]>0: C[i]=min(C[i],C[i-A]+B) d=max(d,A) e=10**9 for i in range(H,H+d+1): if C[i]>0: e=min(C[i],e) print(e)
[ "expression.operation.binary.remove" ]
590,939
590,940
u387774811
python
p02787
h,n=map(int,input().split()) dp=[10**10]*(h+1) dp[0]=1 X=[] for i in range(n): a,b=map(int,input().split()) X.append([a,b]) for i in range(h): for j in range(n): k=min(i+X[j][0],h) dp[k]=min(dp[k],dp[i]+X[j][1]) print(dp[h])
h,n=map(int,input().split()) dp=[10**10]*(h+1) dp[0]=0 X=[] for i in range(n): a,b=map(int,input().split()) X.append([a,b]) for i in range(h): for j in range(n): k=min(i+X[j][0],h) dp[k]=min(dp[k],dp[i]+X[j][1]) print(dp[h])
[ "literal.number.integer.change", "assignment.value.change" ]
590,974
590,975
u210827208
python
p02787
h,n=map(int,input().split()) dp=[10**10]*(h+1) dp[0][0]=1 X=[] for i in range(n): a,b=map(int,input().split()) X.append([a,b]) for i in range(h): for j in range(n): k=min(i+X[j][0],h) dp[k]=min(dp[k],dp[i]+X[j][1]) print(dp[h])
h,n=map(int,input().split()) dp=[10**10]*(h+1) dp[0]=0 X=[] for i in range(n): a,b=map(int,input().split()) X.append([a,b]) for i in range(h): for j in range(n): k=min(i+X[j][0],h) dp[k]=min(dp[k],dp[i]+X[j][1]) print(dp[h])
[ "assignment.remove" ]
590,976
590,975
u210827208
python
p02787
h,n=map(int,input().split()) H=[] A=[] for i in range(n): a,b=map(int,input().split()) H.append([a,b]) A.append(a) a_max=max(A) dp=[10**5]*(h+a_max+1) dp[0]=0 for i in range(1,h+a_max+1): for j in range(n): if i-H[j][0]<0: dp[i]=min(dp[i],H[j][1]) else: dp[i]=min(dp[i],dp[i-H[j][0]]+H[j][1]) print(min(dp[h:h+a_max+1]))
h,n=map(int,input().split()) H=[] A=[] for i in range(n): a,b=map(int,input().split()) H.append([a,b]) A.append(a) a_max=max(A) dp=[10**10]*(h+a_max+1) dp[0]=0 for i in range(1,h+a_max+1): for j in range(n): if i-H[j][0]<0: dp[i]=min(dp[i],H[j][1]) else: dp[i]=min(dp[i],dp[i-H[j][0]]+H[j][1]) print(min(dp[h:h+a_max+1]))
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
590,977
590,978
u210827208
python
p02787
H,N = map(int,input().split()) l = [] for i in range(N): l.append( list(map(int,input().split())) ) #dp[i][h]:i番目の魔法まで見てhのダメージを与えるときの最小魔力 dp = [[10**4+1 for j in range(H+1)] for i in range(N+1)] dp[0][0] = 0 #配るdpで考える for i in range(N): for h in range(H+1): #i番目の魔法を使わないとき dp[i+1][h] = min(dp[i][h], dp[i+1][h]) #i番目の魔法を一個使うとき dp[i+1][ min(h+l[i][0],H) ] = min(dp[i+1][min(h+l[i][0],H)],dp[i+1][h]+l[i][1] ) print(dp[N][H])
H,N = map(int,input().split()) l = [] for i in range(N): l.append( list(map(int,input().split())) ) #dp[i][h]:i番目の魔法まで見てhのダメージを与えるときの最小魔力 dp = [[10**8+1 for j in range(H+1)] for i in range(N+1)] dp[0][0] = 0 #配るdpで考える for i in range(N): for h in range(H+1): #i番目の魔法を使わないとき dp[i+1][h] = min(dp[i][h], dp[i+1][h]) #i番目の魔法を一個使うとき dp[i+1][ min(h+l[i][0],H) ] = min(dp[i+1][min(h+l[i][0],H)],dp[i+1][h]+l[i][1] ) print(dp[N][H])
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
590,987
590,986
u674574659
python
p02787
H,N = map(int,input().split()) l = [] for i in range(N): l.append( list(map(int,input().split())) ) #dp[i][h]:i番目の魔法まで見てhのダメージを与えるときの最小魔力 dp = [[10**4+1 for j in range(H+1)] for i in range(N+1)] dp[0][0] = 0 #配るdpで考える for i in range(N): for h in range(H): #i番目の魔法を使わないとき dp[i+1][h] = min(dp[i][h], dp[i+1][h]) #i番目の魔法を一個使うとき dp[i+1][ min(h+l[i][0],H) ] = min(dp[i+1][min(h+l[i][0],H)],dp[i+1][h]+l[i][1] ) print(dp[N][H])
H,N = map(int,input().split()) l = [] for i in range(N): l.append( list(map(int,input().split())) ) #dp[i][h]:i番目の魔法まで見てhのダメージを与えるときの最小魔力 dp = [[10**8+1 for j in range(H+1)] for i in range(N+1)] dp[0][0] = 0 #配るdpで考える for i in range(N): for h in range(H+1): #i番目の魔法を使わないとき dp[i+1][h] = min(dp[i][h], dp[i+1][h]) #i番目の魔法を一個使うとき dp[i+1][ min(h+l[i][0],H) ] = min(dp[i+1][min(h+l[i][0],H)],dp[i+1][h]+l[i][1] ) print(dp[N][H])
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
590,988
590,986
u674574659
python
p02787
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from math import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 H, N = MAP() A, B = [0]*N, [0]*N for i in range(N): A[i], B[i] = MAP() max_A = max(A) dp = [INF]*(H+max_A+1) dp[0] = 0 for i in range(N): for j in range(A[i], H+max_A+1): dp[j] = min(dp[j], dp[j-A[i]]+B[i]) print(min(dp[N][H:]))
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from math import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 H, N = MAP() A, B = [0]*N, [0]*N for i in range(N): A[i], B[i] = MAP() max_A = max(A) dp = [INF]*(H+max_A+1) dp[0] = 0 for i in range(N): for j in range(A[i], H+max_A+1): dp[j] = min(dp[j], dp[j-A[i]]+B[i]) print(min(dp[H:]))
[]
590,998
590,999
u279493135
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = max(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,004
591,005
u706929073
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = min(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,006
591,005
u706929073
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = max(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,004
591,007
u706929073
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = max(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,004
591,012
u706929073
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = min(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,006
591,012
u706929073
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = max(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,004
591,015
u706929073
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = min(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,006
591,015
u706929073
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = min(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i - a] + b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,006
591,025
u706929073
python
p02787
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = min(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [10 ** 18 for _ in range(h + max_a)] dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a]+b for a, b in ab) print(min(dp[h:]))
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
591,006
591,027
u706929073
python
p02787
inf = 10 ** 18 h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [inf] * (h + max_a) dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(dp[h:])
inf = 10 ** 18 h, n = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] max_a = max(a for a, _ in ab) dp = [inf] * (h + max_a) dp[0] = 0 for i in range(1, h + max_a): dp[i] = min(dp[i-a] + b for a, b in ab) print(min(dp[h:]))
[ "call.arguments.add", "call.arguments.change" ]
591,029
591,030
u706929073
python
p02787
import sys input = sys.stdin.buffer.readline h,n = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(n)] inf=float("inf") dp=[inf]*(h+1) dp[0]=0 for a,b in AB: for i in range(h): if dp[i]!=float("inf"): dp[min(i+a,h)]=min(dp[min(i+a,h),dp[i]+b]) print(dp[-1])
import sys input = sys.stdin.buffer.readline h,n = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(n)] inf=float("inf") dp=[inf]*(h+1) dp[0]=0 for a,b in AB: for i in range(h): if dp[i]!=float("inf"): dp[min(i+a,h)]=min(dp[min(i+a,h)],dp[i]+b) print(dp[-1])
[ "call.arguments.change" ]
591,039
591,040
u573754721
python
p02787
import sys input = sys.stdin.readline h, n = map(int, input().split()) A = [] B = [] for i in range(n): a,b=map(int,input().split()) A.append(a) B.append(b) Ama = max(A) dp=[float("inf")]*(h+Ama) dp[0]=0 for i in range(n): for j in range(A[i],h+Ama+1): dp[j]=min(dp[j],dp[j-A[i]+B[i]]) print(min(dp[h:]))
import sys input = sys.stdin.readline h, n = map(int, input().split()) A = [] B = [] for i in range(n): a,b=map(int,input().split()) A.append(a) B.append(b) Ama = max(A) dp=[float("inf")]*(h+Ama+1) dp[0]=0 for i in range(n): for j in range(A[i],h+Ama+1): dp[j]=min(dp[j],dp[j-A[i]]+B[i]) print(min(dp[h:]))
[ "call.arguments.change" ]
591,041
591,042
u573754721
python
p02787
#int でsplitを使う場合はmap関数を利用しなければならない H,N = map(int,input().split()) li=[] x=[] for i in range(N): A,B = map(int,input().split()) x.append(A) li.append([A,B]) dp = [10**9]*(H+max(x)) dp[0] = 0 for i in range(1,len(dp)): dp[i] = min(dp[i-a] + b for a,b in li) print(min(dp[h:]))
#int でsplitを使う場合はmap関数を利用しなければならない H,N = map(int,input().split()) li=[] x=[] for i in range(N): A,B = map(int,input().split()) x.append(A) li.append([A,B]) dp = [10**9]*(H+max(x)) dp[0] = 0 for i in range(1,len(dp)): dp[i] = min(dp[i-a] + b for a,b in li) print(min(dp[H:]))
[ "identifier.change", "variable_access.subscript.index.change", "call.arguments.change", "io.output.change" ]
591,055
591,056
u972652761
python
p02787
H, N = map(int,input().split()) data = [] for i in range(N): data.append([0, 0]) a, b = map(int,input().split()) data[i][0] = a data[i][1] = b data.sort(key=lambda x: x[0]) cost = [float("inf")] * (H + data[-1][0]) cost[0] = 0 for i in range(1, H + data[-1][0]): for magic in data: if i < magic[0]: break if cost[i] > cost[i - magic[0]] + magic[1]: cost[i] = cost[i - magic[0]] + magic[1] print(min(cost[H:]), cost, data)
H, N = map(int,input().split()) data = [] for i in range(N): data.append([0, 0]) a, b = map(int,input().split()) data[i][0] = a data[i][1] = b data.sort(key=lambda x: x[0]) cost = [float("inf")] * (H + data[-1][0]) cost[0] = 0 for i in range(1, H + data[-1][0]): for magic in data: if i < magic[0]: break if cost[i] > cost[i - magic[0]] + magic[1]: cost[i] = cost[i - magic[0]] + magic[1] print(min(cost[H:]))
[ "call.arguments.change" ]
591,059
591,060
u096616343
python
p02787
H, N = map(int, input().split()) A = [list(map(int, input().split())) for i in range(N)] print(H, N) INF = int(1e18) dp = [INF] * (H + 1) dp[H] = 0; for i in range(N): for j in range(H, -1, -1): dp[max(0, j - A[i][0])] = min(dp[max(0, j - A[i][0])], dp[j] + A[i][1]) ans = dp[0] print(ans)
H, N = map(int, input().split()) A = [list(map(int, input().split())) for i in range(N)] INF = int(1e18) dp = [INF] * (H + 1) dp[H] = 0; for i in range(N): for j in range(H, -1, -1): dp[max(0, j - A[i][0])] = min(dp[max(0, j - A[i][0])], dp[j] + A[i][1]) ans = dp[0] print(ans)
[ "call.remove" ]
591,065
591,066
u278868910
python
p02787
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from functools import * from itertools import permutations,combinations,groupby import sys import bisect import string import math import time import random def Golf(): *a,=map(int,open(0)) def S_(): return input() def IS(): return input().split() def LS(): return [i for i in input().split()] def I(): return int(input()) def MI(): return map(int,input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i)-1 for i in input().split()] def NI(n): return [int(input()) for i in range(n)] def NI_(n): return [int(input())-1 for i in range(n)] def StoI(): return [ord(i)-97 for i in input()] def ItoS(nn): return chr(nn+97) def LtoS(ls): return ''.join([chr(i+97) for i in ls]) def GI(V,E,Directed=False,index=0): org_inp=[] g=[[] for i in range(n)] for i in range(E): inp=LI() org_inp.append(inp) if index==0: inp[0]-=1 inp[1]-=1 if len(inp)==2: a,b=inp g[a].append(b) if not Directed: g[b].append(a) elif len(inp)==3: a,b,c=inp aa=(inp[0],inp[2]) bb=(inp[1],inp[2]) g[a].append(bb) if not Directed: g[b].append(aa) return g,org_inp def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}): #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage mp=[1]*(w+2) found={} for i in range(h): s=input() for char in search: if char in s: found[char]=((i+1)*(w+2)+s.index(char)+1) mp_def[char]=mp_def[replacement_of_found] mp+=[1]+[mp_def[j] for j in s]+[1] mp+=[1]*(w+2) return h+2,w+2,mp,found def bit_combination(k,n=2): rt=[] for tb in range(n**k): s=[tb//(n**bt)%n for bt in range(k)] rt+=[s] return rt def show(*inp,end='\n'): if show_flg: print(*inp,end=end) YN=['YES','NO'] mo=10**9+7 inf=float('inf') l_alp=string.ascii_lowercase u_alp=string.ascii_uppercase ts=time.time() #sys.setrecursionlimit(10**7) input=lambda: sys.stdin.readline().rstrip() def ran_input(): import random n=random.randint(4,16) rmin,rmax=1,10 a=[random.randint(rmin,rmax) for _ in range(n)] return n,a show_flg=False show_flg=True ans=0 h,n=LI() a=[] ab=[] for i in range(n): x,y=LI() ab.append((x,y)) ab.sort() a=[i for i,j in ab] b=[j for i,j in ab] dp=[[0]+[inf]*(h) for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(h+1): dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])],dp[i][min(h,j+a[i])]) ans=dp[n][h] print(ans)
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from functools import * from itertools import permutations,combinations,groupby import sys import bisect import string import math import time import random def Golf(): *a,=map(int,open(0)) def S_(): return input() def IS(): return input().split() def LS(): return [i for i in input().split()] def I(): return int(input()) def MI(): return map(int,input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i)-1 for i in input().split()] def NI(n): return [int(input()) for i in range(n)] def NI_(n): return [int(input())-1 for i in range(n)] def StoI(): return [ord(i)-97 for i in input()] def ItoS(nn): return chr(nn+97) def LtoS(ls): return ''.join([chr(i+97) for i in ls]) def GI(V,E,Directed=False,index=0): org_inp=[] g=[[] for i in range(n)] for i in range(E): inp=LI() org_inp.append(inp) if index==0: inp[0]-=1 inp[1]-=1 if len(inp)==2: a,b=inp g[a].append(b) if not Directed: g[b].append(a) elif len(inp)==3: a,b,c=inp aa=(inp[0],inp[2]) bb=(inp[1],inp[2]) g[a].append(bb) if not Directed: g[b].append(aa) return g,org_inp def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}): #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage mp=[1]*(w+2) found={} for i in range(h): s=input() for char in search: if char in s: found[char]=((i+1)*(w+2)+s.index(char)+1) mp_def[char]=mp_def[replacement_of_found] mp+=[1]+[mp_def[j] for j in s]+[1] mp+=[1]*(w+2) return h+2,w+2,mp,found def bit_combination(k,n=2): rt=[] for tb in range(n**k): s=[tb//(n**bt)%n for bt in range(k)] rt+=[s] return rt def show(*inp,end='\n'): if show_flg: print(*inp,end=end) YN=['YES','NO'] mo=10**9+7 inf=float('inf') l_alp=string.ascii_lowercase u_alp=string.ascii_uppercase ts=time.time() #sys.setrecursionlimit(10**7) input=lambda: sys.stdin.readline().rstrip() def ran_input(): import random n=random.randint(4,16) rmin,rmax=1,10 a=[random.randint(rmin,rmax) for _ in range(n)] return n,a show_flg=False show_flg=True ans=0 h,n=LI() a=[] ab=[] for i in range(n): x,y=LI() ab.append((-x,y)) ab.sort() a=[-i for i,j in ab] b=[j for i,j in ab] dp=[[0]+[inf]*(h) for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(h+1): dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])],dp[i][min(h,j+a[i])]) ans=dp[n][h] print(ans)
[ "expression.operation.unary.add", "call.arguments.change" ]
591,196
591,197
u623819879
python
p02787
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from functools import * from itertools import permutations,combinations,groupby import sys import bisect import string import math import time import random def Golf(): *a,=map(int,open(0)) def S_(): return input() def IS(): return input().split() def LS(): return [i for i in input().split()] def I(): return int(input()) def MI(): return map(int,input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i)-1 for i in input().split()] def NI(n): return [int(input()) for i in range(n)] def NI_(n): return [int(input())-1 for i in range(n)] def StoI(): return [ord(i)-97 for i in input()] def ItoS(nn): return chr(nn+97) def LtoS(ls): return ''.join([chr(i+97) for i in ls]) def GI(V,E,Directed=False,index=0): org_inp=[] g=[[] for i in range(n)] for i in range(E): inp=LI() org_inp.append(inp) if index==0: inp[0]-=1 inp[1]-=1 if len(inp)==2: a,b=inp g[a].append(b) if not Directed: g[b].append(a) elif len(inp)==3: a,b,c=inp aa=(inp[0],inp[2]) bb=(inp[1],inp[2]) g[a].append(bb) if not Directed: g[b].append(aa) return g,org_inp def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}): #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage mp=[1]*(w+2) found={} for i in range(h): s=input() for char in search: if char in s: found[char]=((i+1)*(w+2)+s.index(char)+1) mp_def[char]=mp_def[replacement_of_found] mp+=[1]+[mp_def[j] for j in s]+[1] mp+=[1]*(w+2) return h+2,w+2,mp,found def bit_combination(k,n=2): rt=[] for tb in range(n**k): s=[tb//(n**bt)%n for bt in range(k)] rt+=[s] return rt def show(*inp,end='\n'): if show_flg: print(*inp,end=end) YN=['YES','NO'] mo=10**9+7 inf=float('inf') l_alp=string.ascii_lowercase u_alp=string.ascii_uppercase ts=time.time() #sys.setrecursionlimit(10**7) input=lambda: sys.stdin.readline().rstrip() def ran_input(): import random n=random.randint(4,16) rmin,rmax=1,10 a=[random.randint(rmin,rmax) for _ in range(n)] return n,a show_flg=False show_flg=True ans=0 h,n=LI() a=[] ab=[] for i in range(n): x,y=LI() ab.append((a,b)) ab.sort() a=[i for i,j in ab] b=[j for i,j in ab] dp=[[0]+[inf]*(h) for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(h+1): dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])],dp[i][min(h,j+a[i])]) ans=dp[n][h] print(ans)
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from functools import * from itertools import permutations,combinations,groupby import sys import bisect import string import math import time import random def Golf(): *a,=map(int,open(0)) def S_(): return input() def IS(): return input().split() def LS(): return [i for i in input().split()] def I(): return int(input()) def MI(): return map(int,input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i)-1 for i in input().split()] def NI(n): return [int(input()) for i in range(n)] def NI_(n): return [int(input())-1 for i in range(n)] def StoI(): return [ord(i)-97 for i in input()] def ItoS(nn): return chr(nn+97) def LtoS(ls): return ''.join([chr(i+97) for i in ls]) def GI(V,E,Directed=False,index=0): org_inp=[] g=[[] for i in range(n)] for i in range(E): inp=LI() org_inp.append(inp) if index==0: inp[0]-=1 inp[1]-=1 if len(inp)==2: a,b=inp g[a].append(b) if not Directed: g[b].append(a) elif len(inp)==3: a,b,c=inp aa=(inp[0],inp[2]) bb=(inp[1],inp[2]) g[a].append(bb) if not Directed: g[b].append(aa) return g,org_inp def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}): #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage mp=[1]*(w+2) found={} for i in range(h): s=input() for char in search: if char in s: found[char]=((i+1)*(w+2)+s.index(char)+1) mp_def[char]=mp_def[replacement_of_found] mp+=[1]+[mp_def[j] for j in s]+[1] mp+=[1]*(w+2) return h+2,w+2,mp,found def bit_combination(k,n=2): rt=[] for tb in range(n**k): s=[tb//(n**bt)%n for bt in range(k)] rt+=[s] return rt def show(*inp,end='\n'): if show_flg: print(*inp,end=end) YN=['YES','NO'] mo=10**9+7 inf=float('inf') l_alp=string.ascii_lowercase u_alp=string.ascii_uppercase ts=time.time() #sys.setrecursionlimit(10**7) input=lambda: sys.stdin.readline().rstrip() def ran_input(): import random n=random.randint(4,16) rmin,rmax=1,10 a=[random.randint(rmin,rmax) for _ in range(n)] return n,a show_flg=False show_flg=True ans=0 h,n=LI() a=[] ab=[] for i in range(n): x,y=LI() ab.append((-x,y)) ab.sort() a=[-i for i,j in ab] b=[j for i,j in ab] dp=[[0]+[inf]*(h) for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(h+1): dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])],dp[i][min(h,j+a[i])]) ans=dp[n][h] print(ans)
[ "call.arguments.change", "expression.operation.unary.add", "identifier.change" ]
591,198
591,197
u623819879
python
p02787
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from functools import * from itertools import permutations,combinations,groupby import sys import bisect import string import math import time import random def Golf(): *a,=map(int,open(0)) def S_(): return input() def IS(): return input().split() def LS(): return [i for i in input().split()] def I(): return int(input()) def MI(): return map(int,input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i)-1 for i in input().split()] def NI(n): return [int(input()) for i in range(n)] def NI_(n): return [int(input())-1 for i in range(n)] def StoI(): return [ord(i)-97 for i in input()] def ItoS(nn): return chr(nn+97) def LtoS(ls): return ''.join([chr(i+97) for i in ls]) def GI(V,E,Directed=False,index=0): org_inp=[] g=[[] for i in range(n)] for i in range(E): inp=LI() org_inp.append(inp) if index==0: inp[0]-=1 inp[1]-=1 if len(inp)==2: a,b=inp g[a].append(b) if not Directed: g[b].append(a) elif len(inp)==3: a,b,c=inp aa=(inp[0],inp[2]) bb=(inp[1],inp[2]) g[a].append(bb) if not Directed: g[b].append(aa) return g,org_inp def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}): #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage mp=[1]*(w+2) found={} for i in range(h): s=input() for char in search: if char in s: found[char]=((i+1)*(w+2)+s.index(char)+1) mp_def[char]=mp_def[replacement_of_found] mp+=[1]+[mp_def[j] for j in s]+[1] mp+=[1]*(w+2) return h+2,w+2,mp,found def bit_combination(k,n=2): rt=[] for tb in range(n**k): s=[tb//(n**bt)%n for bt in range(k)] rt+=[s] return rt def show(*inp,end='\n'): if show_flg: print(*inp,end=end) YN=['YES','NO'] mo=10**9+7 inf=float('inf') l_alp=string.ascii_lowercase u_alp=string.ascii_uppercase ts=time.time() #sys.setrecursionlimit(10**7) input=lambda: sys.stdin.readline().rstrip() def ran_input(): import random n=random.randint(4,16) rmin,rmax=1,10 a=[random.randint(rmin,rmax) for _ in range(n)] return n,a show_flg=False show_flg=True ans=0 h,n=LI() a=[] b=[] for i in range(n): x,y=LI() ab.append((a,b)) ab.sort() a=[i for i,j in ab] b=[j for i,j in ab] dp=[[0]+[inf]*(h) for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(h+1): dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])],dp[i][min(h,j+a[i])]) ans=dp[n][h] print(ans)
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from functools import * from itertools import permutations,combinations,groupby import sys import bisect import string import math import time import random def Golf(): *a,=map(int,open(0)) def S_(): return input() def IS(): return input().split() def LS(): return [i for i in input().split()] def I(): return int(input()) def MI(): return map(int,input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i)-1 for i in input().split()] def NI(n): return [int(input()) for i in range(n)] def NI_(n): return [int(input())-1 for i in range(n)] def StoI(): return [ord(i)-97 for i in input()] def ItoS(nn): return chr(nn+97) def LtoS(ls): return ''.join([chr(i+97) for i in ls]) def GI(V,E,Directed=False,index=0): org_inp=[] g=[[] for i in range(n)] for i in range(E): inp=LI() org_inp.append(inp) if index==0: inp[0]-=1 inp[1]-=1 if len(inp)==2: a,b=inp g[a].append(b) if not Directed: g[b].append(a) elif len(inp)==3: a,b,c=inp aa=(inp[0],inp[2]) bb=(inp[1],inp[2]) g[a].append(bb) if not Directed: g[b].append(aa) return g,org_inp def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}): #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage mp=[1]*(w+2) found={} for i in range(h): s=input() for char in search: if char in s: found[char]=((i+1)*(w+2)+s.index(char)+1) mp_def[char]=mp_def[replacement_of_found] mp+=[1]+[mp_def[j] for j in s]+[1] mp+=[1]*(w+2) return h+2,w+2,mp,found def bit_combination(k,n=2): rt=[] for tb in range(n**k): s=[tb//(n**bt)%n for bt in range(k)] rt+=[s] return rt def show(*inp,end='\n'): if show_flg: print(*inp,end=end) YN=['YES','NO'] mo=10**9+7 inf=float('inf') l_alp=string.ascii_lowercase u_alp=string.ascii_uppercase ts=time.time() #sys.setrecursionlimit(10**7) input=lambda: sys.stdin.readline().rstrip() def ran_input(): import random n=random.randint(4,16) rmin,rmax=1,10 a=[random.randint(rmin,rmax) for _ in range(n)] return n,a show_flg=False show_flg=True ans=0 h,n=LI() a=[] ab=[] for i in range(n): x,y=LI() ab.append((-x,y)) ab.sort() a=[-i for i,j in ab] b=[j for i,j in ab] dp=[[0]+[inf]*(h) for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(h+1): dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])],dp[i][min(h,j+a[i])]) ans=dp[n][h] print(ans)
[ "assignment.variable.change", "identifier.change", "call.arguments.change", "expression.operation.unary.add" ]
591,199
591,197
u623819879
python
p02787
h,n = map(int,input().split()) dp = [int(1e18)] * (h+1) dp[0] = 0 for i in range(n): a, b = map(int, input().split()) for j in range(h): nj = min(j+a, h) dp[nj] = min(dp[nj], dp[j]+b) print(dp) print(dp[h])
h,n = map(int,input().split()) dp = [int(1e18)] * (h+1) dp[0] = 0 for i in range(n): a, b = map(int, input().split()) for j in range(h): nj = min(j+a, h) dp[nj] = min(dp[nj], dp[j]+b) print(dp[h])
[ "call.remove" ]
591,202
591,203
u599114793
python
p02787
import math def main(): H,N=map(int,input().split()) inf=float('inf') dp=[0]+[inf]*H for i in range(N): A,B=map(int,input().split()) if A>=H: #dp[-1]=min(B,dp[-1]) if B < dp[-1]: dp[-1]=B else: for j in range(A,H+1): #dp[j]=min(dp[j-A]+B,dp[j]) if dp[j-A]+B<dp[j]: dp[j]=dp[j-A]+B if j > H-A: #dp[-1]=min(dp[-1],dp[j]+B) if dp[j]+B < dp[-1]: dp[-1]=dp[j]+B print(dp) print(dp[-1]) main()
import math def main(): H,N=map(int,input().split()) inf=float('inf') dp=[0]+[inf]*H for i in range(N): A,B=map(int,input().split()) if A>=H: #dp[-1]=min(B,dp[-1]) if B < dp[-1]: dp[-1]=B else: for j in range(A,H+1): #dp[j]=min(dp[j-A]+B,dp[j]) if dp[j-A]+B<dp[j]: dp[j]=dp[j-A]+B if j > H-A: #dp[-1]=min(dp[-1],dp[j]+B) if dp[j]+B < dp[-1]: dp[-1]=dp[j]+B print(dp[-1]) main()
[ "call.remove" ]
591,313
591,314
u025241948
python
p02787
# coding=utf-8 # Date: 2020-01-08 # Author: lee215 get = lambda: int(input().strip()) getl = lambda: input().strip() gets = lambda: list(map(int, input().strip().split())) getss = lambda n: [gets() for _ in range(n)] # fi = open('sample3.in', 'r') # input = fi.readline h, N = gets() AB = getss(N) dp = [0] + [float('inf')] * 100000 for a, b in AB: for i in range(h + 1): j = min(i + a, 1000000) dp[j] = min(dp[j], dp[i] + b) print(dp[h]) # PyPy2 Accepted # PyPy3 Accepted # Python2 TLE # Python3 TLE
# coding=utf-8 # Date: 2020-01-08 # Author: lee215 get = lambda: int(input().strip()) getl = lambda: input().strip() gets = lambda: list(map(int, input().strip().split())) getss = lambda n: [gets() for _ in range(n)] h, N = gets() AB = getss(N) dp = [0] + [float('inf')] * h for a, b in AB: for i in range(h): j = min(i + a, h) dp[j] = min(dp[j], dp[i] + b) print(dp[h])
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "expression.operation.binary.change", "expression.operation.binary.remove", "call.arguments.change" ]
591,361
591,362
u986014912
python
p02787
def chmin(a, b): if (a > b): return b return a def chmax(a, b): if (a < b): return b return a H, N = map(int, input().split()) li = [list(map(int, input().split())) for i in range(N)] dp = [[10**3] * (H+1) for i in range(N+1)] dp[0][0] = 0 for n in range(N): for h in range(0, H+1): dp[n+1][h] = chmin(dp[n+1][h], dp[n][h]) dp[n+1][min(h+li[n][0], H)] = chmin(dp[n+1][min(h+li[n][0], H)], dp[n+1][h]+li[n][1]) print(dp[N][H])
def chmin(a, b): if (a > b): return b return a def chmax(a, b): if (a < b): return b return a H, N = map(int, input().split()) li = [list(map(int, input().split())) for i in range(N)] dp = [[10**9] * (H+1) for i in range(N+1)] dp[0][0] = 0 for n in range(N): for h in range(0, H+1): dp[n+1][h] = chmin(dp[n+1][h], dp[n][h]) dp[n+1][min(h+li[n][0], H)] = chmin(dp[n+1][min(h+li[n][0], H)], dp[n+1][h]+li[n][1]) print(dp[N][H])
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
591,404
591,405
u431981421
python
p02787
h, n = map(int, input().split()) a = [] b = [] for i in range(n): a_, b_ = map(int, input().split()) a.append(a_) b.append(b_) dp = [float("inf")] * (h + 1010) dp[0] = 0 for i in range(h + 1): for j in range(n): dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j]) print(min(dp[h:]))
h, n = map(int, input().split()) a = [] b = [] for i in range(n): a_, b_ = map(int, input().split()) a.append(a_) b.append(b_) dp = [float("inf")] * (h + 10010) dp[0] = 0 for i in range(h + 1): for j in range(n): dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j]) print(min(dp[h:]))
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
591,423
591,424
u737298927
python
p02787
# coding: utf-8 import re import math import fractions import random from heapq import heappop,heappush import time import sys readline = sys.stdin.readline #import numpy as np mod=int(10**9+7) inf=int(10**20) class union_find(): def __init__(self,n): self.n=n self.P=[a for a in range(N)] self.rank=[0]*n def find(self,x): if(x!=self.P[x]):self.P[x]=self.find(self.P[x]) return self.P[x] def same(self,x,y): return self.find(x)==self.find(y) def link(self,x,y): if self.rank[x]<self.rank[y]: self.P[x]=y elif self.rank[y]<self.rank[x]: self.P[y]=x else: self.P[x]=y self.rank[y]+=1 def unite(self,x,y): self.link(self.find(x),self.find(y)) def size(self): S=set() for a in range(self.n): S.add(self.find(a)) return len(S) def bin_(num,size): A=[0]*size for a in range(size): if (num>>(size-a-1))&1==1: A[a]=1 else: A[a]=0 return A def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r) def next_comb(num,size): x=num&(-num) y=num+x z=num&(~y) z//=x z=z>>1 num=(y|z) if(num>=(1<<size)):return False else: return num #main h,n=map(int,input().split()) AB=[list(map(int,input().split())) for a in range(n)] dp=[[inf for b in range(h+1)] for a in range(n+1)] dp[0][0]=0 for a in range(1,n+1): for b in range(0,h+1): dp[a][b]=min(dp[a][b],dp[a-1][b]) key=min(h,b+AB[a-1][0]) dp[a][key]=min(dp[a][key],dp[a][b]+AB[a-1][1]) print(min(dp[n][h]))
# coding: utf-8 import re import math import fractions import random from heapq import heappop,heappush import time import sys readline = sys.stdin.readline #import numpy as np mod=int(10**9+7) inf=int(10**20) class union_find(): def __init__(self,n): self.n=n self.P=[a for a in range(N)] self.rank=[0]*n def find(self,x): if(x!=self.P[x]):self.P[x]=self.find(self.P[x]) return self.P[x] def same(self,x,y): return self.find(x)==self.find(y) def link(self,x,y): if self.rank[x]<self.rank[y]: self.P[x]=y elif self.rank[y]<self.rank[x]: self.P[y]=x else: self.P[x]=y self.rank[y]+=1 def unite(self,x,y): self.link(self.find(x),self.find(y)) def size(self): S=set() for a in range(self.n): S.add(self.find(a)) return len(S) def bin_(num,size): A=[0]*size for a in range(size): if (num>>(size-a-1))&1==1: A[a]=1 else: A[a]=0 return A def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r) def next_comb(num,size): x=num&(-num) y=num+x z=num&(~y) z//=x z=z>>1 num=(y|z) if(num>=(1<<size)):return False else: return num #main h,n=map(int,input().split()) AB=[list(map(int,input().split())) for a in range(n)] dp=[[inf for b in range(h+1)] for a in range(n+1)] dp[0][0]=0 for a in range(1,n+1): for b in range(0,h+1): dp[a][b]=min(dp[a][b],dp[a-1][b]) key=min(h,b+AB[a-1][0]) dp[a][key]=min(dp[a][key],dp[a][b]+AB[a-1][1]) print(dp[n][h])
[ "call.arguments.change" ]
591,464
591,465
u902151549
python
p02787
#モンスターの体力は H #トキはN種類の魔法が使え、 #i番目の魔法を使うと、モンスターの体力を Ai減らすことができますが、 #トキの魔力を Bi消耗します。 #dp[i] = モンスターの体力を i 減らすため消耗する魔力の最小値 #dp[i+1] = min(dp[i-Ai]+Bi,dp[i]) #dp[0]=0 h, n = map(int, input().split()) dp=[10**8]*(10**5+1) ab = [list(map(int, input().split())) for _ in range(n)] for i in range(1,h+1): for j in range(0,n): if i-ab[j][0]<0: x=ab[j][1] else: x=dp[i-ab[j][0]]+ab[j][1] dp[i]=min(dp[i],x) print(dp[h])
#モンスターの体力は H #トキはN種類の魔法が使え、 #i番目の魔法を使うと、モンスターの体力を Ai減らすことができますが、 #トキの魔力を Bi消耗します。 #dp[i] = モンスターの体力を i 減らすため消耗する魔力の最小値 #dp[i+1] = min(dp[i-Ai]+Bi,dp[i]) #dp[0]=0 h, n = map(int, input().split()) dp=[10**8]*(10**5+1) ab = [list(map(int, input().split())) for _ in range(n)] for i in range(1,h+1): for j in range(0,n): if i-ab[j][0]<=0: x=ab[j][1] else: x=dp[i-ab[j][0]]+ab[j][1] dp[i]=min(dp[i],x) print(dp[h])
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
591,466
591,467
u866374539
python
p02787
h,n = map(int,input().split()) dg = 10**5 ba = [] for _ in [0]*n: a,b = map(int,input().split()) if a >= h: a = h ba.append(b*dg + a) ba.sort() d = [10**9]*(h+1) d[0] = 0 for i in range(1, h+1): for e in ba: a,b = e%dg, e//dg if i<=a: if d[i] > b: d[i] = b else: if d[i] > d[i-a]+b: d[i] = d[i-1]+b print(d[-1])
h,n = map(int,input().split()) dg = 10**5 ba = [] for _ in [0]*n: a,b = map(int,input().split()) if a >= h: a = h ba.append(b*dg + a) ba.sort() d = [10**9]*(h+1) d[0] = 0 for i in range(1, h+1): for e in ba: a,b = e%dg, e//dg if i<=a: if d[i] > b: d[i] = b else: if d[i] > d[i-a]+b: d[i] = d[i-a]+b print(d[-1])
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
591,483
591,484
u672475305
python
p02787
import math def inputIntList(): return [int(s) for s in input().split()] def inputInt(): return int(input()) inf = float('inf') def main(): H, N = inputIntList() AB = [inputIntList() for _ in range(N)] dp = [inf for _ in range(H + 1)] dp[0] = 0 for (a, m) in AB: for h in range(H): nxt = min(H, h+a) dp[nxt] = min(dp[h]+m, dp[nxt]) print(dp) return dp[H] if __name__ == "__main__": print(main())
import math def inputIntList(): return [int(s) for s in input().split()] def inputInt(): return int(input()) inf = float('inf') def main(): H, N = inputIntList() AB = [inputIntList() for _ in range(N)] dp = [inf for _ in range(H + 1)] dp[0] = 0 for (a, m) in AB: for h in range(H): nxt = min(H, h+a) dp[nxt] = min(dp[h]+m, dp[nxt]) # print(dp) return dp[H] if __name__ == "__main__": print(main())
[ "call.remove" ]
591,548
591,549
u343128979
python
p02787
H,N = map(int,input().split()) A = [] B = [] for i in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) x = max(A) dp = [10**9 for i in range(H+x+1)] dp[0] = 0 for i in range(N): a = A[i] b = B[i] for j in range(H+x+1): if j < a: continue dp[j] = min(dp[j-a]+b,dp[j]) ans = 10**9 for i in range(H,H+X+1): ans = min(ans,dp[i]) print(ans)
H,N = map(int,input().split()) A = [] B = [] for i in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) x = max(A) dp = [10**9 for i in range(H+x+1)] dp[0] = 0 for i in range(N): a = A[i] b = B[i] for j in range(H+x+1): if j < a: continue dp[j] = min(dp[j-a]+b,dp[j]) ans = 10**9 for i in range(H,H+x+1): ans = min(ans,dp[i]) print(ans)
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change" ]
591,550
591,551
u557494880
python
p02787
# 解き直し H, N = map(int, input().split()) A_to_minB = {} max_A = -1 for i in range(N): a, b = map(int, input().split()) max_A = max(max_A, a) if a not in set(A_to_minB.keys()): A_to_minB[a] = b else: A_to_minB[a] = min(A_to_minB[a], b) dp = [float("inf")] * (H + max_A) dp[0] = 0 for i in range(1, H+N): tmp = [dp[i-a]+b for a, b in A_to_minB.items() if a<=i] if tmp: dp[i] = min(tmp) print(min(dp[H:H+max_A]))
# 解き直し H, N = map(int, input().split()) A_to_minB = {} max_A = -1 for i in range(N): a, b = map(int, input().split()) max_A = max(max_A, a) if a not in set(A_to_minB.keys()): A_to_minB[a] = b else: A_to_minB[a] = min(A_to_minB[a], b) dp = [float("inf")] * (H + max_A) dp[0] = 0 for i in range(1, H+max_A): tmp = [dp[i-a]+b for a, b in A_to_minB.items() if a<=i] if tmp: dp[i] = min(tmp) print(min(dp[H:H+max_A]))
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change" ]
591,604
591,605
u894934980
python
p02787
h,n=map(int,input().split()) a=[0]*n b=[0]*n inf=10**10 for i in range(n): a[i],b[i]=map(int,input().split()) dp = [[inf for i in range(h+1)] for j in range(n+1)] for i in range(n): cnt=1 for j in range(h+1): if j-a[i]<0: dp[i+1][j]=min(dp[i][j],dp[i][j-a[i]]+b[i],b[i]*cnt) else: dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i],dp[i][j-a[i]]+b[i],b[i]*cnt) cnt+=1 """ for i in range(1,n+1): for j in range(h+1): if j+a[i]<=h: dp[i+1][j+a[i]]=min(dp[i+1][a[i]],dp[i][j]+b[i])""" print(dp[n][h]) #print(dp)
h,n=map(int,input().split()) a=[0]*n b=[0]*n inf=10**10 for i in range(n): a[i],b[i]=map(int,input().split()) dp = [[inf for i in range(h+1)] for j in range(n+1)] for i in range(n): cnt=1 for j in range(h+1): if j-a[i]<0: dp[i+1][j]=min(dp[i][j],dp[i][0]+b[i],b[i]*cnt) else: dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i],dp[i][j-a[i]]+b[i],b[i]*cnt) cnt+=1 """ for i in range(1,n+1): for j in range(h+1): if j+a[i]<=h: dp[i+1][j+a[i]]=min(dp[i+1][a[i]],dp[i][j]+b[i])""" print(dp[n][h]) #print(dp)
[ "assignment.value.change", "identifier.replace.remove", "literal.replace.add", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
591,668
591,669
u727787724
python
p02787
def resolve(): H,N=(int(i) for i in input().split()) magics=[[int(i) for i in input().split()] for j in range(N)] mx=2**31 dpt=[mx for i in range(H+1)] dpt[-1]=0 for i in range(H,-1,-1): current=dpt[i] if current> dpt[0]: continue for m in magics: dpt[max(0,i-m[0])]=min(dpt[max(0,i-m[0])],current+m[1]) print(dpt[0]) if __name__ == "__main__": unittest.main()
def resolve(): H,N=(int(i) for i in input().split()) magics=[[int(i) for i in input().split()] for j in range(N)] mx=2**31 dpt=[mx for i in range(H+1)] dpt[-1]=0 for i in range(H,0,-1): current=dpt[i] if current> dpt[0]: continue for m in magics: dpt[max(0,i-m[0])]=min(dpt[max(0,i-m[0])],current+m[1]) print(dpt[0]) if __name__ == "__main__": resolve()
[ "call.arguments.change", "control_flow.loop.range.bounds.step.change", "expression.operation.unary.remove" ]
591,754
591,755
u307592354
python
p02782
r1,c1,r2,c2=map(int,input().split()) mod=10**9+7 def comb(n,k,mod): if n<k: return 0 if n-k<k: k=n-k c=1 for x in range(n-k+1,n+1): c=(c*x)%mod d=1 for x in range(1,k+1): d=(d*x)%mod c=c*pow(d,mod-2,mod) return c%mod def f(i,j): return comb(i+j,i,mod) ans=f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,r2) ans%=mod print(ans)
r1,c1,r2,c2=map(int,input().split()) mod=10**9+7 def comb(n,k,mod): if n<k: return 0 if n-k<k: k=n-k c=1 for x in range(n-k+1,n+1): c=(c*x)%mod d=1 for x in range(1,k+1): d=(d*x)%mod c=c*pow(d,mod-2,mod) return c%mod def f(i,j): return comb(i+j,i,mod) ans=f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,c1) ans%=mod print(ans)
[ "assignment.value.change", "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
591,932
591,933
u333700164
python
p02782
r1,c1,r2,c2 = map(int,input().split()) mod = 10**9+7 def p_mod(m,n,p): a = 1 for i in range(n): a = a*(m-i) % p return a def c_mod(m,n,p): return (p_mod(m,n,p)*pow(p_mod(n,n,p),p-2,p)) % p print(c_mod(r2+c2+2,r2+1,mod) - c_mod(r1+c2+1,r1,mod) - c_mod(r2+c1+1,c1,mod) + c_mod(r1+c1,r1,mod))
r1,c1,r2,c2 = map(int,input().split()) mod = 10**9+7 def p_mod(m,n,p): a = 1 for i in range(n): a = a*(m-i) % p return a def c_mod(m,n,p): return (p_mod(m,n,p)*pow(p_mod(n,n,p),p-2,p)) % p print((c_mod(r2+c2+2,r2+1,mod) - c_mod(r1+c2+1,r1,mod) - c_mod(r2+c1+1,c1,mod) + c_mod(r1+c1,r1,mod)) % mod)
[ "call.arguments.change", "call.arguments.add" ]
592,028
592,029
u119148115
python
p02782
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 def main(): r,c,rr,cc=map(int,input().split()) def COMinit(n,MOD): fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1) fac[0]=fac[1]=1 finv[0]=finv[1]=1 inv[1]=1 for i in range(2,(n+1)): fac[i]=fac[i-1]*i%MOD inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD finv[i]=finv[i-1]*inv[i]%MOD return fac,finv,inv fac,finv,inv=COMinit(rr+cc+10,MOD) def COM(n, k, MOD=MOD): if n<k or n<0 or k<0: return 0 return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD ans=COM(rr+cc+2,rr+1)-COM(rr+c+1,c)-COM(r+cc+1,r)+COM(r+c,r) print(ans) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 def main(): r,c,rr,cc=map(int,input().split()) def COMinit(n,MOD): fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1) fac[0]=fac[1]=1 finv[0]=finv[1]=1 inv[1]=1 for i in range(2,(n+1)): fac[i]=fac[i-1]*i%MOD inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD finv[i]=finv[i-1]*inv[i]%MOD return fac,finv,inv fac,finv,inv=COMinit(rr+cc+10,MOD) def COM(n, k, MOD=MOD): if n<k or n<0 or k<0: return 0 return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD ans=COM(rr+cc+2,rr+1)-COM(rr+c+1,c)-COM(r+cc+1,r)+COM(r+c,r) ans%=MOD print(ans) if __name__ == '__main__': main()
[]
592,040
592,041
u714642969
python
p02788
n, d, a = map(int, input().split()) l = [[0, 0] for _ in range(n)] for i in range(n): x, h = map(int, input().split()) l[i][0] = x l[i][1] = h l.sort() print(l) from collections import deque d = 2*d q = deque([]) total = 0 ans = 0 for i in range(n): x = l[i][0] h = l[i][1] if q: while q[0][0] < x: total -= q[0][1] q.popleft() if not q: break h -= total if h > 0: num = (h+a-1)//a ans += num damage = num*a total += damage q.append([x+d, damage]) print(ans)
n, d, a = map(int, input().split()) l = [[0, 0] for _ in range(n)] for i in range(n): x, h = map(int, input().split()) l[i][0] = x l[i][1] = h l.sort() from collections import deque d = 2*d q = deque([]) total = 0 ans = 0 for i in range(n): x = l[i][0] h = l[i][1] if q: while q[0][0] < x: total -= q[0][1] q.popleft() if not q: break h -= total if h > 0: num = (h+a-1)//a ans += num damage = num*a total += damage q.append([x+d, damage]) print(ans)
[ "call.remove" ]
592,171
592,172
u186838327
python
p02788
from collections import deque def read_int(): return int(input().strip()) def read_ints(): return list(map(int, input().strip().split(' '))) def solve(): """ explosion = FIFO deque and damage, range """ N, D, A = read_ints() XH = [] for _ in range(N): XH.append(read_ints()) XH.sort() explosion = deque([]) current_damage = 0 count = 0 for i in range(N): while len(explosion) != 0 and explosion[0][1] < XH[i][0]: current_damage -= explosion.popleft()[0] if current_damage < XH[i][1]: # damage is not enough left_health = XH[i][1]-current_damage more_bombs = (left_health//A+(1 if left_health%A != 0 else 0)) count += more_bombs more_damage = more_bombs*A current_damage += more_damage explosion.append((current_damage, XH[i][0]+2*D)) return count if __name__ == '__main__': print(solve())
from collections import deque def read_int(): return int(input().strip()) def read_ints(): return list(map(int, input().strip().split(' '))) def solve(): """ explosion = FIFO deque and damage, range """ N, D, A = read_ints() XH = [] for _ in range(N): XH.append(read_ints()) XH.sort() explosion = deque([]) current_damage = 0 count = 0 for i in range(N): while len(explosion) != 0 and explosion[0][1] < XH[i][0]: current_damage -= explosion.popleft()[0] if current_damage < XH[i][1]: # damage is not enough left_health = XH[i][1]-current_damage more_bombs = (left_health//A+(1 if left_health%A != 0 else 0)) count += more_bombs more_damage = more_bombs*A current_damage += more_damage explosion.append((more_damage, XH[i][0]+2*D)) return count if __name__ == '__main__': print(solve())
[ "identifier.change", "call.arguments.change" ]
592,257
592,258
u309716323
python
p02788
import sys import bisect read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines in_n = lambda: int(readline()) in_nn = lambda: map(int, readline().split()) in_s = lambda: readline().rstrip().decode('utf-8') in_nl = lambda: list(map(int, readline().split())) in_nl2 = lambda H: [in_nl() for _ in range(H)] in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')] in_map2 = lambda H: [in_map() for _ in range(H)] in_all = lambda: map(int, read().split()) class SegTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.ide_ele = ide_ele self.segfunc = segfunc self.num = 2**(n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num for i in range(n): self.seg[i + self.num - 1] = init_val[i] for i in range(self.num - 2, -1, -1): self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) def update(self, k, x): k += self.num - 1 self.seg[k] += x while k: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res def main(): N, D, A = in_nn() XH = sorted(in_nl2(N)) X = [0] * N H = [0] * N for i in range(N): x, h = XH[i] X[i] = x H[i] = h seg = SegTree([0] * N, segfunc=lambda a, b: a + b, ide_ele=0) ans = 0 for i in range(N): x, h = X[i], H[i] j = bisect.bisect_right(X, x + 2 * D) cnt_bomb = seg.query(0, i + 1) h -= A * cnt_bomb if h <= 0: continue cnt = -(-h // A) ans += cnt seg.update(i, cnt) seg.update(j, -cnt) # print(i, j) # print(seg.seg) print(ans) if __name__ == '__main__': main()
import sys import bisect read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines in_n = lambda: int(readline()) in_nn = lambda: map(int, readline().split()) in_s = lambda: readline().rstrip().decode('utf-8') in_nl = lambda: list(map(int, readline().split())) in_nl2 = lambda H: [in_nl() for _ in range(H)] in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')] in_map2 = lambda H: [in_map() for _ in range(H)] in_all = lambda: map(int, read().split()) class SegTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.ide_ele = ide_ele self.segfunc = segfunc self.num = 2**(n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num for i in range(n): self.seg[i + self.num - 1] = init_val[i] for i in range(self.num - 2, -1, -1): self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) def update(self, k, x): k += self.num - 1 self.seg[k] += x while k: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res def main(): N, D, A = in_nn() XH = sorted(in_nl2(N)) X = [0] * N H = [0] * N for i in range(N): x, h = XH[i] X[i] = x H[i] = h seg = SegTree([0] * N, segfunc=lambda a, b: a + b, ide_ele=0) ans = 0 for i in range(N): x, h = X[i], H[i] j = bisect.bisect_right(X, x + 2 * D) cnt_bomb = seg.query(0, i + 1) h -= A * cnt_bomb if h <= 0: continue cnt = -(-h // A) ans += cnt seg.update(i, cnt) if j < N: seg.update(j, -cnt) # print(i, j) # print(seg.seg) print(ans) if __name__ == '__main__': main()
[ "control_flow.branch.if.add" ]
592,264
592,265
u163783894
python
p02788
from collections import deque from math import ceil n,d,a = map(int,input().split()) M = [list(map(int,input().split())) for i in range(n)] M = [[x,ceil(h/a)] for x,h in M] M = sorted(M) que = deque() ans = 0 atack = 0 for x,h in M: if len(que) > 0: if que[0][0] < x: tx,ta = que.popleft() atack -= ta bomb_num = max(0, h-atack) atack += bomb_num ans += bomb_num if bomb_num > 0: que.append([x+d*2,bomb_num]) print(ans)
from collections import deque from math import ceil n,d,a = map(int,input().split()) M = [list(map(int,input().split())) for i in range(n)] M = [[x,ceil(h/a)] for x,h in M] M = sorted(M) que = deque() ans = 0 atack = 0 for x,h in M: while len(que) > 0 and que[0][0] < x: tx,ta = que.popleft() atack -= ta bomb_num = max(0, h-atack) atack += bomb_num ans += bomb_num if bomb_num > 0: que.append([x+d*2,bomb_num]) print(ans)
[ "control_flow.branch.while.replace.add", "control_flow.loop.if.replace.remove" ]
592,272
592,273
u898967808
python
p02788
import math from collections import deque N,D,A = map(int,input().split()) monsters = [ list(map(int,input().split())) for _ in range(N) ] monsters = [ [x, math.ceil(h/A)] for x,h in monsters ] que = deque() cur = 0 ans = 0 for x,h in monsters: while que and x > que[0][0]: _,n = que.popleft() cur -= n need = max(0, h-cur) ans += need cur += need if h: # 対象のモンスターを最も左端にいることを想定 que.append([x+2*D, need]) print(ans)
import math from collections import deque N,D,A = map(int,input().split()) monsters = sorted([ list(map(int,input().split())) for _ in range(N) ]) monsters = [ [x, math.ceil(h/A)] for x,h in monsters ] # print(monsters) que = deque() cur = 0 ans = 0 for x,h in monsters: while que and x > que[0][0]: _,n = que.popleft() cur -= n need = max(0, h-cur) ans += need cur += need if h: # 対象のモンスターを最も左端にいることを想定 que.append([x+2*D, need]) print(ans)
[ "call.add", "call.arguments.change" ]
592,274
592,275
u723711163
python
p02788
from collections import deque n,d,a = map(int, input().split()) xhl = [] for _ in range(n): x,h = map(int, input().split()) cnt = (h-1)//a + 1 xhl.append((x,cnt)) attack_q = deque([]) attack_sum = 0 ans = 0 for x,h in xhl: while attack_q and attack_q[0][0] < x: poped_cnt = attack_q.popleft()[1] attack_sum -= poped_cnt rem = h-attack_sum if rem <= 0: continue attack_sum += rem ans += rem attack_q.append((x+2*d, rem)) print(ans)
from collections import deque n,d,a = map(int, input().split()) xhl = [] for _ in range(n): x,h = map(int, input().split()) cnt = (h-1)//a + 1 xhl.append((x,cnt)) xhl.sort() attack_q = deque([]) attack_sum = 0 ans = 0 for x,h in xhl: # print('----',((x,h))) # print(attack_q) # print(attack_sum) while attack_q and attack_q[0][0] < x: poped_cnt = attack_q.popleft()[1] attack_sum -= poped_cnt # print(attack_q) # print(attack_sum) rem = h-attack_sum if rem <= 0: continue attack_sum += rem ans += rem attack_q.append((x+2*d, rem)) # print(rem) print(ans) # print(xhl)
[ "call.add" ]
592,282
592,283
u493520238
python
p02788
from collections import deque n,d,a=map(int,input().split()) xh=[list(map(int,input().split())) for _ in range(n)] xh.sort() d=2*d ans=0 total=0 q=deque() for i in range(n): x,h=xh[i] while len(q)>=1 and x>q[0][0]: total-=q.popleft()[1] h-=total if h>0: num=(h-1//a)+1 damage=a*num ans+=num total+=damage q.append([x+d,damage]) print(ans)
from collections import deque n,d,a=map(int,input().split()) xh=[list(map(int,input().split())) for _ in range(n)] xh.sort() d=2*d ans=0 total=0 q=deque() for i in range(n): x,h=xh[i] while len(q)>=1 and x>q[0][0]: total-=q.popleft()[1] h-=total if h>0: num=(h-1)//a+1 damage=a*num ans+=num total+=damage q.append([x+d,damage]) print(ans)
[]
592,306
592,307
u333700164
python
p02788
from collections import deque n,d,a=map(int,input().split()) xh=[list(map(int,input().split())) for _ in range(n)] xh.sort() d=2*d ans=0 total=0 q=deque() for i in range(n): x,h=xh[i] while len(q)>=1 and x>q[0][0]: total-=q.popleft()[1] h-=total if h>0: num=(h-h%a)//a damage=a*num ans+=num total+=damage q.append([x+d,damage]) print(ans)
from collections import deque n,d,a=map(int,input().split()) xh=[list(map(int,input().split())) for _ in range(n)] xh.sort() d=2*d ans=0 total=0 q=deque() for i in range(n): x,h=xh[i] while len(q)>=1 and x>q[0][0]: total-=q.popleft()[1] h-=total if h>0: num=(h-1)//a+1 damage=a*num ans+=num total+=damage q.append([x+d,damage]) print(ans)
[ "assignment.value.change", "identifier.replace.remove", "literal.replace.add", "expression.operation.binary.change", "expression.operation.binary.remove" ]
592,308
592,307
u333700164
python
p02788
from collections import deque n, d, a = map(int, input().split()) mons = [] for i in range(n): x, h = map(int, input().split()) mons.append((x, h)) mons = sorted(mons) print(mons) q = deque() dm_sum = 0 ans = 0 for i in range(n): while dm_sum > 0: if q[0][0] < mons[i][0]: cur = q.popleft() dm_sum -= cur[1] else: break if mons[i][1] <= dm_sum: continue rem = mons[i][1] - dm_sum at_num = rem // a if rem % a != 0: at_num += 1 ans += at_num q.append((mons[i][0] + 2 * d, at_num*a)) dm_sum += at_num*a print(ans)
from collections import deque n, d, a = map(int, input().split()) mons = [] for i in range(n): x, h = map(int, input().split()) mons.append((x, h)) mons = sorted(mons) q = deque() dm_sum = 0 ans = 0 for i in range(n): while dm_sum > 0: if q[0][0] < mons[i][0]: cur = q.popleft() dm_sum -= cur[1] else: break if mons[i][1] <= dm_sum: continue rem = mons[i][1] - dm_sum at_num = rem // a if rem % a != 0: at_num += 1 ans += at_num q.append((mons[i][0] + 2 * d, at_num*a)) dm_sum += at_num*a print(ans)
[ "call.remove" ]
592,356
592,357
u353402627
python
p02788
from collections import deque n, d, a = map(int, input().split()) mons = [] for i in range(n): x, h = map(int, input().split()) mons.append((x, h)) mons = sorted(mons) q = deque() dm_sum = 0 ans = 0 for i in range(n): if dm_sum > 0: if q[0][0] < mons[i][0]: cur = q.popleft() dm_sum -= cur[1] if mons[i][1] <= dm_sum: continue rem = mons[i][1] - dm_sum at_num = rem // a if rem % a != 0: at_num += 1 ans += at_num q.append((mons[i][0] + 2 * d, at_num*a)) dm_sum += at_num*a print(ans)
from collections import deque n, d, a = map(int, input().split()) mons = [] for i in range(n): x, h = map(int, input().split()) mons.append((x, h)) mons = sorted(mons) q = deque() dm_sum = 0 ans = 0 for i in range(n): while dm_sum > 0: if q[0][0] < mons[i][0]: cur = q.popleft() dm_sum -= cur[1] else: break if mons[i][1] <= dm_sum: continue rem = mons[i][1] - dm_sum at_num = rem // a if rem % a != 0: at_num += 1 ans += at_num q.append((mons[i][0] + 2 * d, at_num*a)) dm_sum += at_num*a print(ans)
[ "control_flow.branch.while.replace.add", "control_flow.loop.if.replace.remove", "control_flow.break.add" ]
592,358
592,357
u353402627
python
p02788
from math import ceil from collections import deque n, d, a = map(int, input().split()) m = [list(map(int, input().split())) for _ in range(n)] m = [[x, ceil(h/a)] for x, h in m] acc_damage = 0 que = deque() ans = 0 for x, h in m: while que and x > que[0][0]: limit, damage = que.popleft() acc_damage -= damage rest_h = max(0, h - acc_damage) ans += rest_h acc_damage += rest_h if rest_h: que.append([x + 2 * d, rest_h]) print(ans)
from math import ceil from collections import deque n, d, a = map(int, input().split()) m = sorted([list(map(int, input().split())) for _ in range(n)]) m = [[x, ceil(h / a)] for x, h in m] acc_damage = 0 que = deque() ans = 0 for x, h in m: while que and x > que[0][0]: limit, damage = que.popleft() acc_damage -= damage rest_h = max(0, h - acc_damage) ans += rest_h acc_damage += rest_h if rest_h: que.append([x + 2 * d, rest_h]) print(ans)
[ "call.add", "call.arguments.change" ]
592,365
592,366
u653837719
python
p02788
from math import ceil from collections import deque n, d, a = map(int, input().split()) m = sorted([list(map(int, input().split())) for _ in range(n)]) m = [[x, ceil(h / A)] for x, h in m] acc_damage = 0 que = deque() ans = 0 for x, h in m: while que and x > que[0][0]: limit, damage = que.popleft() acc_damage -= damage need = max(0, h - acc_damage) ans += need acc_damage += need if need: que.append([x + 2 * d, need]) print(ans)
from math import ceil from collections import deque n, d, a = map(int, input().split()) m = sorted([list(map(int, input().split())) for _ in range(n)]) m = [[x, ceil(h / a)] for x, h in m] acc_damage = 0 que = deque() ans = 0 for x, h in m: while que and x > que[0][0]: limit, damage = que.popleft() acc_damage -= damage need = max(0, h - acc_damage) ans += need acc_damage += need if need: que.append([x + 2 * d, need]) print(ans)
[ "assignment.value.change", "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
592,367
592,368
u653837719
python
p02788
from heapq import heappush, heappop n, d, a = map(int, input().split()) actions = [] for _ in range(n): x, h = map(int, input().split()) heappush(actions, (x, 0, h // a)) cnt = 0 bomb = 0 current_bomb = 0 while cnt < n: a, c, b = heappop(actions) if c: current_bomb -= b continue else: HP = b if HP <= current_bomb: cnt += 1 continue else: HP -= current_bomb cnt += 1 current_bomb += HP bomb += HP heappush(actions, (a + 2 * d, 1, HP)) print(bomb)
from heapq import heappush, heappop n, d, a = map(int, input().split()) actions = [] for _ in range(n): x, h = map(int, input().split()) heappush(actions, (x, 0, (h + a - 1) // a)) cnt = 0 bomb = 0 current_bomb = 0 while cnt < n: a, c, b = heappop(actions) if c: current_bomb -= b continue else: HP = b if HP <= current_bomb: cnt += 1 continue else: HP -= current_bomb cnt += 1 current_bomb += HP bomb += HP heappush(actions, (a + 2 * d, 1, HP)) print(bomb)
[ "call.arguments.change" ]
592,371
592,372
u994521204
python
p02788
import sys input = sys.stdin.readline n,d,a = map(int,input().split()) xh = [list(map(int,input().split())) for _ in range(n)] xh.sort() class Bit: def __init__(self, n): self.size = n self.tree = [0]*(n+1) self.depth = n.bit_length() def __iter__(self): psum = 0 for i in range(self.size): csum = self.sum(i+1) yield csum - psum psum = csum raise StopIteration() def __str__(self): # O(nlogn) return str(list(self)) def sum(self, i): # [0, i) の要素の総和を返す if not (0 <= i <= self.size): raise ValueError("error!") s = 0 while i>0: s += self.tree[i] i -= i & -i return s def add(self, i, x): if not (0 <= i < self.size): raise ValueError("error!") i += 1 while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, x): """ 累積和がx以上になる最小のindexと、その直前までの累積和 """ sum_ = 0 pos = 0 for i in range(self.depth, -1, -1): k = pos + (1 << i) if k <= self.size and sum_ + self.tree[k] < x: sum_ += self.tree[k] pos += 1 << i return pos + 1, sum_ def __getitem__(self, key): if not (0 <= key < self.size): raise IndexError("error!") return self.sum(key+1) - self.sum(key) def __setitem__(self, key, value): # 足し算と引き算にはaddを使うべき if not (0 <= key < self.size): raise IndexError("error!") self.add(key, value - self[key]) class BitImos: """ ・範囲すべての要素に加算 ・ひとつの値を取得 の2種類のクエリをO(logn)で処理 """ def __init__(self, n): self.bit = Bit(n+1) def add(self, s, t, x): # [s, t)にxを加算 self.bit.add(s, x) self.bit.add(t, -x) def get(self, i): return self[i] def __getitem__(self, key): # 位置iの値を取得 return self.bit.sum(key+1) bit = BitImos(n) ans = 0 att = [0]*n cnt = 0 for i in range(n): tmp = xh[i][0] + 2 * d while cnt < n: if xh[cnt][0] < tmp: cnt += 1 else: break att[i] = min(cnt, n-1) for i,xh1 in enumerate(xh): x,h = xh1 if bit.get(i) < h: at = -(-(h - bit.get(i)) // a) ans += at bit.add(i, att[i]+1, at*a) print(ans)
import sys input = sys.stdin.readline n,d,a = map(int,input().split()) xh = [list(map(int,input().split())) for _ in range(n)] xh.sort() class Bit: def __init__(self, n): self.size = n self.tree = [0]*(n+1) self.depth = n.bit_length() def __iter__(self): psum = 0 for i in range(self.size): csum = self.sum(i+1) yield csum - psum psum = csum raise StopIteration() def __str__(self): # O(nlogn) return str(list(self)) def sum(self, i): # [0, i) の要素の総和を返す if not (0 <= i <= self.size): raise ValueError("error!") s = 0 while i>0: s += self.tree[i] i -= i & -i return s def add(self, i, x): if not (0 <= i < self.size): raise ValueError("error!") i += 1 while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, x): """ 累積和がx以上になる最小のindexと、その直前までの累積和 """ sum_ = 0 pos = 0 for i in range(self.depth, -1, -1): k = pos + (1 << i) if k <= self.size and sum_ + self.tree[k] < x: sum_ += self.tree[k] pos += 1 << i return pos + 1, sum_ def __getitem__(self, key): if not (0 <= key < self.size): raise IndexError("error!") return self.sum(key+1) - self.sum(key) def __setitem__(self, key, value): # 足し算と引き算にはaddを使うべき if not (0 <= key < self.size): raise IndexError("error!") self.add(key, value - self[key]) class BitImos: """ ・範囲すべての要素に加算 ・ひとつの値を取得 の2種類のクエリをO(logn)で処理 """ def __init__(self, n): self.bit = Bit(n+1) def add(self, s, t, x): # [s, t)にxを加算 self.bit.add(s, x) self.bit.add(t, -x) def get(self, i): return self[i] def __getitem__(self, key): # 位置iの値を取得 return self.bit.sum(key+1) bit = BitImos(n) ans = 0 att = [0]*n cnt = 0 for i in range(n): tmp = xh[i][0] + 2 * d while cnt < n: if xh[cnt][0] <= tmp: cnt += 1 else: break att[i] = min(cnt-1, n-1) for i,xh1 in enumerate(xh): x,h = xh1 if bit.get(i) < h: at = -(-(h - bit.get(i)) // a) ans += at bit.add(i, att[i]+1, at*a) print(ans)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
592,384
592,385
u623231048
python
p02788
import sys, heapq input = sys.stdin.readline N, D, A = [int(_) for _ in input().split()] XH = [[int(_) for _ in input().split()] for _ in range(N)] He = [[2 * x, h, 0] for x, h in XH] heapq.heapify(He) now = 0 ans = 0 while He: x, h, t = heapq.heappop(He) if t: now -= h else: if h - D * now > 0: diff = (h - now - 1) // A + 1 now += diff ans += diff heapq.heappush(He, [x + 4 * D + 1, diff, 1]) print(ans)
import sys, heapq input = sys.stdin.readline N, D, A = [int(_) for _ in input().split()] XH = [[int(_) for _ in input().split()] for _ in range(N)] He = [[2 * x, h, 0] for x, h in XH] heapq.heapify(He) now = 0 ans = 0 while He: x, h, t = heapq.heappop(He) if t: now -= h else: if h - A * now > 0: diff = (h - A * now - 1) // A + 1 now += diff ans += diff heapq.heappush(He, [x + 4 * D + 1, diff, 1]) print(ans)
[ "identifier.change", "control_flow.branch.if.condition.change" ]
592,403
592,404
u844789719
python
p02788
from collections import deque import math N, D, A = map(int, input().split()) monster = [list(map(int, input().split())) for _ in range(N)] monster.sort(key=lambda x:x[0]) bomb = deque() s = 0 ans = 0 for i in range(N): x, h = monster[i] while len(bomb) > 0 and bomb[0][1] < x: s -= bomb.popleft()[2] h -= s if h > 0: cnt = math.ceil((h-s)/A) damage = cnt*A bomb.append([x, x+2*D, damage]) s += damage ans += cnt print(ans)
from collections import deque import math N, D, A = map(int, input().split()) monster = [list(map(int, input().split())) for _ in range(N)] monster.sort(key=lambda x:x[0]) bomb = deque() s = 0 ans = 0 for i in range(N): x, h = monster[i] while len(bomb) > 0 and bomb[0][1] < x: s -= bomb.popleft()[2] h -= s if h > 0: cnt = math.ceil(h/A) damage = cnt*A bomb.append([x, x+2*D, damage]) s += damage ans += cnt print(ans)
[ "call.arguments.change" ]
592,422
592,423
u419877586
python
p02788
from collections import deque N, D, A=map(int, input().split()) XH=[list(map(int, input().split())) for _ in range(N)] XH.sort(key=lambda x:x[0]) total=0 q=deque() ans=0 for i in range(N): X, H=XH[i] while len(q) and q[0][0]<X: total-=q.pop()[1] H-=total if H>0: attack_cnt=(H-1)//A+1 ans+=attack_cnt damage=attack_cnt*A total+=damage q.append([X+2*D, damage]) print(ans)
from collections import deque N, D, A=map(int, input().split()) XH=[list(map(int, input().split())) for _ in range(N)] XH.sort(key=lambda x:x[0]) total=0 q=deque() ans=0 for i in range(N): X, H=XH[i] while len(q) and q[0][0]<X: total-=q.popleft()[1] H-=total if H>0: attack_cnt=(H-1)//A+1 ans+=attack_cnt damage=attack_cnt*A total+=damage q.append([X+2*D, damage]) print(ans)
[ "identifier.change" ]
592,424
592,425
u419877586
python