Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int (input())
X = int (input())
T = int (input())

time = 0

while (N > 0):
    N -= X
    time += T

print(time)


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

time = 0

while (i[0] > 0):
    i[0] -= i[1]
    time += i[2]

print(time)
Buggy python submission (verdict: Runtime Error):
N=input()
R=input()
N=int(N)
R=int(R)
if N<10:
  R+=100*(10-N)
print(R)

Fixed submission:
N,R=input().split()
N=int(N)
R=int(R)
if N<10:
  R+=100*(10-N)
print(R)
Buggy python submission (verdict: Runtime Error):
n=int(input())

count=0
c_list=[]
for i in range(n):
    d1, d2=map(int, input().split())
    if d1==d2:
        count+=1
        c_list.append(count)
    else:
        count=0
        
if max(c_list)>=3:
    print("Yes")
else:
    print("No")

Fixed submission:
n=int(input())

count=0
c_list=[1]

for i in range(n):
    d1, d2=map(int, input().split())
    if d1==d2:
        count+=1
        c_list.append(count)
        #print(c_list)
    else:
        count=0
        
if max(c_list)>=3:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

re_list=[]

while n>0:
    re_list.append(n%10)
    n//=10
    
if sum(re_list)%9==0:
    print("Yes")
else:
    print("No")
    


Fixed submission:
n=int(input())

if n%9==0:
    print("Yes")

else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

def f_count(j):
    count=0
    rt=int(j**0.5)
    for x in range(1,rt):
        for y in range(1,rt):
            for z in range(1,rt):
                if x**2+y**2+z**2+x*y+y*z+z*x==j:
                    count+=1
    return count
    
for i in range(1,n+1):
    print(f_count(i))
    
                    

Fixed submission:
N=int(input())

#f(N)を入れるリスト。f(1)=ans_list[0], f(N)=ans_list[N-1]
ans_list=[0]*N

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            s=x**2+y**2+z**2+x*y+y*z+z*x
            if s<=N:
                ans_list[s-1]+=1
            
   
