Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int(input().split())))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)

Fixed submission:
N = int(input())
d = list(map(int,input().split()))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int(input().sprit())))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)

Fixed submission:
N = int(input())
d = list(map(int,input().split()))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

L.sort()
count = 0

for i in reversed(range(N)):
  for j in reversed(range(i)):
    for k in range(j):
      if L[j] + L[k] > L[i]:
        count += j - k
        break
        
print(count)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
count = 0
 
for i in reversed(range(N)):
  kmin = 0
  for j in reversed(range(i)):
    for k in range(kmin,j):
      if L[j] + L[k] > L[i]:
        count += j - k
        kmin = k
        break
        
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())

counter = 0
for i in range(N):
    h = int(input())
    if h >= K:
        counter += 1

print(counter)

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

counter = 0

for i in range(NK[0]):
    if h_list[i] >= NK[1]:
        counter += 1

print(counter)

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

counter = 0
for i in range(N):
    h = int(input())
    if h >= K:
        counter += 1

print(counter)

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

counter = 0

for i in range(NK[0]):
    if h_list[i] >= NK[1]:
        counter += 1

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

N = int(input())
power = 1
for i in range(N):
  power = power*(i+1) % (10**9+7)
  
print(power)

Fixed submission:
N = int(input())
power = 1
for i in range(N):
  power = power*(i+1) % (10**9+7)
  
print(power)

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

N = int(input())
power = 1
for i in range(N):
  power = power*(i+1)
  if power > 10**9+7:
    power = power % (10**9+7)
  
print(power)

Fixed submission:
N = int(input())
power = 1
for i in range(N):
  power = power*(i+1) % (10**9+7)
  
print(power)

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

N = int(input())
power = 1
for i in range(N):
  power = power*(i+1)%(10**9+7)
  
print(power)

Fixed submission:
N = int(input())
power = 1
for i in range(N):
  power = power*(i+1) % (10**9+7)
  
print(power)
Buggy python submission (verdict: Runtime Error):
d,t,s = map(int,input().split())
if d/s<=t:
  print('Yes')
 else:
  print('No')


Fixed submission:
d,t,s = map(int,input().split())
if d/s<=t:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
d,t,s = map(int,input().split())
if d/s<=t:
  print('Yes')
 else:
  print('No)

Fixed submission:
d,t,s = map(int,input().split())
if d/s<=t:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()

d = defaultdict(list)

for i in range(m):
    a,b = input().split()
    d[int(a)].append(b)
ca = pe = 0
for i in range(1,n+1):
    if "AC" in d[i]:
        ca+=1
        pe+=d[i].index("AC")
print(ca,de)

Fixed submission:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()

d = defaultdict(list)

for i in range(m):
    a,b = input().split()
    d[int(a)].append(b)
ca = pe = 0
for i in range(1,n+1):
    if "AC" in d[i]:
        ca+=1
        pe+=d[i].index("AC")
print(ca,pe)
Buggy python submission (verdict: Runtime Error):

n = int(input())


def num2alpha(num):
    if num <= 26:
        return chr(64+num)
    elif num % 26 == 0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num % 26)


print(num2alpha(n).lower())
z

Fixed submission:

n = int(input())


def num2alpha(num):
    if num <= 26:
        return chr(64+num)
    elif num % 26 == 0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num % 26)


print(num2alpha(n).lower())
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = []
result = "No"
for i in range(1, 10):
    for j in range(i, 10):
        x.append(i*j)
print(x)
if N in x:
    result = "Yes"
print(result)

Fixed submission:
a, b = map(int, input().split())
result = -1
if a in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
    if b in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
        result = a*b
print(result)
Buggy python submission (verdict: Runtime Error):
n = input()
digitSum = 0
for digit in n:
    digitSum += int(digit)

print("Yes" if int(n) % digitSum == 0 else "No")

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

print(a*n if a*n < b else b)
Buggy python submission (verdict: Time Limit Exceeded):
a = [0,0,0,0,0,0,0,0,0,0]
a[0] = int(input())

for i in range(9):
  while a[i] != 0:
    a[i+1] += a[i] % 10
    a[i] = a[i] // 10 


if a[9] % 9 == 0:
  print('Yes')
else:
  print('No')


Fixed submission:
a = 0
s = input()
for c in s:
  a += int(c)

if a % 9 == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
a = [0,0,0,0,0,0,0,0,0,0]

a = 0
a[0] = int(input())

for i in range(9):
  while a[i] != 0:
    a[i+1] += a[i] % 10
    a[i] = a[i] // 10 


if a[9] % 9 == 0:
  print('Yes')
else:
  print('No')


Fixed submission:
a = 0
s = input()
for c in s:
  a += int(c)

