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

Fixed submission:
listNAB = input().split()
listNABint = [int(s) for s in listNAB]

def Placesum(x):
    y = str(x)
    counter = 0
    for i in range(len(y)):
        counter += int(y[i])
    return counter

sumcounter = 0
for i in range(listNABint[0]):
    if listNABint[1] <= Placesum(i+1) & Placesum(i+1) <= listNABint[2]:
        sumcounter += i+1
print(sumcounter)

Buggy submission (verdict: Runtime Error):
listNAB = input().split()
listNABint = [int(s) for s in A]

def Placesum(x):
    y = str(x)
    counter = 0
    for i in range(len(y)):
        counter += int(y[i])
    return counter

sumcounter = 0
for i in range(N):
    if A <= Placesum(i+1) & Placesum(i+1) <= B:
        sumcounter += i+1
        print(sumcounter)
print(sumcounter)
Problem p03479 (python)

Fixed submission:
X,Y = list(map(int,input().split()))

cnt = 0
while X <= Y:
    X = X * 2
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))
S = input()

for i in range(A):
    if S[i] == "-":
        print("No")
        exit()

if S[A] != "-":
    print("No")
    exit()

for i in range(A+1,A+1+B):
    if S[i] == "-":
        print("No")
        exit()

print("Yes")
Problem p03487 (python)

Fixed submission:
N = int(input())
a = input().split()
a_n = [int(s) for s in a]

dict = {}
for i in range(N):
    if a_n[i] in dict:
        dict[a_n[i]] += 1
    else:
        dict[a_n[i]] = 1

cnt = 0
for i in dict:
    if dict[i] > i:
        cnt += dict[i] - i
    elif dict[i] < i:
        cnt += dict[i]
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = input().split()
a_n = [int(s) for s in a]

max = max(a_n)
a_n_num = [0]*(max+1)
for i in range(len(a_n)):
    a_n_num[a_n[i]] += 1

counter = 0
for i in range(len(a_n_num)):
    if a_n_num[i] > i:
        counter += a_n_num[i] - i
    elif a_n_num[i] < i:
        counter += a_n_num[i]

print(counter)
Problem p03493 (python)

Fixed submission:
a = input()

counter = 0
for i in range(3):
    if int(a[-1-i]) ==  1:
        counter += 1
print(counter)

Buggy submission (verdict: Runtime Error):
a = int(input())

x = str(a)
counter = 0
for i in range(3):
    if int(x[-1-i]) ==  1:
        counter += 1
print(counter)
Problem p03069 (python)

Fixed submission:
n = int(input())
s = list(input())

w_sum = [0]
b_sum = [0]
for i in range(len(s)):
    if s[i] == '.':
        w_sum.append(w_sum[-1] + 1) 
        b_sum.append(b_sum[-1])
    else:
        b_sum.append(b_sum[-1] + 1)
        w_sum.append(w_sum[-1])

assert len(w_sum) == len(b_sum)
assert len(w_sum) == len(s) + 1

minSum = 10 ** 5
for i in range(len(s)):
    minSum = min(minSum, b_sum[i] + (w_sum[-1] - w_sum[i+1]))
    
print(minSum)

# .##...####... ->
# ......#######

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())

cnt = 0
for i in range(len(s)-2):
    if s[i] == '#' and s[i+1] == '.':
        if s[i+2] == '.':
            s[i] = '.'
        else:
            s[i+1] = "#"

        cnt += 1

if s[-2] == "#" and  s[-1] == ".":
    s[-1] = "#"
    cnt += 1

print(cnt)
Problem p03294 (python)

Fixed submission:
import functools

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b / gcd(a, b)

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

lcmVal = int(functools.reduce(lcm, a, 0))
print(sum(map(lambda x: (lcmVal-1) % x, a)))

Buggy submission (verdict: Runtime Error):
import functools

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b / gcd(a, b)

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

lcmVal = int(functools.reduce(lcm, a))
print(sum(map(lambda x: (lcmVal-1) % x, a)))

Buggy submission (verdict: Runtime Error):
import functools

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b / gcd(a, b)

