Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

count = (K + 1) ** 3
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z != S:
                count -= 1

print(count)

Fixed submission:
K, S = map(int, input().split())

count = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= S - (x + y) <= K:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
N,D=map(int,input().split())
sum=0
for _ in range(N):
    X,Y=map(int,input().split())
    if math.sqrt(((X*X)+(Y*Y)))<=D:
        sum=sum+1
print(sum)
    


Fixed submission:
import math

N,D=map(int,input().split())
sum=0
for _ in range(N):
    X,Y=map(int,input().split())
    if math.sqrt(((X*X)+(Y*Y)))<=D:
        sum=sum+1
print(sum)

Buggy python submission (verdict: Runtime Error):
N,D=map(int,input().split())
sum=0
for _ in range(N):
    X,Y=map(int,input().split())
    if math.sqrt(((X*X)+(Y*Y)))<=D:
        sum=sum+1
    print(sum)
    

Fixed submission:
import math

N,D=map(int,input().split())
sum=0
for _ in range(N):
    X,Y=map(int,input().split())
    if math.sqrt(((X*X)+(Y*Y)))<=D:
        sum=sum+1
print(sum)
Buggy python submission (verdict: Runtime Error):
#C
N = int(input())

count = [0] * 10000
for j in range(1, 100):
    for k in range(1, 100):
        for l in range(1, 100):
            v = (j+k+l) ** 2 - (j*k + k*l + l*j)
            if v <= 10000:
                count[v] += 1

for i in range(1, N+1):
    print(count[i])

Fixed submission:
#C
N = int(input())

count = [0] * 10050
for j in range(1, 105):
    for k in range(1, 105):
        for l in range(1, 105):
            v = (j+k+l) ** 2 - (j*k + k*l + l*j)
            if v < 10050:
                count[v] += 1

for i in range(1, N+1):
    print(count[i])

Buggy python submission (verdict: Runtime Error):
#C
import math

N = int(input())


count = [0] * 10050
for j in range(1, 105):
    for k in range(1, 105):
        for l in range(1, 105):
            v = (j+k+l) ** 2 - (j*k + k*l + l*j)
            if v <= 10050:
                count[v] += 1

for i in range(1, N):
    print(count[i])

Fixed submission:
#C
N = int(input())

count = [0] * 10050
for j in range(1, 105):
    for k in range(1, 105):
        for l in range(1, 105):
            v = (j+k+l) ** 2 - (j*k + k*l + l*j)
            if v < 10050:
                count[v] += 1

for i in range(1, N+1):
    print(count[i])

Buggy python submission (verdict: Time Limit Exceeded):
#C
import math

N = int(input())


for i in range(1, N+1):
    count = 0
    for j in range(1, int(math.sqrt(i))):
        for k in range(1, int(math.sqrt(i))):
            for l in range(1, int(math.sqrt(i))):
                if i == (j+k+l) ** 2 - (j*k + k*l + l*j):
                    count += 1

    print(count)



Fixed submission:
#C
N = int(input())

count = [0] * 10050
for j in range(1, 105):
    for k in range(1, 105):
        for l in range(1, 105):
            v = (j+k+l) ** 2 - (j*k + k*l + l*j)
            if v < 10050:
                count[v] += 1

for i in range(1, N+1):
    print(count[i])
Buggy python submission (verdict: Runtime Error):
a, b = input().split()