if a % 9 == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Time Limit Exceeded):
a = 0
n = int(input())
while n != 0:
  a += n % 10
  n = n // 10 

b = 0
while a != 0:
  b += a % 10
  a = a // 10 

c = 0
while b != 0:
  c += b % 10
  b = b // 10 

d = 0
while c != 0:
  d += c % 10
  c = c // 10 

e = 0
while d != 0:
  e += d % 10
  d = d // 10 


if e % 9 == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
a = 0
s = input()
for c in s:
  a += int(c)

if a % 9 == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Time Limit Exceeded):
a = 0
n = int(input())
while n != 0:
  a += n % 10
  n = n // 10 

b = 0
while a != 0:
  b += a % 10
  a = a // 10 

c = 0
while b != 0:
  c += b % 10
  b = b // 10 

d = 0
while c != 0:
  d += c % 10
  c = c // 10 


if d % 9 == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
a = 0
s = input()
for c in s:
  a += int(c)

if a % 9 == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Time Limit Exceeded):
a = 0
n = int(input())
while n != 0:
  a += n % 10
  n = n // 10 

b = 0
while a != 0:
  b += a % 10
  a = a // 10 

if b % 9 == 0:
  print('Yes')
else:
  print('No')


Fixed submission:
a = 0
s = input()
for c in s:
  a += int(c)

if a % 9 == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Time Limit Exceeded):
a = 0
n = int(input())
while n != 0:
  a += n % 10
  n = n // 10 

if a % 9 == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
a = 0
s = input()
for c in s:
  a += int(c)

if a % 9 == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = list(map(int, input().split()))
num = 1
for a in alist:
    num = num * a

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

Fixed submission:
n = int(input())
alist = list(map(int, input().split()))
num = 1

if 0 in alist:
    print(0)
    exit()

for a in alist:
    num = num * a
    if num > 10**18:
        print(-1)
        exit()

print(num)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
print(abs(n-k) % k)

# if n % k == 0:
#   print(0)
#   exit()

# min = 10**18

# while True:
#   n = abs(n-k)
#   if min > n:
#     min = n
#   else:
#     break

# print(min)






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

d = c
c = b 
b = a
a = d
 
print(a,b,c)

Buggy python submission (verdict: Runtime Error):
a = input().int()
b = input().int()
c = input().int()

d = c
c = b 
b = d
d = a

print(a)
print(b)
print(c)

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

d = c
c = b 
b = a
a = d
 
print(a,b,c)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())

if n % k == 0:
  print(0)
  exit()

min = 10**18

while True:
  n = abs(n-k)
  if min > n:
    min = n
  else:
    break

print(min)






Fixed submission:
n,k = map(int, input().split())
n = n % k
a = abs(n-k)
if n <= a:
  print(n)
else:
  print(a)

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

if k == 1:
  print(0)
  exit()

min = 10**18

while True:
  n = abs(n-k)
  if min > n:
    min = n
  else:
    break

print(min)

Fixed submission:
n,k = map(int, input().split())
n = n % k
a = abs(n-k)
if n <= a:
  print(n)
else:
  print(a)

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

min = 10**18

while True:
  n = abs(n-k)
  if min > n:
    min = n
  else:
    break

print(min)






Fixed submission:
n,k = map(int, input().split())
n = n % k
a = abs(n-k)
if n <= a:
  print(n)
else:
  print(a)
Buggy python submission (verdict: Runtime Error):
mport queue

k = int(input())
q = queue.Queue()
for i in range(1,9):
  q.put(i)

n = 0
while True:
  val = q.get()
  if val % 10 != 0:
    q.put(10 * val + (val % 10) - 1)
  q.put(10 * val + (val % 10))
  if val % 10 != 9:
    q.put(10 * val + (val % 10) + 1)
  
  n += 1
  if n == k:
    print(val)
    break

Fixed submission:
import queue

k = int(input())
q = queue.Queue()
for i in range(1,10):
  q.put(i)

