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

Fixed submission:
N,M,Q=map(int,input().split())
L = []
for i in range(Q):
  L.append(list(map(int, input().split())))
  L[i][0]-=1
  L[i][1]-=1
 
import itertools
l =list(range(1,M+1))
v=list(itertools.combinations_with_replacement(l,N))
ans=0
for arr in v:
  score=0
  for a,b,c,d in L:
    if (arr[b] - arr[a])==c:      
      score+=d
  ans=max(ans,score)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)
n,m,q = map(int, input().split())
lis = [1 for i in range(n)]
ords = []
cost = []
dp = [-1 for i in range(200)]
ans = 0
for i in range(q):
    o = list(map(int, input().split()))
    ords.append(o[:n])
    cost.append(o[-1])
def checker(p, arr, ans):
    if(dp[p] == ans):
        return dp[p]
    for i in range(n-p-1, -1, -1):
        for c in range(1, m+1):
            arr[p] = c
            temp = 0
            ans = checker(p+1, arr, ans)
            for i in range(q):
                if(arr[ords[i][1]-1]-arr[ords[i][0]-1]==ords[i][2]):
                    temp+=cost[i]
            if(temp > ans):
                ans = temp
            dp[p] = ans
    return ans
print(checker(0, lis, 0))

Buggy submission (verdict: Runtime Error):
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)
n,m,q = map(int, input().split())
lis = [1 for i in range(n)]
ords = []
cost = []
dp = [-1 for i in range(200)]
ans = 0
for i in range(q):
    o = list(map(int, input().split()))
    ords.append(o[:n])
    cost.append(o[-1])
def checker(p, arr, ans):
    if(dp[p] == ans):
        return dp[p]
    for i in range(n-p-1, -1, -1):
        for c in range(m):
            arr[p] = c
            temp = 0
            ans = checker(p+1, arr, ans)
            for i in range(q):
                if(arr[ords[i][1]-1]-arr[ords[i][0]-1]==ords[i][2]):
                    temp+=cost[i]
            if(temp > ans):
                ans = temp
            dp[p] = ans
    return ans
print(checker(0, lis, 0))

Buggy submission (verdict: Runtime Error):
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)
n,m,q = map(int, input().split())
lis = [1 for i in range(n)]
ords = []
cost = []
dp = [200 for i in range(200)]
ans = 0
for i in range(q):
    o = list(map(int, input().split()))
    ords.append(o[:n])
    cost.append(o[-1])
def checker(p, arr, ans):
    if(dp[p]!= 200):
        return dp[p]
    for i in range(n-p-1, -1, -1):
        for c in range(m):
            arr[p] = c
            temp = 0
            ans = checker(p+1, arr, ans)
            for i in range(q):
                if(arr[ords[i][1]-1]-arr[ords[i][0]-1]==ords[i][2]):
                    temp+=cost[i]
            if(temp > ans):
                ans = temp
            dp[p] = ans
    return ans
print(checker(0, lis, 0))
Problem p03107 (python)

Fixed submission:
S=input()
print(2*min(S.count("0"), S.count("1")))