result = int(a) * int(100 * float(b) // 100

print(result)

Fixed submission:
import decimal

a, b = input().split()

a = int(a)
b = decimal.Decimal(b)

result = a * b

print(int(result))

Buggy python submission (verdict: Runtime Error):
a, b = input().split()

result = a * int(100 * b) // 100

print(result)

Fixed submission:
import decimal

a, b = input().split()

a = int(a)
b = decimal.Decimal(b)

result = a * b

print(int(result))
Buggy python submission (verdict: Time Limit Exceeded):
def post_pd(t):
    for i in t:
        if i == '?':
            t = t[:t.index('?')] + 'D' + t[t.index('?')+1:]
    
    return t

if __name__ == '__main__':
    t = input()
    print(post_pd(t))

Fixed submission:
def post_pd(t):
    string_list = ''
    for i in t:
        if i == '?':
            string_list = string_list + 'D'
        else:
            string_list = string_list + i
    
    return string_list

if __name__ == '__main__':
    t = input()
    print(post_pd(t))
Buggy python submission (verdict: Runtime Error):
#A
s = input()

if s == ABC:
    print('ARC')
else:
    print('ABC')

Fixed submission:
#A
s = input()

if s == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy python submission (verdict: Runtime Error):
#A
s = input()

if s == ABC:
    print('ARC')
else:
    print('ABC')

Fixed submission:
#A
s = input()

if s == 'ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
#C
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))


result = [[1 for _ in range(n)] for _ in range(m)]
for i in range(m):
    a, b = list(map(int, input().split()))
    if h[a-1] < h[b-1]:
        result[i][b-1] = 1
        result[i][a-1] = 0
    elif h[a-1] > h[b-1]:
        result[i][b-1] = 0
        result[i][a-1] = 1
    else:
        result[i][b-1] = 0
        result[i][a-1] = 0

ans = [1 for _ in range(n)]
for i in range(m):
    for j in result:
        if 0 in j:
            ans[result.index(j)] = 0

print(ans.count(1))


Fixed submission:
#C
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))


result = [1 for _ in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    if h[a-1] < h[b-1]:
        result[a-1] = 0
    elif h[a-1] > h[b-1]:
        result[b-1] = 0
    else:
        result[b-1] = 0
        result[a-1] = 0

print(result.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [0 for _ in range(n)]

for i in range(n):
    s_input = input().split()
    if s_input not in s:
        s[i] = s_input

print(n - s.count(0))

Fixed submission:
#ABC164_C
n = int(input())

s = {input() for _ in range(n)}

print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())

result = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            result += math.gcd(i, math.gcd(j, k))
            
print(result)

Fixed submission:
import math
K = int(input())

ans = 0
ab = []
for b in range(1, K+1):
    for a in range(1, K+1):
        ab.append(math.gcd(a, b))
        
for c in range(1, K+1):
    for i in ab:
        ans += math.gcd(c, i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())

ans = 0
for c in range(1, K+1):
    for b in range(1, K+1):
        for a in range(1, K+1):
            ans += math.gcd(math.gcd(a, b), c)
print(ans)

Fixed submission:
import math
K = int(input())

ans = 0
ab = []
for b in range(1, K+1):
    for a in range(1, K+1):
        ab.append(math.gcd(a, b))
        
for c in range(1, K+1):
    for i in ab:
        ans += math.gcd(c, i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = []
for _ in range(N):
    A.append(int(input()))

for i in range(N):
    tmp = A[i]
    A[i] = 0
    print(max(A))
    A[i] = tmp

Fixed submission:
N = int(input())
A = [next(map(int, input().split())) for _ in range(N)]

AA = sorted(A, reverse=True)

for i in A:
    if i != AA[0]:
        print(AA[0])
    else:
        print(AA[1])
Buggy python submission (verdict: Time Limit Exceeded):
# ABC_129 C

def stairs(n, a):
    num_list = [i for i in range(n+1) if i not in a]
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in num_list:
        if i > 1:
            dp[i] = dp[i-1] + dp[i-2]

    result = dp[n] % 1000000007

    print(result)


n, m = list(map(int, input().split()))
a = [int(input()) for _ in range(m)]

if __name__ == '__main__':
    stairs(n, a)

Fixed submission:
# ABC_129 C

def stairs(n, a):
    num_list = set(i for i in range(n+1) if i not in a)
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in num_list:
        if i > 1:
            dp[i] = dp[i-1] + dp[i-2]
            
    result = dp[n] % 1000000007

    print(result)

    
n, m = list(map(int, input().split()))
a = set(int(input()) for _ in range(m))


if __name__ == '__main__':
    stairs(n, a)

Buggy python submission (verdict: Time Limit Exceeded):
# ABC_129 C

def stairs(n, a):
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, n+1):
        if i in a:
            continue
        dp[i] = dp[i-1]
        dp[i] += dp[i-2]

    result = dp[n] % 1000000007

    print(result)


n, m = list(map(int, input().split()))
a = [int(input()) for _ in range(m)]

if __name__ == '__main__':
    stairs(n, a)

Fixed submission:
# ABC_129 C

def stairs(n, a):
    num_list = set(i for i in range(n+1) if i not in a)
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in num_list:
        if i > 1:
            dp[i] = dp[i-1] + dp[i-2]
            
    result = dp[n] % 1000000007

    print(result)

    
n, m = list(map(int, input().split()))
a = set(int(input()) for _ in range(m))


if __name__ == '__main__':
    stairs(n, a)

Buggy python submission (verdict: Time Limit Exceeded):
# ABC_129 C

def stairs(n, a):
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, n+1):
        if i in a:
            continue
        else:
            dp[i] = dp[i-1]
            dp[i] += dp[i-2]

    result = dp[n] % 1000000007

    print(result)


