qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def main():
    H, W, K = list(map(int, input().split()))
    dp = [[0 for _ in range(W)] for _ in range(H + 1)]
    dp[0][0] = 1

    for i in range(H):
        for j in range(1 << (W - 1)):
            if '11' in bin(j):
                continue
            j <<= 1
            for k in range(W):
                if j & (1 << k):
                    dp[i + 1][k] += dp[i][k - 1]
                elif j & (1 << (k + 1)):
                    dp[i + 1][k] += dp[i][k + 1]
                else:
                    dp[i + 1][k] += dp[i][k]
                dp[i + 1][k] %= (10 * 9 + 7)

    print(dp[H][K - 1])


if __name__ == '__main__':
    main()


Fixed code:
def main():
    H, W, K = list(map(int, input().split()))
    dp = [[0 for _ in range(W)] for _ in range(H + 1)]
    dp[0][0] = 1

    for i in range(H):
        for j in range(1 << (W - 1)):
            if '11' in bin(j):
                continue
            j <<= 1
            for w in range(W):
                if j & (1 << w):
                    dp[i + 1][w] += dp[i][w - 1]
                elif j & (1 << (w + 1)):
                    dp[i + 1][w] += dp[i][w + 1]
                else:
                    dp[i + 1][w] += dp[i][w]
                dp[i + 1][w] %= (10 ** 9 + 7)

    print(dp[H][K - 1])


if __name__ == '__main__':
    main()
Buggy code:
def fib(W):
    a, b = 1, 1
    n = [a, b]
    while W > len(n):
        a, b = b, b + a
        n.append(b)
    return n
H, W, K = map(int, input().split())
f = fib(W)
r = [1] + [0] * (W - 1)
for i in range(H):
    tmp = [0] * W
    for j in range(W):
        if j == 0:
            tmp[j] = r[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2]
        elif j == W - 1:
            tmp[j] = r[j] * f[j] + r[j - 1] * f[j - 1]
        else:
            tmp[j] = r[j] * f[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2] * f[j] + r[j - 1] * f[W - j - 1] * f[j - 1]
    r = tmp
print(r[K - 1] % 1_000_000_007)

Fixed code:
def fib(W):
    a, b = 1, 1
    n = [a, b]
    while W > len(n):
        a, b = b, b + a
        n.append(b)
    return n
H, W, K = map(int, input().split())
f = fib(W)
r = [1] + [0] * (W - 1)
for i in range(H):
    tmp = [0] * W
    for j in range(W):
        if j == 0:
            tmp[j] = r[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2] if W != 1 else 1
        elif j == W - 1:
            tmp[j] = r[j] * f[j] + r[j - 1] * f[j - 1]
        else:
            tmp[j] = r[j] * f[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2] * f[j] + r[j - 1] * f[W - j - 1] * f[j - 1]
    r = tmp
print(r[K - 1] % 1000000007)
Buggy code:
import itertools

H,W,K = map(int, input().split())
p = 1000000007

if K - 1 > H:
    print(0)
    exit(0)

R = []
for r in itertools.product( [0,1], repeat=(W-1) ):
    if 1 not in list(map(lambda i : r[i]*r[i+1], range(len(r)-1)) ):
        R.append(r)


M = [ (
    len( list( filter( lambda r:r[0]==0, R) ) ),
    len( list( filter( lambda r:r[0]==1, R) ) ),
    0
) ]
for c in range(1,W-1):
    M.append((
        len( list( filter( lambda r:r[c]==0 and r[c-1]==0, R) ) ),
        len( list( filter( lambda r:r[c]==1, R) ) ),
        len( list( filter( lambda r:r[c-1]==1, R) ) )
    ))
M.append((
    len( list( filter( lambda r:r[W-2]==0, R) ) ),
    0,
    len( list( filter( lambda r:r[W-2]==1, R) ) )
))

print(R)
print(M)

count = [1] + [0]*(W-1)
for h in range(H):
    count_ = [0] * W
    for num,c in zip(count, range(len(count))):
        for m,n in zip(M[c], [0,+1,-1]):
            if c+n >= 0 and c+n < W:
                count_[c+n] += num * m
    count = count_
        
print(count_[K-1]%p)    
    


Fixed code:
import itertools

H,W,K = map(int, input().split())
p = 1000000007