Buggy submission (verdict: Runtime Error):
S=list(input())
c=0
while len(S)>1:
    before=len(S)
    l=0
    # 双方向から見ればループ回数は半分になる？
    for i in range(before//2):
    #for i in range(before-1):
        if S[i]+S[i+1]=="01" or S[i]+S[i+1]=="10":
            c+=2
            #S.pop(i)
            #S.pop(i)
            del S[i:i+2]
            #break
            l=1
        if S[-i-1]+S[-i-2]=="10" or S[-i-1]+S[-i-2]=="01":
            c+=2
            if i==0:
                del S[-i-2:]
            else:
                del S[-i-2:-i]
            break
        if l:
          	break
    if before==len(S):
        break
print(c)
Problem p03803 (python)

Fixed submission:
a,b=map(int,input().split())
def one_14(num):
  if num==1:
    return 14
  else:
    return num
a=one_14(a)
b=one_14(b)
if a > b:
  print("Alice")
elif a < b:
  print("Bob")
else:
  print("Draw")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
def one_14(num):
  if num==1:
    return 14
a=one_14(a)
b=one_14(b)
if a > b:
  print("Alice")
elif b < a:
  print("Bob")
else:
  print("Draw")
Problem p02759 (python)

Fixed submission:
n = int(input())

ans = n//2 + n%2

print(ans)

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

listans = [-1] * n
ans = 0

for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        ans = -1
    if listans[int(s)-1] != c:
        if listans[int(s)-1] == "0":
            listans[int(s)-1] = c
        else :
            ans = -1

if ans == 0:
    if n > 1 and listans[0] == "0":
        listans[0] = "1"
    ans = int("".join([str(li) for li in listans]))

print(ans)
Problem p02847 (python)

Fixed submission:
day = input()

if day == 'SUN' :
    print(7)
elif day == 'MON' :
    print(6)
elif day == 'TUE' :
    print(5)
elif day == 'WED' :
    print(4)
elif day == 'THU' :
    print(3)
elif day == 'FRI' :
    print(2)
elif day == 'SAT' :
    print(1)

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

if day == 'SUN :
    print(7)
elif day == 'MON' :
    print(6)
elif day == 'TUE' :
    print(5)
elif day == 'WED' :
    print(4)
elif day == 'THU' :
    print(3)
elif day == 'FRI' :
    print(2)
elif day == 'SAT' :
    print(1)
Problem p03077 (python)

Fixed submission:
n = int(input())
abc = []
ans = 0

for i in range(5) :
    abc.append(int(input()))

minabc = min(abc)
ans += n//minabc
if n % minabc != 0:
    ans += 1

if minabc >= n :
    print(5)
else :
    print(4 + ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
abc = []
ans = 0

for i in range(5) :
    abc.append(int(input()))

minabc = min(abc)
ans += n//minabc

if x >= n :
    print(5)
else :
    print(5 + ans)
Problem p02819 (python)

Fixed submission:

import math

X = int(input())

#xが素数か判定する    
def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False
    
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2    
    return True

for i in range(X,10**10):
    if isPrime(i):
        print(i)
        break

Buggy submission (verdict: Runtime Error):

import math

X = int(input())
  
#素数判定
#Nが素数か True/False で返す
#O(√N)
def is_prime(N):
    if N == 1:
        return False
    for i in range(2,N+1):
        #調べるのはNの1/2乗まででよい
        if i * i > N:
            break
        #割り切れたら素数じゃない
        if N % i == 0:
            return False
    
    return True

for i in range(X,10**10):
    if isPrime(i):
        print(i)
        break
Problem p02831 (python)

Fixed submission:

import math
import fractions

x,y = map(int,input().split())

print((x * y) // fractions.gcd(x, y))

Buggy submission (verdict: Runtime Error):

#ユークリッドの互除法( A < B　とし, O(logA))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

#3個以上の最大公約数を求める必要がある
# res=0 と初期化して、res=gcd(res,x[i])と更新する
# gcd(a,b,c,....) → gcd(gcd(gcd(a,b),c),...) 
res = 0
x = list(map(int,input().split()))

for i in range(N):
    res = gcd(res,abs(x[i] - X))

print(res)

Buggy submission (verdict: Runtime Error):

import math

x,y = map(int,input().split())

print((x * y) // math.gcd(x, y))
Problem p02990 (python)

Fixed submission:

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

for i in range(1,k+1):
    if n - k + 1 >= i:
        print(( cmb(n-k+1,i) * cmb(k-1,i-1) ) % (10**9+7))
    #青を分けようとするけど赤玉の隙間がたらないとき
    else:
        print(0)

Buggy submission (verdict: Runtime Error):

# 再帰制限に引っかかった場合に外す
import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

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

for i in range(1,k+1):
    print(( cmb(n-k+1,i) * cmb(k-1,i-1) ) % (10**9+7))

Buggy submission (verdict: Runtime Error):

# 再帰制限に引っかかった場合に外す
import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

a = cmb(n,r)


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

for i in range(1,k+1):
    print(( cmb(n-k+1,i) * cmb(k-1,i-1) ) % (10**9+7))

Buggy submission (verdict: Runtime Error):

from operator import mul
from functools import reduce

import sys

sys.setrecursionlimit(20000000)

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


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

for i in range(1,k+1):
    print(( cmb(n-k+1,i) * cmb(k-1,i-1) ) % (10**9+7))

Buggy submission (verdict: Runtime Error):

from operator import mul
from functools import reduce

import sys

sys.setrecursionlimit(20000)

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


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

for i in range(1,k+1):
    print(( cmb(n-k+1,i) * cmb(k-1,i-1) ) % (10**9+7))

Buggy submission (verdict: Runtime Error):

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


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

for i in range(1,k+1):
    print(( cmb(n-k+1,i) * cmb(k-1,i-1) ) % (10**9+7))
Problem p03038 (python)

Fixed submission:

#AのリストにCのリストを加えて大きい順に並べ替えてNまでの和を求める
N,M = map(int,input().split())

#Aの入力
A_list = list(map(int,input().split()))

C_list = []

#Cのリストに追加する
for i in range(M):
    bi,ci = map(int,input().split())
    C_list.append([bi,ci])

#C_listをCの値でソート
C_list=sorted(C_list, reverse=True, key=lambda x:x[1])

count = 0
for bi,ci in C_list:
    count += bi
    if count > N:
        #countがNより大きくなったらNより大きくなった分だけ使う
        bi = N - count + bi
    A_list.extend([ci]*bi)

#A_Listを大きい順に並べ替える
A_list=sorted(A_list,reverse=True)

#N番目までの総和を求める
print(sum(A_list[0:N]))

Buggy submission (verdict: Runtime Error):

import copy

N,M = map(int,input().split())

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

B =[]
C =[]

tA = []
ans = sum(A)

for i in range(M):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)

for i in range(N):
    for j in range(M):
        tA = copy.copy(A)
        for k in range(B[j]):
            if tA[i] < C[k]:
                tA[i] = C[k]
        if sum(tA) > ans:
            ans = sum(tA)

print (ans)

Buggy submission (verdict: Runtime Error):

import copy

N,M = map(int,input().split())

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

B =[]
C =[]

tA = []
ans = sum(A)

for i in range(M):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)

for i in range(N):
    for j in range(M):
        tA = copy.copy(A)
        for k in range(B[j]):
            if tA[i] < C[k]:
                tA[i] = C[k]
        if sum(tA) > ans:
            ans = sum(tA)

print (ans)
Problem p02699 (python)

Fixed submission:
s,w=(int(x) for x in input().split())
if(s<=w):
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
s=int(input())
w=int(input())
if(s<=w):
  print("unsafe")
else:
  print("safe")
Problem p02572 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sum_n[0] = l[0]
sumall = sum(l)
for i in range(1,n):
    sum_n[i] = sum_n[i-1] + l[i]
for i in range(n):
    ans += ((l[i]*(sumall-sum_n[i]))%1000000007)
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += ((l[i]*sum(l[i+1:n]))%1000000007
print(ans%1000000007)
Problem p02578 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = 0
 
for i in range(n-1):
  if A[i]>A[i+1]:
    ans += A[i]-A[i+1]
    A[i+1] = A[i]
 
print(ans)

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

for i in range(n):
  if A[i]>A[i+1]:
    A[i+1]=A[i]
    ans += A[i]-A[i+1]

print(ans)
Problem p02594 (python)

Fixed submission:
x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
int x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
int x = int(input())
if x >= 30:
  print("yes")
else:
  print("no")
Problem p02595 (python)

Fixed submission:
import math

info = list(map(int, input().split()))
num = info[0]
dis = info[1]
A = [list(map(int, input().split())) for i in range(num)]
disA = [math.sqrt(A[i][0]**2 + A[i][1]**2) for i in range(num)]
cnt = 0 
for i in range(num):
    if disA[i] <= dis:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math

info = list(map(int, input().split()))
num = info[0]
dis = info[1]
A = [list(map(int, input().split())) for i in range(num)]
disA = [math.squart(A[i][0]^2 + A[i][1]^2) for i in range(num)]
cnt = 0 
for i in range(num):
    if disA <= dis:
        cnt += 1
print(cnt)
Problem p02659 (python)

Fixed submission:
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(str(A*B))
ans = 0
if len(prd) < 3:
    ans = 0
else:
    prd.pop()
    prd.pop()
    ans = int(''.join(prd))
print(ans)

Buggy submission (verdict: Runtime Error):
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(str(A*B))
ans = 0
if len(prd) < 3:
    ans = 0
else:
    prd.pop(-1,-2)
    ans = int(''.join(prd))
print(ans)

Buggy submission (verdict: Runtime Error):
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(string(A*B))
ans = int(prd[0]+prd[1]+prd[2])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = list(input().split())
A = int(N[0])
B = int(N[0])*100 + int(N[2])*10 + int(N[3])
prd = A*B/100
prd = math.floor(prd)
print(prd)
Problem p03317 (python)

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

print(-((1-n)//(k-1)))

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

if (n-1)%%(k-1) == 0:
  print(n-1/k-1)
else:
  print((n-1//k-1)+1)
Problem p03013 (python)

Fixed submission:
from itertools import accumulate
n,m=map(int,input().split())
dp=[0]*(n+1)
List=[int(input()) for i in range(m)]
List.sort()
step=0

dp[0]=1
dp[1]=1

if(m>0 and List[0]==1):
    dp[1]=0
    step+=1
for i in range(2,n+1):
    # print(i,step)
    if(step<m and i==List[step]):
        step+=1
        dp[i]=0
    else:
        dp[i]=dp[i-2]+dp[i-1]
# print(List)
# print(dp)
print(dp[n]%((10**9)+7))

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n,m=map(int,input().split())
dp=[0]*(n+1)
List=[int(input()) for i in range(m)]
List.sort()
step=0

dp[0]=1
dp[1]=1

if(List[0]==1):
    dp[1]=0
    step+=1
for i in range(2,n+1):
    # print(i,step)
    if(step<m and i==List[step]):
        step+=1
        dp[i]=0
    else:
        dp[i]=dp[i-2]+dp[i-1]
# print(List)
# print(dp)
print(dp[n]%((10**9)+7))
Problem p02595 (python)

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

ans = 0
for i in range(n):
    x, y = map(int, input().split())
    if x ** 2 + y ** 2 <= d ** 2:
        ans += 1

print(ans)

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

ans = 0
for i in range(n):
    x, y = map(int, input())
    if x ** 2 + y ** 2 <= d:
        ans += 1

print(ans)
Problem p02711 (python)

Fixed submission:
n = input()
if '7' in n:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
if '7' in j:
  print("Yes")
else:
  print("No")
Problem p02712 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(n+1):
  if not (i % 3 == 0 or i % 5 == 0):
    ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(n+1):
  if not (i % 3 == 0 or i % 5 == 0):
	ans += i
   
print(ans)
Problem p02766 (python)

Fixed submission:
n, k = map(int, input().split())
count = 0

while n > 0:
    n = n // k
    count += 1

print(count)

Buggy submission (verdict: Runtime Error):
314159265 3
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())

print(a * b //gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())

print(a * b //math.gcd(a,b))
Problem p02897 (python)

Fixed submission:
n = int(input())

if n == 1:
    print(1)
elif n % 2 == 0:
    print(0.5)
else:
    print(((n+1) / 2) / n)

Buggy submission (verdict: Runtime Error):
import sys

import numpy as np
from math import gcd

a, b = map(int, sys.stdin.readline().split())

U = gcd(a, b)

is_prime = np.zeros(10**6, dtype=bool)
is_prime[2] = True
is_prime[3::2] = True

for i in range(int(np.sqrt(U))):
    if is_prime[i]:
        is_prime[2 * i::i] = False
    
primes = is_prime.nonzero()[0]
ans = (U % primes == 0).sum()

if U != 1:
    ans += 1
print(ans)
Problem p03053 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
m = [list(input()) for _ in range(h)]

flag = [[True] * w for _ in range(h)]

q = deque()

for i in range(h):
    for j in range(w):
        if m[i][j] == "#":
            q.appendleft((i, j, 0))
            flag[i][j] = False

ans = 0
while q:
    (i, j, n) = q.pop()
    ans = n
    for dx, dy in zip([1,0, -1, 0], [0, 1, 0, -1]):
        ni = i + dx
        nj = j + dy
        if (0 <= ni < h and 0 <= nj < w and flag[ni][nj]):
            flag[ni][nj] = False
            q.appendleft((ni, nj, n + 1))

print(ans)

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

h, w = map(int, input().split())
m = np.array([list(input()) for _ in range(h)])

black_loc = []
for i in range(h):
    for j in range(w):
        if m[i][j] == "#":
            black_loc.append((i, j))

ans = 0
for i in range(h):
    for j in range(w):
        if m[i][j] == ".":
            tmp = 1000000000
            for (b_h, b_w) in black_loc:
                tmp = min(tmp, abs(i - b_h) + abs(j - b_w))
            ans = max(ans, tmp)

print(ans)
Problem p03803 (python)

Fixed submission:
import sys

a,b = map(int, sys.stdin.readline().split())

if a == 1:
    a = 14
if b == 1:
    b = 14

if a > b:
    print("Alice")
elif a == b:
    print("Draw")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
import sys

a,b = map(int, sys.stdin.readline().split())

if a == 1:
    a = 14
if b == 1:
    b = 14:

if a > b:
    print("Alice")
elif a == b:
    print("Draw")
else:
    print("Bob")
Problem p02552 (python)

Fixed submission:
x = int(input())

if x == 1:
  print(0)
if x == 0:
  print(1)

Buggy submission (verdict: Runtime Error):
if x=1:
  print(0)
if x=0:
  print(1)
Problem p02679 (python)

Fixed submission:
from collections import defaultdict
from math import gcd

mod = 10 ** 9 + 7
n = int(input())
fishes = defaultdict(int)
zero_zero = 0
zero = 0
inf = 0

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero_zero += 1

    elif a == 0:
        zero += 1

    elif b == 0:
        inf += 1

    else:
        div = gcd(a, b)
        a //= div
        b //= div
        if b < 0:
            a *= -1
            b *= -1
        key = (a, b)
        fishes[key] += 1


def get_bad_pair(fish):
    a, b = fish
    if a < 0:
        a *= -1
        b *= -1
    return (-b, a)


ans = 1
counted_key = set()
for fish_key, count in fishes.items():
    if fish_key in counted_key:
        continue

    bad_pair = get_bad_pair(fish_key)
    if bad_pair in fishes:
        pair_count = fishes[bad_pair]
        pattern = pow(2, count, mod) + pow(2, pair_count, mod) - 1
        counted_key.add(bad_pair)

    else:
        pattern = pow(2, count, mod)

    ans = ans * pattern % mod

ans *= pow(2, zero, mod) + pow(2, inf, mod) - 1
if zero_zero:
    ans += zero_zero

ans -= 1
print(ans % mod)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from fractions import Fraction
import sys
input = sys.stdin.readline

mod = 1000000007
n = int(input())

a_per_b = defaultdict(int)
minus_b_per_a = defaultdict(int)

for _ in range(n):
    a, b = map(int, input().split())
    x = Fraction(a, b)
    y = -Fraction(b, a)
    a_per_b[x] += 1
    minus_b_per_a[y] += 1


def inverse(f):
    return Fraction(f.denominator, f.numerator)


ans = 1
calculated = set()
for key, count in a_per_b.items():
    if key in calculated:
        continue

    if key in minus_b_per_a:
        bad_count = minus_b_per_a[key]
        ans *= pow(2, count+bad_count, mod) - (pow(2, count, mod) - 1) * (pow(2, bad_count, mod) - 1) % mod
        ans %= mod
        calculated.add(-inverse(key))
    else:
        ans *= pow(2, count, mod)
        ans %= mod

print(ans - 1)
Problem p02835 (python)

Fixed submission:
A = list(map(int, input().split()))
if sum(A) >= 22:
    print('bust')
else:
    print('win')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
inf = float('INF')
A = []
B = []

for i in range(h):
    line = list(map(int, input().split()))
    A.append(line)

for i in range(h):
    line = list(map(int, input().split()))
    B.append(line)

D = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        D[i][j] = abs(A[i][j] - B[i][j])


def slide_down(y, x, possible: set):
    new = set()
    delta = D[y+1][x]
    for num in possible:
        if num + delta <=6400:
            new.add(num+delta)
        if abs(num-delta) <= 6400:
            new.add(abs(num-delta))
    return new


def slide_right(y, x, possible: set):
    new = set()
    delta = D[y][x+1]
    for num in possible:
        if num + delta <=6400:
            new.add(num+delta)
        if abs(num-delta) <=6400:
            new.add(abs(num-delta))
    return new


DP = [[set() for j in range(w)] for i in range(h)]
DP[0][0] = {D[0][0]}
for row in range(h):
    for col in range(w):
        possible = DP[row][col]
        if col < w-1:
            new = slide_right(row, col, possible)
            DP[row][col+1] |= new
        if row < h-1:
            new = slide_down(row, col, possible)
            DP[row+1][col] |= new

ans = min(DP[h-1][w-1])
print(ans)