Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03599 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def main():
    A, B, C, D, E, F = map(int, input().split())
    weight = 0.1
    sugar = 0

    for p in range(F // (100 * A) + 1):
        for q in range(0, (F - 100 * A * p) // (100 * B) + 1):
            upper = (A * p + B * q) * E
            water = (A * p + B * q) * 100
            if water == 0: continue
            for r in range(0, upper // C + 1):
                if water + C * r > F: continue
                s = (upper - C * r) // D
                while s >= 0 and water + C * r + D * s > F: s -= 1
                if s < 0: continue
                if sugar * (water + C * r + D * s) < (C * r + D * s) * weight:
                    weight = water + C * r + D * s
                    sugar = C * r + D * s
    if sugar == 0:
        print("{} 0".format(100 * A))
    else:
        print("{} {}".format(weight, sugar))

    


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    A, B, C, D, E, F = map(int, input().split())
    weight = 0.1
    sugar = 0

    for p in range(F // (100 * A) + 1):
        for q in range((F - 100 * A) // (100 * B) + 1):
            upper = (A * p + B * q) * E
            water = (A * p + B * q) * 100
            if water == 0: continue
            for r in range(upper // C + 1):
                if water + r > F: continue
                s = min((upper - C * r) // D, F - (water + r))
                if s < 0: continue
                if sugar * (water + C * r + D * s) < (C * r + D * s) * weight:
                    weight = water + C * r + D * s
                    sugar = C * r + D * s
    if sugar = 0:
        print("0 0")
    else:
        print("{} {}".format(weight, sugar))

    


if __name__ == "__main__":
    main()
Problem p03612 (python)

Fixed submission:
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    P = [0] + list(map(int, input().split()))
    same = deque()
    for i in range(1, N + 1):
        if i == P[i]: same.append(i)
    if not same:
        print(0)
        return

    ans = 0
    x = same.popleft()
    if not same:
        print(1)
        return
    while same:
        if same[0] - x == 1:
            same.popleft()
            ans += 1
            if same:
                x = same.popleft()
                if not same:
                    ans += 1
                    break
        else:
            ans += 1
            x = same.popleft()
            if not same:
                ans += 1
                break
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    P = [0] + list(map(int, input().split()))
    ans = 0
    for i in range(1, N + 1):
        if i == P[i]:
            P[i + 1] = P[i]
            ans += 1
    print(ans)



if __name__ == "__main__":
    main()
Problem p03658 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)
    print(sum(L[:k]))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)
    print(sum[:K])

if __name__ == "__main__":
    main()
Problem p04045 (python)

Fixed submission:
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()

def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))
    while True:
        check = True
        for c in str(N):
            if int(c) in D:
                check = False
        if check:
            print(N)
            return
        N += 1


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()

def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))
    ok = [i for i in range(10) if i not in D]
    N = str(N)
    l = len(N)
    if {i for i in range(int(N[0]), 10)} <= D:
        if ok[0] == 0:
            ans = ok[1] * 10 ** l
            print(ans)
    else:
        ans = 0
        for c in N:
            ans *= 10
            idx = bisect_left(ok, int(c))
            ans += ok[idx]
        print(ans)




if __name__ == "__main__":
    main()
Problem p04046 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(10**6)

def main():
    H, W, A, B = map(int, input().split())
    ans = 0
    for i in range(1, H - A + 1):
        ans += comb(i + B - 2, i - 1) * comb(H - i + W - B - 1, H - i)
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(10**5)

def main():
    H, W, A, B = map(int, input().split())
    ans = 0
    for i in range(1, H - A + 1):
        ans += comb(i + B - 2, i - 1) * comb(H - i + W - B - 1, H - i)
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()
Problem p02584 (python)

Fixed submission:
X,K,D = map(int, input().split())
absX = abs(X)
ans = 0
if absX//D > K:
  ans = absX - D*K
else:
  if (absX//D)%2 == (K%2):
    ans = absX%D
  else:
    posX = absX%D+D
    negX = abs(absX%D-D)
    if posX < negX:
      ans = posX
    else:
      ans = negX
print(ans)

Buggy submission (verdict: Runtime Error):
1000000000000000 1000000000000000 1000000000000000
Problem p02586 (python)

Fixed submission:
R,C,K = map(int, input().split())
a = [[0] * (C+1) for i in range(R+1)]
dp = [[[0] * (C+1) for i in range(R+1)] for j in range(4)]
for i in range(K):
  r,c,v = map(int, input().split())
  a[r-1][c-1] = v

for i in range(R):
  for j in range(C):
    for k in range(2, -1, -1):
      dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j]+a[i][j])
    for k in range(4):
      dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
      dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])

    