if K - 1 > H:
    print(0)
    exit(0)
if W == 1:
    print(1)
    exit(0)

R = []
for r in itertools.product( [0,1], repeat=(W-1) ):
    if 1 not in list(map(lambda i : r[i]*r[i+1], range(len(r)-1)) ):
        R.append(r)


M = [ (
    len( list( filter( lambda r:r[0]==0, R) ) ),
    len( list( filter( lambda r:r[0]==1, R) ) ),
    0
) ]
for c in range(1,W-1):
    M.append((
        len( list( filter( lambda r:r[c]==0 and r[c-1]==0, R) ) ),
        len( list( filter( lambda r:r[c]==1, R) ) ),
        len( list( filter( lambda r:r[c-1]==1, R) ) )
    ))
M.append((
    len( list( filter( lambda r:r[W-2]==0, R) ) ),
    0,
    len( list( filter( lambda r:r[W-2]==1, R) ) )
))

count = [1] + [0]*(W-1)
for h in range(H):
    count_ = [0] * W
    for num,c in zip(count, range(len(count))):
        for m,n in zip(M[c], [0,+1,-1]):
            if c+n >= 0 and c+n < W:
                count_[c+n] += num * m
    count = count_
        
print(count_[K-1]%p)
Buggy code:
H, W, K = (int(i) for i in input().split())

if W == 1:
    print(1)

else:

    wnum = [0]*(W-1)
    for i in range(W-1):
        wsum = 0
        for j in range(2**(W-1)):
            bit = format(j, "0{}b".format(W-1))
            cc = 0
            for k in range(W-2):
                if bit[k] == "1" and bit[k + 1] == "1":
                    pass
                else:
                    if bit[i] == "1":
                        wnum[i] += 1
                        print(bit)
                    wsum += 1

    dp = [[0]*W for i in range(H+1)]
    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            if 1 <= j <= W-2:
                dp[i+1][j] = dp[i][j-1] * wnum[j-1] + dp[i][j+1] * wnum[j] 
                + dp[i][j] * (wsum-wnum[j-1]-wnum[j])
            elif j == 0:
                dp[i+1][j] = dp[i][j+1] * wnum[j] + dp[i][j] * (wsum-wnum[j])
            else:
                dp[i+1][j] = dp[i][j-1] * wnum[j-1] + dp[i][j] * (wsum-wnum[j-1])
            dp[i+1][j] = dp[i+1][j] % 1000000007

    print(dp[H][K-1])

Fixed code:
H, W, K = (int(i) for i in input().split())

if W == 1:
    print(1)

else:

    wnum = [0]*(W-1)
    for i in range(W-1):
        wsum = 0
        for j in range(2**(W-1)):
            bit = format(j, "0{}b".format(W-1))
            cc = 0
            for k in range(W-2):
                if bit[k] == "1" and bit[k + 1] == "1":
                    break
            else:
                if bit[i] == "1":
                    wnum[i] += 1
                wsum += 1

    dp = [[0]*W for i in range(H+1)]
    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            if 1 <= j <= W-2:
                dp[i+1][j] = dp[i][j-1] * wnum[j-1] + dp[i][j+1] * wnum[j] + dp[i][j] * (wsum-wnum[j-1]-wnum[j])
            elif j == 0:
                dp[i+1][j] = dp[i][j+1] * wnum[j] + dp[i][j] * (wsum-wnum[j])
            else:
                dp[i+1][j] = dp[i][j-1] * wnum[j-1] + dp[i][j] * (wsum-wnum[j-1])
            dp[i+1][j] = dp[i+1][j] % 1000000007
    print(dp[H][K-1])
Buggy code:
height, width, k = map(int, input().split())

ans = [[0] * (width + 2) for i in range(height + 1)]
start_w = 1
end_w = width
start_h = 0
ans[start_h][start_w] = 1
search_range = start_w + 1 if end_w > 1 else 1
f = [0] * (width + 2)
f[0], f[1], f[2] = 1, 1, 1


def det_unused(n, m=0):
    front = n - (start_w + 1)
    rear = end_w - (n + 1)

    if m == -1:
        front -= 1
    elif m == 1:
        rear -= 1

    ret = int(calc(front) * calc(rear))
    return ret


def calc(n):
    if n < 1:
        return 1
    return calc_f(n+2)


