qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
n = n

c = 0
m = 100
while True:
    m = m * 1.01
    c += 1
    if m > n:
        break
print(c)
    

Fixed code:
n = int(input())

c = 0
m = 100
while True:
    m = m * 1.01
    m = int(m)
    c += 1
    if m >= n:
        break
print(c)
Buggy code:

X = int(input())
m = 100
y = 0
while True:
    if X <= m: break
    m = math.floor(m * 1.01)
    y += 1
print(y)


Fixed code:
import math

X = int(input())
m = 100
y = 0
while True:
    if X <= m: break
    m = math.floor(m * 1.01)
    y += 1
print(y)
Buggy code:
x = int(input())/100

amt=100

t=0
while(amt<x):
  amt+= amt//100
  t+=1
  
print(t)

Fixed code:
x = int(input())
 
amt=100
 
t=0
while(amt<x):
  amt+= amt//100
  t+=1
  
print(t)
Buggy code:
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

X = inp()
yen = 100
for i in range(10**4):
    yen += (yen // 100)
    if yen >= X:
        print(i)
        break

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Fixed code:
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

X = inp()
yen = 100
for i in range(10**4):
    yen += (yen // 100)
    if yen >= X:
        print(i+1)
        break

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)
Buggy code:
X = int(input())

now = 0
cnt = 0
while now < X:
  cnt += 1
  now = int(now*1.01)
print(cnt)

Fixed code:
X = int(input())
 
now = 100
cnt = 0
while now < X:
  cnt += 1
  now += int(now*0.01)
print(cnt)
Buggy code:
X = int(input())
 
Deposit = 100
ans = 0
 
while Deposit < X:
  Deposit *= 1.01
  ans += 1
  
print(ans)

Fixed code:
X = int(input())
 
Deposit = 100
ans = 0
 
while Deposit < X:
  Deposit = int(Deposit * 1.01)
  ans += 1
  
print(ans)
Buggy code:
X = int(input())
i = 0
K = 100

while K < X:
  K = K*1.01
  K = round(K)
  i = i + 1
  
print(i)

Fixed code:
X = int(input())
i = 0
K = 100
 
while K < X:
  i = i + 1
  K = int(K*1.01)
  
print(i)
Buggy code:
x = int(input())
m = 100
ans = 0
while m <= x:
  m += m//100
  ans += 1
print(ans)

Fixed code:
x = int(input())
m = 100
ans = 0
while m < x:
  m += m//100
  ans += 1
print(ans)
Buggy code:
x = int(input())
c = 100
r = 0
while c <= x:
    c = int(c*1.01)
    r += 1
print(r)

Fixed code:
x = int(input()) 
c = 100
r = 0
while c < x:
    c = c + int(c*0.01)
    r += 1
print(r)
Buggy code:
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()

x = int(input())

p = 100
year = 0
while p<=x:
  p = p*(1.01)
  p //= 1
  year += 1
print(year)

Fixed code:
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()

x = int(input())

p = 100
year = 0
while p<x:
  p = p*(1.01)
  p //= 1
  year += 1
print(year)
Buggy code:
import math

A = int(input())
X = 0
N = 100

while N < A:
    N = N * 1.01
    math.floor(N)
    X += 1
    
    # print(N)
    
print(X)
    

Fixed code:
import math

A = int(input())
X = 0
N = 100

while N < A:
    N = N * 1.01
    N = math.floor(N)
    X += 1
    
    # print(N)
    
print(X)
Buggy code:
x = int(input())
m = 100
year = 0
while m <= x:
    year += 1
    m *= 1.01
    m = int(m)
print(year)

Fixed code:
x = int(input())
m = 100
year = 0
while m < x:
    year += 1
    m *= 1.01
    m = int(m)
print(year)
Buggy code:
x=int(input())
c=0
k=100
while(k<x):
    k+=k/100
    print(k)
    c+=1
print(c)

Fixed code:
x=int(input())
c=0
k=100
while(k<x):
    k+=k//100
    c+=1
print(c)
Buggy code:
c = 100
y = 0
x = int(input())
while True:
    if c>x:
        print(y)
        break
    c = int(c*1.01)
    y += 1

Fixed code:
c = 100
y = 0
x = int(input())
while True:
    if c>=x:
        print(y)
        break
    c = int(c*1.01)
    y += 1
Buggy code:
x = int(input())

a = 100
i = 0
while True:
	i += 1
	a = int(a * 1.01)
	if(x < a):
		print(i)
		break


Fixed code:
x = int(input())

a = 100
i = 0
while True:
	i += 1
	a = int(a * 1.01)
#	print(a)
	if(x <= a):
		print(i)
		break
Buggy code:
n = int(input())
res = 100
a = 0

while res < n:
  res = res * 1.01
  a += 1
print(a)

Fixed code:
n = int(input())
res = 100
a = 0

while res < n:
  res = int(res * 1.01)
  a += 1
print(a)
Buggy code:
import sys
from itertools import combinations_with_replacement as cwr
input = sys.stdin.readline

def dfs(n,m):
    adj = {}
    for i in range(1,m+1):
        adj[i] = [j for j in range(i,m+1)]
    
    stack = [[i] for i in range(1,m+1)]
    combs = []
    while stack:
        node = stack.pop()
        if len(node) == n:
            combs.append(node)
        else:
            for child in adj[node[-1]]:
                cand = node+[child]
                stack.append(cand)
    return combs


N,M,Q = map(int,input().split())
A,B,C,D = [],[],[],[]
for i in range(Q):
    a,b,c,d = map(int,input().split())
    a,b = a-1, b-1
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

ans = 0
combs = dfs(N,M)
#combs = cwr(range(1,M+1),N)
print(combs)
ans = [0]*(len(combs))
for i,comb in enumerate(combs):
    for a,b,c,d in zip(A,B,C,D):
        if comb[b] - comb[a] ==c:
            ans[i] += d
print(max(ans))



Fixed code:
import sys
from itertools import combinations_with_replacement as cwr
input = sys.stdin.readline

def dfs(n,m):
    adj = {}
    for i in range(1,m+1):
        adj[i] = [j for j in range(i,m+1)]
    
    stack = [[i] for i in range(1,m+1)]
    combs = []
    while stack:
        node = stack.pop()
        if len(node) == n:
            combs.append(node)
        else:
            for child in adj[node[-1]]:
                cand = node+[child]
                stack.append(cand)
    return combs


N,M,Q = map(int,input().split())
A,B,C,D = [],[],[],[]
for i in range(Q):
    a,b,c,d = map(int,input().split())
    a,b = a-1, b-1
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

ans = 0
combs = dfs(N,M)
#combs = cwr(range(1,M+1),N)
# print(combs)
ans = [0]*(len(combs))
for i,comb in enumerate(combs):
    for a,b,c,d in zip(A,B,C,D):
        if comb[b] - comb[a] ==c:
            ans[i] += d
print(max(ans))
Buggy code:
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M, Q = map(int, readline().split())

kumi = []
for _ in range(Q):
    tmp = list(map(int, readline().split()))
    kumi.append(tmp)

ans = 0
res = []
def F(l):
    if len(l) == N:
        ans = 0
        for i in range(Q):
            a, b, c, d = kumi[i]
            if l[b-1] - l[a-1] == c:
                ans += d
        yield ans
        return
    for i in range(M):
        l.append(i)
        yield from F(l)
        l.pop()

ans = max(F([]))
print(ans)

Fixed code:
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M, Q = map(int, readline().split())

kumi = []
for _ in range(Q):
    tmp = list(map(int, readline().split()))
    kumi.append(tmp)

ans = 0
res = []
def F(l):
    if len(l) == N:
        ans = 0
        for i in range(Q):
            a, b, c, d = kumi[i]
            if l[b-1] - l[a-1] == c:
                ans += d
        yield ans
        return
    start = l[-1] if len(l) else 0
    for i in range(start, M):
        l.append(i)
        yield from F(l)
        l.pop()
    
ans = max(F([]))
print(ans)
Buggy code:
import itertools
N, M, Q = map(int, input().split())
A = []
for i in range(0, Q):
        a, b, c, d = map(int,input().split())
        A.append([a,b,c,d])

nums = []
for i in range(1, M+1):
        nums.append(i)

ans_l = [0]
for A_n in itertools.combinations(nums, N):
        ans = 0
        for i in range(0, Q):
                if( A_n[(A[i][1] - 1)] - A_n[(A[i][0] - 1)] == A[i][2]):
                        ans += A[i][3]
        ans_l.append(ans)

print(max(ans_l))

Fixed code:
import itertools
N, M, Q = map(int, input().split())
A = []
for i in range(0, Q):
        a, b, c, d = map(int,input().split())
        A.append([a,b,c,d])

nums = []
for i in range(1, M+1):
        nums.append(i)

ans_l = [0]
for A_n in itertools.combinations_with_replacement(nums, N):
        # print(A_n)
        ans = 0
        for i in range(0, Q):
                if A_n[(A[i][1] - 1)] - A_n[(A[i][0] - 1)] == A[i][2]:
                        # print(A_n[(A[i][1] - 1)], A_n[(A[i][0] - 1)], A[i][2], A[i][3])
                        ans += A[i][3]
        ans_l.append(ans)

# print(ans_l)
print(max(ans_l))
Buggy code:
import sys
import math
import itertools

def main():
    input = sys.stdin.readline
    N, M, Q = map(int, input().split())
    A = list(itertools.combinations(range(1, M+1), N))
    l = []
    m = 0
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        l.append([a, b, c, d])
    for a_list in A:
        tmp = 0
        for i in l:
            if a_list[i[1] -1] - a_list[i[0] - 1] == i[2]:
                tmp += i[3]
        if tmp > m:
            m = tmp
    return m


if __name__ == '__main__':
    print(main())



Fixed code:
import sys
import itertools

def main():
    input = sys.stdin.readline
    N, M, Q = map(int, input().split())
    data = range(1, M+1)
    A = list(itertools.combinations_with_replacement(range(1, M+1), N))
    l = []
    m = 0
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        l.append([a, b, c, d])
    for a_list in A:
        tmp = 0
        for i in l:
            if a_list[i[1] -1] - a_list[i[0] - 1] == i[2]:
                tmp += i[3]
        if tmp > m:
            m = tmp
    return m


if __name__ == '__main__':
    print(main())
Buggy code:
N, M, Q = map(int, input().split())

query = []
for i in range(Q):
    a, b, c, d = map(int, input().split())
    query.append([a, b, c, d])


def calcPoint(num):
    ret = 0
    for q in range(Q):
        if num[query[q][1] - 1] - num[query[q][0] - 1] == query[q][2]:
            ret += query[q][3]

    return ret


ans = 0


def dfs(suu, keta):
    global ans
    if keta == N:
        ans = max(ans, calcPoint(suu))
        print(*suu)
        return

    co = suu.copy()

    for i in range(suu[keta - 1], M):
        co[keta] = i
        dfs(co, keta + 1)


retsu = [0] * N

dfs(retsu, 1)
print(ans)

Fixed code:
N, M, Q = map(int, input().split())

query = []
for i in range(Q):
    a, b, c, d = map(int, input().split())
    query.append([a, b, c, d])


def calcPoint(num):
    ret = 0
    for q in range(Q):
        if num[query[q][1] - 1] - num[query[q][0] - 1] == query[q][2]:
            ret += query[q][3]

    return ret


ans = 0


def dfs(suu, keta):
    global ans
    if keta == N:
        ans = max(ans, calcPoint(suu))
        # print(*suu)
        return

    co = suu.copy()

    for i in range(suu[keta - 1], M):
        co[keta] = i
        dfs(co, keta + 1)


retsu = [0] * N

dfs(retsu, 1)
print(ans)
Buggy code:
import sys
import itertools
import collections
# X = int(input())
N, M, Q = map(int, input().split())
As =[0]
Bs =[0]
Cs =[0]
Ds =[0]

for i in range(Q):
	a, b, c, d = map(int, input().split())
	As.append(a)
	Bs.append(b)
	Cs.append(c)
	Ds.append(d)

lst = range(1, M+1)
AAss = list(itertools.combinations(lst, N))

rCs = collections.Counter()
for i, c in enumerate(Cs):
	# print(i)
	rCs[c] = Ds[i]
max_score = 0
# print("rCs")
# print(rCs)
for AAs in AAss:
	score = 0
	# print("AAs")
	# print(AAs)
	AAs = [0] + list(AAs)
	# print(AAs)
	for i in range(1,Q+1):
		# print("AAs[Bs[i]] - AAs[As[i]]")
		# print(AAs[Bs[i]] - AAs[As[i]])
		score += rCs[AAs[Bs[i]] - AAs[As[i]]]
		# print("dif_score")
		# print(rCs[AAs[Bs[i]] - AAs[As[i]]])

	if score > max_score:
		max_score = score
	# print("score")
	# print(score)
print(max_score)

Fixed code:
import sys
import itertools
import collections
# X = int(input())
N, M, Q = map(int, input().split())
As =[0]
Bs =[0]
Cs =[0]
Ds =[0]
 
for i in range(Q):
	a, b, c, d = map(int, input().split())
	As.append(a)
	Bs.append(b)
	Cs.append(c)
	Ds.append(d)
 
lst = range(1, M+1)
AAss = list(itertools.combinations_with_replacement(lst, N))

rCs = collections.Counter()
# for i, c in enumerate(Cs):
	# print(i)
	# rCs[c] = Ds[i]
max_score = 0
# print("rCs")
# print(rCs)
for AAs in AAss:
	score = 0
	# print("AAs")
	# print(AAs)
	AAs = [0] + list(AAs)
	for i in range(1,Q+1):
		# print("AAs[Bs[i]] - AAs[As[i]]")
		# print(AAs[Bs[i]] - AAs[As[i]])
		if Cs[i] == AAs[Bs[i]] - AAs[As[i]]:
			score+=Ds[i]
		# print("dif_score")
 
	if score > max_score:
		max_score = score
	# print("score")
	# print(score)
print(max_score)
Buggy code:
import itertools as it

n,m,q = map(int, input().split())
l = [list(map(int, input().split())) for i in range(q)]
ans = 0

for v in list(it.product(range(1,m+1),repeat=n)):
    num = 0
    for w in l:
        x,y,z = w[0]-1,w[1]-1,w[2]
        if v[y] - v[x] == z:
            num += w[3]
    if num > ans:
        ans = num
print(ans)

Fixed code:
import itertools as it
 
n,m,q = map(int, input().split())
l = [list(map(int, input().split())) for i in range(q)]
ans = 0
 
for v in list(it.combinations_with_replacement(range(1,m+1),n)):
    num = 0
    for w in l:
        x,y,z = w[0]-1,w[1]-1,w[2]
        if v[y] - v[x] == z:
            num += w[3]
    if num > ans:
        ans = num
print(ans)
Buggy code:
import itertools
n, m, q = map(int, input().split())
A = itertools.product(range(1, m + 1), repeat=m)
quads = [[int(i) for i in input().split()] for j in range(q)]
max_p = 0
for a in A:
    p = 0
    for quad in quads:
        if a[quad[1] - 1] - a[quad[0] - 1] == quad[2]:
            p += quad[3]
    if max_p < p:
        max_p = p
print(max_p)

Fixed code:
import itertools
n, m, q = map(int, input().split())
A = itertools.combinations_with_replacement(range(1, m+1), n)
quads = [[int(i) for i in input().split()] for j in range(q)]
max_p = 0
for a in A:
    p = 0
    for quad in quads:
        if a[quad[1] - 1] - a[quad[0] - 1] == quad[2]:
            p += quad[3]
    if max_p < p:
        max_p = p
print(max_p)
Buggy code:
 n, m, q = map(int, input().split())
 T = []
 for i in range(q):
     a, b, c, d = map(int, input().split())
     T.append((a-1, b-1, c, d))
 
 L = []
 def f(l):
     if len(l) == n+1:
         L.append(l[1:])
         return
     for i in range(l[-1], m + 1):
         f(l + [i])
	f([1])
 
 print(max(sum(d for a, b, c, d in T if l[b] - l[a] == c)) for l in L)

Fixed code:
n, m, q = map(int, input().split())
T = []
for i in range(q):
    a, b, c, d = map(int, input().split())
    T.append((a - 1, b - 1, c, d))

L = []
def f(l):
    if len(l) == n + 1:
        L.append(l[1:])
        return
    for i in range(l[-1], m + 1):
        f(l + [i])
f([1])

print(max(sum(d for a, b, c, d in T if l[b] - l[a] == c) for l in L))
Buggy code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**6)