n, m = list(map(int, input().split()))
a = [int(input()) for _ in range(m)]

if __name__ == '__main__':
    stairs(n, a)

Fixed submission:
# ABC_129 C

def stairs(n, a):
    num_list = set(i for i in range(n+1) if i not in a)
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in num_list:
        if i > 1:
            dp[i] = dp[i-1] + dp[i-2]
            
    result = dp[n] % 1000000007

    print(result)

    
n, m = list(map(int, input().split()))
a = set(int(input()) for _ in range(m))


if __name__ == '__main__':
    stairs(n, a)
Buggy python submission (verdict: Runtime Error):
S = input()

AGCT = 'AGCT'

count = []
tmp_num = 0
for i in S:
    if i in AGCT:
        tmp_num += 1
    else:
        count.append(tmp_num)
        tmp_num = 0

print(max(count))

Fixed submission:
S = input()

ACGT = 'ACGT'

count = []
tmp_num = 0
for i in S:
    if i in ACGT:
        tmp_num += 1
    elif i not in ACGT:
        count.append(tmp_num)
        tmp_num = 0
count.append(tmp_num)

print(max(count))

Buggy python submission (verdict: Runtime Error):
s = input()

str = []
ans = []

for i in range(len(s)):
    if s[i] in "ACGT":
        str.append(s[i])
    else:
        ans.append(len(str))
        str = []
print(max(ans))
print(ans)

Fixed submission:
S = input()

ACGT = 'ACGT'

count = []
tmp_num = 0
for i in S:
    if i in ACGT:
        tmp_num += 1
    elif i not in ACGT:
        count.append(tmp_num)
        tmp_num = 0
count.append(tmp_num)

print(max(count))

Buggy python submission (verdict: Runtime Error):
s = [i for i in input()]

str = []
ans = []

for i in s:
    if i in "ACGT":
        str.append(i)
    else:
        ans.append(len(str))
        str = []
print(max(ans))

Fixed submission:
S = input()

ACGT = 'ACGT'

count = []
tmp_num = 0
for i in S:
    if i in ACGT:
        tmp_num += 1
    elif i not in ACGT:
        count.append(tmp_num)
        tmp_num = 0
count.append(tmp_num)

print(max(count))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int, input().split())

if A == B:
    print(0)
else:
    for _ in range(K):
        tmp_A = B + C
        tmp_B = A + C
        C = A + B
        A = tmp_A
        B = tmp_B
        if A - B >= 10 ** 18:
            print(Unfair)
            break
    else:
        print(A-B)

Fixed submission:
A, B, C, K = map(int, input().split())