def calc_f(n):
    if f[n] == 0:
        f[n] = calc_f(n - 1) + calc_f(n - 2)
    return f[n]


for h in range(1, height + 1):
    for w in range(1, search_range + 1):
        prev_ans = ans[h - 1]
        ans[h][w] = prev_ans[w] * det_unused(w) + prev_ans[w - 1] * det_unused(w, -1) + prev_ans[w + 1] * det_unused(w, 1)
    if search_range < end_w:
        search_range += 1

print(ans[height][k])

Fixed code:
height, width, k = map(int, input().split())

ans = [[0] * (width + 2) for i in range(height + 1)]
start_w = 1
end_w = width
start_h = 0
ans[start_h][start_w] = 1
search_range = start_w + 1 if end_w > 1 else 1
f = [0] * (width + 2)
f[0], f[1], f[2] = 1, 1, 1


def det_unused(n, m=0):
    front = n - (start_w + 1)
    rear = end_w - (n + 1)

    if m == -1:
        front -= 1
    elif m == 1:
        rear -= 1

    ret = int(calc(front) * calc(rear))
    return ret


def calc(n):
    if n < 1:
        return 1
    return calc_f(n+2)


def calc_f(n):
    if f[n] == 0:
        f[n] = calc_f(n - 1) + calc_f(n - 2)
    return f[n]


for h in range(1, height + 1):
    for w in range(1, search_range + 1):
        prev_ans = ans[h - 1]
        ans[h][w] = prev_ans[w] * det_unused(w) + prev_ans[w - 1] * det_unused(w, -1) + prev_ans[w + 1] * det_unused(w, 1)
        ans[h][w] %= 1000000007
    if search_range < end_w:
        search_range += 1

print(ans[height][k])
Buggy code:
import sys
input=sys.stdin.readline
h,w,k = map(int, input().split())

lis = [0]*(w-1)
n = 0
for i in range(2**(w-1)):
    
    tmp = bin(i)[2:].zfill(w-1)
    if '11' in tmp:continue
    n += 1
    for j in range(w-1):
        lis[j] += int(tmp[j])


res = [1]+[0]*(w-1)
for i in range(h):
    res2 = res.copy()
    for j in range(w):
        if j == 0:
            a=0
            x = 0
        else:
            a = lis[j-1]
            x = res[j-1]
        if j== w-1:
            b = 0
            y = 0
        else:
            b = lis[j]
            y = res[j+1]
        res2[j] = x*a + res[j]*(n - a - b) + y*b
    res = res2
print(res[k-1])

Fixed code:
import sys
input=sys.stdin.readline
h,w,k = map(int, input().split())

lis = [0]*(w-1)
n = 0
for i in range(2**(w-1)):
    
    tmp = bin(i)[2:].zfill(w-1)
    if '11' in tmp:continue
    n += 1
    for j in range(w-1):
        lis[j] += int(tmp[j])


res = [1]+[0]*(w-1)
for i in range(h):
    res2 = res.copy()
    for j in range(w):
        if j == 0:
            a=0
            x = 0
        else:
            a = lis[j-1]
            x = res[j-1]
        if j== w-1:
            b = 0
            y = 0
        else:
            b = lis[j]
            y = res[j+1]
        res2[j] = x*a + res[j]*(n - a - b) + y*b
    res = res2
print(res[k-1] % (10**9+7))
Buggy code:
h, w, k = map(int, input().split())
a = [0]*(w-1) + [1]
for i in range(w-1):
    a[i] = a[i-1] + a[i-2]
dp = [0]*(w+1)
tmp = [0]*(w+1)
dp[0] = 1
for _ in range(1, h+1):
    for i in range(w):
        tmp[i] = (dp[i]*a[i-1]*a[w-i-2]
            + dp[i+1]*a[i-1]*a[w-i-3]
            + dp[i-1]*a[i-2]*a[w-i-2]) % (10**9+7)
        tmp[i] %= m
    dp, tmp = tmp, dp
print(dp[k-1])

Fixed code:
m = 10**9+7
h, w, k = map(int, input().split())
a = [0]*(w-1) + [1]
for i in range(w-1):
    a[i] = a[i-1] + a[i-2]