n,m,q = map(int,input().split())
E = [list(map(int,input().split())) for i in range(q)]
def dfs(l,string):
  global ans
  if l == n: ans = max(ans,check(string));return
  for i in range(int(string[-1]),m+1):
    dfs(l+1,string+str(i))

def check(string):
  print(string)
  re = 0
  for a,b,c,d in E:
    if int(string[b])-int(string[a]) == c:
      re += d
  return re
dfs(0,"1")
print(ans)

Fixed code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**6)

n,m,q = map(int,input().split())
E = [list(map(int,input().split())) for i in range(q)]
def dfs(l,string):
  if l == n:
    global ans
    ans = max(ans,check(string));return
  for i in range(int(string[-1]),m+1):
    dfs(l+1,(string+[str(i)]).copy())

def check(string):
  global count
  count += 1
  re = 0
  for a,b,c,d in E:
    if int(string[b])-int(string[a]) == c:
      re += d
  # print(string,re)
  return re
dfs(0,[1])
print(ans)
# print(count)
Buggy code:
from itertools import product

n, m, q = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(q)]

temp = list(combinations([i for i in range(1,m+1)],n))


ans = 0

for a_temp in temp:
    ans_temp = 0
    for i in range(q):
        if a_temp[a[i][1]-1] - a_temp[a[i][0]-1] == a[i][2]:
            ans_temp += a[i][3]
    if ans < ans_temp:
        ans = ans_temp