ans = 0
for k in range(4):
  ans = max(ans, dp[k][R-1][C-1])
print(ans)

Buggy submission (verdict: Runtime Error):
a = [[0] * 3005 for i in range(3005)]
dp = [[[0] * 3005 for i in range(3005)] for j in range(5)]
R,C,K = map(int, input().split())

for i in range(K):
  r,c,v = map(int, input().split())
  a[r-1][c-1] = v

for i in range(R):
  for j in range(C):
    for k in range(2, -1, -1):
      dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k]+a[i][j])
    for k in range(4):
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k])
      dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k])
    
ans = 0
for k in range(4):
  ans = max(ans, dp[R-1][C-1][k])
print(ans)

Buggy submission (verdict: Runtime Error):
a = [[0] * 3001 for i in range(3001)]
dp = [[[0] * 3001 for i in range(3001)] for j in range(5)]
R,C,K = map(int, input().split())

for i in range(K):
  r,c,v = map(int, input().split())
  a[r-1][c-1] = v

for i in range(R):
  for j in range(C):
    for k in range(2, -1, -1):
      dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k]+a[i][j])
    for k in range(4):
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k])
      dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k])
    
ans = 0
for k in range(4):
  ans = max(ans, dp[R-1][C-1][k])
print(ans)
Problem p02630 (python)

Fixed submission:
N = int(input())
AList = list(map(int, input().split()))
Q = int(input())
dp = [0]*(10**5+1)
total = 0
for i in AList:
  dp[i] += 1
  total += i
  
for i in range(Q):
  B,C = map(int, input().split())
  bNum = dp[B]
  dp[B] = 0
  dp[C] += bNum
  cNum = dp[C]
  total = total - B*bNum + C*bNum
  print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
AList = list(map(int, input().split()))
Q = int(input())
dp = [0]*(10**5)
total = 0
for i in AList:
  dp[i] += 1
  total += i
  
for i in range(Q):
  B,C = map(int, input().split())
  bNum = dp[B]
  dp[B] = 0
  dp[C] += bNum
  cNum = dp[C]
  total = total - B*bNum + C*bNum
  print(total)
Problem p03087 (python)

Fixed submission:
a = list(map(int,input().split()))
N = a[0]
Q = a[1]
numofac = [0 for i in range(N)]
S = input()
appear = 0
index = 1
while index < N:
    if S[index-1] == "A" and S[index] == "C":
        appear += 1
        numofac[index] = appear
        if index != N-1:
            numofac[index+1] = appear
        index += 2
    else:
        numofac[index] = appear
        index += 1
for i in range(Q):
    q = list(map(int,input().split()))
    print(str(numofac[q[1]-1] - numofac[q[0]-1]))

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
N = a[0]
Q = a[1]
numofac = [0 for i in range(N)]
S = input()
appear = 0
index = 1
while index < N:
    if S[index-1] == "A" and S[index] == "C":
        appear += 1
        numofac[index] = appear
        numofac[index+1] = appear
        index += 2
    else:
        numofac[index] = appear
        index += 1
for i in range(Q):
    q = list(map(int,input().split()))
    print(str(numofac[q[1]-1] - numofac[q[0]-1]))
Problem p03103 (python)