dp = [0]*w
tmp = [0]*w
dp[0] = 1
for _ in range(1, h+1):
    for i in range(w):
        tmp[i] = dp[i]*a[i-1]*a[w-i-2]
        if i != w-1:
            tmp[i] += dp[i+1]*a[i-1]*a[w-i-3]
        if i != 0:
            tmp[i] += dp[i-1]*a[i-2]*a[w-i-2]
        tmp[i] %= m
    dp, tmp = tmp, dp
print(dp[k-1])
Buggy code:
h,w,k = map(int,input().split())
mod = 10 ** 9 + 7
if w == 1:
  print(1)
  exit()
lis = [[0 for i in range(w)] for s in range(h+1)]
lis[0][0] = 1
dp1 = [0 for i in range(w-1)]
dp2 = [0 for i in range(w-1)]
dp1[0] = 0
dp2[0] = 1
for i in range(1,w-1):
  dp1.append(dp2[i-1])
  dp2.append(dp2[i-1] + dp1[i-1])
dp1.insert(0,0)
dp2.insert(0,0)
dp = [dp1[i] + dp2[i] for i in range(w)]
for i in range(h):
  for j in range(w):
    if j == 0 or j == w-1:num = dp[w-1]
    else:num = dp[j] * dp[w-j-1]
    lis[i+1][j] += num * lis[i][j] % mod
    if j != 0:
      lis[i+1][j-1] += max(1,dp[j-1]) * max(1,dp[w-j-1]) * lis[i][j] % mod
    if j != w-1:
      lis[i+1][j+1] += max(1,dp[j]) * max(1,dp[w-j-2]) * lis[i][j] % mod
print(lis[h][k-1] % mod)

Fixed code:
h,w,k = map(int,input().split())
mod = 10 ** 9 + 7
if w == 1:
  print(1)
  exit()
lis = [[0 for i in range(w)] for s in range(h+1)]
lis[0][0] = 1
dp1 = [0]
dp2 = [1]
for i in range(1,w-1):
  dp1.append(dp2[i-1])
  dp2.append(dp2[i-1] + dp1[i-1])
dp1.insert(0,0)
dp2.insert(0,0)
dp = [dp1[i] + dp2[i] for i in range(w)]
for i in range(h):
  for j in range(w):
    if j == 0 or j == w-1:num = dp[w-1]
    else:num = dp[j] * dp[w-j-1]
    lis[i+1][j] += num * lis[i][j] % mod
    if j != 0:
      lis[i+1][j-1] += max(1,dp[j-1]) * max(1,dp[w-j-1]) * lis[i][j] % mod
    if j != w-1:
      lis[i+1][j+1] += max(1,dp[j]) * max(1,dp[w-j-2]) * lis[i][j] % mod
print(lis[h][k-1] % mod)
Buggy code:
MOD = 1000000007
H,W,K=map(int,input().split())
##Precalculation            
num = [[0 for _ in range(W)]for _ in range(W)]
for value in range(2**(W-1)):
    bit = [False for _ in range(W-1)]
    for d in range(W-1):
        bit[d] = (2**d & value) > 0
    duplicate = False
    for d in range(1,W-1):
        if bit[d] and bit[d-1]:
            duplicate = True
            break
    if duplicate:
        break
    ##No Duplicate Assured
    for x in range(W):
        num[x][x] += 1
    for d in range(W-1):
        if bit[d]:
            num[d][d+1] += 1
            num[d+1][d] += 1
            num[d][d] -= 1
            num[d+1][d+1] -= 1
##Time to Dynamic Programming YEAHHHHHH##
dp = [[0 for _ in range(W)] for _ in range(H+1)]
dp[0][0] = 1
for h in range(1,H+1):
    for k in range(W):
        for j in range(W):
            dp[h][k] += (dp[h-1][j]*num[j][k])%MOD
            dp[h][k] %= MOD
print(dp[H][K-1])

Fixed code:
MOD = 1000000007
H,W,K=map(int,input().split())
##Precalculation            
num = [[0 for _ in range(W)] for _ in range(W)]
for value in range(2**(W-1)):
    bit = [False for _ in range(W-1)]
    for d in range(W-1):
        bit[d] = (2**d & value) > 0
    duplicate = False
    for d in range(1,W-1):
        if bit[d] and bit[d-1]:
            duplicate = True
            break
    if duplicate:
        continue
    ##No Duplicate Assured
    for x in range(W):
        num[x][x] += 1
    for d in range(W-1):
        if bit[d]:
            num[d][d+1] += 1
            num[d+1][d] += 1
            num[d][d] -= 1
            num[d+1][d+1] -= 1