N = int(input())
a = list(map(int, input().split()))
assert(len(a) == N)

lcmVal = int(functools.reduce(lcm, a))
print(sum(map(lambda x: (lcmVal-1) % x, a)))

Buggy submission (verdict: Runtime Error):
import functools

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b / gcd(a, b)

N = int(input())
a = list(map(int, input().split()))
assert(len(a) == N)

lcmVal = int(functools.reduce(lcm, a))
print(lcmVal)
print(sum(map(lambda x: (lcmVal-1) % x, a)))
Problem p04016 (python)

Fixed submission:
def digit_sum(n, s):
    if s > n:
        return -1
    if s == n:
        return n + 1

    b = 2
    while b**2 < n:
        if f(b, n) == s:
            return b

        b += 1

    p = int(n ** 0.5)
    while p >= 1:
        b = (n - s) // p + 1
        if b > 1 and f(b, n) == s:
            return b
        
        p -= 1

    return -1


def f(b, n):
    if n < b:
        return n

    return f(b, n // b) + (n % b)

def solve():
    n = int(input())
    s = int(input())
    result = digit_sum(n, s)
    print(result)

solve()

Buggy submission (verdict: Runtime Error):
def digit_sum(n, s):
    if s > n:
        return -1
    if s == n:
        return n + 1

    b = 2
    while b**2 < n:
        if f(b, n) == s:
            return b

        b += 1

    p = 1
    while p**2 < n:
        b = (n - s) // p + 1
        if f(b, n) == s:
            return b
        
        p += 1

    return -1


def f(b, n):
    if n < b:
        return n

    return f(b, n // b) + (n % b)

def solve():
    n = int(input())
    s = int(input())
    result = digit_sum(n, s)
    print(result)

solve()
Problem p03109 (python)

Fixed submission:
a=input().split('/')
if int(a[1])<=4:
  print("Heisei")
else:
  print("TBD")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=0
for i in range(a):
  c=input().split()
  if c[1]=='BTC':
    b+=(float)c[0]*380000.0
  else:
    b+=(float)c[0]
print(b)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=0
for i in range(a):
  c=input().split()
  if c[1]=='BTC':
    b+=(float)c[0]*380000.0
  else:
    b+=(int)c[0]
print(b)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=0
for i in range(a):
  c=input().split()
  if c[1]='BTC':
    b+=(float)c[0]*380000.0
  else:
    b+=(int)c[0]
print(b)

Buggy submission (verdict: Runtime Error):
a=input().split('/')
if int(a[1]<=4):
  print("Heisei")
else:
  print("TBD")
Problem p03059 (python)

Fixed submission:
a,b,t = map(int, input().split())
c = 0
tt = 0

while t + 0.5 > tt + a:
	c+= b
	tt += a	

	
print(c)

Buggy submission (verdict: Runtime Error):
import math
import functools
import fractions

n = int(input())
v = list(map(int, input().split()))

if max(v) % 2 ==0:
	b = True
else:
	b = False
		
v.sort()

for index,_ in enumerate(v):
	if _  % 2 ==0:
		if not b:
			v[index] = v[-1]
			break
			
	else:
		if b:
			v[index] = v[-1]
			break
				
#ans = functools.reduce(math.gcd,v)
#ans = v[0]
for i in range(1,len(v)):
	ans = fractions.gcd(ans, v[i])
	
print(ans)

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

n = int(input())
v = list(map(int, input().split()))

if max(v) % 2 ==0:
	b = True
else:
	b = False
		
v.sort()

for index,_ in enumerate(v):
	if _  % 2 ==0:
		if not b:
			v[index] = v[-1]
			break
			
	else:
		if b:
			v[index] = v[-1]
			break
			
ans = functools.reduce(math.gcd,v)
print(ans)
Problem p03060 (python)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))


a=0
b=0

for _ in range(n):
	if v[_] > c[_]:
		a += v[_]
		b += c[_]
		
print(a-b)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = [int(input()) for _ in range(n)]
c = [int(input()) for _ in range(n)]

a=0
b=0