for i in range(N):
   print(ans_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

def f_count(j):
    count=0
    rt=int(j**0.5)+1
    for x in range(1,rt):
        for y in range(1,rt):
            for z in range(1,rt):
                if x**2+y**2+z**2+x*y+y*z+z*x==j:
                    count+=1
    return count
    
for i in range(1,n+1):
    print(f_count(i))
    
                    
            


Fixed submission:
N=int(input())

#f(N)を入れるリスト。f(1)=ans_list[0], f(N)=ans_list[N-1]
ans_list=[0]*N

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            s=x**2+y**2+z**2+x*y+y*z+z*x
            if s<=N:
                ans_list[s-1]+=1
            
   
for i in range(N):
   print(ans_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

def f_count(j):
    count=0
    for x in range(1,j):
        for y in range(1,j):
            rt=(x+y)**2-4*(x**2+y**2+x*y-j)
            z=(-(x+y)+rt**0.5)/2

            if rt>=0 and (-(x+y)+rt**0.5)%2==0:
                if int(z)>=1:
                    count+=1

            
           
    return count
    
for i in range(1,n+1):
    print(f_count(i))
    
                    

Fixed submission:
N=int(input())

#f(N)を入れるリスト。f(1)=ans_list[0], f(N)=ans_list[N-1]
ans_list=[0]*N

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            s=x**2+y**2+z**2+x*y+y*z+z*x
            if s<=N:
                ans_list[s-1]+=1
            
   
for i in range(N):
   print(ans_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

def f_count(j):
    count=0
    for x in range(1,j):
        for y in range(1,j):
            for z in range(1,j):
                if x**2+y**2+z**2+x*y+y*z+z*x==j:
                    count+=1
    return count
    
for i in range(1,n+1):
    print(f_count(i))
    

Fixed submission:
N=int(input())

#f(N)を入れるリスト。f(1)=ans_list[0], f(N)=ans_list[N-1]
ans_list=[0]*N

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            s=x**2+y**2+z**2+x*y+y*z+z*x
            if s<=N:
                ans_list[s-1]+=1
            
   
for i in range(N):
   print(ans_list[i])
Buggy python submission (verdict: Runtime Error):
[x,n]=[int(i) for i in input().split()]

if n!=0:
    p_list=[int(i) for i in input().split()]


    abs_list=[]
    a_list=list(range(min(p_list),max(p_list)+1))

    for i in p_list:
        a_list.remove(i)

   

    for i in a_list:
     abs_list.append(abs(x-i))
    
    num=abs_list.index(min(abs_list))
    print(a_list[num])

else:
    print(x)
    

Fixed submission:
[x,n]=[int(i) for i in input().split()]

if n!=0:
    p_list=[int(i) for i in input().split()]
    
    if x not in p_list:
        print(x)
        
    else:
        i=1
        while True:
            if (x-i) not in p_list:
                print(x-i)
                break
            elif (x+i) not in p_list:
                print(x+i)
                break
            else:
                i+=1
                


else:
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a_list=[int(i) for i in input().split()]

ans=1
for i in range(N):
    ans*=a_list[i]
    
if ans>10**18:
    print(-1)
else:
    print(ans)
    

Fixed submission:
N=int(input())
a_list=[int(i) for i in input().split()]

if 0 in a_list:
    print(0)
    
else:
    
    ans=1
    for i in range(N):
        ans*=a_list[i]
        if ans>10**18:
            ans=-1
            break
    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,k=map(int, input().split())
all_list=[1]*a+[0]*b+[-1]*c
#print(all_list)
print(sum(all_list[:k]))


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

if k<=a:
    print(k)
elif a<k<=(a+b):
    print(a)
else:
    print(a+(k-a-b)*(-1))
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int, input().split())

num=n//(a+b)+1

line=("b"*a+"r"*b)*num

print(line[:n].count("b"))


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

if a==0:
    print(0)
    
elif b==0:
    print(n)
    
else:
    
    quo=n//(a+b)
    
    #商
    if n%(a+b)==0:
        rem=0
    elif  1<=n%(a+b)<=a:
        rem=n%(a+b)
    else:
        rem=a
        
    print(quo*a+rem)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=[int(i) for i in input().split()]

count=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                count+=1
                break
                
print(count)

Fixed submission:
k,s=[int(i) for i in input().split()]

count=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-(x+y)<=k:
            count+=1
               
                
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=[int(i) for i in input().split()]

count=0
for i in range(k+1):
    for j in range(k+1):
        for r in range(k+1):
            if i+j+r==s:
                count+=1
                
print(count)


Fixed submission:
k,s=[int(i) for i in input().split()]

count=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-(x+y)<=k:
            count+=1
               
                
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = max(a)-min(b)
print(b)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
print(max(a)-min(a))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = max(a)-min(b)
print(b)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
C = input()
c_R = 0
c_W = 0
for c in C:
    if c == "R": c_R += 1
    else: c_W += 1
ans = min(c_R, c_W)


if C[0] + C[1] == "WR":
    C[2:].find("WR") != -1:
    C = list(C)
    C[0] = "R"
    C[C[2:].find("WR") + 1] = "W"
    C = "".join(C)
    
ind1 = C.find("RWR")
if ind1 != -1:
    ind2 = C[ind1 + 2:].find("WR")
else:
    ind2 = -1


while ((ind1 != -1) & (ind2 != -1)):
    C = list(C)
    C[ind1 + 1] = "R"
    C[ind2 + 1] = "W"
    C = "".join(C)

    ind1 = C.find("RWR")
    if ind1 != -1:
        ind2 = C[ind1 + 2:].find("WR")
    else:
        ind2 = -1


    


c_R = 0
c_W = 0
for c in C:
    if c == "R": c_R += 1
    else: c_W += 1
ans = min(ans,c_R, c_W)








    


Fixed submission:
n = int(input())
s = input()
a = 0
b = 0
for c in s:
    if c == "R": a += 1
ans = max(a,b)
for i in range(n):
    if s[i] == "R": a -= 1
    else: b += 1
    ans = min(ans, max(a, b))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))