##Time to Dynamic Programming YEAHHHHHH##
dp = [[0 for _ in range(W)] for _ in range(H+1)]
dp[0][0] = 1
for h in range(1,H+1):
    for k in range(W):
        for j in range(W):
            dp[h][k] += (dp[h-1][j]*num[j][k])%MOD
            dp[h][k] %= MOD
print(dp[H][K-1])
Buggy code:
H,W,K = [int(i) for i in input().split()]

DP = [[0 for i in range(W)]for j in range(2)]

t = [0 for i in range(W+10)]

t[1] = 1
t[2] = 2
for i in range(2,W+8):
    t[i+1] = t[i] + t[i-1]

#print(t)
n = 0
DP[0][0] = 1
for i in range(H):
    if W == 1:
        break
    DP[not(n)][0] = (DP[n][0] * t[W-1] + DP[n][1] * t[W-2]) % 1000000007
    for i in range(1,W-1):
        DP[not(n)][i] =( DP[n][i-1] *t[W - (i+1)] + DP[n][i]*(t[i-1] + t[W-i]) + DP[n][i+1]*t[i-2] ) % 1000000007
    
    DP[not(n)][W-1] = (DP[n][W-2]*t[W-2] + DP[n][W-1] * t[W-1]) % 1000000007
    n = not(n)
print(DP[n][K])


Fixed code:
H,W,K = [int(i) for i in input().split()]

DP = [[0 for i in range(W)]for j in range(2)]

t = [0 for i in range(W+10)]
t[0]  = 1
t[1] = 1
t[2] = 2
for i in range(2,W+8):
    t[i+1] = t[i] + t[i-1]

#print(t)
n = 0
DP[0][0] = 1
for i in range(H):
    if W == 1:
        break
    DP[not(n)][0] = (DP[n][0] * t[W-1] + DP[n][1] * t[W-2]) % 1000000007
    for i in range(1,W-1):
        DP[not(n)][i] =( DP[n][i-1] *(t[W-i-1] * t[i-1]) + DP[n][i] * (t[i] * t[W-i-1]) + DP[n][i+1]*(t[W-i-2] * t[i])) % 1000000007
    
    DP[not(n)][W-1] = (DP[n][W-2]*t[W-2] + DP[n][W-1] * t[W-1]) % 1000000007
    n = not(n)
print(DP[n][K-1])
Buggy code:
from collections import defaultdict
A = [1, 2, 3, 5, 8, 13, 21]
MOD = 10**9 + 7
H, W, K = map(int, input().split())
W -= 1
K -= 1
if W == 0:
    if K in [0, 1]:
        print(1)
    else:
        print(0)
    exit()
dp = [[0] * (W + 1) for _ in range(H + 1)]
dp[0][0] = 1
for i in range(1, H + 1):
    for j in range(i + 1):
        for k in [-1, 0, 1]:
            if j + k < 0 or W <= j + k: continue
            if j < 0 or W < j: continue
            if k == -1:
                left = max(0, j - 2 - 1)
                right = max(0, W - j - 1)
            elif k == 0:
                left = max(0, j - 2)
                right = max(0, W - j - 1)
            elif k == 1:
                left = max(0, j - 2)
                right = max(0, W - j - 1 - 1)
            dp[i][j] += dp[i - 1][j + k] * A[left] * A[right]
print(dp[H][K] % MOD)

Fixed code:
from collections import defaultdict
A = [1, 2, 3, 5, 8, 13, 21, 34]
MOD = 10**9 + 7
H, W, K = map(int, input().split())
K -= 1
if W == 0:
    print(1)
    exit()
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(1, H + 1):
    for j in range(i + 1):
        for k in [-1, 0, 1]:
            if not 0 <= j + k < W: continue
            if not 0 <= j < W: continue
            if k == -1:
                left = max(0, j - 1 - 1)
                right = max(0, W - j - 2)
            elif k == 0:
                left = max(0, j - 1)
                right = max(0, W - j - 2)
            elif k == 1:
                left = max(0, j - 1)
                right = max(0, W - j - 2 - 1)
            dp[i][j] += dp[i - 1][j + k] * A[left] * A[right]