for _ in range(n):
	if v[_] > c[_]:
		a += v[_]
		b += c[_]
		
print(a-b)
Problem p04043 (python)

Fixed submission:
a,b,c = map(int, input().split())
l = [a,b,c]



count = 0
for i in l:
	if i == 5:
		count += 1
		
		if count == 2:
			break

if any([i == 7 for i in l]) and count == 2:
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
import sys

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

if 7 in [a,b,c]:
  if filter(lambda x:x ==5,[a,b,c]) is 2:
  	print("YES")
    sys.exit()

print("NO")
Problem p03037 (python)

Fixed submission:
N,M = list(map(int,input().split()))
L = 1
R = N+1
ans = N*2

for i in range(M):
    tL,tR = list(map(int,input().split()))
    if tR < L or R < tL:
        ans = 0
        break
    if tL > L:
        L = tL
    if tR < R:
        R = tR

print(min(ans,R-L+1))

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
ans = [0 for i in range(N)]
anss = 0

for i in range(M):
    L,R = list(map(int,input().split()))
    if L == R:
        ans[L-1]+=1
    else:
        for j in range(L-1,R,1):
            ans[j]+=1

maxn = 0
for i in range(M):
    if ans[i] > maxn:
        maxn = ans[i]
        
for i in range(M):
    if ans[i] == maxn:
        anss += 1
print(anss)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
ans = [0 for i in range(N)]
anss = 0

for i in range(M):
    L,R = list(map(int,input().split()))
    if L == R:
      ans[L-1]+=1
    else:
      for j in range(L-1,R,1):
        ans[j]+=1

maxn = 0
for i in range(M):
    if ans[i] > maxn:
        maxn = ans[i]
        
for i in range(M):
    if ans[i] == maxn:
        anss += 1
print(anss)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
ans = [0 for i in range(N)]

for i in range(M):
    L,R = list(map(int,input().split()))
    for j in range(L-1,R,1):
        ans[j]+=1

maxn = 0
for i in range(M):
    if ans[i] > maxn:
        maxn = ans[i]
        
print(maxn)
Problem p03047 (python)

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

print(N-K+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [str(input()) for i in range(N)]
ans = 0
a = 0
b = 0
ab = 0
for i in range(N):
    ans += s[i].count('AB')
    if s[i][0] == 'B' and not s[i][-1] == 'A':
        b += 1
    if s[i][-1] == 'A' and not s[i][0] == 'B':
        a += 1
    if s[i][0] == 'B' and s[i][-1] == 'A':
        ab += 1
ans += min(a,b)
ans += ab
print(ans)
Problem p03106 (python)

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

nums = []
cnt = 0

for i in range(1,min(A,B)+1,1):    
    if B % i == 0 and A % i == 0:
        nums.append(i)

print(nums[-K])

Buggy submission (verdict: Runtime Error):
A,B,K = list(map(int,input().split()))

nums = []

for i in range(1,min(A,B),1):
    if B % i == 0 and A % i == 0:
        nums.append(i)

if nums == []:
    print(1)
else:
    print(nums[K-1])
Problem p03126 (python)

Fixed submission:
N,M = list(map(int,input().split()))

ref = [i+1 for i in range(M)]
LIKE = [i+1 for i in range(M)]

for i in range(N):
    myLIKE = list(map(int,input().split()[1:]))
    for j in ref:
        try:
            if j not in myLIKE:
                LIKE.remove(j)
        except ValueError:
            pass
            
print(len(LIKE))

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))

ref = [i+1 for i in range(M)]
LIKE = [i+1 for i in range(M)]

for i in range(N):
    myLIKE = list(map(int,input().split()[1:]))
    for j in ref:
        if j not in myLIKE:
            LIKE.remove(j)
print(len(LIKE))
Problem p03071 (python)

Fixed submission:
arr = (input()).split()

for i,temp in enumerate(arr):
  arr[i] = int(arr[i])
  
result = 0
for i in range(2):
  result += max(arr)
  index = arr.index(max(arr))
  arr[index] = arr[index] -1
  
print(result)

