Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, iinput().split())
if A <= C and B >= C:
    print("Yes")
else:
    print("No")
    

Fixed submission:
A, B, C = map(int, input().split())
if A <= C and B >= C:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()
print(chr(ord(a) + 26) + chr(ord(b) + 26) + chr(ord(c) + 26))

Fixed submission:
a, b, c = input().split()
print(chr(ord(a[0]) - 32) + chr(ord(b[0]) - 32) + chr(ord(c[0]) - 32))
Buggy python submission (verdict: Runtime Error):
def ABC057D():

    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    v = sorted(v)[::-1]

    anslist = []
    for i in range(A, B + 1):

        anslist.append([sum(v[0:i]) / i, i, v[i - 1]])
    anslist.sort()
    anslist = anslist[::-1]
    ans = anslist[0][0]
    key = anslist[0][2]
    long = anslist[0][1]
    print(ans)
    for i in range(1, len(anslist)):
        if anslist[i][0] == anslist[i - 1][0]:
            ans = anslist[i][0]
            key = anslist[i][2]
            long = anslist[i][1]
        else:
            break
    #print(anslist)
    #print(ans, key, long)
    cnt = 0
    for i in v:
        if i == key:
            cnt += 1

    c = 0
    for i in v[:long]:
        #print(i)
        if i == key:
            c += 1
    #print(c, long)
    ans = 0
    if c == long:
        for i in range(A,  min(B + 1, cnt + 1)):
            ans += cc(cnt, i)
    else:
        ans = cc(cnt, c)
    #print(anslist)
    #print(cnt, c, long)
    print(ans)
ABC057D()


Fixed submission:
import math
def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def ABC057D():

    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    v = sorted(v)[::-1]

    anslist = []
    for i in range(A, B + 1):

        anslist.append([sum(v[0:i]) / i, i, v[i - 1]])
    anslist.sort()
    anslist = anslist[::-1]
    ans = anslist[0][0]
    key = anslist[0][2]
    long = anslist[0][1]
    print(ans)
    for i in range(1, len(anslist)):
        if anslist[i][0] == anslist[i - 1][0]:
            ans = anslist[i][0]
            key = anslist[i][2]
            long = anslist[i][1]
        else:
            break
    #print(anslist)
    #print(ans, key, long)
    cnt = 0
    for i in v:
        if i == key:
            cnt += 1

    c = 0
    for i in v[:long]:
        #print(i)
        if i == key:
            c += 1
    #print(c, long)
    ans = 0
    if c == long:
        for i in range(A,  min(B + 1, cnt + 1)):
            ans += cc(cnt, i)
    else:
        ans = cc(cnt, c)
    #print(anslist)
    #print(cnt, c, long)
    print(ans)
ABC057D()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = 1
for i in range(1, N + 1):
    p *= i
print(p % 1000000007)


Fixed submission:
import math
N = int(input())
print(math.factorial(N) % 1000000007)

Buggy python submission (verdict: Runtime Error):
N = int(input())
p = 1
for i in range(1, N ; 1):
    p *= i
print(p % 1000000007)

Fixed submission:
import math
N = int(input())
print(math.factorial(N) % 1000000007)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())
if A == B:
  print("Draw")
elif A == 1:
  print("Alice")
elif B == 1:
  print("Bob")
else:
  if A < B:
    print("Bob")
  else:
    print("Alice")

Fixed submission:
A, B = map(int, input().split())
if A == B:
  print("Draw")
elif A == 1:
  print("Alice")
elif B == 1:
  print("Bob")
else:
  if A < B:
    print("Bob")
  else:
    print("Alice")
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
print(max[A * B, C * D])