if K % 2 == 1:
    print(B-A)
elif K % 2 == 0:
    print(A-B)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))


a.sort()
b.sort()
c.sort()


bi = bisect.bisect_right

result = 0
for i in range(n):
    a_bi_in_b = bi(b, a[i])
    for j in range(a_bi_in_b, n):
        b_bi_in_c = bi(c, b[j])
        result += n - b_bi_in_c
        
        
print(result)

Fixed submission:
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))


a.sort()
b.sort()
c.sort()


result = 0
for i in range(n):
    b_bisect_in_a = bisect.bisect_left(a, b[i])
    b_bisect_in_c = bisect.bisect_right(c, b[i])
    result += b_bisect_in_a * (n - b_bisect_in_c)
        
        
print(result)

Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))


a.sort()
b.sort()
c.sort()


bi = bisect.bisect_right

result = 0
for i in range(n):
    a_bi_in_b = bi(b, a[i])
    b_bi_in_c = bi(c, b[a_bi_in_b])
    result += (n - a_bi_in_b) * (n - b_bi_in_c)
        
        
print(result)

Fixed submission:
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))


a.sort()
b.sort()
c.sort()


result = 0
for i in range(n):
    b_bisect_in_a = bisect.bisect_left(a, b[i])
    b_bisect_in_c = bisect.bisect_right(c, b[i])
    result += b_bisect_in_a * (n - b_bisect_in_c)
        
        
print(result)
Buggy python submission (verdict: Runtime Error):
N = input()
print((N + 1) // 2)

Fixed submission:
N = int(input())
print((N + 1) // 2)

Buggy python submission (verdict: Runtime Error):
print((input() + 1) // 2)


Fixed submission:
N = int(input())
print((N + 1) // 2)
Buggy python submission (verdict: Runtime Error):
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	weather := []string{"Sunny","Cloudy","Rainy","Sunny"}
	for i, wthr := range weather{
		if S == wthr {
			fmt.Println(weather[i+1])
			return
		}
	}
}


Fixed submission:
S = input()
weather = ['Sunny', 'Cloudy', 'Rainy']
if S == weather[0]:
    ans = weather[1]
elif S == weather[1]:
    ans = weather[2]
elif S == weather[2]:
    ans = weather[0]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int, input().split()))
v.sort()
u = [0]*(N-1)
for i in range(N):
    if i == 0:
        u[0] = (v[0] + v[1]) / 2
    else:
        u[i] = (u[i-1]+v[i+1])/2
print(u[-1])

Fixed submission:
N = int(input())
v = list(map(int, input().split()))
v.sort()
u = [0]*N
for i in range(N):
    if i == 0:
        u[0] = (v[0] + v[1]) / 2
    elif i == N-1:
        u[i] = (u[i-1]+v[i])/2
    else:
        u[i] = (u[i-1]+v[i+1])/2
print(u[-2])
Buggy python submission (verdict: Runtime Error):
t = input()

if t >= 30:
  print("Yes")
else:
  print("No")

Fixed submission:
t = int(input())

if t >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
An = list(map(int, input().split()))
sum = 1
for i in range(N):
  sum *= An[i]
  if sum > 1e18:
    print(-1)
    quit()
  else sum == 0:
    print(0)
    quit()
print(sum)

Fixed submission:
N = int(input())
An = list(map(int, input().split()))
sum = 1
max = 10 ** 18
if 0 in An:
  print(0)
  quit()
for i in range(N):
  sum *= An[i]
  if sum > max:
    print(-1)
    quit()
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
An = list(map(int, input().split()))
sum = 1
for i in range(len(An)):
  sum *= An[i]
if sum > 1e18:
  print(-1)
else:
  print(sum)

Fixed submission:
N = int(input())
An = list(map(int, input().split()))
sum = 1
max = 10 ** 18
if 0 in An:
  print(0)
  quit()
for i in range(N):
  sum *= An[i]
  if sum > max:
    print(-1)
    quit()
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sum = 0
for i in range(N):
  diff = i + A[i]
  for j in range(i+1, N):
    if (j - A[j]) == diff:
      sum += 1
print(sum)

Fixed submission:
from collections import defaultdict
 
N = int(input())	# 使わない
 
# j - i = A[i] + A[j] から、
# i + A[i] = j - A[j] となり、iとjが独立するため、同時並行で処理
L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)
for i, val in enumerate(map(int, input().split())):
  L[i - val] += 1	# i - val <= j - A[j]
  R[i + val] += 1	# i + val <= i + A[i]
  