Buggy submission (verdict: Runtime Error):
arr = (input()).split()

for i,temp in enumerate(arr):
  arr[i] = int(arr[i])
  
result = 0
for i in range(2):
  result += max(arr)
  index = arr.index(mac(arr))
  arr[index] = arr[index] -1
  
print(result)
Problem p03076 (python)

Fixed submission:
import sys
input = sys.stdin.readline
num = []
iti = []

for temp in range(5):
    temp2 = input()
    temp3 = int(temp2)
    if temp3 >= 10 and temp2[-2] != "0":
        num.append((int(temp2[0:-2])+1)*10)
    elif temp2[-2] == "0":
        num.append(int(temp2[0:-2])*10)
    else:
        num.append(10)
    if int(temp2[-2]) != 0:
        iti.append(int(temp2[-2]))

if iti == []:
    last = 10
else:
    last = min(iti)
print(sum(num)-10+last)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
num = []
iti = []

for temp in range(5):
    temp2 = input()
    temp3 = int(temp2)
    if temp3 >= 10 and temp2[-2] != "0":
        num.append((int(temp2[0:-2])+1)*10)
    elif temp2[-2] == "0":
        num.append(int(temp2[0:-2])*10)
    else:
        num.append(10)
    if int(temp2[-2]) != 0:
        iti.append(int(temp2[-2]))

print(sum(num)-10+min(iti))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
num = []
iti = []

for temp in range(5):
    temp2 = input()
    temp3 = int(temp2)
    if temp3 > 10 and temp2[-2] != "0":
        num.append((int(temp2[0:-2])+1)*10)
    elif temp2[-2] == "0":
        num.append(int(temp2[0:-2])*10)
    else:
        num.append(10)
    if int(temp2[-2]) != 0:
        iti.append(int(temp2[-2]))

print(sum(num)-10+min(iti))
Problem p04043 (python)

Fixed submission:
a, b, c = map(int, input().split())
if(a==7):
    if(b==5 and c==5):
        print('YES')
    else:
        print('NO')
elif(b==7):
    if(a==5 and c==5):
        print('YES')
    else:
        print('NO')
elif(c==7):
    if(b==5 and a==5):
        print('YES')
    else:
        print('NO')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if(a==7):
    if(b==5 & c==5):
        print('YES')
    else:
        print('NO')
elif(b==7):
    if(a==5 & c==5):
        print('YES')
    else:
        print('NO')
elif(c==7):
    if(b==5 & a==5):
        print('YES')
    else:
        print('NO')
else
    print('NO')
Problem p03294 (python)

Fixed submission:
import statistics
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
nums = list(map(int, input().split()))
lcm = lcm_list(nums)

# print(nums, lcm)
sum =0
for num in nums:
    sum += (lcm-1)%num
print(sum)

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
nums = list(map(int, input().split()))
lcm = lcm_list(nums)

# print(nums, lcm)
sum =0
for num in nums:
    sum += (lcm-1)%num
print(sum)
Problem p03059 (python)

Fixed submission:
A , B , T = map(int , input().split())
 
count =  T // A * B
 
print(count)

Buggy submission (verdict: Runtime Error):
A , B , T = map(int , input()split())

count =  T // A * B

print(count)
Problem p03060 (python)

Fixed submission:
Number = int(input())
tresure_value = list(map(int , input().split()))
cost = list(map(int , input().split()))
cnt = 0
 
for i in range(len(tresure_value)):
  benefit = tresure_value[i] - cost[i]
  if benefit  > 0:
    cnt = cnt + benefit 
    
print(cnt)

Buggy submission (verdict: Runtime Error):
Number = int(input())
tresure_value = list(map(int , input().split()))
cost = list(map(int , input().split()))
cnt = 0
 
for i in range(len(tresure_value)):
  benefit = tresure_value[i] - cost[i]
  if benefit  > 0:
    count = count + benefit 
    
print(cnt)

Buggy submission (verdict: Runtime Error):
Number = int(input())
tresure_value = list(map(int , input().split()))
cost = list(map(int , input().split()))
 
count = 0
 