Fixed submission:
A, B, C, D = map(int, input().split())
print(max([A * B, C * D]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort()
def main():
    if A[0] == N % 2:
        print(0)
        return 0
    if A[0] == 0:
        del A[0]
    if A[0] == 0:
        print(0)
        return 0
    i = 1
    while True:
        if i >= len(A):
            break
        if len(A) % 2 != 0:
            print(0)
            return 0
        if A[i] != A[i - 1]:
            print(0)
            return 0
        i += 2
    i = 2
    while True:
        if i >= len(A):
            break
        if A[i] == A[i - 1]:
            print(0)
            return 0
        i += 2
    print(pow(2, len(A) // 2) % 1000000007)
main()

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
def main():
    if A[0] == N % 2:
        print(0)
        return 0
    if len(A) == 1 and A[0] == 0:
        print(1)
        return 0
    elif len(A) == 1:
        print(0)
        return 0
    if A[0] == 0:
        del A[0]
    if A[0] == 0:
        print(0)
        return 0
    i = 1
    while True:
        if i >= len(A):
            break
        if len(A) % 2 != 0:
            print(0)
            return 0
        if A[i] != A[i - 1]:
            print(0)
            return 0
        i += 2
    i = 2
    while True:
        if i >= len(A):
            break
        if A[i] == A[i - 1]:
            print(0)
            return 0
        i += 2
    print(pow(2, len(A) // 2) % 1000000007)
main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
h = []
for i in range(N):
    if i == 0:
        h.append(1)
    elif i == N - 1:
        h.append(1)
    else:
        if T[i] > T[i - 1]:
            h.append(1)
            if T[i] > A[i]:
                h[i] = 0
                break
        elif A[i] > A[i + 1]:
            h.append(1)
            if A[i] > T[i]:
                h[i] = 0
                break
        else:
            h.append(min([A[i], T[i]]) % 1000000007)

if max(T) != max(A):
    h.append(0)
    
cnt = 1
for i in range(len(h)):
    cnt *= h[i]
                     
print(cnt % 1000000007)

Fixed submission:
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
h = []
for i in range(N):
    if i == 0:
        h.append(1)
    elif i == N - 1:
        h.append(1)
    else:
        if T[i] > T[i - 1]:
            h.append(1)
            if T[i] > A[i]:
                h[i] = 0
                break
        elif A[i] > A[i + 1]:
            h.append(1)
            if A[i] > T[i]:
                h[i] = 0
                break
        else:
            h.append(min([A[i], T[i]]))

if max(T) != max(A):
    h.append(0)
    
cnt = 1
for i in range(len(h)):
    cnt *= h[i]
    cnt %= 1000000007
                     
print(cnt % 1000000007)

Buggy python submission (verdict: Runtime Error):
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
h = []
for i in range(N):
    if i == 0:
        h.append(1)
    elif i == N - 1:
        h.append(1)
    else:
        if T[i] > T[i - 1]:
            h.append(1)
            if T[i] > A[i]:
                h[i] = 0
                break
        elif A[i] > A[i + 1]:
            h.append(1)
            if A[i] > T[i]:
                h[i] = 0
                break
        else:
            h.append(min([A[i], T[i]]) % 1000000007)

if max[T] != max[A]:
    h.append(0)
    
cnt = 1
for i in range(len(h)):
    cnt *= h[i]
                     
print(cnt % 1000000007)

Fixed submission:
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
h = []
for i in range(N):
    if i == 0:
        h.append(1)
    elif i == N - 1:
        h.append(1)
    else:
        if T[i] > T[i - 1]:
            h.append(1)
            if T[i] > A[i]:
                h[i] = 0
                break
        elif A[i] > A[i + 1]:
            h.append(1)
            if A[i] > T[i]:
                h[i] = 0
                break
        else:
            h.append(min([A[i], T[i]]))

if max(T) != max(A):
    h.append(0)
    
cnt = 1
for i in range(len(h)):
    cnt *= h[i]
    cnt %= 1000000007
                     
print(cnt % 1000000007)
Buggy python submission (verdict: Runtime Error):
def make(x):
    x = bin(x)[2:]
    while len(x) < len(S) - 1:
        x = "0" + x
    return list(x)

S = input()
a = pow(2, len(S) - 1)
b = []

for i in range(0, a):
    b.append(make(i))

i = 0
j = 0
key = int(S[0])
snum = 1
ans = 0
for i in b:
    snum = 1
    key = int(S[0])
    for j in i:
        if j == "0":
            key *= 10
            key += int(S[snum])
        elif j == "1":
            ans += key
            key = int(S[snum])
        #print(i, j, key)
        snum += 1
    ans += key
print(ans)


Fixed submission:
def make(x):
    x = bin(x)[2:]
    while len(x) < len(S) - 1:
        x = "0" + x
    return list(x)

S = input()
a = pow(2, len(S) - 1)
b = []

for i in range(0, a):
    b.append(make(i))

i = 0
j = 0
key = int(S[0])
snum = 1
ans = 0
if len(S) != 1:
    for i in b:
        snum = 1
        key = int(S[0])
        for j in i:
            if j == "0":
                key *= 10
                key += int(S[snum])
            elif j == "1":
                ans += key
                key = int(S[snum])
            #print(i, j, key)
            snum += 1
        ans += key
    print(ans)
else:
    print(S)
Buggy python submission (verdict: Runtime Error):
S = input()
S_len = len(S) - 1
p = []
for i in range(2 ** S_len):
    tmp = bin(i)[2::]
    while len(tmp) < S_len:
        tmp = "0" + tmp
    p.append(str(tmp))

sum = 0
for i in p:
    P = list(i)
    tmp = int(S[0])
    cnt = 1
    for j in P:
        if j == "0":
            tmp *= 10
            tmp += int(S[cnt])
        else:
            sum += tmp
            tmp = int(S[cnt])
        cnt += 1
    sum += tmp
print(sum)

Fixed submission:
S = input()
S_len = len(S) - 1
p = []
for i in range(2 ** S_len):
    tmp = bin(i)[2::]
    while len(tmp) < S_len:
        tmp = "0" + tmp
    p.append(str(tmp))

sum = 0
for i in p:
    if len(p) == 1:
        sum = S
        break
    P = list(i)
    tmp = int(S[0])
    cnt = 1
    for j in P:
        if j == "0":
            tmp *= 10
            tmp += int(S[cnt])
        else:
            sum += tmp
            tmp = int(S[cnt])
        cnt += 1
    sum += tmp
print(sum)
Buggy python submission (verdict: Runtime Error):
n, a = map(int, input().split())
x = list(map(int, input().split()))
x = [0] + x
dp = [[[0 for _ in range(max(x)*n+1)] for _ in range(n+1)] for _ in range(n+1)]
x.sort()
for j in range(n+1):
    for k in range(n+1):
        for s in range(max(x)*n+1):
            if j == 0 and k == 0 and s == 0:
                dp[j][k][s] = 1
            elif j >= 1 and s < x[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]]
            else:
                dp[j][k][s] = 0

ans = 0
for k in range(1, n+1):
    ans += dp[n][k][k*a]

print(ans)

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))
x = [0] + x
dp = [[[0 for _ in range(max(x)*n+1)] for _ in range(n+1)] for _ in range(n+1)]
x.sort()
for j in range(n+1):
    for k in range(n+1):
        for s in range(max(x)*n+1):
            if j == 0 and k == 0 and s == 0:
                dp[j][k][s] = 1
            elif j >= 1 and s < x[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]]
            else:
                dp[j][k][s] = 0

ans = 0
for k in range(1, n+1):
    try:
        ans += dp[n][k][k*a]
    except:
        pass

print(ans)
Buggy python submission (verdict: Runtime Error):
        n = int(input())
        p = 10**9+7
        print((pow(10, n, p) - 2*pow(9, n, p) + pow(8, n, p)) % p)

Fixed submission:
n = int(input())
p = 10**9+7
print((pow(10, n, p) - 2*pow(9, n, p) + pow(8, n, p)) % p)

Buggy python submission (verdict: Runtime Error):
    n = int(input())
    p = 10**9+7
    print((pow(10, n, p) - 2*pow(9, n, p) + pow(8, n, p) % p)

Fixed submission:
n = int(input())
p = 10**9+7
print((pow(10, n, p) - 2*pow(9, n, p) + pow(8, n, p)) % p)

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = 10**9+7
print((pow(10, n, p) - 2*pow(9, n, p) + pow(8, n, p)) % p

Fixed submission:
n = int(input())
p = 10**9+7
print((pow(10, n, p) - 2*pow(9, n, p) + pow(8, n, p)) % p)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
from random import randint
from time import time
 
start = time()

D = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(D)]
T = [randint(1, 26) for _ in range(D)]

days = [[0] for _ in range(26)]

def init():
    global T, days
    score = 0
    last = [0] * 26
    for d, t in enumerate(T, 1):
        score += S[d - 1][t - 1]
        last[t - 1] = d
        for c, l in zip(C, last): score -= c * (d - l)
        days[t - 1].append(d)
    for i in range(26): days[i].append(D+1)
    return score

def diff(d, q):
    global T, C, S, days
    dif = 0
    p = T[d - 1]
    dif += S[d - 1][q - 1] - S[d - 1][p - 1]
    
    idx_p = bisect_left(days[p - 1], d)
    bef_p, aft_p = days[p - 1][idx_p - 1], days[p - 1][idx_p + 1]
    del days[p - 1][idx_p]
    
    idx_q = bisect_left(days[q - 1], d)
    bef_q, aft_q = days[q - 1][idx_q - 1], days[q - 1][idx_q]
    days[q - 1].insert(idx_q, d)
    dif += C[q - 1] * (d - bef_q) * (aft_q - d) - C[p - 1] * (d - bef_p) * (aft_p - d)
    
    
    
    return dif
    
score = init()
while time() - start < 1.8:
    d, q = randint(1, D), randint(1, 26)
    dif = diff(d, q)
    if dif > 0:
        T[d - 1] = q
        score += dif
print(*T, sep='\n')

Fixed submission:
from bisect import bisect_left
from random import randint
from time import time
 
start = time()

D = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(D)]
T = [randint(1, 26) for _ in range(D)]

days = [[0] for _ in range(26)]

def init():
    global T, days
    score = 0
    last = [0] * 26
    for d, t in enumerate(T, 1):
        score += S[d - 1][t - 1]
        last[t - 1] = d
        for c, l in zip(C, last): score -= c * (d - l)
        days[t - 1].append(d)
    for i in range(26): days[i].append(D+1)
    return score

def diff(d, q):
    global T, C, S, days
    dif = 0
    p = T[d - 1]
    dif += S[d - 1][q - 1] - S[d - 1][p - 1]
    
    idx_p = bisect_left(days[p - 1], d)
    bef_p, aft_p = days[p - 1][idx_p - 1], days[p - 1][idx_p + 1]
    
    idx_q = bisect_left(days[q - 1], d)
    bef_q, aft_q = days[q - 1][idx_q - 1], days[q - 1][idx_q]
    dif += C[q - 1] * (d - bef_q) * (aft_q - d) - C[p - 1] * (d - bef_p) * (aft_p - d)
    
    return idx_p, idx_q, dif
    
score = init()
while time() - start < 1.8:
    d, q = randint(1, D), randint(1, 26)
    idx_p, idx_q, dif = diff(d, q)
    if dif > 0:
        p = T[d - 1]
        T[d - 1] = q
        del days[p - 1][idx_p]
        days[q - 1].insert(idx_q, d)
        score += dif
print(*T, sep='\n')
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

N, M, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
cumsum_A, cumsum_B = [0] + list(accumulate(A)), [0] + list(accumulate(B))
ans = 0
j = M
for i in range(N+1):
    if cumsum_A[i] > K: break
    while cumsum_A[i] + cumsum_B[j] >= K: j -= 1
    ans = max(ans, i + j)
print(ans)

Fixed submission:
from itertools import accumulate

N, M, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
cumsum_A, cumsum_B = [0] + list(accumulate(A)), [0] + list(accumulate(B))
ans = 0
j = M
for i in range(N+1):
    if cumsum_A[i] > K: break
    while cumsum_A[i] + cumsum_B[j] > K: j -= 1
    ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1, N+1):
    j = 1
    while i * j <= N:
        ans += i * j
        j += 1
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1):
    temp = N // i
    ans += i * temp * (temp + 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
*P, = map(int, input().split())
cand = set(range(101)) - set(P)
ans, temp = None, 10**10
for c in cand:
    t = abs(X - c)
    if t < temp:
        temp = t; ans = min(ans, c)
print(ans)

Fixed submission:
X, N = map(int, input().split())
*P, = map(int, input().split())
cand = set(range(-50, 151)) - set(P)
cand = sorted([c for c in cand], key=lambda x: (abs(X - x), x))
print(cand[0])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
*A, = map(int, input().split())
for _ in range(min(K, 50)):
    counter = [0] * (N+2)
    for i, a in enumerate(A, 1):
        counter[max(0, i - a)] += 1
        counter[min(N + 1, i + a + 1)] += -1
    for i in range(1, len(counter) - 1):
        counter[i] += counter[i-1]
    A = counter[1:N+1]
print(*A)


Fixed submission:
S = input()
print(S[:3])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*A, = map(int, input().split())
if 0 in A: print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18: ans = -1
    print(ans)

Fixed submission:
N = int(input())
*A, = map(int, input().split())
if 0 in A: print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18: ans = -1; break
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*A, = map(int, input().split())
if 0 in A: print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18: ans = -1
    print(ans)

Fixed submission:
N = int(input())
*A, = map(int, input().split())
if 0 in A: print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18: ans = -1; break
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*A, = map(int, input().split())
ans = 1
for a in A: ans *= a
if ans > 10**18: ans = -1
print(ans)

Fixed submission:
N = int(input())
*A, = map(int, input().split())
if 0 in A: print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18: ans = -1; break
    print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from heapq import heappush, heappop

class Dijkstra:
    def __init__(self, N):
        self.N = N # #vertices
        self.E = [[] for _ in range(N)]

    def add_edge(self, init, end, weight, undirected=False):
        self.E[init].append((end, weight))
        if undirected: self.E[end].append((init, weight))
    
    def distance(self, s):
        INF = float('inf')
        E, N = self.E, self.N
        self.dist = dist = [INF] * N # the distance of each vertex from s
        self.prev = prev = [-1] * N # the previous vertex of each vertex on a shortest path from s
        dist[s] = 0
        n_visited = 1 # #(visited vertices)
        heap = []
        heappush(heap, (0, s))
        while heap:
            d, v = heappop(heap)
            if dist[v] < d: continue
            for u, c in E[v]:
                temp = d + c
                if dist[u] > temp:
                    dist[u] = temp; prev[u] = v
                    heappush(heap, (temp, u))
            n_visited += 1
            if n_visited == N: break
        return dist
    
    def shortest_path(self, t):
        P = []
        prev = self.prev
        while True:
            P.append(t)
            t = prev[t]
            if t == -1: break
        return P[::-1]


def get_result(data):
    N, M = data[0]
    A = data[1:]
    solver = Dijkstra(N)
    for val in A:
        solver.add_edge(val[0]-1, val[1]-1, undirected=True)
    _, prev = solver.distance(0)
    print('Yes')
    for p in prev[1:]:
        print(p + 1)
    return None

if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    get_result(data)

Fixed submission:
from collections import deque

def bfs(E, s):
    N = len(E)
    order = [-1] * N # a bfs ordering of each vertex
    parent = [-1] * N # parent of each vertex in the bfs search tree
    depth = [-1] * N # the depth of each vertex
    q = deque([(s, -1, 0)]) # (vertex, parent, depth)
    num = 0 # current ordering
    while q:
        v, p, d = q.popleft()
        if order[v] < 0: # visited v for the first time
            order[v] = num; parent[v] = p; depth[v] = d
            num += 1
            for u in E[v]:
                if order[u] >= 0: continue
                q.append((u, v, d+1))
    return order, parent, depth

N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    E[a-1].append(b-1); E[b-1].append(a-1)
_, par, _ = bfs(E, 0)
print('Yes')
for p in par[1:]: print(p + 1)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())