Fixed submission:
a = list(map(int,input().split()))
N = a[0]
M = a[1]
dct = {}
for i in range(N):
    temp = list(map(int,input().split()))
    if temp[0] in dct:
        val = dct[temp[0]] + temp[1]
        dct[temp[0]] = val
    else:
        dct[temp[0]] = temp[1]

dct = sorted(dct.items())
ruiseki = 0
loop = 0

cost = []
nums = []
ans = 0
lendct = len(dct)
for i in range(lendct):
    cost.append(dct[i][0])
    nums.append(dct[i][1])
if nums[0] >= M:
    print(str(cost[0]*M))
else:
    ans += cost[0]*nums[0]
    for i in range(1, 100001):
        nums[i] += nums[i-1]
        if nums[i] >= M:
            print(str(ans + cost[i]*(M - nums[i-1])))
            break
        ans += cost[i]*(nums[i]-nums[i-1])

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
N = a[0]
M = a[1]
dct = {}
for i in range(N):
    temp = list(map(int,input().split()))
    if temp[0] in dct:
        val = dct[temp[0]] + temp[1]
        dct[temp[0]] = val
    else:
        dct[temp[0]] = temp[1]

dct = sorted(dct.items())
ruiseki = 0
loop = 0

cost = []
nums = []
ans = 0
for i in range(N):
    cost.append(dct[i][0])
    nums.append(dct[i][1])
if nums[0] >= M:
    print(str(cost[0]*M))
else:
    ans += cost[0]*nums[0]
    for i in range(1, 100001):
        nums[i] += nums[i-1]
        if nums[i] >= M:
            print(str(ans + cost[i]*(M - nums[i-1])))
            break
        ans += cost[i]*(nums[i]-nums[i-1])
Problem p03206 (python)

Fixed submission:
D=int(input())
if D==25:
    print("Christmas")
elif D==24:
    print("Christmas Eve")
elif D==23:
    print("Christmas Eve Eve")
elif D==22:
    print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
D=int(input())
if D==25:
    print("Christmas")
else if D==24:
    print("Christmas Eve")
else if D==23:
    print("Christmas Eve Eve")
else if D==22:
    print("Christmas Eve Eve Eve")
Problem p03337 (python)

Fixed submission:
A, B = map(int,input().split())
print(str(max(A+B, A-B, A*B)))

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())
print(str(max(A+B, A-B., A*B)))
Problem p03651 (python)

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    if a <= b:
        temp = a
        a = b
        b = temp
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)


N, K = map(int,input().split())
A = list(map(int,input().split()))
#Aの最大公約数を作ることが出来る

A.sort()
if K > A[-1]:
    print("IMPOSSIBLE")
elif N == 1:
    if K != A[0]:
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")
else:
    g = gcd(A[0], A[1])
    for i in range(2, N):
        g = gcd(g, A[i])
    if K % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    if a <= b:
        temp = a
        a = b
        b = temp
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)


N, K = map(int,input().split())
A = list(map(int,input().split()))
#Aの最大公約数を作ることが出来る

A.sort()
if K > A[-1]:
    print("IMPOSSIBLE")
else:
    g = gcd(A[0], A[1])
    for i in range(2, N):
        g = gcd(g, A[2])
    if K % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
Problem p03815 (python)

Fixed submission:
x=int(input())
mod=x%11
div=int(x/11)
if mod > 6:
    print(div*2+2)
elif mod == 0:
    print(div*2)
else:
    print(div*2+1)

Buggy submission (verdict: Runtime Error):
x=int(input())
mod=x%11
div=int(x/11)
if mod > 6:
    print(div*2+2)
elif: mod == 0:
    print(div*2)
else:
    print(div*2+1)
Problem p04039 (python)

Fixed submission:
import sys

N, K = map(int,input().split())
D = list(input().split())
for i in range(N, 100001):
    flg = 1
    cost = str(i)
    digit = len(cost)
    for j in range(digit):
        if cost[j] in D:
            flg = 0
            break
    if flg == 1:
        print(cost)
        sys.exit()
