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

Fixed submission:
S = input()
ans = 0
 
for i in range(2**(len(S)-1)):
  temp = S
  for j in range(len(S)-1):
    if(i >> j) & 1:
      temp = temp[:j - len(S) + 1]+'+'+temp[j-len(S)+1:]
  ans += eval(temp)
 
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0

for i in range(2**(len(S)-1):
	temp = S
	for j in range(len(S)-1):
		if(i >> j) & 1:
               temp = temp[:j - len(S) + 1]+'+'+temp[j-len(S)+1:]
    ans += eval(temp)

print(ans)
Problem p02576 (python)

Fixed submission:
a,b,c=map(int,input().split())
s=b
m=c
while s<a:
  s=s+b
  m=m+c
print(m)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
s=k
m=c
while s<a:
  s=s+b
  m=m+c
print(m)
Problem p02582 (python)

Fixed submission:
s=input()
if 'RRR' in s:
  c=3
elif 'RR' in s:
  c=2
elif 'R' in s:
  c=1
else:
  c=0
print(c)

Buggy submission (verdict: Runtime Error):
s=input()
i=0
c=0
if s[i]=='R':
  c=1
  if s[i+1]=='R':
    c=2
    if s[i+2]=='R':
      c=3
if s[i]=='S':
  c=0
  if s[i+1]=='R':
    c=1
   	if s[i+2]=='R':
      c=2
print(c)

Buggy submission (verdict: Runtime Error):
s=input()
l=[]
for i in range(0,len(s)):
  if s[i]=='R':
    c=1
    p=i
    while True:
      if s[p+1]=='R':
        c=c+1
        p=p+1
      else:
        break
    l.append(c)
print(max(l))
Problem p02583 (python)

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

ans=0

for i in range(N):
	for j in range(i, N):
		for k in range(j, N):
			if L_list[i]!= L_list[j] and L_list[j] != L_list[k] and L_list[k] != L_list[i]:
				if L_list[i]+L_list[j]> L_list[k] and L_list[j]+L_list[k]>L_list[i] and L_list[k]+L_list[i]>L_list[j]:
					ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split())
c=0
for i in range(0,n):
      for j in range(i,n):
       		for k in range(j,n):
       				if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
       						if l[i]+l[j]>l[k] and l[k]+l[j]>l[i] and l[i]+l[k]>l[j]:
       										c=c+1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split())
c=0
for i in range(1,n):
      for j in range(i,n):
       		for k in range(j,n):
       				if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
       						if l[i]+l[j]>l[k] and l[k]+l[j]>l[i] and l[i]+l[k]>l[j]:
       										c=c+1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split())
c=0
for i in range(1,n):
      for j in range(i,n):
       		for k in range(j,n):
       				if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
       						if l[i]+l[j]>l[k] and l[k]+l[j]>l[i] and l[i]+l[k]>l[j]:
       										c=c+1
       print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split())
c=0
for i in range(1,N):
       for j in range(i,N):
       		for k in range(j,N):
       			if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
       				if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j]:
       							c=c+1
print(c)
Problem p02609 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def pop_cnt(n):
    return bin(n).count('1')


def f(n):
    cnt = 0
    while n != 0:
        n = n % pop_cnt(n)
        cnt += 1
    return cnt
 
n = int(readline())
x2 = list(readline().decode().rstrip())
x10 = int(''.join(x2), 2)

c = x2.count('1')
mod1 = x10 % (c + 1)
mod2 = x10 % (c - 1) if c-1 != 0 else 0

for i in range(n):
    ans = 0
    if x2[i] == '0':
        t = (mod1 + pow(2, n-i-1, c+1)) % (c+1)
    else:
        if c-1 != 0:
            t = (mod2 - pow(2, n-i-1, c-1)) % (c-1)
        else:
            print(0)
            continue
    
    ans = f(t) + 1
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
bin_X = input()
int_X = int(bin_X, 2)

pop_cnt_1 = 0
for i in bin_X:
    if i == '1':
        pop_cnt_1 += 1
pop_cnt_0 = pop_cnt_1 + 1
pop_cnt_1 = pop_cnt_1 - 1

int_X_0 = int_X % pop_cnt_0
int_X_1 = int_X % pop_cnt_1

def pop_cnt(n):
    c = 0
    for i in bin(n):
        if i == '1':
            c += 1
    return c

for i in range(N):
    if bin_X == '0':
        print(0)
        continue
    
    z = 2 ** (N-i-1)
    if bin_X[i] == '1':
        n = (int_X-z)%pop_cnt_1
    else:
        n = (int_X+z)%pop_cnt_0
   
    cnt = 1
    while n != 0:
        n = n % pop_cnt(n)
        cnt += 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