for i in range(Number):
  benefit = tresure_value(i) - cost(i)
  if benefit  > 0:
    count = count + benefit 
    
print(count)

Buggy submission (verdict: Runtime Error):
Number = input()
 
tresure_value = list(map(int , input().split()))
 
cost = list(map(int , input().split()))
 
count = 0
 
for i in range(Number):
  benefit = tresure_value(i) - cost(i)
  if benefit  > 0:
    count = count + benefit 
    
print(count)

Buggy submission (verdict: Runtime Error):
Number = input()
 
tresure_value = list(map(int , input().split()))
 
cost = list(map(int , input().split()))
 
count = 0
 
for i in range(Number):
  benefit = int(tresure_value[i]) - int(cost[i])
  if benefit  > 0:
    count += benefit 
    
print(count)

Buggy submission (verdict: Runtime Error):
Number = input()
 
tresure_value = list(map(int , input().split()))
 
cost = list(map(int , input().split()))
 
count = 0
 
for i in range(Number):
  benefit = int(tresure_value[i] - cost[i])
  if benefit  > 0:
    count += benefit 
    
print(count)

Buggy submission (verdict: Runtime Error):
Number = input()

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

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

count = 0

for i in range(Number):
  if tresure_value[i] - cost[i] > 0:
    count += tresure_value[i] - cost[i]
    
print(count)
Problem p03061 (python)

Fixed submission:
N = int(input())
a= list(map(int , input().split()))


def gcd(a, b):
    if a < b: return gcd(b, a)
    elif b > 0: return gcd(b, a % b)
    else:
        return a

L = [0,a[0]]
R = [0,a[-1]]

for i in range(1,N):
	L.append(gcd(a[i] , L[-1]))
	R.append(gcd(a[-(i+1)] , R[-1]))
gcd_val_list = []
for i in range(N):
	gcd_val_list.append(gcd(L[i] , R[-(i+2)]))
print(max(gcd_val_list))

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

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


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

if N<=2:
	print(max(a))
else:
	ans = gcd_list(a[1:])
	for i in range(1,N):
		temp_gcd = gcd_list(a[0:i]+a[i+1:])

		ans = max(ans , temp_gcd)

print(ans)
Problem p03102 (python)

Fixed submission:
import numpy as np
N,M,C = map(int,input().split())
B = np.array(list(map(int , input().split())))
A = [list(map(int , input().split())) for _ in range(N)]
ans = 0
for i in range(N):
	tem = np.array(A[i])
	if np.dot(tem,B)+C>0:
		ans +=1

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M,C = map(int,input().split())
B = np.array(list(map(int , input().split())))
A = [list(map(int , input().split())) for _ in range(N)]
ans = 0
for i in range(N):
	tem = np.array(A[i])
	if np.dot(tem,B)+C>0:
		ans +=1

print(ans)
Problem p03323 (python)

Fixed submission:
a,b = map(int,input().split())
if (a <= 8) and (b <= 8):
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
A,B = map(int , input().split())

if (A<=8) and (B<=8):
  print('Yay!')
else:
  pront(':(')
Problem p03024 (python)

Fixed submission:
s = input()
valid = 0
left = 15 - len(s)
for tok in s:
    if tok == 'o':
        valid += 1
if valid + left >= 8:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s = raw_input()
valid = 0
left = 15 - len(s)
for tok in s:
    if tok == 'o':
        valid += 1
if valid + left >= 8:
    print('YES')
else:
    print('NO')
Problem p03026 (python)

Fixed submission:
n = int(input())