print("error")

Buggy submission (verdict: Runtime Error):
import sys

N, K = map(int,input().split())
D = list(input().split())
flg = 1
for i in range(N, 10001):
    flg = 1
    cost = str(i)
    digit = len(cost)
    for j in range(digit):
        if cost[j] in D:
            flg = 0
            break
    if flg == 1:
        print(cost)
        sys.exit()
print("error")
sys.exit(1)
Problem p03369 (python)

Fixed submission:
opt=input()
sum=700
if opt[0] == 'o':
  sum+=100
if opt[1] == 'o':
  sum+=100
if opt[2] == 'o':
  sum+=100
print(sum)

Buggy submission (verdict: Runtime Error):
opt=input()
sum=700
if opt[0] == o:
  sum+=100
if opt[1] == o:
  sum+=100
if opt[2] == o:
  sum+=100
print(sum)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
tmp = 0
for a in range(1, k+1):
  for b in range(a, k+1):
    for c in range(b, k+1):
      #print('a='+str(a)+', b='+str(b)+', c='+str(c))
      if a == b and a == c:
        tmp += gcd_list([a, b, c]) 
      elif a == b and a != c:
        tmp += gcd_list([a, b, c]) * 3
#        tmp += gcd_list([b, c, a]) 
#        tmp += gcd_list([c, a, b]) 
      elif b == c and a != c:
        tmp += gcd_list([a, b, c]) * 3
#        tmp += gcd_list([b, c, a]) 
#        tmp += gcd_list([c, a, b]) 
      elif a == c and b != c:
        tmp += gcd_list([a, b, c]) * 3
#        tmp += gcd_list([b, c, a]) 
#        tmp += gcd_list([c, a, b]) 
      else:
        tmp += gcd_list([a, b, c]) * 6
#        tmp += gcd_list([a, c, b])
#        tmp += gcd_list([b, a, c])
#        tmp += gcd_list([b, c, a])
#        tmp += gcd_list([c, a, b])
#        tmp += gcd_list([c, b, a])
print(tmp)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
tmp = 0
for a range(1, k+1):
  for b range(1, k+1):
    for c range(1, k+1):
      tmp += gcd_list([a, b, c])
print(tmp)
Problem p02741 (python)

Fixed submission:
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])

Buggy submission (verdict: Runtime Error):
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    arr=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    println(arr[parseInt(readline())])
end
main()
Problem p02742 (python)

Fixed submission:
from math import ceil,floor
h,w=[int(i) for i in input().split()]
if h==1 or w==1:
    print(1)
else:
    print(ceil(h*w/4)+floor(h*w/4))

Buggy submission (verdict: Runtime Error):
h,w=[int(i) for i in input().split()]
print(ceil(h/2)*ceil(w/2)+floor(h/2)*floor(w/2))
Problem p02743 (python)

Fixed submission:
from math import ceil,floor,sqrt
from collections import deque,Counter
from decimal import Decimal
a,b,c=[int(i) for i in input().split()]
print("Yes" if Decimal(a).sqrt()+Decimal(b).sqrt()<Decimal(c).sqrt() else "No")

Buggy submission (verdict: Runtime Error):
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=split(readline())
    if sqrt(parseFloat(a))+sqrt(parseFloat(b))<sqrt(parseFloat(c))
        println("Yes")
    else
        println("No")
    end
end
main()
Problem p02796 (python)