bin_X = input()
int_X = int(bin_X, 2)

pop_cnt_1 = 0
for i in bin_X:
    if i == '1':
        pop_cnt_1 += 1
pop_cnt_0 = pop_cnt_1 + 1
pop_cnt_1 = pop_cnt_1 - 1

int_X_0 = int_X % pop_cnt_0
int_X_1 = int_X % pop_cnt_1

def pop_cnt(n):
    c = 0
    for i in bin(n):
        if i == '1':
            c += 1
    return c

for i in range(N):
    if bin_X == '0':
        print(0)
        continue
    
    z = 2 ** (N-i-1)
    if bin_X[i] == '1':
        n = (int_X-z)%pop_cnt_1
    else:
        n = (int_X+z)%pop_cnt_0
   
    cnt = 1
    while n != 0:
        n = n % pop_cnt(n)
        cnt += 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
X = input()

if X == '1':
    print(1)
    exit()
elif X == '0':
    print(0)
    exit()
    
x1 = 0
for i in X:
    if i == '1':
        x1 += 1

for i in range(N):
    if X[i] == '1':
        tmp = - (1<<(N-i-1))
        tmp2 = -1
    else:
        tmp = (1<<(N-i-1))
        tmp2 = 1
    
    n = int(X, 2) + tmp
    n %= x1 + tmp2
    cnt = 1
    while n != 0:
        c = 0
        for j in bin(n):
            c += j=='1'
        n %= c
        cnt += 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
X = input()

x1 = 0
for i in X:
    if i == '1':
        x1 += 1

for i in range(N):
    if X[i] == '1':
        tmp = - (1<<(N-i-1))
        tmp2 = -1
    else:
        tmp = (1<<(N-i-1))
        tmp2 = 1
    
    n = int(X, 2) + tmp
    n %= x1 + tmp2
    cnt = 1
    while n != 0:
        c = 0
        for j in bin(n):
            c += j=='1'
        n %= c
        cnt += 1
    print(cnt)
Problem p02630 (python)

Fixed submission:
from collections import Counter

N = int(input())
a = Counter(map(int, input().split()))
Q = int(input())

sum_a = sum(a.elements())

for i in range(Q):
    b, c = map(int, input().split())
    a[c] += a[b]
    sum_a += (c-b) * a[b]
    a[b] = 0
    print(sum_a)

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

r = [0] * (10^5)
for a in a_list:
    r[a-1] += a

for i in range(Q):
    b, c = map(int, input().split())
    tmp = r[b-1] // b
    r[b-1] = 0
    r[c-1] += tmp * c
    print(sum(r))

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

N = int(input())
a = np.array(list(map(int, input().split())))
Q = int(input())
bc = [list(map(int, input().split())) for _ in range(Q)]

for i in range(Q):
    b, c = bc[i]
    a[a == b] = c
    print(np.sum(a))
Problem p02641 (python)

Fixed submission:
import numpy as np

X, N = list(map(int, input().split()))
p_list = set(sorted(list(map(int, input().split()))))

if N == 0:
  print(X)
  exit()
  
i = sorted(list(set(range(X-N, X+1)) - p_list))[-1]
j = sorted(list(set(range(X, X+N+1)) - p_list))[0]

if X-i <= j-X:
  print(i)
else:
  print(j)

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

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

if N == 0:
  print(X)
  exit()
  
p_list = list(map(int, input().split()))

num_list = list(set([*range(1,101)]) - set(p_list))

diff = np.abs(np.array(num_list)-X)
diff_arg_min = np.argmin(diff)

print(num_list[diff_arg_min])

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

X, N = list(map(int, input().split()))
p_list = list(map(int, input().split()))

num_list = list(set([*range(1,101)]) - set(p_list))

diff = np.abs(np.array(num_list)-X)
diff_arg_min = np.argmin(diff)

print(num_list[diff_arg_min])
Problem p02642 (python)

Fixed submission:
N = int(input())
a_list = sorted(list(map(int, input().split())))
a_max = a_list[-1]

count = [0] * (a_max+1)

for a in a_list:
  for j in range(a, a_max+1, a):
    count[j] += 1
  
ans = 0
for a in a_list:
  if count[a] == 1:
    ans += 1
print(ans)

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

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

num_array = np.zeros(max(a_list), dtype=np.int8)
for a in a_list:
    num_array[a::a] += 1

count = 0
for a in a_list:
  if num_array[a] == 1:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N = int(input())