cnt = 0
for key, val in L.items():
  if key > 0:
    cnt += L[key] * R[key]
    
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sum = 0
for i in range(N):
  i_diff = 0
  A1 = A[i]
  for j in range(i+1, N):
    i_diff += 1
    if (A[j] + A1) == i_diff:
      sum += 1
print(sum)

Fixed submission:
from collections import defaultdict
 
N = int(input())	# 使わない
 
# j - i = A[i] + A[j] から、
# i + A[i] = j - A[j] となり、iとjが独立するため、同時並行で処理
L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)
for i, val in enumerate(map(int, input().split())):
  L[i - val] += 1	# i - val <= j - A[j]
  R[i + val] += 1	# i + val <= i + A[i]
  
cnt = 0
for key, val in L.items():
  if key > 0:
    cnt += L[key] * R[key]
    
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sum = 0
for i in range(N):
  for j in range(i+1, N):
    if (A[i] + A[j]) == (j - i):
      sum += 1
print(sum)

Fixed submission:
from collections import defaultdict
 
N = int(input())	# 使わない
 
# j - i = A[i] + A[j] から、
# i + A[i] = j - A[j] となり、iとjが独立するため、同時並行で処理
L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)
for i, val in enumerate(map(int, input().split())):
  L[i - val] += 1	# i - val <= j - A[j]
  R[i + val] += 1	# i + val <= i + A[i]
  
cnt = 0
for key, val in L.items():
  if key > 0:
    cnt += L[key] * R[key]
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
divider = 2019
min = divider
if (R - L >= 2018):
  min = 0
else:
  L = L % divider
  R = R % divider
if (L > R):
  min = 0
else:
  for i in range(L, R):
    # modulo = (i * i) % divider
    for j in range(i + 1, R + 1):
      # modulo = (modulo + i) % divider
      modulo = i * j % divider
      if (modulo < min):
        min = modulo
print(min)

Fixed submission:
lr = input().split()
l = int(lr[0])
r = int(lr[1])
 
mini = 2018
 
for i in range(l, r+1):
  for j in range(i+1, r+1):
    mini = min(mini, (i*j)%2019)
 
    if mini==0:
      break
  if mini==0:
    break
print(mini)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
min = 2019
if (R - L >= 2018):
  min = 0
else:
  L = L % 2019
  R = R % 2019
if (L > R):
  min = 0
else:
  for i in range(L, R):
    modulo = (i * i) % 2019
    for j in range(i + 1, R + 1):
      modulo = (modulo + i) % 2019
      if (modulo < min):
        min = modulo
print(min)

Fixed submission:
lr = input().split()
l = int(lr[0])
r = int(lr[1])
 
mini = 2018
 
for i in range(l, r+1):
  for j in range(i+1, r+1):
    mini = min(mini, (i*j)%2019)
 
    if mini==0:
      break
  if mini==0:
    break
print(mini)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
min = 2019
modulo = 2019
for i in range(L, R + 1):
  for j in range(i + 1, R + 1):
    if (i == 2019 or j == 2019):
      min = 0
      break
    else:
      modulo = (i * j) % 2019
      if (modulo < min ):
        min = modulo
print(min)

Fixed submission:
lr = input().split()
l = int(lr[0])
r = int(lr[1])
 
mini = 2018
 