print(ans)

Fixed code:
from itertools import combinations_with_replacement

n, m, q = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(q)]

temp = list(combinations_with_replacement([i for i in range(1,m+1)],n))

ans = 0

for a_temp in temp:
    ans_temp = 0
    for i in range(q):
        if a_temp[a[i][1]-1] - a_temp[a[i][0]-1] == a[i][2]:
            ans_temp += a[i][3]
    if ans < ans_temp:
        ans = ans_temp
        
print(ans)
Buggy code:
n, m, q = map(int,input().split())
abcd = []
for _ in range(q):
    a, b, c, d = map(int,input().split())
    abcd.append([a,b,c,d])

a_l = [1] * n
ans = 0
while True:
    if a_l == [m]*n:
        break
    ans_tmp = 0
    for i in range(q):
        a = abcd[i][0]
        b = abcd[i][1]
        c = abcd[i][2]
        d = abcd[i][3]
        if a_l[b-1] - a_l[a-1] == c:
            ans_tmp += d
    ans = max(ans,ans_tmp)
    for i in range(1,n+1):
        a_l[-i] += 1
        if a_l[-i] == m+1:
            a_l[-i] = 1
            continue
        else:
            break

print(ans)

Fixed code:
n, m, q = map(int,input().split())
abcd = []
for _ in range(q):
    abcd.append(list(map(int,input().split())))