def func(x): return (A * x) // B - A * (x // B)

ans = 0
for i in range(1, min(B, N)+1):
    ans = max(ans, func(i))
print(ans)

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

def func(x): return (A * x) // B - A * (x // B)

ans = func(min(B - 1, N))
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
matches = []
used = [False] * N
i = -1
l = 1
while len(matches) < M:
    i += 1
    j = (i + l) % N
    if used[i] or used[j]: continue
    used[i], used[j] = True, True
    matches.append((i+1, j+1))
    l += 1
for a, b in matches:
    print(a, b)

Fixed submission:
N, M = map(int, input().split())
matches = []
i = 1
l = N // 2 - 1 if N % 2 == 0 else N // 2
while len(matches) < M:
    if l <= 0:
        i = N // 2 + 1 if N % 2 == 0 else N // 2 + 2
        l = N // 2 - 2 if N % 2 == 0 else N // 2 - 1
        continue
    matches.append((i, i+l))
    i += 1; l -= 2
for a, b in matches: print(a, b)

Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
matches = []
used = [False] * N
q = deque(range(N))
i = 0
l = 1
while len(matches) < M:
    i = q.popleft()
    j = (i + l) % N
    if used[i] or used[j]: continue
    used[i], used[j] = True, True
    matches.append((i+1, j+1))
    l += 1
    i += 1