Fixed submission:
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[tuple(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)
Problem p02917 (python)

Fixed submission:
n=int(input())
b=[10000000000]+[int(i) for i in input().split()]+[100000000000000]
ans=0
for i in range(n):
    ans+=min(b[i],b[i+1])
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
b=[int(i) for i in input().split()]
ans=b[-1]
for i in range(n-1):
    ans+=min(b[i],b[i+1])
print(ans)
Problem p02960 (python)

Fixed submission:
s=input()
n=len(s)
dp=[[0]*13 for _ in range(100010)]
dp[0][0]=1
for i in range(n):
    for j in range(10):
        if s[i]==str(j) or s[i]=="?":
            for h in range(13):
                dp[i+1][(h*10+j)%13]+=dp[i][h]
    for h in range(13):
        dp[i+1][h]%=1000000007
print(dp[n][5])

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
ans=0
def bfs(st,numQ):
    global ans
    if numQ==n:
        if int(st)%13==5:
            ans=(ans+1)%1000000007
    else:
        if st[numQ]=="?":
            for i in range(10):
                bfs(st[:numQ]+str(i)+st[numQ+1:],numQ+1)
        else:
            bfs(st,numQ+1)
bfs(s,0)
print(ans)
Problem p03000 (python)

Fixed submission:
n,x=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
i=0
dis=0
cnt=0
try:
    while dis<=x:
        dis+=l[i]
        i+=1
        cnt+=1
    print(cnt)
except:
    print(n+1)

Buggy submission (verdict: Runtime Error):
n,x=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
i=0
dis=0
cnt=0
while dis<=x:
    dis+=l[i]
    i+=1
    cnt+=1
print(cnt)
Problem p03032 (python)

Fixed submission:
n,k=[int(i) for i in input().split()]
v=[int(i) for i in input().split()]
res=0
for right in range(k+1):
    for left in range(min(n,k)-right+1):
        ans=[]
        ans+=v[:right]
        ans+=v[n-left:]
        ans.sort()
        for i in range(min(k-right-left,len(ans))+1):
            res=max(res,sum(ans[i:]))
print(res)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,k=[int(i) for i in input().split()]
v=[int(i) for i in input().split()]
tmp=v.copy()
res=0
for right in range(k+1):
    for left in range(k-right+1):
        v=tmp.copy()
        ans=[]
        ans+=v[:right]
        ans+=v[n-left:]
        v=v[right:n-left]
        ans.sort()
        for i in range(min(k-right-left,len(ans))+1):
            res=max(res,sum(ans[i:]))
print(res)
Problem p03061 (python)

Fixed submission:
def gcd(num1,num2):
    if num2==0:
        return num1
    return gcd(num2,num1%num2)
from collections import deque
n=int(input())
a=[int(i) for i in input().split()]
left_gcd=a[0]
right_gcd=a[-1]
left=deque([])
right=deque([])
for i in a:
    left_gcd=gcd(left_gcd,i)
    left.append(left_gcd)
for i in a[::-1]:
    right_gcd=gcd(right_gcd,i)
    right.append(right_gcd)
right=deque(reversed(right))
Max=max(right[1],left[-2])
for i in range(1,n-1):
    Max=max(Max,gcd(left[i-1],right[i+1]))
print(Max)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=sorted([int(i) for i in input().split()])
gcd1=[0]*n
gcd2=[0]*n
for i in range(n):
    if i!=0:
        gcd1[i]=gcd(a[0],a[i])
    if i!=1:
        gcd2[i]=gcd(a[1],a[i])
print(max(max(gcd1),max(gcd2)))
Problem p03103 (python)

Fixed submission:
n,m=[int(i) for i in input().split()]
hoge=[tuple([int(i) for i in input().split()]) for j in range(n)]
hoge.sort()
ans=0
for i in range(len(hoge)):
    if hoge[i][1]>m:
        ans+=hoge[i][0]*m
        break
    else:
        ans+=hoge[i][0]*hoge[i][1]
        m-=hoge[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
min_money=[10000000000,1000000001,1000000002]
min_buy=[0,0,0]
for i in range(n):
    a,b=[int(i) for i in input().split()]
    min_money.append(a)
    min_money.sort()
    min_money.pop()
    if a in min_money:
        min_buy[min_money.index(a)],min_buy[min_money.index(a)+1]=b,min_buy[min_money.index(a)]
ans=0
for i in range(3):
    if min_buy[i]>=m:
        ans+=min_money[i]*m
        break
    else:
        ans+=min_money[i]*min_buy[i]
        m-=min_buy[i]
print(ans)