tmp = 1
for i in range(k):
    tmp *= A[i]

output = []
count = 0
for i in range(k, n):
    if tmp < int(tmp * A[i] / A[count]):
        output.append("Yes")
    else:
        output.append("No")
    tmp = int(tmp * A[i] / A[count])
    count += 1
    
print(*output, sep="\n")

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

output = []
count = 0
for i in range(k, n):
    if A[i] > A[count]:
        output.append("Yes")
    else:
        output.append("No")
    count += 1
    
print(*output, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))

mul = [1]
for i in range(n):
    mul.append(mul[i] * A[i])
#print(mul)
output = []
for i in range(k+1, n+1):
    if mul[i]/mul[i-k] > mul[i-1]/mul[(i-1)-k]: output.append("Yes")
    else: output.append("No")
print(*output, sep="\n")

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

output = []
count = 0
for i in range(k, n):
    if A[i] > A[count]:
        output.append("Yes")
    else:
        output.append("No")
    count += 1
    
print(*output, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))

mul = [1]
for i in range(n):
    mul.append(mul[i] * A[i])
#print(mul)
output = []
for i in range(k+1, n+1):
    if mul[i]/mul[i-k] > mul[i-1]/mul[(i-1)-k]: output.append("Yes")
    else: output.append("No")
print(*output, sep="\n")

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

output = []
count = 0
for i in range(k, n):
    if A[i] > A[count]:
        output.append("Yes")
    else:
        output.append("No")
    count += 1
    