n = 0
while True:
  val = q.get()
  n += 1
  if n == k:
    print(val)
    break

  if val % 10 != 0:
    q.put(10 * val + (val % 10) - 1)
  q.put(10 * val + (val % 10))
  if val % 10 != 9:
    q.put(10 * val + (val % 10) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    k = int(input())
    tmp = 7
    cnt = 0
    if k%2 == 0:
        print(-1)
        return

    while 1:
        tmp %= k
        cnt += 1
        if tmp == 0:
            break
        tmp = 10*tmp%k
        tmp += 7
    print(cnt)



if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    k = int(input())
    tmp = 7
    cnt = 0
    if k%2 == 0 or k%5 == 0:
        print(-1)
        return

    while 1:
        tmp %= k
        cnt += 1
        if tmp == 0:
            break
        tmp = 10*tmp%k
        tmp += 7
    print(cnt)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n , k = map(int, input().split())
    a = list(map(int, input().split()))
    l = 0
    r = max(a)
    while l < r:
        m = (l+r)//2
        cnt = 0
        for x in a:
            cnt += (x-1)//m
        if cnt > k: l = m+1
        else: r = m
    print(r)

    


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n , k = map(int, input().split())
    a = list(map(int, input().split()))
    l = 1
    r = max(a)
    while l < r:
        m = (l+r)//2
        cnt = 0
        for x in a:
            cnt += (x-1)//m
        if cnt > k: l = m+1
        else: r = m
    print(r)
    


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n , k = map(int, input().split())
    a = list(map(int, input().split()))
    l = 0
    r = max(a)
    while l < r:
        m = (l+r)//2
        cnt = 0
        for x in a:
            cnt += (x-1)//m
        if cnt > k: l = m
        else: r = m-1
    print(m)

    


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n , k = map(int, input().split())
    a = list(map(int, input().split()))
    l = 1
    r = max(a)
    while l < r:
        m = (l+r)//2
        cnt = 0
        for x in a:
            cnt += (x-1)//m
        if cnt > k: l = m+1
        else: r = m
    print(r)
    


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    a = int(input())
    for i in range(3):
        ans += a**(i+1)
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    a = int(input())
    ans = 0
    for i in range(3):
        ans += a**(i+1)
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x = list(map(int,input().split()))
for i,el in enumerate(x):
	if el == 0:
    	print(i+1)

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    x = list(map(int, input().split()))
    for i,el in enumerate(x):
        if el == 0:
            print(i+1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a = sorterd(a)
    limit = 10**18
    ans = 1
    for ai in a:
        ans *= ai
        if ans > limit:
            print(-1)
            exit(0)
        if ans == 0:
            break
    print(ans)

    


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    limit = 10**18
    ans = 1
    for ai in a:
        ans *= ai
        if ans > limit:
            print(-1)
            exit(0)
        if ans == 0:
            break
    print(ans)

    


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M, X = map(int, input().split())
C = []
A = np.zeros((N, M), dtype=int)
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A[i] = a

S = np.sum(A, axis=0)
print(A)
print(S)
if True in (S < X):
    print(-1)
    exit(0)

mlt = [0]*12
C_ = []
for i in range(2**N):
    total = 0
    arr = np.zeros((M,),dtype=int)
    for j in range(N):
        if ((i>>j) & 1) == 1:
            total += C[j]
            arr += A[j]
    if True in (arr < X):
        continue
    C_.append(total)
print(min(C_))

Fixed submission:
import numpy as np
N, M, X = map(int, input().split())
C = []
A = np.zeros((N, M), dtype=int)
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A[i] = a

S = np.sum(A, axis=0)
if True in (S < X):
    print(-1)
    exit(0)

C_ = []
for i in range(2**N):
    total = 0
    arr = np.zeros((M,),dtype=int)
    for j in range(N):
        if ((i>>j) & 1) == 1:
            total += C[j]
            arr += A[j]
    if True in (arr < X):
        continue
    C_.append(total)
print(min(C_))
Buggy python submission (verdict: Runtime Error):
class Combination():
    def __init__(self, n, mod=10**9+7):
        self.mod = mod
        self.fac = [1]*(n+1)
        for i in range(1,n+1):
            self.fac[i] = self.fac[i-1] * i % self.mod
        self.invfac = [1]*(n+1)
        self.invfac[n] = pow(self.fac[n], self.mod - 2, self.mod)
        for i in range(n-1, 0, -1):
            self.invfac[i] = self.invfac[i+1] * (i+1) % self.mod
    
    def combination(self, n, r):
        ans = self.fac[n] * self.invfac[r] % self.mod * self.invfac[n-r] % self.mod
        if n >= r:
            return ans
        else:
            return 0
    
    def factorial(self, i):
        return self.fac[i]
    
    def invfactorial(self, i):
        return self.invfac[i]


def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m, k = map(int, input().split())
    mod = 998244353
    c = Combination(n,mod)
    ans = 0
    mex = [0]*(k+1)
    mex[0] = pow(m-1,n-k-1,mod)
    for i in range(1,k+1):
        mod[i] = mex[i-1]*(m-1)%mod
    mex = mex[::-1]
    for i in range(k+1):
        ans += c.combination(n-1, i)*mex[i]
        ans %= mod
    ans *= m
    ans %= mod
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
class Combination():
    def __init__(self, n, mod=10**9+7):
        self.mod = mod
        self.fac = [1]*(n+1)
        for i in range(1,n+1):
            self.fac[i] = self.fac[i-1] * i % self.mod
        self.invfac = [1]*(n+1)
        self.invfac[n] = pow(self.fac[n], self.mod - 2, self.mod)
        for i in range(n-1, 0, -1):
            self.invfac[i] = self.invfac[i+1] * (i+1) % self.mod
    
    def combination(self, n, r):
        ans = self.fac[n] * self.invfac[r] % self.mod * self.invfac[n-r] % self.mod
        if n >= r:
            return ans
        else:
            return 0
    
    def factorial(self, i):
        return self.fac[i]
    
    def invfactorial(self, i):
        return self.invfac[i]


def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m, k = map(int, input().split())
    mod = 998244353
    c = Combination(n,mod)
    ans = 0
    mex = [0]*(k+1)
    mex[0] = pow(m-1,n-k-1,mod)
    for i in range(1,k+1):
        mex[i] = mex[i-1]*(m-1)%mod
    mex = mex[::-1]
    for i in range(k+1):
        ans += c.combination(n-1, i)*mex[i]
        ans %= mod
    ans *= m
    ans %= mod
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
h = list(map(int,input().split()))
ma = [0]*(n)
for i in range(n):
  a,b = map(lambda x: int(x)-1,input().split())
  ma[a] = max(ma[a], h[b])
  ma[b] = max(h[a], ma[b])
ans = 0
for i in range(n):
  if h[i]>ma[i]:
    ans+=1
print(ans)

Fixed submission:
import numpy as np
N,M = map(int,input().split())
H = np.array(list(map(int,input().split())))

adj = [[] for _ in range(N)]

for _ in range(M):
    a,b = map(lambda x: int(x) -1 ,input().split())
    if a in adj[b]:
        continue
    adj[a].append(b)
    adj[b].append(a)

ans = 0 
for i, item in enumerate(adj):
     if item == []:
         ans+=1
         continue
     adj_max = max(H[item])
     if H[i] > adj_max:
         ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
    start = i+A[i]
    if start > N-1:
        continue
    for j in range(start,N):
        if j == start + A[j]:
            ans+=1
print(ans)

Fixed submission:
import numpy as np
from collections import Counter as cc
N = int(input())
A = list(map(int,input().split()))

ans = 0
A_p = cc(A+np.arange(N))
A_n = cc(np.arange(N) - A)
for k in range(1,N+1):
    ans += A_p[k]*A_n[k]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from itertools import combinations_with_replacement as cwr
input = sys.stdin.readline


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.append(a)
    B.append(b)
    C.append(c)
    D.append(d)
# ind = np.argsort(np.array(D))
# A,B,C,D = np.array(A)[ind],np.array(B)[ind],np.array(C)[ind],np.array(D)[ind]
# A,B,C,D = A[::-1],B[::-1],C[::-1],D[::-1]
# Array = [0]*(N+1)
ans = 0
combs = list(cwr(np.arange(1,M+1),N))
ans = [0]*(len(combs))
for i,comb in enumerate(combs):
    for a,b,c,d in zip(A,B,C,D):
        if comb[b-1] - comb[a-1] ==c:
            ans[i] += d
print(max(ans))
# for i,d in enumerate(D):
#     a,b,c,d= A[i],B[i],C[i],D[i]
#     if Array[a] ==0:
#         Array[a] = a
#     if Array[b] == 0:
#         Array[b] = a+c
#     if Array[b] - Array[a] == c:
#         ans += d


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

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.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

ans = 0
combs = list(cwr(range(1,M+1),N))
ans = [0]*(len(combs))
for i,comb in enumerate(combs):
    for a,b,c,d in zip(A,B,C,D):
        if comb[b-1] - comb[a-1] ==c:
            ans[i] += d
print(max(ans))
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    if n%2 == 0
        for i in range(m):
            print(n//2-i,n//2+i)
    else:
        for i in range(m):
            print(n//2-i,n//2+i+2)



if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    r = m//2
    s = 1
    e = 2*r+1
    for _ in range(r):
        print(s,e)
        s += 1
        e -=1
    
    s = n-2*(m-r)+1
    e = n
    for _ in range(m-r):
        print(s,e)
        s += 1
        e -=1


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input(),split())
turn = 0
while a > 0 and c> 0:
    if turn%2 ==0:
        c -= b
    else:
        a -= d
    turn += 1
if turn%2 == 1:
    print('Yes')
else:
    print('No')   

Fixed submission:
a,b,c,d = map(int,input().split())
turn = 0
while a > 0 and c> 0:
    if turn%2 ==0:
        c -= b
    else:
        a -= d
    turn += 1
if turn%2 == 1:
    print('Yes')
else:
    print('No')