edge = [[] for i in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

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

hhh = c.copy()

c.sort(reverse=True)

w = [0] * n

w[0] = c.pop(0)

chk = [i for i in edge[0]]
# print(chk)

while chk != []:
    node = chk.pop(0)
    if w[node] == 0:
        w[node] = c.pop(0)
        chk.extend(edge[node])

print(sum(hhh) - max(hhh))

print(' '.join(map(str, w)))

Buggy submission (verdict: Runtime Error):
n = int(input())

edge = [[] for i in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

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

c.sort(reverse=True)

w = [0] * n

w[0] = c.pop(0)

chk = [i for i in edge[0]]
# print(chk)

while chk != []:
    node = chk.pop(0)
    if w[node] == 0:
        w[node] = c.pop(0)
        chk.extend(edge[node])

print(sum(c) - max(c))

print(' '.join(map(str, w)))
Problem p03085 (python)

Fixed submission:
b=input()
if b =="A":
  print("T")
elif b =="T":
  print("A")
elif b =="G":
  print("C")
elif b =="C":
  print("G")

Buggy submission (verdict: Runtime Error):
b=input()
if b =="A"
  print("T")
elif b =="T"
  print("A")
elif b =="G"
  print("C")
elif b =="C"
  print("G")
Problem p03032 (python)

Fixed submission:
import itertools
import numpy as np
import copy

def main():
	N, K = map(int,input().split())

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

	allCandidates = []
	for i in range(K + 1):
		for one in range(0, K - i + 1):
			allCandidates.extend([[0] * one + [1] * (K - i - one) + [-1] * i])

	maxScore = 0
	for candidate in allCandidates:
		have = []
		vs = copy.deepcopy(Vs)
		exceptFlag = False
		for k in candidate:
			if k == 0:
				try:
					have.append(vs[0])
					del vs[0]
				except:
					exceptFlag = True
					break
			if k == 1:
				try:
					have.append(vs[-1])
					del vs[-1]
				except:
					exceptFlag = True
					break
			if k == -1:
				try:
					if have[np.argmin(have)] < 0:
						del have[np.argmin(have)]
				except:
					exceptFlag = True
					break
		if not exceptFlag:
			score = sum(have)
			if score > maxScore:
				maxScore = score

	print(maxScore)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

def main():
	N, K = map(int,input().split())

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

	allCandidates = []
	for i in range(int(K / 2) + 1):
		for one in range(0, K - i + 1):
			allCandidates.extend([[0] * one + [1] * (K - i - one) + [-1] * i])

	maxScore = 0
	for candidate in allCandidates:
		have = []
		zeroCount = 0
		oneCount = 0
		for k in candidate:
			if k == 0:
				try:
					have.append(Vs[0 + zeroCount])
					zeroCount += 1
				except:
					continue
			if k == 1:
				try:
					have.append(Vs[-1 - oneCount])
					oneCount += 1
				except:
					continue
			if k == -1:
				del have[np.argmin(have)]
		score = sum(have)

		if score > maxScore:
			maxScore = score
	print(maxScore)



if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

def main():
	N, K = map(int,input().split())

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

	allCandidates = []
	for i in range(int(K / 2) + 1):
		for one in range(0, K - i + 1):
			allCandidates.extend([[0] * one + [1] * (K - i - one) + [-1] * i])

	maxScore = 0
	for candidate in allCandidates:
		have = []
		zeroCount = 0
		oneCount = 0
		for k in candidate:
			if k == 0:
				have.append(Vs[0 + zeroCount])
				zeroCount += 1
			if k == 1:
				have.append(Vs[-1 - oneCount])
				oneCount += 1
			if k == -1:
				del have[np.argmin(have)]
		score = sum(have)

		if score > maxScore:
			maxScore = score
	print(maxScore)



if __name__ == '__main__':
	main()
Problem p03037 (python)

Fixed submission:
N, M = map(int,input().split())


def main():
	Ls = []
	Rs = []
	for i in range(M):
		inputs = list(map(int,input().split()))
		Ls.append(inputs[0])
		Rs.append(inputs[1])

	maxL = max(Ls)
	minR = min(Rs)

	if maxL > minR:
		print(0)
	else:
		print(minR - maxL + 1)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())

As = list(map(int,input().split())).sort()

Bs = []
Cs = []
for i in range(M):
	inputs = list(map(int,input().split()))
	Bs.append(inputs[0])
	Cs.append(inputs[1])

for j in range(1, M + 1):
	for n in range(Bs[j - 1]):
		if As[n] < Cs[j - 1]:
			As[n] = Cs[j - 1]
	As.sort()

print(sum(As))