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

Fixed submission:
s = input()
answer_1 = answer_2 = -1

for i in range(len(s) - 1):
  if s[i] == s[i+1]:
    answer_1 = i + 1
    answer_2 = i + 2
    break
  
  elif i != len(s) - 2 and s[i] == s[i+2]:
    answer_1 = i + 1
    answer_2 = i + 3
    break

print(str(answer_1) + " " + str(answer_2))

Buggy submission (verdict: Runtime Error):
s = input()
answer_1 = answer_2 = -1

for i in range(len(s) - 1):
  if s[i] == s[i+1]:
    answer_1 = i + 1
    answer_2 = i + 2
    break
  
  elif i+1 != len(s) and s[i] == s[i+2]:
    answer_1 = i + 1
    answer_2 = i + 3
    break

print(str(answer_1) + " " + str(answer_2))

Buggy submission (verdict: Runtime Error):
s = input()
answer_1 = answer_2 = -1

for i in range(len(s) - 1):
  if s[i] == s[i+1]:
    answer_1 = i + 1
    answer_2 = i + 2
    break
  
  elif i+1 != len(s) and s[i] == s[i+2]:
    answer_1 = i + 1
    answer_2 = i + 3
    break

print(str(answer_1) + " " + str(answer_2))

Buggy submission (verdict: Runtime Error):
s = input()
answer_1 = answer_2 = -1

for i in range(len(s)):
  if s[i] == s[i+1]:
    answer_1 = i + 1
    answer_2 = i + 2
    break
  
  elif s[i] == s[i+2]:
    answer_1 = i + 1
    answer_2 = i + 3
    break

print(str(answer_1) + " " + str(answer_2))
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 a == 5:
  if (b == 5 and c == 7) or (b == 7 and c == 5):
    print("YES")
  else:
    print("NO")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
#入力
n, k = map(int, input().split())
d = input().split()
stop = min(10000, n * 10)

for l in range(n, stop):
  a = str(n)
  flag = 0
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        n += 1
        break
    if (flag % k) != 0 and flag == 0:
      break
  if flag == len(a) * k:
    break
print(n)
Problem p02607 (python)

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

for i in range(0,N,2):
    if a[i] ==1:
        ans += 1
    elif a[i]%2 ==1:
        ans += 1
print(ans)

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

for i in range(0,N+1,2):
    if a[i] ==1:
        ans += 1
    elif a[i]%2 ==1:
        ans += 1
print(ans)

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

for i in range(0,N+1,2):
    if a[i]%2 ==1:
        ans += 1
print(ans)
Problem p02608 (python)

Fixed submission:
import math
N = int(input())
ans = [0]*N
l = int(math.sqrt(N))

for i in range(1,l):
    for j in range(1,l):
        for k in range(1,l):
            a = (i+j+k)**2-(i*j+j*k+k*i)
            if a <= N:
                ans[a-1] += 1

print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = [0]*N
l = int(math.sqrt(N-3))

for i in range(1,l):
    for j in range(1,l):
        for k in range(1,l):
            if (i+j+k)**2-(i*j+j*k+k*i) <= N:
                ans[(i+j+k)**2-(i*j+j*k+k*i)-1] += 1

s = '\n'.join([str(n) for n in ans])
print(s)

# print(ans, sep='\n')

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = [0]*N
l = int(math.sqrt(N-2))

for i in range(1,l):
    for j in range(1,l):
        for k in range(1,l):
            if (i+j+k)**2-(i*j+j*k+k*i) <= N:
                ans[(i+j+k)**2-(i*j+j*k+k*i)-1] += 1

s = '\n'.join([str(n) for n in ans])
print(s)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input(). split ()))
 
a = 1
for i in l:
	a *= i
	if a > 1e18:
		a = -1
		break
print(a)

Buggy submission (verdict: Runtime Error):
l = map(int, input())
 
a = 1
for i in l:
	a *= i
	if a > 1e18:
		a = -1
		break
print(a)

Buggy submission (verdict: Runtime Error):
n, *l = map(int, open(0).read().split())

a = 1
for i in l:
	a *= i
	if a > 1e18:
		a =-1
		break
ptint(a)
Problem p02658 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()
a = 1
for i in l:
	a *= i
	if a > 10**18:
		a = -1
		break
print(a)

Buggy submission (verdict: Runtime Error):
n, *l = map(int, open(0).read.split())

a = 1
for i in l:
	a *= i
	if a > 1e18:
		a =-1
		break
print(a)
Problem p02675 (python)