x_list = np.array(list(map(int, input().split()))).reshape(1,N)
count = np.sum(x_list%x_list.reshape(N,1)==0, axis=0)==1
print(np.sum(count))

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N = int(input())
x_list = np.array(list(map(int, input().split()))).reshape(1,N)

print(np.sum(np.sum(x_list%x_list.reshape(N,1)==0, axis=0)==1))

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

N = int(input())
x_list = np.repeat(list(map(int, input().split())), N).reshape(N,N)

print(np.sum(np.sum(x_list%x_list[:,0]==0, axis=1)==1))

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

N = int(input())
x_list = np.repeat(list(map(int, input().split())), N).reshape(N,N)

print(np.sum(np.sum(x_list%x_list[:,0]==0, axis=1)==1))

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

N = int(input())
x_list = np.array(list(map(int, input().split())), reverse=True)

count = 0
for xi in x_list:
  if np.sum(xi%x_list==0) == 1:
      count += 1
print(count)
Problem p02660 (python)

Fixed submission:
N = int(input())

div_counts = []
for i in range(2, int(N**0.5)+1):
  count = 0
  while N%i == 0:
    count += 1
    N //= i
    if N == 1:
      break
  div_counts.append(count)
  
if N != 1:
  div_counts.append(1)

ans = 0
for count in div_counts:
  for i in range(1, count+1):
    if count >= i:
      ans += 1
      count -= i
print(ans)

Buggy submission (verdict: Runtime Error):
import math
 
N = int(input())
num_list = [0] + [0] * int(math.sqrt(N))  # 0~N
pn_list = []
for i in range(2, int(math.sqrt(N))+2):
    if num_list[i] == 0:
        pn_list.append(i)
        num_list[i::i] = [1] * len(num_list[i::i])
        
count = 0
for pn in pn_list:
    e = 1
    while N%(pn**e)==0 and N//(pn**e)>=1:
        N //= (pn**e)
        e += 1
        count += 1
if count == 0 and N>1:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
num_list = [0] + [0] * math.sqrt(N)  # 0~sqrt(N)
pn_list = []
for i in range(2, int(math.sqrt(N))+2):
    if num_list[i] == 0:
        pn_list.append(i)
        num_list[i::i] = [1] * len(num_list[i::i])

count = 0
for pn in pn_list:
    e = 1
    while N%(pn**e)==0 and N>=(pn**e):
        N //= (pn**e)
        e += 1
        count += 1
if count==0 and N>1:  # count==0のとき，Nは素数のため
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
num_list = [0] + [0] * N  # 0~N
pn_list = []
for i in range(2, int(math.sqrt(N))+1):
    if num_list[i] == 0:
        pn_list.append(i)
        num_list[i::i] = [1] * len(num_list[i::i])

count = 0
for pn in pn_list:
    e = 1
    while N%(pn**e)==0 and N//(pn**e)>=1:
        N //= (pn**e)
        e += 1
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
num_list = [0] + [0] * N  # 0~N
pn_list = []
for i in range(2, N+1):
    if num_list[i] == 0:
        pn_list.append(i)
        num_list[i::i] = [1] * len(num_list[i::i])

count = 0
for pn in pn_list:
    e = 1
    while N%(pn**e)==0 and N//(pn**e)>=1:
        N //= (pn**e)
        e += 1
        count += 1
print(count)
Problem p02675 (python)

Fixed submission:
last_num = input()[-1]

if last_num in ['2', '4', '5', '7', '9']:
  print('hon')
elif last_num in ['0', '1', '6', '8']:
  print('pon')
elif last_num in ['3']:
  print('bon')

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

result = []
passed_room = [1]
depth = 1

while paths and depth<N:
  tmp_passed = passed_room.copy()
  
  for i, path in enumerate(paths):
   
    if path[0] in passed_room:
      if path[1] in passed_room:
        del paths[i]
        continue
      result.append((path[1], path[0]))
      tmp_passed.append(path[1])
      del paths[i]
      continue
    
    if path[1] in passed_room:
      if path[0] in passed_room:
        del paths[i]
      result.append((path[0], path[1]))
      tmp_passed.append(path[0])
      del paths[i]
      continue
  depth += 1
  passed_room  = passed_room + tmp_passed
  if len(tmp_passed) == 0:
    print('No')
    exit()
  
    
result = sorted(result)
print('Yes')
for i, j in result:
  print(j)
Problem p02713 (python)

Fixed submission:
from itertools import combinations_with_replacement