for a, b in matches:
    print(a, b)

Fixed submission:
N, M = map(int, input().split())
matches = []
i = 1
l = N // 2 - 1 if N % 2 == 0 else N // 2
while len(matches) < M:
    if l <= 0:
        i = N // 2 + 1 if N % 2 == 0 else N // 2 + 2
        l = N // 2 - 2 if N % 2 == 0 else N // 2 - 1
        continue
    matches.append((i, i+l))
    i += 1; l -= 2
for a, b in matches: print(a, b)

Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
matches = []
used = [False] * N
q = deque(range(N))
l = 1
while q and len(matches) < M:
    i = q.popleft()
    j = i + l
    if used[i] or used[j]: continue
    used[i], used[j] = True, True
    matches.append((i+1, j+1))
    l += 1
for a, b in matches:
    print(a, b)

Fixed submission:
N, M = map(int, input().split())
matches = []
i = 1
l = N // 2 - 1 if N % 2 == 0 else N // 2
while len(matches) < M:
    if l <= 0:
        i = N // 2 + 1 if N % 2 == 0 else N // 2 + 2
        l = N // 2 - 2 if N % 2 == 0 else N // 2 - 1
        continue
    matches.append((i, i+l))
    i += 1; l -= 2
for a, b in matches: print(a, b)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
from itertools import product

def gcd(a, b):
    while b: a, b = b, a % b
    return a

def gcd_list(A): return reduce(gcd, A)

K = int(input())
S = K * (K + 1) // 2
for a, b in combinations(range(1, K+1), 2):
    S += 6 * gcd(a, b)
for a, b, c in combinations(range(1, K+1), 3):
    S += 6 * gcd_list((a, b, c))
print(S)

Fixed submission:
from functools import reduce
from itertools import combinations

def gcd(a, b):
    while b: a, b = b, a % b
    return a

def gcd_list(A): return reduce(gcd, A)

K = int(input())
S = K * (K + 1) // 2
for a, b in combinations(range(1, K+1), 2):
    S += 6 * gcd(a, b)
for a, b, c in combinations(range(1, K+1), 3):
    S += 6 * gcd_list((a, b, c))
print(S)