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

Fixed submission:
n = int(input())
i = 1
ans = n
 
while i * i <= n:
    j, m = divmod(n, i)
    if m == 0:
        ans = min(ans, i + j - 2)
    i += 1
 
print(ans)

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

m = np.array(int(input()))

a = 1
b = m

# for i in reversed(range(2, int(round(np.sqrt(n))))):
#     if n % i ==  0:
#         a = int(i)
#         b = int(n / i)
#         break

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

soin = prime_factorize(n)

soin_r = soin[::-1]

tmp = 1
for i in range(len(soin) // 2):
    tmp *= soin[i]

zan = m / tmp

print(int(tmp + zan - 2))

"""
10
5

50
13

10000000019
10000000018

"""
Problem p02990 (python)

Fixed submission:
import math

n, k = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    if n - k + 1 >= i:
        tmp1 = combinations_count(k - 1, i - 1) % 1000000007
        tmp2 = combinations_count(n - k + 1, i) % 1000000007
        ans = (tmp1 * tmp2) % 1000000007
        print(ans)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    tmp1 = combinations_count(k - 1, i - 1) % 1000000007
    tmp2 = combinations_count(n - k + 1, i) % 1000000007
    ans = (tmp1 * tmp2) % 1000000007
    print(ans)
    if ans == 1:
        exit()

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    if k - 1 == i - 1:
        tmp1 = 1
    else:
        tmp1 = combinations_count(k - 1, i - 1) % 1000000007
    if n - k + 1 == i:
        tmp2 = 1
    else:
        tmp2 = combinations_count(n - k + 1, i) % 1000000007
    print((tmp1 * tmp2) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    if i == k:
        tmp1 = 1
    else:
        tmp1 = combinations_count(k - 1, i - 1) % 1000000007
    if i == (n - k + 1):
        tmp2 = 1
    else:
        tmp2 = combinations_count(n - k + 1, i) % 1000000007
    print((tmp1 * tmp2) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    tmp1 = combinations_count(k - 1, k - (k - i + 1)) % 1000000007
    tmp2 = combinations_count(n - k + 1, i) % 1000000007
    print((tmp1 * tmp2) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    tmp1 = combinations_count(k - 1, k - (k - i + 1)) % 1000000007
    tmp2 = combinations_count(n - k + 1, i) % 1000000007
    print((tmp1 * tmp2))

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    tmp1 = combinations_count(k - 1, k - (k - i + 1))
    tmp2 = combinations_count(n - k + 1, i)
    print((tmp1 * tmp2) % 1000000007)
Problem p03017 (python)

Fixed submission:
n, a, b, c, d = map(int, input().split())

s = input()

if c < d:
    for i in range(b, d):
        if s[i:i+2] == "##":
            print(('No'))
            exit()
    for i in range(a, c):
        if s[i:i+2] == "##":
            print(('No'))
            exit()
    print('Yes')
else:
    for i in range(b, d):
        if s[i:i+2] == "##":
            print(('No'))
            exit()
    for i in range(a, c):
        if s[i:i+2] == "##":
            print(('No'))
            exit()
    for i in range(b-2, d-1):
        if s[i:i+3] == "...":
            print(('Yes'))
            exit()
    print('No')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())

s = input()

flagA = True
flagB = True

for i in range(d - b):
    if s[b + i] == "#" and s[b + i + 1] == "#":
        flagB = False

for i in range(c - a):
    if ((s[a + i] == "#") or (a + i == d - 1)) and ((s[a + i + 1] == "#") or (a + i + 1 == d - 1)):
        flagA = False
        for j in range(c - a):
            if (s[a + j] == "." and s[a + j + 1] == "." and s[a + j + 2] == "."):
                flagA = True

if flagA and flagB:
    print("Yes")
else:
    print("No")
Problem p03207 (python)

Fixed submission:
n = int(input())
p = []
for i in range(n):
    p.append(int(input()))

p_max = max(p)

print(int(sum(p) - p_max / 2))

Buggy submission (verdict: Runtime Error):
n = int(input())
p = []
for i in range(n):
    p.append(int(input()))

p_max = max(p)

print(int(sum(p) - p_max / 2)
Problem p03242 (python)

Fixed submission:
s = list(input())

if s[0] == '1':
    s[0] = s[0].replace('1', '9')
elif s[0] == '9':
    s[0] = s[0].replace('9', '1')
if s[1] == '1':
    s[1] = s[1].replace('1', '9')
elif s[1] == '9':
    s[1] = s[1].replace('9', '1')
if s[2] == '1':
    s[2] = s[2].replace('1', '9')
elif s[2] == '9':
    s[2] = s[2].replace('9', '1')

print(''.join(s))

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

if '1' in n:
  s = s.replace('1', '9')

if '9' in n:
  s = s.replace('9', '1')
  
print(s)
Problem p02933 (python)

Fixed submission:
a=int(input())
s = str(input())

if a >= 3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
d = {}
ans = [0]*(n+1)
for i in range(n-1):
    sta,gol = map(int,input().split())
    d[gol] = sta

for i in range(q):
    sta,val = map(int,input().split())
    ans[sta]+=val
    

for i in range(n):
    gol = i+1
    if gol in d:
        ans[gol]+=ans[d[gol]]
    

anss = ""
for i in range(n):
    anss = anss+str(ans[i+1])+" "
print(anss)
Problem p02990 (python)

Fixed submission:
n,k=map(int,input().split())
inf = 10**9+7

inv_t = [0]+[1]
for i in range(2,n+1):
    inv_t += [inv_t[inf % i] * (inf - int(inf / i)) % inf]
    
bik =  [1]+[1]
for i in range(2,n+1):
    bik += [(bik[i-1]*i)% inf]
    
bik_inv =  [1]+[1]
for i in range(2,n+1):
    bik_inv += [(bik_inv[i-1]*inv_t[i])% inf]

def conv(l,r):
    if l>=r:
        up = bik[l]
        lo = bik_inv[l-r]*bik_inv[r]
        return up*lo
    else:
        return 0

for i in range(1,k+1):
    """print("#########")
    print(i)
    print(conv(n-k+1,i))
    print(conv(k-1,i-1))"""
    print((conv(n-k+1,i)*conv(k-1,i-1))%inf)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
inf = 10**9+7
def conv(l,r):
    up = 1
    lo = 1
    for i in range(r):
        up *= l-i
        lo *= r-i
    return int(up/lo)

for i in range(1,k+1):
    print((conv(n-k+1,i)*conv(k-1,i-1))%inf)
Problem p02897 (python)

Fixed submission:
N = int(input())

if N%2 == 0:
    print(1/2)
else:
    print(((N-1)//2+1)/N)

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

if N%2 == 0:
    print(0.5000)
else:
    print(((N-1)//(2*N))
Problem p02987 (python)

Fixed submission:
s = list(input())
#print(s)

l = []

for i in range(4):
  if not s[i] in l:
    l.append(s[i])
#print(l)

if len(l) != 2:
  print("No")
else:
  if s.count(l[0]) == 2:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
def P(p, q):
  return math.factorial(p)//math.factorial(p-q)

def cmb(p, q):
  return P(p, q)//math.factorial(q)

n,k = map(int,input().split())
#print(n,k)

ans = []

x = 0
a = 1
if n-k == 1:
  b = 2
elif n-k > 1:
  b = cmb(n-k-1, 1)
else:
  b = 0
x = (2 + a * b)%(1000000007)
ans.append(x)

x = 0
if k == 1:
  a = 1
else:
  a = cmb(k-1, 1)
if n-k == 1:
  b = 1
elif n-k == 2:
  b = cmb(n-k-1, 1) * 2 + 1
else:
  b = cmb(n-k-1, 2) + cmb(n-k-1, 1) * 2 + 1
x = (a * b)%(1000000007)
ans.append(x)

#print(ans)

 
for i in range(3,k+1):
  x = 0
  a = cmb(k-1, i-1)#青玉の並べ方
  if n-k-1 < i-2:
    b = 0
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-2)
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  else:
    b = cmb(n-k-1,i) + cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  x = (a * b)%(1000000007)
  ans.append(x)

for i in range(k):
  print(ans[i])
Problem p02990 (python)

Fixed submission:
import math
def P(p, q):
  return math.factorial(p)//math.factorial(p-q)

def cmb(p, q):
  return P(p, q)//math.factorial(q)

n,k = map(int,input().split())
#print(n,k)

ans = []

x = 0
a = 1
if n-k == 1:
  b = 2
  x = (2 + a * b)%(1000000007)
elif n-k > 1:
  b = cmb(n-k-1, 1)
  x = (2 + a * b)%(1000000007)
else:
  x = 1
ans.append(x)

x = 0
if k == 1:
  a = 1
else:
  a = cmb(k-1, 1)
if n-k == 1:
  b = 1
elif n-k == 2:
  b = cmb(n-k-1, 1) * 2 + 1
elif n-k > 2:
  b = cmb(n-k-1, 2) + cmb(n-k-1, 1) * 2 + 1
else:
  b = 0
x = (a * b)%(1000000007)
ans.append(x)

#print(ans)

 
for i in range(3,k+1):
  x = 0
  a = cmb(k-1, i-1)#青玉の並べ方
  if n-k-1 < i-2:
    b = 0
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-2)
  elif n-k-1 < i:
    b = cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  else:
    b = cmb(n-k-1,i) + cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  x = (a * b)%(1000000007)
  ans.append(x)

for i in range(k):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
import math
def P(p, q):
  return math.factorial(p)//math.factorial(p-q)

def cmb(p, q):
  return P(p, q)//math.factorial(q)

n,k = map(int,input().split())
#print(n,k)

ans = []

x = 0
a = 1
if n-k == 1:
  b = 2
elif n-k > 1:
  b = cmb(n-k-1, 1)
else:
  b = 0
x = (2 + a * b)%(1000000007)
ans.append(x)

x = 0
if k == 1:
  a = 1
else:
  a = cmb(k-1, 1)
if n-k == 1:
  b = 1
elif n-k == 2:
  b = cmb(n-k-1, 1) * 2 + 1
else:
  b = cmb(n-k-1, 2) + cmb(n-k-1, 1) * 2 + 1
x = (a * b)%(1000000007)
ans.append(x)

#print(ans)

 
for i in range(3,k+1):
  x = 0
  a = cmb(k-1, i-1)#青玉の並べ方
  if n-k-1 < i-2:
    b = 0
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-2)
  elif n-k-1 < i:
    b = cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  else:
    b = cmb(n-k-1,i) + cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  x = (a * b)%(1000000007)
  ans.append(x)

for i in range(k):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
import math
def P(p, q):
  return math.factorial(p)//math.factorial(p-q)

def cmb(p, q):
  return P(p, q)//math.factorial(q)

n,k = map(int,input().split())
#print(n,k)

ans = []

x = 0
a = 1
if n-k == 1:
  b = 2
elif n-k > 1:
  b = cmb(n-k-1, 1)
else:
  b = 0
x = (2 + a * b)%(1000000007)
ans.append(x)

x = 0
if k == 1:
  a = 1
else:
  a = cmb(k-1, 1)
if n-k == 1:
  b = 1
elif n-k == 2:
  b = cmb(n-k-1, 1) * 2 + 1
else:
  b = cmb(n-k-1, 2) + cmb(n-k-1, 1) * 2 + 1
x = (a * b)%(1000000007)
ans.append(x)

#print(ans)

 
for i in range(3,k+1):
  x = 0
  a = cmb(k-1, i-1)#青玉の並べ方
  if n-k-1 < i-2:
    b = 0
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-2)
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  else:
    b = cmb(n-k-1,i) + cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  x = (a * b)%(1000000007)
  ans.append(x)

for i in range(k):
  print(ans[i])
Problem p03017 (python)

Fixed submission:
n,a,b,c,d=map(int,input().split())
s = input()

if c > d:#追い抜きが必要な場合
    x = 0
    for i in range(b-2,d-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            x = 1
    if x == 0:
        print("No")#追い抜きが出来ない
    else:#追い抜き可能な場合
        check = 0#岩が2連続以上だと達成不能
        for i in range(a-1,c-1):
            if s[i] == "#" and s[i+1] == "#":
                check = 1
        if check == 1:
            print("No")
        else:
            print("Yes")
else:#a<b<c<dと並ぶ場合、もしくはacbdと並ぶ場合
    a_check = 0#Aがいけるか
    b_check = 0#Bがいけるか
    for i in range(a-1,c-1):
        if s[i] == "#" and s[i+1] == "#":
            a_check = 1
    for i in range(b-1,d-1):
        if s[i] == "#" and s[i+1] == "#":
            b_check = 1
    if a_check == 0 and b_check == 0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s = input()

if c > d:#追い抜きが必要な場合
    x = 0
    for i in range(b-1,d-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            x = 1
    if x == 0:
        print("No")#追い抜きが出来ない
    else:#追い抜き可能な場合
        check = 0#岩が2連続以上だと達成不能
        for i in range(a-1,c-1):
            if s[i] == "#" and s[i+1] == "#":
                check = 1
        if check == 1:
            print("No")
        else:
            print("Yes")
else:#a<b<c<dと並ぶ場合、もしくはacbdと並ぶ場合
    a_check = 0#Aがいけるか
    b_check = 0#Bがいけるか
    for i in range(a-1,c-1):
        if s[i] == "#" and s[i+1] == "#":
            a_check = 1
    for i in range(b-1,d-1):
        if s[i] == "#" and s[i+1] == "#":
            b_check = 1
    if a_check == 0 and b_check == 0:
        print("Yes")
    else:
Problem p03041 (python)

Fixed submission:
n, k = map(int, input().split())
s = list(input())

if s[k-1] == "A":
  s[k-1] = "a"
elif s[k-1] == "B":
  s[k-1] = "b"
else:
  s[k-1] = "c"

for i in range(n):
  print(s[i], end="")

Buggy submission (verdict: Runtime Error):
s = int(input())
 
a = int(s / 100) #百の位と千の位
b = s - a*100 #下二桁

if a > 12:
  if b > 12 or b == 0:
    print("NA")
  else:
    print("YYMM")
elif a == 0:
  if b < 13 and b > 0:
    print("YYMM")
  else:
    print("NA")
elif b > 12 or b == 0:
  print("MMYY")
else:
  print("AMBIGUOUS")
Problem p03272 (python)

Fixed submission:
n,i = map(int,input().split())
print(n-i+1)

Buggy submission (verdict: Runtime Error):
n,i = map(int,input().spilt())
print(n-i+1)

Buggy submission (verdict: Runtime Error):
n,i = map(int,input())
print(n-i+1)
Problem p02860 (python)

Fixed submission:
N = int(input())
S = str(input())
S = list(S)

if N%2 != 0:
    print('No')
    exit()

S1, S2 = [], []
for i, s in enumerate(S):
    if i < (N/2):
        S1.append(s)
    else:
        S2.append(s)

s1 = ' '
for s in S1:
    s1 += s

s2 = ' '
for s in S2:
    s2 += s

if s1 == s2:
    print('Yes')
else:
    print('No')

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

if N%2 != 0:
    print('No')
    exit()

S1, S2 = [], []
for i, s in enumerate(S):
    if i < (N/2):
        s1.append(s)
    else:
        s2.append(s)

s1, s2 = ' ', ' '
for s in S1:
    s1 += s

for s in S2:
    s2 += s

if s1 ==s2:
    print('Yes')
else:
    print('No')

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

if N%2 != 0:
    print('No')
    exit()

S1, S2 = [], []
for i, s enumerate(S):
    if i < (N/2):
        s1.append(s)
    else:
        s2.append(s)

s1, s2 = ' ', ' '
for s in S1:
    s1 += s

for s in S2:
    s2 += s

if s1 ==s2:
    print('Yes')
else:
    print('No')
Problem p03107 (python)

Fixed submission:
s=input()
s_=list(s)
s0=s_.count("0")
s1=s_.count("1")
print(len(s)-abs(s0-s1))

Buggy submission (verdict: Runtime Error):
s=input()
s_=list(s)
i=0
while i<=len(s_)-2:
    if s_[i]!=s_[i+1]:
        del s_[i:i+2]
        i=i-1
    else:
        i+=1
print(len(s)-len(s_))
Problem p03135 (python)

Fixed submission:
t,x=list(map(int,input().split(" ")))
print(t/x)

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

list_x.sort()
list_d=[]

if m<=n:
    print(0)
else:
    i=0
    while i<=m-2:
        list_d.append(list_x[i+1]-list_x[i])
        i+=1
    list_d.sort()
    print(sum(list_d[0:m-n:1]))
Problem p03013 (python)

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

memo = [-1] * (n + 1)
memo[0] = 1
memo[1] = 1
for i in range(m):
  memo[int(input())] = 0

def fib(x):
  if memo[x] == -1:
    memo[x] = fib(x-1) + fib(x-2)
  return memo[x]

def fib2(x):
  if x <= 1:
    return memo[x]
  else:
    for i in range(x - 1):
      if memo[i + 2] == 0:
        continue
      memo[i + 2] = memo[i] + memo[i + 1]
    return memo[x]

# print(fib2(n))
# print(memo)
print(fib2(n) % 1000000007)

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

memo = [-1] * (n + 1)
memo[0] = 1
memo[1] = 1
for i in range(m):
  memo[int(input())] = 0

def fib(x):
  if memo[x] == -1:
    memo[x] = fib(x-1) + fib(x-2)
  return memo[x]

print(fib(n) % 1000000007)

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

memo = [-1] * (n + 1)
memo[0] = 1
memo[1] = 1
for i in range(m):
  memo[int(input())] = 0

def fib(x):
  if memo[x] > -1:
    return memo[x]
  else:
    memo[x] = fib(x-1) + fib(x-2)
    return memo[x]

# print(fib(n))
# print(memo)
print(fib(n) % 1000000007)

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

memo = [-1] * (n + 1)
memo[0] = 1
memo[1] = 1
for i in range(m):
  memo[int(input())] = 0

def fib(x):
  if memo[x] == 0:
    return 0
  if memo[x] > 0:
    return memo[x]
  else:
    memo[x] = fib(x-1) + fib(x-2)
    return memo[x]

# print(fib(n))
# print(memo)
print(fib(n) % 1000000007)
Problem p02984 (python)

Fixed submission:
import sys
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)


main()

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


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    va = np.array(a)
    m = np.identity(n, dtype=int)
    for i in range(n):
        if i < n - 1:
            m[i][i + 1] = 1
        else:
            m[i][0] = 1
    vx = np.linalg.solve(m, va).astype(np.int) * 2
    print(*vx)


main()
Problem p03222 (python)

Fixed submission:
import sys
MOD = 1000000007


def main():
    h, w, k = [int(x) for x in input().split()]
    fibonacci = [1, 2]
    for i in range(w - 2):
        fibonacci.append(fibonacci[i] + fibonacci[i + 1])
    pattern = [0 for _ in range(w)]
    pattern[0] = 1
    for _ in range(h):
        nextp = [0 for _ in range(w)]
        for i in range(w):
            nextp[i] = (pattern[i] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i > 0:
                nextp[i] += (pattern[i - 1] * (fibonacci[max(0, i - 2)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i < w - 1:
                nextp[i] += (pattern[i + 1] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 3))])) % MOD
            nextp[i] %= MOD
        pattern = nextp
    print(pattern[k-1])


main()

Buggy submission (verdict: Runtime Error):
import sys
MOD = 1_000_000_007


def main():
    h, w, k = [int(x) for x in input().split()]
    fibonacci = [1, 2]
    for i in range(w - 2):
        fibonacci.append(fibonacci[i] + fibonacci[i + 1])
    pattern = [0 for _ in range(w)]
    pattern[0] = 1
    for _ in range(h):
        nextp = [0 for _ in range(w)]
        for i in range(w):
            nextp[i] = (pattern[i] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i > 0:
                nextp[i] += (pattern[i - 1] * (fibonacci[max(0, i - 2)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i < w - 1:
                nextp[i] += (pattern[i + 1] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 3))])) % MOD
            nextp[i] %= MOD
        pattern = nextp
    print(pattern[k-1])


main()
Problem p03634 (python)

Fixed submission:
import sys
import collections

n = int(input())
adj = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = [int(x) for x in input().split()]
    adj[a].append((b, c))
    adj[b].append((a, c))
q, k = [int(x) for x in input().split()]
dist = [0] * (n + 1)
queue = collections.deque()
queue.append(k)
while len(queue) > 0:
    u = queue.popleft()
    for v, weight in adj[u]:
        if dist[v] == 0:
            queue.append(v)
            dist[v] = dist[u] + weight
for j in range(q):
    l, r = [int(x) for x in input().split()]
    print(dist[l] + dist[r])
# print(*data, sep='\n')

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra


def main():
    n = int(input())
    graph = np.zeros((n + 1, n + 1))
    for i in range(n-1):
        a, b, c = [int(x) for x in input().split()]
        graph[a, b] = c
    graph = csr_matrix(graph)
    q, k = [int(x) for x in input().split()]
    dist = dijkstra(csgraph=graph, directed=False, indices=k)
    for j in range(q):
        l, r = [int(x) for x in input().split()]
        print(int(dist[l]+dist[r]))


main()

Buggy submission (verdict: Runtime Error):
def dfs(v, parent):
    for tail, weight in adj[v]:
        if tail == parent:
            continue
        dist[tail] = dist[v] + weight
        dfs(tail, v)


n = int(input())
adj = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = [int(x) for x in input().split()]
    adj[a].append((b, c))
    adj[b].append((a, c))
q, k = [int(x) for x in input().split()]
dist = [0] * (n + 1)
dfs(k, k)
for j in range(q):
    l, r = [int(x) for x in input().split()]
    print(dist[l] + dist[r])
# print(*data, sep='\n')

Buggy submission (verdict: Runtime Error):
def dfs(v, parent):
    for edge in adj[v]:
        if edge[0] == parent:
            continue
        dist[edge[0]] = dist[v] + edge[1]
        dfs(edge[0], v)


n = int(input())
adj = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = [int(x) for x in input().split()]
    adj[a].append((b, c))
    adj[b].append((a, c))
q, k = [int(x) for x in input().split()]
dist = [0] * (n + 1)
dfs(k, k)
for j in range(q):
    l, r = [int(x) for x in input().split()]
    print(dist[l] + dist[r])
# print(*data, sep='\n')
Problem p02989 (python)

Fixed submission:
n=int(input())
ls=list(map(int,input().split()))
ls.sort()

print(ls[n//2]-ls[n//2-1])

Buggy submission (verdict: Runtime Error):
s=list(input())
k=int(input())
s.append(-1)
i=0
ans=-1
while True:
    if s[i]=="-1":
        ans=s[i]
        break
    if s[i]!="1":
        ans=s[i]
        if i+1>k:
            ans="1"   
        break
    i+=1
print(ans)
Problem p02879 (python)

Fixed submission:
j=input()
i = j.split(' ')
k = []
for c in i:
    k.append(int(c))
if k[0]<10 and k[1]<10:
	print(k[0]*k[1])
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
abc = input()
abc_int = int(abc)
prolist = []
chk = int(abc_int**0.5)+2
for c1 in range(chk):
	if abc_int % c1 == 0:
		prolist.append(c1+abc_int//c1-2)
print(min(prolist))

Buggy submission (verdict: Runtime Error):
i = int(input().split(' '))
if i[0]<10 and i[1]<10:
	print(i[0]*i[1])
else:
	print(-1)
Problem p02881 (python)

Fixed submission:
abc = input()
abc_int = int(abc)
prolist = []
chk = int(abc_int**0.5)+2
for c1 in range(chk):
	if abc_int % (c1+1) == 0:
		prolist.append(c1+1+abc_int//(c1+1)-2)
print(min(prolist))

Buggy submission (verdict: Runtime Error):
abc = input()
abc_int = int(abc)
prolist = []
chk = int(abc_int**0.5)
print(chk)
for c1 in range(chk):
    for c2 in range(chk):
        if (c1+1)*(c2+1) == abc_int:
            prolist.append(c1+c2)
print(min(prolist))