K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    for i in range(min_abc, 0, -1):
        if (comb[0]%i == 0 and comb[1]%i == 0) and comb[2]%i == 0:
            if comb[0]==comb[1] and comb[1]==comb[2]:
                coef = 1
            elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
                coef = 6
            else:
                coef = 3
            result += i * coef
            break
print(result)

Buggy submission (verdict: Runtime Error):
from itertools import combinations_with_replacement


def euclidean(num_list: list):
    a, b = sorted(num_list)
    while b % a != 0:
        redi = b % a
        b = a
        a = redi
    return a


K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    gcd = euclidean(comb[0:2])
    gcd = euclidean([gcd, comb[2]])
    if comb[0]==comb[1] and comb[1]==comb[2]:
        coef = 1
    elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
        coef = 6
    else:
        coef = 3
    result += i * coef
print(result)
Problem p02717 (python)

Fixed submission:
x, y, z = list(map(int, input().split()))
x, y = y, x
x, z = z, x
print(x, y, z)

Buggy submission (verdict: Runtime Error):
x, y, z = list(map(int, input()))
x, y = y, x
x, z = z, x
print(x, y, z)
Problem p02718 (python)

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

sum_a = sum(a)
a = sorted(a)

cnt = 0
for i in a:
    if i >= sum_a / (4*m):
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

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

sum_a = sum(a)
a = a.sort()
cnt = 0
for i in a:
    if i >= 1 / (4*sum_a):
        cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')
Problem p02760 (python)

Fixed submission:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b_list = [int(input()) for _ in range(n)]