a_l = [1] * n
ans = 0
while True:
    ans_tmp = 0
    for a, b, c, d in abcd:
        if a_l[b-1] - a_l[a-1] == c:
            ans_tmp += d
    ans = max(ans,ans_tmp)
    if a_l == [m]*n:
        break
    for i in range(1,n+1):
        a_l[-i] += 1
        if a_l[-i] == m+1:
            a_l[-i] = 1
            continue
        else:
            break
    for i in range(1,n):
        while a_l[i-1] > a_l[i]:
            a_l[i] += 1

print(ans)
Buggy code:
from itertools import product
def score_check(A,L):
    point = 0
    for a, b, c, score in L:
        temp = A[b - 1] - A[a - 1]
        if temp == c:point += score

    return point

n, m, q = map(int,input().split())
l = [list(map(int,input().split())) for i in range(q)]

num = 0
for i in product(list(range(1, m + 1)), repeat = n):
    #print(i)
    temp = score_check(i, l)
    if num < temp:num = temp
print(num)

Fixed code:
from itertools import combinations_with_replacement
def score_check(A,L):
    point = 0
    for a, b, c, score in L:
        temp = A[b - 1] - A[a - 1]
        if temp == c:point += score

    return point

n, m, q = map(int,input().split())
l = [list(map(int,input().split())) for i in range(q)]