print(dp[H][K] % MOD)
Buggy code:
# your code goes here
mp={-2:1,-1:1,0:1}
def func(xx,mp):
    if mp.get(xx,0) : return mp[xx]
    mp[xx]=(func(xx-1,mp)+func(xx-2,mp))%1000000007
    return mp[xx]
h,w,k= map(int, input().split())
if w == 1:
    print('1')
    exit(0)
DT = [0 for i in range(w)]
CR =  [0 for i in range(w)]
DT [0]=1
#print(sum(DT),sum(CR))
for _ in range(h):
    for i in range(w-2):
        CR[i]+=DT[i+1]*func(w-4,mp)
        CR[i+1]+=DT[i+1]*func(w-3,mp)
        CR[i+2]+=DT[i+1]*func(w-4,mp)
    CR[0]+=DT[0]*func(w-2,mp)
    CR[1]+=DT[0]*func(w-3,mp)
    CR[-2]+=DT[-1]*func(w-3,mp)
    CR[-1]+=DT[-1]*func(w-2,mp)
    for i in range(w):
        DT[i]=CR[i]%1000000007
        CR[i]=0
    #print(sum(DT))
    #print(DT)
print(DT[k-1])

Fixed code:
# your code goes here
mp={-6:0,-5:0,-4:0,-3:0,-2:0,-1:1,0:1}
def func(xx):
    if mp.get(xx,0)!=0:
        return mp[xx]
    mp[xx]=(func(xx-1)+func(xx-2))%1000000007
    return mp[xx]
h,w,k= map(int, input().split())
if w == 1:
    print('1')
    exit(0)
DT = [0 for i in range(w)]
CR =  [0 for i in range(w)]
DT [0]=1
#print(sum(DT),sum(CR))
for _ in range(h):
    for i in range(w-2):
        CR[i]+=DT[i+1]*func(i-1)*func(w-2-i-1)
        CR[i+1]+=DT[i+1]*func(i)*func(w-2-i-1)
        CR[i+2]+=DT[i+1]*func(i)*func(w-2-i-2)
    CR[0]+=DT[0]*func(w-2)
    CR[1]+=DT[0]*func(w-3)
    CR[-2]+=DT[-1]*func(w-3)
    CR[-1]+=DT[-1]*func(w-2)
    for i in range(w):
        DT[i]=CR[i]%1000000007
        CR[i]=0
    #print(sum(DT))
    #print(DT)
print(DT[k-1])
Buggy code:
import numpy as np
H, W, K = map(int, input().split())
p = 10**9 + 7
r = [1, 1, 2, 3, 5, 8, 13, 21, 34]
dp = np.zeros([H + 1, W], dtype=int)
dp[0, 0] = 1
for h in range(H):
    for w in range(W):
        if w != 0:
            dp[h+1, w] += ((dp[h, w-1] * r[w-1])%p * r[W-1-w])%p
        dp[h+1, w] = ((dp[h, w] * r[w])%p * r[W-1-w])%p
        if w != W-1:
            dp[h+1, w] += ((dp[h, w+1] * r[w])%p * r[W-2-w])%p
        dp[h+1, w] = dp[h+1, w]%p
print(dp[H, K-1])

Fixed code:
import numpy as np
H, W, K = map(int, input().split())
p = 10**9 + 7
r = [1, 1, 2, 3, 5, 8, 13, 21, 34]
dp = np.zeros([H + 1, W], dtype=int)
dp[0, 0] = 1
for h in range(H):
    for w in range(W):
        if w == 0:
            a = 0
        else:
            a = ((dp[h, w-1] * r[w-1])%p * r[W-1-w])%p
        b = ((dp[h, w] * r[w])%p * r[W-1-w])%p
        if w == W-1:
            c = 0
        else:
            c = ((dp[h, w+1] * r[w])%p * r[W-2-w])%p
        dp[h+1, w] = (a+b+c)%p
print(dp[H, K-1])
Buggy code:

H,W,K = list(map(int,input().split()))


amida = [0 for i in range(8)]
amida[0]=1
amida[1]=2
amida[2]=3
amida[3]=5
amida[4]=8
amida[5]=13
amida[6]=21
amida[7]=34

def amida_num(k,l):
    return amida[max(k,0)]*amida[max(l,0)]