for i in range(l, r+1):
  for j in range(i+1, r+1):
    mini = min(mini, (i*j)%2019)
 
    if mini==0:
      break
  if mini==0:
    break
print(mini)
Buggy python submission (verdict: Runtime Error):
alpha = str(input())
if str.isupper(alpha) = True:
  print("A")
else:
  print("a")

Fixed submission:
alpha = input()
if alpha.isupper():
  print("A")
else:
  print("a")
Buggy python submission (verdict: Runtime Error):
x=input()
if(x>=30):
  print("Yes")
else:
  print("No")

Fixed submission:
x=int(input())
if(x>=30):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math

n=input()

print(math.ceil(n/2))

Fixed submission:
import math

n=int(input())

print(math.ceil(n/2))

Buggy python submission (verdict: Runtime Error):
import math

n=input()

print(math.ceil(n))

Fixed submission:
import math

n=int(input())

print(math.ceil(n/2))
Buggy python submission (verdict: Runtime Error):
r=input()
print(r*r)

Fixed submission:
r=int(input())
print(r*r)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))


longest = max(x)
x.remove(longest)

if longest < sum(x):
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
 
longest = max(x)
x.remove(longest)
 
if longest < sum(x):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
prices = list(map(int, input().split()))


INF = 10000000000

memo = {}

def minPrice(n, k):
    if (n, k) in memo:
        return memo[(n, k)]
    if n < k:
        return INF
    if k == 0:
        return 0
    if k == 1:
        return min(prices)
    take = prices[n-1] + minPrice(n-1, k-1)
    skip = minPrice(n-1, k)
    ans = min(INF, take, skip)
    memo[(n, k)] = ans
    return ans

print(minPrice(N, K))

Fixed submission:
import sys
sys.setrecursionlimit(100000000)

N, K = map(int, input().split())
prices = list(map(int, input().split()))
INF = 10000000000

memo = {}

def minPrice(n, k):
    if (n, k) in memo:
        return memo[(n, k)]
    if n < k:
        return INF
    if k == 0:
        return 0
    take = prices[n-1] + minPrice(n-1, k-1)
    skip = minPrice(n-1, k)
    ans = min(INF, take, skip)
    memo[(n, k)] = ans
    return ans

print(minPrice(N, K))
Buggy python submission (verdict: Time Limit Exceeded):
L = 1000000000000000000
r = 1
n = input()
for a in map(int, input().split()):
    r *= a
if r > L: print(-1)
else: print(r)

Fixed submission:
L = 1000000000000000000
r = 1
n = input()
A = list(map(int, input().split()))
A = sorted(A)
if A[0] == 0:
    print(0)
else:
    p = True
    while len(A) > 0:
        b = A.pop()
        r *= b
        if r > L:
            print(-1)
            p = False
            break
    if p: print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = map(int, input().split())

ans = 1
for tmp in a:
    ans *= tmp

if (ans > 1e18) :
    print(-1)
else:
    print(ans)


Fixed submission:
def main():
    n = int(input())

    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
        return

    ans = 1
    for tmp in a:
        ans *= tmp
        if (ans > 1e18) :
            print(-1)
            return

    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
def aaaa():
    n=int(input())
    a=list(map(int, input().split()))
    ans=0
    if a[0]>0:
        return -1
    nezen=1
    hazen=0
    line=[]
    liha=[]
    line.append(nezen)
    liha.append(hazen)
    su=0
    su=sum(a[x] for x in range(len(a)))
    for x in range(1,n+1):
        if nezen<=0:
            return -1
        ha=a[x]
        su-=ha
        ne=min(nezen*2-ha,su)
        nezen=ne
        line.append(ne)
        liha.append(ha)
    line[n]=0
    for x in range(len(line)):
        ans+=line[x]+liha[x]
    return ans
print(aaaa())

Fixed submission:
h1,m1,h2,m2,k=map(int, input().split())
oki=h1*60+m1
ne=h2*60+m2
print(ne-oki-k)