num = 0
nums = list(range(1, m + 1))
for i in combinations_with_replacement(nums, n):
    #print(i)
    temp = score_check(i, l)
    if num < temp:num = temp
print(num)
Buggy code:
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
for t in combinations_with_replacement(range(1, M+1), N):
    an = 0
    for a, b, c, d in ABCD:
        if t[b-1]-t[a-1] == c:
            an += d
    if ans < an:
        ans = an
print(an

Fixed code:
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
for t in combinations_with_replacement(range(1, M+1), N):
    an = 0
    for a, b, c, d in ABCD:
        if t[b-1]-t[a-1] == c:
            an += d
    if ans < an:
        ans = an
print(ans)
Buggy code:
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int,input().split())
A_list = []
for p in itertools.combinations_with_replacement(range(1,m+1),n):
    A_list.append(p)
# print(A_list)

ans = 0
for v in A_list:
    cur_score = 0
    for i in range(q):
        if v[b[i]-1] - v[a[i]-1] == c[i]:
            cur_score += d[i]
    ans = max(ans,cur_score)
print(ans)

Fixed code:
import itertools
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int,input().split())
A_list = []
for p in itertools.combinations_with_replacement(range(1,m+1),n):
    A_list.append(p)
# print(A_list)

ans = 0
for v in A_list:
    cur_score = 0
    for i in range(q):
        if v[b[i]-1] - v[a[i]-1] == c[i]:
            cur_score += d[i]
    ans = max(ans,cur_score)