print(*output, sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
output = []

for n in range(1,N+1):
    cnt = 0
    for x in range(1,45):
        if x**2+2*x+1 > n: break
        for y in range(1,45):
            if x**2+y**2+x*y+y+x > n: break
            for z in range(1,45):
                tmp = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
                if tmp > n: break
                if tmp == n: cnt += 1
    output.append(cnt)

print(*output, sep = "\n")

                

Fixed submission:
N = int(input())
ls = {i+1: 0 for i in range(N+1)}
flag = 0
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            tmp = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
            if tmp > N:
                flag = 1
                break
            else:
                ls[tmp] += 1
        #if flag: break
    #if flag: break
            

for i in range(N):
    print(ls[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
output = []

for n in range(1,N+1):
    cnt = 0
    for x in range(1,100):
        if x**2 > n: break
        for y in range(1,100):
            if x**2+y**2+x*y > n: break
            for z in range(1,100):
                tmp = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
                if tmp > n: break
                if tmp == n: cnt += 1
    output.append(cnt)

print(*output, sep = "\n")

                

Fixed submission:
N = int(input())
ls = {i+1: 0 for i in range(N+1)}
flag = 0
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            tmp = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
            if tmp > N:
                flag = 1
                break
            else:
                ls[tmp] += 1
        #if flag: break
    #if flag: break
            

for i in range(N):
    print(ls[i+1])
Buggy python submission (verdict: Runtime Error):
#from collections import deque
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
A = A[::-1]
B = list(map(int, input().split()))

book = A + B
sum_a = sum(A)
sum_b = sum(B)

l = 0
r = len(A)
time = sum_a
ans = 0
#print(book)
while ((r < len(book))|(l <= len(A))):
    if time + book[r] <= K:
        time += book[r]
        ans = max(ans,len(book[l:r])+1)
        r += 1
    elif r == l:
        r += 1
        l += 1
    else:
        time -= book[l]
        l += 1

    #print(l, r)
    #print(ans)
    #print()

book = B[::-1]+A[::-1]

l = 0
r = len(B)
time = sum_b

while ((r < len(book))|(l <= len(B))):
    if time + book[r] <= K:
        time += book[r]
        ans = max(ans,len(book[l:r])+1)
        r += 1
    elif r == l:
        r += 1
        l += 1
    else:
        time -= book[l]
        l += 1
    


print(ans)
    

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_a = [0]
sum_b = [0]
ans = 0
for i in range(1,len(A)+1):
    sum_a.append(sum_a[i - 1] + A[i - 1])
for i in range(1,len(B)+1):
    sum_b.append(sum_b[i - 1] + B[i - 1])


j = len(sum_b)-1
for i in range(len(sum_a)):
    if sum_a[i] > K: break
    while (sum_b[j] + sum_a[i] > K):
        j -= 1
    ans = max(ans, i + j)

    
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt_tb = [0]*n
for i in range(1, n + 1):
    j = 1
    tmp = i*j
    while (tmp <= n):
        cnt_tb[tmp] += 1
        j += 1
        tmp = i*j
ans = 0
for i, cnt in enumerate(cnt_tb):
    ans += (i + 1) * cnt
print(ans)
    

Fixed submission:
n = int(input())

L = [0] * (n + 1)

for i in range(1, n + 1):
    for j in range(1, (n // i)+1):
        L[i * j] += 1

i = 0
ans = 0
for i in range(len(L)):
    ans += i *L[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt_tb = [0]*n
for i in range(1, n + 1):
    j = 1
    tmp = i*j
    while (tmp <= n):
        cnt_tb[tmp] += 1
        j += 1
ans = 0
for i, cnt in enumerate(cnt_tb):
    ans += (i + 1) * cnt
print(ans)
    

Fixed submission:
n = int(input())

L = [0] * (n + 1)

for i in range(1, n + 1):
    for j in range(1, (n // i)+1):
        L[i * j] += 1

i = 0
ans = 0
for i in range(len(L)):
    ans += i *L[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
imos = [0]*(N+1)

# 全体でO(NlogN) ≒ 10^6
for k in range(K): # 下のifによってO(logN)で抑えられる.
    if min(A) == N:
        break

    imos = [0]*(N+1)
    for i,a in enumerate(A): # O(N)
        imos[max(0, i-a)] += 1
        imos[min(N, i + a + 1)] -= 1
        
    A = [imos[0]]
    for i in range(1,len(imos)-1): # O(N)
        A.append(A[i - 1] + imos[i])
        
print(*A, sep=" ")

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
imos = [0]*(N+1)

# 全体でO(NlogN) ≒ 10^6
for k in range(K): # 下のifによってO(logN)で抑えられる.
    if min(A) == N:
        break

    imos = [0]*(N+1)
    for i,a in enumerate(A): # O(N)
        imos[max(0, i-a)] += 1
        imos[min(N, i + a + 1)] -= 1
        
    A = [imos[0]]
    for i in range(1,len(imos)-1): # O(N)
        A.append(A[i - 1] + imos[i])
        
print(*A, sep=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) 
A = list(map(int, input().split()))
flag = 1
ans = 1
for a in A:
  ans *= a


if ans > 10**18 :
  print(-1)
else:
  print(ans)

 

Fixed submission:

N = int(input()) 
A = list(map(int, input().split()))
S = set(A)
if 0 in S:
  print(0)
  exit()
 
upp = 10**18
flag = 1
ans = 1
#print(A)
for a in A:
  ans *= a
  if ans > upp:
    ans = -1
    break
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
T = input()
T_l = [t for t in T]
#print(T_l)
out = []
i = 0
while(i < len(T)):
  if T_l[i] == "?":
    if (i+1 != len(T)) & (i-1 != -1):
      if T_l[i+1]=="D": 
        out.append("P")
        i += 1
      elif T_l[i-1]=="P": 
        out.append("D")
        i += 1
      elif T_l[i+1]=="?":
        out.append("PD")
        i += 2

    elif (i+1 == len(T)):
      out.append("D")
      i += 1

    elif (i-1 == -1):
      if T_l[i+1]=="D": 
        out.append("P")
        i += 1
      elif T_l[i+1]=="P": 
        out.append("D")
        i += 1
      elif T_l[i+1]=="?":
        out.append("PD")
        i += 2

  else:
    out.append(T_l[i])
    i += 1

  #print(out)

print("".join(out))


Fixed submission:
T = input()
T_l = [t for t in T]

for i in range(len(T_l)):
  if T[i] =="?": T_l[i] = "D"

print("".join(T_l))

Buggy python submission (verdict: Time Limit Exceeded):
T = input()
out = []
i = 0
while(i < len(T)):
  if T[i] == "?":
    if (i+1 != len(T)) & (i-1 != -1):
      if T[i+1]=="D": 
        out.append("P")
        i += 1
      elif T[i-1]=="P": 
        out.append("D")
        i += 1
      elif T[i+1]=="?":
        out.append("PD")
        i += 2

    elif (i+1 == len(T)):
      out.append("D")
      i += 1

    elif (i-1 == -1):
      if T[i+1]=="D": 
        out.append("P")
        i += 1
      elif T[i+1]=="P": 
        out.append("D")
        i += 1
      elif T[i+1]=="?":
        out.append("PD")
        i += 2

  else:
    out.append(T[i])
    i += 1

  #print(out)

print("".join(out))


Fixed submission:
T = input()
T_l = [t for t in T]

for i in range(len(T_l)):
  if T[i] =="?": T_l[i] = "D"

print("".join(T_l))

Buggy python submission (verdict: Time Limit Exceeded):
T = input()
out = ""
i = 0
while(i < len(T)):
  if T[i] == "?":
    if (i+1 != len(T)) & (i-1 != -1):
      if T[i+1]=="D": 
        out += "P"
        i += 1
      elif T[i-1]=="P": 
        out += "D"
        i += 1
      elif T[i+1]=="?":
        out += "PD"
        i += 2

    elif (i+1 == len(T)):
      out += "D"
      i += 1

    elif (i-1 == -1):
      if T[i+1]=="D": 
        out += "P"
        i += 1
      elif T[i+1]=="P": 
        out += "D"
        i += 1
      elif T[i+1]=="?":
        out += "PD"
        i += 2

  else:
    out += T[i]
    i += 1

  #print(out)

print(out)


Fixed submission:
T = input()
T_l = [t for t in T]

for i in range(len(T_l)):
  if T[i] =="?": T_l[i] = "D"

print("".join(T_l))
Buggy python submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
List = [list(map(int, input().split())) for n in range(N)]
INF = 10**7
ans = INF
C_pro = list(itertools.product([0,1], repeat=N))

for c_pro in C_pro:
    count = 0
    cost = 0
    ans_list = [0 for i in range(M)]
    for c in c_pro:
        if c == 1:
            cost += List[count][0]
            ans_list = [ans+list for ans, list in zip(ans_list,List[count][1:])]
        count += 1
    if ans_list >= [X for i in range(M)]:
        ans = min(ans, cost)
    

if ans == INF:
    print(-1)
else:
    print(ans)

Fixed submission:
import itertools

N, M, X = map(int, input().split())
List = [list(map(int, input().split())) for n in range(N)]
INF = 10**7
ans = INF
C_pro = list(itertools.product([0,1], repeat=N))

for c_pro in C_pro:
    count = 0
    cost = 0
    ans_list = [0 for i in range(M)]
    for c in c_pro:
        if c == 1:
            cost += List[count][0]
            ans_list = [answ+list for answ, list in zip(ans_list,List[count][1:])]
        count += 1
    ok = True
    for i in range(len(ans_list)):
        if ans_list[i] < X:
            ok = False
            break
    if ok:
        ans = min(ans, cost)
    

if ans == 10**7:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
way = A[0]
List = [0 for n in range(N)]
List[way-1] += 1
count = 0
string = f"{way}"
#print(f"string:{string}")
#print(f"way:{way}")

for i in range(10**7):
    way = A[way-1]
    List[way-1] += 1 
    count += 1
    #print(f"way:{way}")
    #print(f"count:{count}")
    #print(List)
    if max(List) == 3:
        break
    else:
        string += f"{way}"
        #print(f"string:{string}")
        #print()

#print(List)
#print()
new_list = [i for i in List if i == 1]
length = len(new_list)
n_list = [j for j in List if j >= 2]
#print(new_list)
#print(n_list)
amari = (K - length)% len(n_list)

print(int(n_list[amari+1]))


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))# 0index
visi = [-1 for i in range(N)]# 訪れたタイミングを記録(-1: 訪れてない)
L = [1] # 今いる町を追加(町番号:1index)
visi[0] = 0
way = A[0] #次に向かう町の番号を取得
#l = []
count = 1

while visi[way-1] == -1: #すでに訪れた町が出てくるまでループ
    visi[way-1] = count
    count += 1
    L.append(way)
    way = A[way-1]

l = count - visi[way-1]
l_pre = visi[way-1]
loop_L = L[l_pre:]



if K > l_pre:
    index = (K- l_pre)% l
    ans = loop_L[index]
else:
    ans = L[K]
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
vec = [list(map(int, input().split())) for i in range(Q)]
A = itertools.combinations_with_replacement(range(1,M+1), N)
ans = 0

for a in A:
    tmp = 0
    for v in vec:
        if (a[v[1]-1] - a[v[0]-1]) == v[2]:
            tmp += v[3]
    if ans < tmp:
        ans = tmp
        
print(ans)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
vec = [list(map(int, input().split())) for i in range(Q)]
A = itertools.combinations_with_replacement(range(1,M+1), N)
ans = 0

for a in A:
    tmp = 0
    for v in vec:
        if (a[v[1]-1] - a[v[0]-1]) == v[2]:
            tmp += v[3]
    if ans < tmp:
        ans = tmp
        
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
max_n = 0


A_list = []
N=2
for i in range(10**(N-1),10**N):
    #A = [int(x) for x in list(str(i))]
    #A_replace = [int(str(a).replace('0', '10')) for a in A]
    #if A_replace == sorted(A_replace):
    A_list.append(sorted(str(i)))
abcd_list = []
for q in range(Q):
    abcd_list.append(list(map(int, input().split())))

for A in A_list:
    tokuten = 0
    for q in range(Q):
        if (A[abcd_list[q][1]-1] - A[abcd_list[q][0]-1] == abcd_list[q][2]):
            tokuten += abcd_list[q][3]

    if tokuten > max_n:
        max_n = tokuten

print(max_n)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
vec = [list(map(int, input().split())) for i in range(Q)]
A = itertools.combinations_with_replacement(range(1,M+1), N)
ans = 0

for a in A:
    tmp = 0
    for v in vec:
        if (a[v[1]-1] - a[v[0]-1]) == v[2]:
            tmp += v[3]
    if ans < tmp:
        ans = tmp
        
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
max_n = 0


A_list = []
N=2
for i in range(10**(N-1),10**N):
    #A = [int(x) for x in list(str(i))]
    #A_replace = [int(str(a).replace('0', '10')) for a in A]
    #if A_replace == sorted(A_replace):
    A_list.append(sorted(i))
abcd_list = []
for q in range(Q):
    abcd_list.append(list(map(int, input().split())))

for A in A_list:
    tokuten = 0
    for q in range(Q):
        if (A[abcd_list[q][1]-1] - A[abcd_list[q][0]-1] == abcd_list[q][2]):
            tokuten += abcd_list[q][3]

    if tokuten > max_n:
        max_n = tokuten

print(max_n)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
vec = [list(map(int, input().split())) for i in range(Q)]
A = itertools.combinations_with_replacement(range(1,M+1), N)
ans = 0

for a in A:
    tmp = 0
    for v in vec:
        if (a[v[1]-1] - a[v[0]-1]) == v[2]:
            tmp += v[3]
    if ans < tmp:
        ans = tmp
        
print(ans)
Buggy python submission (verdict: Runtime Error):
s=set(input().split(''))
if len(s)==2:print('Yes')
else:print('No')


Fixed submission:
s=set(input())
if len(s)==2:print('Yes')
else:print('No')