dp=[[0 for i in range(W)] for j in range(H+1)]

dp[0][0] = 1

for i in range(1,H+1):
    for j in range(W):
        if j==0:
            dp[i][j]=dp[i-1][j+1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
        elif j==W-1:
            dp[i][j]=dp[i-1][j-1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
        else:
            dp[i][j]=dp[i-1][j-1]*amida_num(j-2,W-j-2) + dp[i-1][j]*amida_num(j-1,W-j-2) + dp[i-1][j+1]*amida_num(j-1,W-j-3)

print(dp[H][K-1]%(10**9+7))

Fixed code:
H,W,K = list(map(int,input().split()))


amida = [0 for i in range(8)]
amida[0]=1
amida[1]=2
amida[2]=3
amida[3]=5
amida[4]=8
amida[5]=13
amida[6]=21
amida[7]=34

def amida_num(k,l):
    return amida[max(k,0)]*amida[max(l,0)]


dp=[[0 for i in range(W)] for j in range(H+1)]

dp[0][0] = 1

if W!=1:
    for i in range(1,H+1):
        for j in range(W):
            if j==0:
                dp[i][j]=dp[i-1][j+1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
            elif j==W-1:
                dp[i][j]=dp[i-1][j-1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
            else:
                dp[i][j]=dp[i-1][j-1]*amida_num(j-2,W-j-2) + dp[i-1][j]*amida_num(j-1,W-j-2) + dp[i-1][j+1]*amida_num(j-1,W-j-3)
    print(dp[H][K-1]%(10**9+7))
else:
    print(1)
Buggy code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

H, W, K = reads()
P = 10**9 + 7

M = W + 100
fib = [0] * M
fib[0] = fib[1] = 1
for i in range(M-2):
  fib[i+2] = (fib[i] + fib[i+1]) % P

@functools.lru_cache(100000)
def solve(h, k):
  if h == 0:
    return 1 if k == 1 else 0
  if k == 1:
    return (solve(h-1, 1) * fib[W-1] + solve(h-1, 2) * fib[W-2]) % P
  elif k == W:
    return (solve(h-1, W) * fib[W-1] + solve(h-1, W-1) * fib[W-2]) % P
  else:
    return (solve(h-1, k) * fib[k-1] * fib[W-k]
      + solve(h-1, k-1) * fib[k-2] * fib[W-k]
      + solve(h-1, k+1) * fib[k-1] * fib[W-k-1]) % P

print(solve(H, K))



Fixed code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

H, W, K = reads()
P = 10**9 + 7

M = W + 100
fib = [0] * M
fib[0] = fib[1] = 1
for i in range(M-2):
  fib[i+2] = (fib[i] + fib[i+1]) % P

@functools.lru_cache(100000)
def solve(h, k):
  if h == 0:
    return 1 if k == 1 else 0
  if k == 1:
    return (solve(h-1, 1) * fib[W-1] + solve(h-1, 2) * fib[W-2]) % P
  elif k == W:
    return (solve(h-1, W) * fib[W-1] + solve(h-1, W-1) * fib[W-2]) % P
  else:
    return (solve(h-1, k) * fib[k-1] * fib[W-k]
      + solve(h-1, k-1) * fib[k-2] * fib[W-k]
      + solve(h-1, k+1) * fib[k-1] * fib[W-k-1]) % P

if W == 1:
  print(1); exit()
print(solve(H, K))
Buggy code:
a, b = map(int, input.split())
print(max(0, a-b))

Fixed code:
a, b =list(map(int, input().split()))
print(max(0, a-b))
Buggy code:
    a,b=map(int,input().split())
    if a<b:
        print("0")
    else:
        print(a-b)

Fixed code:
a,b=map(int,input().split())
if a<b:
    print("0")
else:
    print(a-b)
Buggy code:
X,t = map(int,input.split())
snd = X - t
if X > t:
  print(snd)
else:
  print(0)

Fixed code:
X, t = map(int, input().split())
 
if X >= t:
    print(X - t)
else:
    print(0)
Buggy code:
X,t = map(int,input().split())
ans = X-t
if ans>=0
    print(ans)
else:
    print(0)

Fixed code:
X,t = map(int,input().split())
ans = X-t
if ans>=0:
    print(ans)
else:
    print(0)