Fixed submission:
n = str(input())
num = int(n[-1])

if num in [2, 4, 5, 7, 9]:
    print("hon")
elif num in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")

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

if num[print(len(n))] == [2, 4, 5, 7, 9]:
	print("hon")
elif num[print(len(n))] == [0, 1, 6, 8]:
	print("pon")
else:
	print("bon")
Problem p03290 (python)

Fixed submission:
D, G = map(int, input().split())
PC = [0]+[list(map(int,input().split())) for _ in range(D)]

def dfs(d, g):
    if(d == 0):
        return 1e9

    c = min(g//(100*d), PC[d][0])
    s = 100*d*c
    if c == PC[d][0]:
        s += PC[d][1]
    if s<g:
        c += dfs(d-1, g-s)
    return min(c, dfs(d-1,g))

print(dfs(D, G))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
PC = [0]+[list(map(int,input().split())) for _ in range(D)]

def dfs(d, g):
    if(d == 0):
        return 1e9

    c = min(g//(100*d), PC[d][0])
    s = 100*d*c
    if c == PC[d][0]:
        s += PC[d][1]
    if s<g:
        c += f(d-1, g-s)
    return min(c, f(d-1,g))

print(dfs(D, G))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
PC = [0]+[list(map(int,input().split())) for _ in range(D)]

def dfs(d, g):
    # if(d == 0):
    #     return 1e9

    c = min(g//(100*d), PC[d][0])
    s = 100*d*c
    if c == PC[d][0]:
        s += PC[d][1]
    if s<g:
        c += f(d-1, g-s)
    return min(c, f(d-1,g))

print(dfs(D, G))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
PC = [0]+[list(map(int,input().split())) for _ in range(D)]
print(1e9)

def dfs(d, g):
    if(d == 0):
        return 1e9

    c = min(g//(100*d), PC[d][0])
    s = 100*d*c
    if c == PC[d][0]:
        s += PC[d][1]
    if s<g:
        c += f(d-1, g-s)
    return min(c, f(d-1,g))

print(dfs(D, G))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
PC = [0]+[list(map(int,input().split())) for _ in range(D)]
print(1e9)

def dfs(d, g):
    # if(d == 0):
    #     return 1e9

    c = min(g//(100*d), PC[d][0])
    s = 100*d*c
    if c == PC[d][0]:
        s += PC[d][1]
    if s<g:
        c += f(d-1, g-s)
    return min(c, f(d-1,g))

print(dfs(D, G))
Problem p03308 (python)

Fixed submission:
N =int(input())
A =list(map(int, input().split()))
print(max(A)-min(A))

Buggy submission (verdict: Runtime Error):
N =int(input())        
A =list(map(int, input(
                       
print(max(A)-min(A))
Problem p03339 (python)

Fixed submission:
N = int(input())
S =list(input())
ans = N
W = 0
E = S.count('E')

for i in range(N):
    if S[i] =='E':
        E -= 1
    ans = min(ans, W+E)
    if S[i] == 'W':
        W += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S =list(input())
count = N

for i in xrange(N):
    count = min(S[0:i].count('W') + S[i+1:N].count('E'), count)
print(count)
Problem p03433 (python)

Fixed submission:
n = int(input())
a = int(input())
if  n% 500 <= a:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
if ( N - A )% 500 == 0:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
if ( N - A ) % 500 == 0:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
if ( N - A ) % 5 == 0:
	print("Yes")
else:
	print("No")
Problem p03485 (python)

Fixed submission:
a, b = map(int, input().split())
import math
print(math.ceil((a + b)/2))

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

if sorted(s) < list(reversed(t)):
    print('Yes')
else:
    print('No')
Problem p03493 (python)

Fixed submission:
s = input()
print(s.count('1'))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
element = [a, b, c]
marble = 0
for x in element:
	if x == 1:
		marble +=1
element = [a, b, c]
marble = 0
for x in element:
	if x == 1:
		marble +=1
Problem p03611 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
l = [0]*(10**5+2)

for i in a:
    l[i] +=1
    l[i+1] +=1
    l[i+2] +=1

print(max(l))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
l = [0]*10**5+2

for i in a:
    l[i] +=1
    l[i+1] +=1
    l[i+2] +=1

print(max(l))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())
l = [0]*10**5+2
ans = 0
num = 0

for i in a:
    l[i] +=1
    l[i+1] +=1
    l[i+2] +=1


print(max(l))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())
l = [0]*10**5
ans = 0
num = 0

for i in a:
    l[i] +=1
    l[i+1] +=1
    l[i+2] +=1

print(max(l))
Problem p02621 (python)

Fixed submission:
a=int(input())
print(a+(a**2)+(a**3))

Buggy submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
Ai=list(map(int,input().split()))
Bi=list(map(int,input().split()))
list=[]
for i in range(N+M):
    if A[i]>B[i]:
        list.append(B[i])
    else:
        list.append(A[i])
        if sum(list)>=K:
            break
print(len(list))
Problem p02748 (python)

Fixed submission:
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[input().split() for l in range(M)]
tot_1=min(a)+min(b)
lis=[]
for i in range(M):
    tot=a[int(x[i][0])-1]+b[int(x[i][1])-1]-int(x[i][2])
    lis.append(tot)
if tot_1<=min(lis):
    print(tot_1)
else:
    print(min(lis))

Buggy submission (verdict: Runtime Error):
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[input().split() for l in range(M)]
tot_1=min(a)+min(b)
lis=[]
for i in range(M):
    tot=a[int(x[i][0])]+b[int(x[i][1])]-int(x[i][2])
    lis.append(tot)
if tot_1<=min(lis):
    print(tot_1)
else:
    print(min(lis))
Problem p02760 (python)

Fixed submission:
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'
if Aij[0].count('0')==3 or Aij[1].count('0')==3 or Aij[2].count('0')==3:
    print('Yes')
elif Aij[0][0]=='0' and Aij[1][0]=='0' and Aij[2][0]=='0':
    print('Yes')
elif Aij[0][1]=='0' and Aij[1][1]=='0' and Aij[2][1]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][2]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'
if (A[0][0] == A[0][1] == A[0][2] == 0) or (A[1][0] == A[1][1] == A[1][2] == 0) or (A[2][0] == A[2][1] == A[2][2] == 0):
    print('Yes')
elif Aij[0][0]=='0' and Aij[0][1]=='0' and Aij[0][2]=='0':
    print('Yes')
elif Aij[1][0]=='0' and Aij[1][1]=='0' and Aij[1][2]=='0':
    print('Yes')
elif Aij[2][0]=='0' and Aij[2][1]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'
if (A[0][0] == A[0][1] == A[0][2] == 0) or (A[1][0] == A[1][1] == A[1][2] == 0) or (A[2][0] == A[2][1] == A[2][2] == 0):
elif Aij[0][0]=='0' and Aij[0][1]=='0' and Aij[0][2]=='0':
    print('Yes')
elif Aij[1][0]=='0' and Aij[1][1]=='0' and Aij[1][2]=='0':
    print('Yes')
elif Aij[2][0]=='0' and Aij[2][1]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')
Problem p03086 (python)

Fixed submission:
S=input()
cnt=0
lis=[0]
for i in range(len(S)):
    if S[i]=='A'or S[i]=='C' or S[i]=='G' or S[i]=='T':
        cnt+=1
        lis.append(cnt)
    else:
        cnt=0
print(max(lis))

Buggy submission (verdict: Runtime Error):
S=input()
cnt=0
lis=[]
for i in range(len(S)):
    if S[i]=='A'or S[i]=='C' or S[i]=='G' or S[i]=='T':
        cnt+=1
        lis.append(cnt)
    else:
        cnt=0
print(max(lis))
Problem p03102 (python)

Fixed submission:
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
Ai= [input().split() for l in range(N)]
count=0
for i in range(N):
    tot=0
    for j in range(M):
        tot+=int(Ai[i][j])*B[j]
    if tot+C>0:
        count+=1  
print(count)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
Ai= [input().split() for l in range(N)]
count=0
tot=0
for i in range(N):
    for j in range(M):
        tot+=Ai[i][j]*B[i]
        if tot+C>0:
            count+=1
print(count)
Problem p03448 (python)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())
counter=0

for a in range(A+1):
    a_total=a*500
    for b in range(B+1):
        b_total=b*100
        for c in range(C+1):
            c_total=c*50
            total_amount=(a_total+b_total+c_total)
            if X==total_amount:
                counter=counter+1
print(counter)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
counter=0

for a in range(A+1):
    a_total=a*500
    for b in range(B+1):
        b_total=b*100
        for c in range(C+1):
            c_total=c*50
            total_amount=(a_total+b_total+c_total)
            if X==total_amount:
                count=counter+1
print(count)
Problem p03456 (python)

Fixed submission:
a,b=map(str,input().split())
c=a+b
c=(int(c)**(1/2))
if (c.is_integer())==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b=map(input().split())
c=a+b
c=int(c)**0.5
if isinstance(c, int)==True:
    print('Yes')
else:
    print('No')
Problem p02677 (python)

Fixed submission:
import math


hour_hand_speed = (2 * math.pi) / (12 * 60)
minute_hand_speed = (2 * math.pi) / 60

hour_hand, minute_hand, hour, minute = list(
    map(int, input().split())
)

elapsed_time = 60 * hour + minute

hour_hand_angle = elapsed_time * hour_hand_speed
minute_hand_angle = minute * minute_hand_speed

angle_btw_hour_minute = abs(hour_hand_angle - minute_hand_angle)

distance = math.sqrt(
    hour_hand**2 + minute_hand**2 - (2 * hour_hand * minute_hand * math.cos(angle_btw_hour_minute))
)

print(distance)

Buggy submission (verdict: Runtime Error):
import math


hour_hand_speed = (2 * math.pi) / (12 * 60)
minute_hand_speed = (2 * math.pi) / 60

hour_hand, minute_hand, hour, minute = list(
    map(int, input().split())
)

elapsed_time = 60 * hour + minute

hour_hand_angle = elapsed_time * hour_hand_speed
minute_hand_angle = minute * minute_hand_speed

angle_btw_hour_minute = abs(hour_hand_angle - minute_hand_angle)

distance = math.sqrt(
    hour_hand**2 + minute_hand**2 - (2 * hour_hand * minute_hand * math.cos(angle_btw_hour_minute))
)

print(distance)import math


hour_hand_speed = (2 * math.pi) / (12 * 60)
minute_hand_speed = (2 * math.pi) / 60

hour_hand, minute_hand, hour, minute = list(
    map(int, input().split())
)

elapsed_time = 60 * hour + minute

hour_hand_angle = elapsed_time * hour_hand_speed
minute_hand_angle = minute * minute_hand_speed

angle_btw_hour_minute = abs(hour_hand_angle - minute_hand_angle)

distance = math.sqrt(
    hour_hand**2 + minute_hand**2 - (2 * hour_hand * minute_hand * math.cos(angle_btw_hour_minute))
)

print(distance)
Problem p03281 (python)

Fixed submission:
number = int(input())

num_eight_divisors = 0

numbers = list(range(9, number + 1, 2))

for i in range(9, number + 1, 2):
    divisors = [1, i]

    for j in range(2, i):
        q, mod = divmod(i, j)

        if mod == 0:
            divisors.append(j)
            divisors.append(q)

    if len(set(divisors)) == 8:
        num_eight_divisors = num_eight_divisors + 1

print(num_eight_divisors)

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

num_eight_divisors = 0

numbers = list(range(9, number + 1, 2))

for i in range(9, number + 1, 2):
    divisors = [1, i]

    for j in range(2, i):
        q, mod = divmod(i, j)

        if mod == 0:
            divisors.append(j, q)

    if len(set(divisors)):
        num_eight_divisors = num_eight_divisors + 1

print(num_eight_divisors)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
tel = [int(e)-1 for e in input().split()]

pl = [0]
for i in range(2*n+1000):
    nxt = tel[pl[-1]]
    pl.append(nxt)

if k < n + 1:
    print(pl[k]+1)
    exit()

loop_end = n
loop_start = n-1
while pl[loop_start] != pl[loop_end]:
    loop_start -= 1

#pl[loop_start] == pl[loop_end]
period = loop_end - loop_start

k %= period

while k < n:
    k += period

print(pl[k]+1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
tel = [int(e)-1 for e in input().split()]

now = 0
cnt = 0
pl = [0]

while k > 0:
    now = tel[now]
    k -= 1
    if now in pl:
        break
    else:
        pl.append(now)
    
loop = now
cnt = 0
while k > 0:
    now = tel[now]
    cnt += 1
    k -= 1
    if now == loop:
        break

k %= cnt
for i in range(k):
    now = tel[now]

print(now+1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
tel = [int(e) for e in input().split()]

now = 0
cnt = 0
pl = [0]

while k > 0:
    now = tel[now]-1
    k -= 1
    if now in pl:
        break
    else:
        pl.append(now)
    
loop = now
cnt = 0
while k > 0:
    now = tel[now]-1
    cnt += 1
    k -= 1
    if now == loop:
        break

k %= cnt
for i in range(k):
    now = tel[now]-1

print(now+1)
Problem p02742 (python)

Fixed submission:
import sys
h,w=map(int,input().split())
if(h==1 or w==1):
    print(1)
    sys.exit()
if((h*w)%2):
    print(int((h*w)//2+1))
else:
    print(int((h*w)//2))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
if(h==1 or w==1):
    print(1)
    sys.exit()
if((h*w)%2):
    print(int((h*w)//2+1))
else:
    print(int((h*w)//2))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
if((h*w)%2):
    print((h*w)//2+1)
else:
    print((h*w)/2)
Problem p02783 (python)

Fixed submission:
import sys
import math
input=sys.stdin.readline


h,a=map(int,input().split())
ans=h//a
h=h%a
if(h>0):
    print(ans+1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
input=sys.stdin.readline
INF=1000000000
# A Dynamic Programming based Python Program for 0-1 Knapsack problem 
# Returns the maximum value that can be put in a knapsack of capacity W 
def knapSack(W,l, n):
    
    
    
    min_cost = [[0 for i in range(W+1)] for j in range(n+1)] 
    # fill 0th row with infinity 
    for i in range(W+1): 
        min_cost[0][i] = INF 
  
    # fill 0th column with 0 
    for i in range(1, n+1): 
        min_cost[i][0] = 0
    # now check for each weight one by one and fill the 
    # matrix according to the condition 
    for i in range(1, n+1): 
        for j in range(1, W+1): 
            # wt[i-1]>j means capacity of bag is 
            # less than weight of item 
            if (l[i-1][0] > j): 
                min_cost[i][j] = min(min_cost[i-1][j] ,l[i-1][1])
            # here we check we get minimum cost either 
            # by including it or excluding it 
            else: 
                min_cost[i][j] = min(min_cost[i-1][j], 
                    min_cost[i][j-l[i-1][0]] + l[i-1][1]) 
    
  
    # exactly weight W can not be made by given weights 
    if(min_cost[n][W] == INF): 
        return -1
    else: 
        return min_cost[n][W]

h,n=map(int,input().split())
l=list()
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
print( knapSack(h , l , n) )
Problem p02917 (python)

Fixed submission:
#code
n=int(input())
b=input()

b=b.split()

b=list(map(int,b))
a=list()
a.append(b[0])

for i in range(1,len(b)):
    
    
    a.append(min(b[i],b[i-1]))
if(n>2):
    a.append(b[len(b)-1])
if(n==2):
    a.append(b[0])
sum=0 
for i in range(len(a)):
    sum+=a[i]
print(sum)

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

b=b.split()

b=list(map(int,b))
a=list()
for i in range(len(b)-1):
    if(i==0):
        a.append(b[i])
        a.append(b[i])
    else:
        a.append(min(b[i],b[i+1]))
a.append(max(b[len(b)-1],a[len(a)-1]))
sum=0 
for i in range(len(a)):
    sum+=a[i]
print(sum)
Problem p02641 (python)

Fixed submission:
x,n=map(int,input().split())
p=list(map(int,input().split()))

if n==0:
    print(x)
    exit()

for i in range(n):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()
print(x-n)

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
p=list(map(int,input().split()))

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if n==1:
        if sort_p[0]!=0:
            print(x)
        else:
            print(x-1)
    else:
        num=0
        if sort_p[0]!=0:
            print(x)
        else:
            for i in range(1,n):
                if i%2!=0:
                    num+=1
                if sort_p[i]!=num:
                    ans=num
                    break
            small=x-ans
            big=x+ans
            if (small not in p)&(big not in p):
                print(small)
            elif small in p:
                print(big)
            elif big in p:
                print(small)

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
p=list(map(int,input().split()))

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if n==1:
        if sort_p[0]!=0:
            print(x)
        else:
            print(x-1)
    else:
        num=0
        for i in range(1,n):
            if i%2!=0:
                num+=1
            if sort_p[i]!=num:
                ans=num
                break
        small=x-ans
        big=x+ans
        if (small not in p)&(big not in p):
            print(small)
        elif small in p:
            print(big)
        elif big in p:
            print(small)

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
p=list(map(int,input().split()))

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if sort_p[0]!=0:
        print(x)
    else:
        num=0
        for i in range(1,n):
            if i%2!=0:
                num+=1
            if sort_p[i]!=num:
                ans=num
                break
        #print(ans)
        small=x-ans
        big=x+ans
        #print(p)
        #print(small,big)
        if (small not in p)&(big not in p):
            print(small)
        elif small in p:
            print(big)
        elif big in p:
            print(small)