print(ans)
Buggy code:
import itertools

N,M,Q = map(int,input().split())
num = [[0 for i in range(4)] for j in range(Q)]
test = list()

k = 1
for i in range(M):
    test.append(k)
    k += 1

k = 0
for i in range(Q):
    num[k][0], num[k][1], num[k][2], num[k][3] = map(int,input().split())
    k += 1

k = 0
score = 0
maxscore = 0
for list in itertools.combinations(test, N):
    for i in range(Q):
        if list[num[k][1]-1] - list[num[k][0]-1] == num[k][2]:
            score += num[k][3]
            k += 1
        if score > maxscore:
            maxscore = score
    print(list)
    print(score)
    score = 0
    k = 0

print(maxscore)


Fixed code:
import itertools

N,M,Q = map(int,input().split())
num = [[0 for i in range(4)] for j in range(Q)]
test = list()

k = 1
for i in range(M):
    test.append(k)
    k += 1

k = 0
for i in range(Q):
    num[k][0], num[k][1], num[k][2], num[k][3] = map(int,input().split())
    k += 1

k = 0
score = 0
maxscore = 0
for list in itertools.combinations_with_replacement(test, N):
    for i in range(Q):
        if list[num[k][1]-1] - list[num[k][0]-1] == num[k][2]:
            score += num[k][3]
        k += 1
        if score > maxscore:
            maxscore = score
    score = 0
    k = 0

print(maxscore)
Buggy code:
from itertools import combinations_with_replacement

n, m, q = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(q)]
def keisan(tup):
    ans_keisan = 0
    print(tup)
    for j in A:
        if tup[j[1]-1] - tup[j[0]-1] == j[2]:
            ans_keisan += j[3]
    return ans_keisan
ans = 0
for i in combinations_with_replacement(range(m),n):
    ans = max(keisan(i), ans)
print(ans)

Fixed code:
from itertools import combinations_with_replacement

n, m, q = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(q)]
def keisan(tup):
    ans_keisan = 0
    for j in A:
        if tup[j[1]-1] - tup[j[0]-1] == j[2]:
            ans_keisan += j[3]
    return ans_keisan
ans = 0
for i in combinations_with_replacement(range(m),n):
    ans = max(keisan(i), ans)
print(ans)
Buggy code:

import itertools

n, m, q = map(int, input().split())


n, m, q = map(int, input().split())
query = []
for i in range(q):
    query.append(list(map(int, input().split())))

choices = list(itertools.combinations_with_replacement([i for i in range(1, m+1)], n))
ans = -1
for choice in choices:
    score = 0
    for q in query:
        if choice[q[1]-1] - choice[q[0]-1] == q[2]:
            score += q[3]
    ans = max(ans, score)
print(ans)

Fixed code:

import itertools


n, m, q = map(int, input().split())
query = []
for i in range(q):
    query.append(list(map(int, input().split())))

choices = list(itertools.combinations_with_replacement([i for i in range(1, m+1)], n))
ans = -1
for choice in choices:
    score = 0
    for q in query:
        if choice[q[1]-1] - choice[q[0]-1] == q[2]:
            score += q[3]
    ans = max(ans, score)
print(ans)