card = [[0] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b_list:
            card[i][j] = 1

for i in range(3):
    if sum(card[i]) == 3 or sum([card[0][i], card[1][i], card[2][i]]) == 3:
        print('Yes')
        exit()
if sum([card[0][0], card[1][1], card[2][2]]) == 3 or sum([card[0][2], card[1][1], card[2][0]]) == 3:
    print('Yes')
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b_list = [int(input()) for _ in range(n)]

card = [[0] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] == b_list:
            card[i][j] = 1

for i in range(3):
    if card[i][:] == [1,1,1] or card[:][i] == [1,1,1]:
        print('Yes')
        exit()
if sum([card[0][0], card[1][1], card[2][2]]) == 3 or sum([card[0][2], card[1][1], card[2][0]) == 3:
    print('Yes')
    exit()
print('No')
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if n == 1:
    num_list = list(range(10))
else:
    num_list = list(range(10**(n-1), 10**n))
        
for i in num_list:
    flg = True
    for s, c in sc:
        if str(i)[s-1] != str(c):
            flg = False
            break
    if flg:
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

for i in range(10**(n-1), 10**n):
    for j, (s, c) in enumerate(sc, 1):
        if not str(i)[s-1] == str(c):
            break
        if j == m:
            print(i)
            exit()
print(-1n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if n == 1:
    num_list = list(range(10))
else:
    num_list = list(range(10**(n-1), 10**n))
        
for i in num_list:
    for j, (s, c) in enumerate(sc, 1):
        if not str(i)[s-1] == str(c):
            break
        if j == m:
            print(i)
            exit()
print(-1)
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
MOD = 10**9 + 7

u = [1]
d = [1]
c = [1]
for i in range(1, b+1):
    u.append(u[-1] * (n-i+1) % MOD)
    d.append(d[-1] * i % MOD)
    # c.append(u[-1] // d[-1] % MOD)
    c.append(u[-1] * pow(d[-1], MOD-2, MOD) % MOD)

print((pow(2, n, MOD) - c[a] - c[b] - 1) % MOD)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
MOD = 10**9 + 7

fact = [0] * (n+1)
inv_fact = [0] * (n+1)

fact[0] = 1
for i in range(1, n+1):
    fact[i] = fact[i-1] * i % MOD

inv_fact[n] = pow(fact[n], MOD-2, MOD)
for i in range(n, 0, -1):
    inv_fact[i-1] = inv_fact[i] * i % MOD


def nCk(n, k):
    return (fact[n] * inv_fact[k] * inv_fact[n-k]) % MOD


ans = 0
for k in range(1, n+1):
    if k == a or k == b:
        continue
    ans += nCk(n, k) % MOD
    
print(ans % MOD)
Problem p02786 (python)

Fixed submission:
H = int(input())

cnt = 0
i = 0
while H > 0:
    H //= 2
    cnt += 2 ** i
    i += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
i = 0
while H > 0:
    H //= 2
    cnt += 2 ** i
    i += 1
print(cnt)
Problem p02802 (python)

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

correct = [0] * N
penalty = [0] * N
for p, s in ps:
    p = int(p)
    if correct[p-1] == 1:
        continue
    if s == 'AC':
        correct[p-1] = 1
    else:
        penalty[p-1] += 1
print(sum(correct), sum([p*c for p, c in zip(penalty, correct)]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ps = [input().split() for _ in range(M)]

correct = [0] * N
penalty = [0] * N
for p, s in ps:
    p = int(p)
    if correct[p-1] == 1:
        continue
    if s == 'AC':
        correct[p-1] = 1
    else:
        penalty[p-1] += 1
print(sum(correct), sum([p*c for p, c in zip(penalty, correct)]))))
Problem p02913 (python)

Fixed submission:
n = int(input())
s = input()
 
max_len = 0
j = 0
 
for i in range(n):
    while j < n and s[i:j] in s[j:]:
        j += 1
    max_len = max(max_len,j-i-1)
 
print(max_len)

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

def z_algo(S):
    N = len(S)
    A = [0] * N
    i = 1
    j = 0
    l = len(S)
    A[0] = l

    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        k = 1
        while min(l-i, j-A[k]) > k:
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A

ans = 0
for i in range(N):
    s = S[i:]
    tmp = z_algo(s)
    for i in range(1, len(tmp)+1):
        if tmp[i] > i:
            tmp[i] = 0
    if len(tmp) >= 2:
        ans = max(ans, max(tmp[1:]))
print(ans)
Problem p03060 (python)

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

ans = 0
for i in range(N):
    if v[i] > c[i]:
        ans += v[i] - c[i]
print(ans)

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

ans = 0
for _ in range(N):
    if v[i] > c[i]:
        ans += v[i] - c[i]
print(ans)
Problem p03161 (python)

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

dp = [1e10] * N
dp[0] = 0
for i in range(N):
    for j in range(i+1, i+K+1):
        if j >= N:
            break
        dp[j] = min([dp[j], dp[i]+abs(h[j]-h[i])])
print(dp[N-1])

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

dp = [10**9+5] * N
dp[0] = 0
for i in range(1, N):
    for j in range(1, min(i, K)+1):
        dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j])
print(dp[N-1])
Problem p03168 (python)

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

dp = [[0.] * (N+1) for _ in range(N+1)]
dp[0][0] = 1.

for i in range(1, N+1):
    for j in range(i+1):
        prob = dp[i-1][j-1]*p[i-1]
        if i > 0:
            prob += dp[i-1][j]*(1.-p[i-1])
        dp[i][j] = max(dp[i][j], prob)
print(sum(dp[-1][N//2+1:]))

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

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for j in range(N+1):
        dp[i][j] += dp[i-1][j] * (1-p_list[i-1])
        if j > 0:
            dp[i][j] += dp[i-1][j-1] * p_list[i-1]
            
start = N//2 + 1
for p in dp[N][start:]:
    ans += p
print(ans)
Problem p03125 (python)

Fixed submission:
a,b=map(int,input().split())
if b%a==0:
  print(a+b)
else:
  print(b-a)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
b=input()
if b%a==0:
  print(a+b)
else:
  print(b-a)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
if b%a==0:print(a+b)
else:print(b-a)
Problem p02706 (python)

Fixed submission:
n,m=map(int,input().split())
print(max(-1,n-sum(list(map(int,input().split())))))

Buggy submission (verdict: Runtime Error):
n,m=map(int(input().split()))
a=list(map(int,input().split()))
print(max(-1,n-sum(a)))

Buggy submission (verdict: Runtime Error):
n,m=map(int(input().split()))
print(max(-1,n-sum(list(map(int,input().split())))))
Problem p02748 (python)

Fixed submission:
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
z=min(al)+min(bl)
for i in range(m):
  x,y,c=map(int,input().split())
  t=al[x-1]+bl[y-1]-c
  z=min(z,t)
print(z)

Buggy submission (verdict: Runtime Error):
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
x=min(al)+min(bl)
for i in range(m):
  x,y,c=map(int,input().split())
  t=a[x-1]+b[y-1]-c
  x=min(x,t)
print(x)
Problem p02806 (python)

Fixed submission:
n=int(input())
a=[list(input().split()) for _ in range(n)]
x=input()
s=0
for i in range(n):
  if a[i][0]==x:
    p=i
    break
for i in range(p+1,n):
  s+=int(a[i][1])
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
x=input()
s=0
for i in range(n):
  if a[i][0]==x:
    p=i
    break
for i in range(p+1,n):
  s+=a[i][1]
print(s)