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

Fixed submission:
from collections import defaultdict
S = input()

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def update(self, i, v):
        while i <= self.n:
            self.bit[i] += v
            i += i & -i
            
    def query(self, i):
        ret = 0
        while i > 0:
            ret += self.bit[i]
            i -= i & -i
            
        return ret

d = defaultdict(list)
for i, v in enumerate(S):
    d[v].append(i + 1)

if sum(len(l) % 2 != 0 for l in d.values()) > 1:
    print(-1)
    exit()

N = len(S)
ctr = []
key_map = [-1] * (N + 1)

for k, v in d.items():
    t = len(v)
    if t % 2  == 1:
        key_map[v[t // 2]] = N // 2 + 1

    for j in range(t // 2):
        ctr.append((v[j], v[-j - 1]))
        
ctr.sort()

for i, (l, r) in enumerate(ctr):
    key_map[l] = i + 1
    key_map[r] = N - i

tree = BIT(N)
ans = 0
for i, v in enumerate(key_map[1:]):
    ans += i - tree.query(v)
    tree.update(v, 1)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
S = input()

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def update(self, i, v):
        while i <= self.n:
            self.bit[i] += v
            i += i & -i
            
    def query(self, i):
        ret = 0
        while i > 0:
            ret += self.bit[i]
            i -= i & -i
            
        return ret

d = defaultdict(list)
for i, v in enumerate(S):
    d[v].append(i + 1)

if sum(len(l) % 2 != 0 for l in d.values()) > 1:
    print(-1)
    exit()

N = len(S)
ctr = []
key_map = [-1] * (N + 1)

for k, v in d.items():
    t = len(v)
    if t % 2  == 1:
        key_map[v[t % 2]] = N // 2 + 1

    for j in range(t // 2):
        ctr.append((v[j], v[-j - 1]))
        
ctr.sort()

for i, (l, r) in enumerate(ctr):
    key_map[l] = i + 1
    key_map[r] = N - i

tree = BIT(N)
ans = 0
for i, v in enumerate(key_map[1:]):
    ans += i - tree.query(v)
    tree.update(v, 1)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter, defaultdict
S = input()

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def update(self, i, v):
        while i <= self.n:
            self.bit[i] += v
            i += i & -i
            
    def query(self, i):
        ret = 0
        while i > 0:
            ret += self.bit[i]
            i -= i & -i
            
        return ret

ctr = Counter(S)
if sum(c % 2 != 0 for c in ctr.values()) > 1:
    print(-1)
    
ctr = {k: v / 2 for k, v in ctr.items()}
A = []
C = []
ans = 0
MAX_LEN = len(S)
for i, v in enumerate(S):
    if ctr[v] >= 1:
        A.append(v)
        ctr[v] -= 1
        ans += max(0, i + 1 - MAX_LEN // 2)
    elif ctr[v] > 0:
        ans += abs(i - MAX_LEN // 2)
    else:
        C.append(v)

d = defaultdict(list)
for i, v in enumerate(C[::-1]):
    d[v].append(i + 1)
    
tree = BIT(len(A))
for i, a in enumerate(A):
    ans += i - tree.query(d[a][0])
    tree.update(d[a][0], 1)
    d[a] = d[a][1:]

print(ans)
Problem p03545 (python)

Fixed submission:
a, b, c, d = map(int, input())
ans = ''
if a + b + c + d == 7:
    ans = '{}+{}+{}+{}=7'
elif a - b + c + d == 7:
    ans = '{}-{}+{}+{}=7'
elif a + b - c + d == 7:
    ans = '{}+{}-{}+{}=7'
elif a + b + c - d == 7:
    ans = '{}+{}+{}-{}=7'
elif a - b - c + d == 7:
    ans = '{}-{}-{}+{}=7'
elif a + b - c - d == 7:
    ans = '{}+{}-{}-{}=7'
elif a - b + c - d == 7:
    ans = '{}-{}+{}-{}=7'
elif a - b - c - d == 7:
    ans = '{}-{}-{}-{}=7'
    
print(ans.format(a, b, c, d))

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
ans = ''
if a + b + c + d == 7:
    ans = '{}+{}+{}+{}=7'
elif a - b + c + d == 7:
    ans = '{}-{}+{}+{}=7'
elif a + b - c + d == 7:
    ans = '{}+{}-{}+{}=7'
elif a + b + c - d == 7:
    ans = '{}+{}+{}-{}=7'
elif a - b - c + d == 7:
    ans = '{}-{}-{}+{}=7'
elif a + b - c - d == 7:
    ans = '{}+{}-{}-{}=7'
elif a - b + c - d == 7:
    ans = '{}-{}+{}-{}=7'
elif a - b - c - d == 7:
    ans = '{}-{}-{}-{}=7'
    
print(ans.format(a, b, c, d))
Problem p03579 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for x, y in edges:
    graph[x - 1].append(y - 1)
    graph[y - 1].append(x - 1)

def dfs(v, c):
    # c: color = 1 or -1
    node[v] = c
    for i in graph[v]:
        if node[i] == c:
            return False
        
        if node[i] == 0 and not dfs(i, -c):
            return False
        
    return True

node = [0] * N
if dfs(0, 1):
    x = sum(v + 1 for v in node) // 2
    print(x * (N - x) - M)
else:
    print(N * (N - 1) // 2 - M)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

def dfs(u, c):
    color[u] = c
    for v in graph[u]:
        if color[v] == c:
            return False
        if color[v] == 0 and not dfs(v, -c):
            return False
        
    return True

graph = [[] for _ in range(N)]
for a, b in X:
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

color = [0] * N
if dfs(0, 1):
    c = sum(v == 1 for v in color)
    print(c * (N - c) - M)
else:
    print(N * (N - 1) // 2 - M)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for x, y in edges:
    graph[x - 1].append(y - 1)
    graph[y - 1].append(x - 1)

def dfs(v, c):
    # c: color = 1 or -1
    node[v] = c
    for i in graph[v]:
        if node[i] == c:
            return False
        
        if node[i] == 0 and not dfs(i, -c):
            return False
        
    return True

node = [0] * N
if dfs(0, 1):
    x = sum(v + 1 for v in node) // 2
    print(x * (N - x) - M)
else:
    print(N * (N - 1) // 2 - M)
Problem p03611 (python)

Fixed submission:
N, *a = map(int, open(0).read().split())
cnt = [0] * (10 ** 5 + 2)

for v in a:
    cnt[v] += 1
    cnt[v + 1] += 1
    cnt[v + 2] += 1
    
print(max(cnt))

Buggy submission (verdict: Runtime Error):
from collections import Counter

N, *a = map(int, open(0).read().split())
c = [y for _, y in sorted(Counter(a).most_common())]
print(max(sum(c[i:i + 3]) for i in range(len(c) - 2)))
Problem p03612 (python)

Fixed submission:
N, *X = map(int, open(0).read().split())

ans = 0
for i in range(N):
    if X[i] == i + 1:
        if i < N - 1:
            X[i], X[i + 1] = X[i + 1], X[i]
        else:
            X[i - 1], X[i] = X[i], X[i - 1]
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N, *X = map(int, open(0).read().split())

ans = 0
for i in range(N - 1):
    if X[i] == i + 1:
        X[i], X[j] = X[j], X[i]
        ans += 1

print(ans)
Problem p03646 (python)

Fixed submission:
K = int(input())

N = 50
x = [v + K // N for v in range(N)]
for i in range(K % N):
    for j in range(N):
        if j == i:
            x[j] += N
        else:
            x[j] -= 1
            
print(N)
print(*x)

Buggy submission (verdict: Runtime Error):
N = 5
x = list(range(5))
for i in range(min(N - 1, K)):
    for j in range(N):
        if j == i:
            x[j] += N
        else:
            x[j] -= 1
            
print(N)
print(*x)
Problem p03674 (python)

Fixed submission:
N, *X = map(int, open(0).read().split())

MAX = 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k:
        return 0
    return fac[n] * finv[n - k] * finv[k]

# Find indices of duplicated values
indices = [-1] * (N + 1)
for i in range(N + 1):
    if indices[X[i]] < 0:
        indices[X[i]] = i
    else:
        l = indices[X[i]]
        r = i
        break

for k in range(1, N + 2):
    print((comb(N + 1, k) - comb(l + N - r, k - 1)) % MOD)

Buggy submission (verdict: Runtime Error):
N, *X = map(int, open(0).read().split())

MAX = 10 ** 5
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k:
        return 0
    return fac[n] * finv[n - k] * finv[k]

# Find indices of duplicated values
indices = [-1] * (N + 1)
for i in range(N + 1):
    if indices[X[i]] < 0:
        indices[X[i]] = i
    else:
        l = indices[X[i]]
        r = i
        break

for k in range(1, N + 2):
    print((comb(N + 1, k) - comb(l + N - r, k - 1)) % MOD)
Problem p03722 (python)

Fixed submission:
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    edges[i][2] *= -1

INF = 10 ** 20
d = [INF] * (N + 1)

def bellman_ford():    
    d[1] = 0
    for _ in range(N):
        for u, v, c in edges:
            if (d[u] != INF) and (d[v] > d[u] + c):
                d[v] = d[u] + c

negative = [False] * (N + 1)

def bellman_ford_neg():
    for _ in range(N):
        for u, v, c in edges:
            if (d[u] != INF) and (d[v] > d[u] + c):
                d[v] = d[u] + c
                negative[v] = True
                
            if negative[u]:
                negative[v] = True

bellman_ford()
bellman_ford_neg()

if negative[-1]:
    print('inf')
else:
    print(-d[-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

def bellman_ford():
    d = [None] * (N + 1)
    visited = [False] * (N + 1)
    d[1] = 0
    visited[1] = True
    updated = True
    cnt = 0
    
    while updated and (cnt < N):
        updated = False
        cnt += 1
        for u, v, c in edges:
            if (not visited[v]) or (visited[v] and visited[u] and d[v] < d[u] + c):
                d[v] = d[u] + c
                visited[v] = True
                updated = True
                
    return d, cnt

d, cnt = bellman_ford()
print(d[-1] if cnt < N else 'inf')
Problem p03730 (python)

Fixed submission:
from fractions import gcd

A, B, C = map(int, open(0).read().split())

if C % gcd(A, B) == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
from math import gcd

A, B, C = map(int, open(0).read().split())

if C % gcd(A, B) == 0:
    print("YES")
else:
    print("NO")
Problem p03732 (python)

Fixed submission:
N, W = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

w0 = X[0][0]
ctr = [[] for _ in range(4)]
for w, v in X:
    ctr[w - w0].append(v)

for n in range(4):
    values = sorted(ctr[n], reverse=True)
    s = [0] * (len(values) + 1)
    for i in range(len(values)):
        s[i + 1] = s[i] + values[i]
    ctr[n] = s

ans = 0
for i in range(len(ctr[0])):
    for j in range(len(ctr[1])):
        for k in range(len(ctr[2])):
            for l in range(len(ctr[3])):
                tmp = ctr[0][i] + ctr[1][j] + ctr[2][k] + ctr[3][l]
                w = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l
                if w <= W:
                    ans = max(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(W + 1):
        if j < X[i][0]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - X[i][0]] + X[i][1])

print(dp[-1][-1])
Problem p03085 (python)

Fixed submission:
b = input()
c = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}
print(c[b])

Buggy submission (verdict: Runtime Error):
1 b = input()
2 c = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}
3 print(c[b])
Problem p02641 (python)

Fixed submission:
a,b=map(int,input().split())
if b!=0:
  B=list(map(int,input().split()))
  A=B.copy()
  for i in range(b):
    A[i]= abs(A[i]-a)
  A.sort()
  for i in range(A[-1]+2):
    if A.count(i)==1:
      if i!=0:
        if a-i in B:
          result=a+i
          break
        else:
          result=a-i
          break
    elif A.count(i)==0:
      result=a-i
      break
else:
  result=a
print(result)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
B=list(map(int,input().split()))
A=B.copy()
for i in range(b):
  A[i]= abs(A[i]-a)
A.sort()
for i in range(A[-1]+2):
  if A.count(i)==1:
    if i!=0:
      if a-i in B:
        result=a+i
        break
      else:
        result=a-i
        break
  elif A.count(i)==0:
    result=a-i
    break

    
print(result)
Problem p02646 (python)

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

print('YES' if abs(b-a) <= (v-w) * t else 'NO')

Buggy submission (verdict: Runtime Error):
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
v=V-W
l=B-A
if l>0:
  if l <= v*T:
    if l%v==0:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")
else:
  if l <= v*T:
    if l%v==0:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")

Buggy submission (verdict: Runtime Error):
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
v=V-W
l=B-A
if l < v*T:
  if l%v==0:
    print("YES")
  else:
    print("NO")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
v=V-W
l=B-A
if A+V*T > B+W*T:
  if l%v==0:
    print("YES")
else:
  print("NO")
Problem p03494 (python)

Fixed submission:
n=int(input())
X = list(map(int,input().split()))
h = True
count = 0
while h:
  for i in range(n):
    if X[i] %2 == 0 :
      X[i] = X[i]/2
    else:
      h = False
      break
  count+=1
  
print(count-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
X = list(map(int,input().split()))
h = Ture
count = 0
while h:
  for i in range(n):
    if X[i] %2 == 0 :
      X[i] = X[i]/2
    else:
      h = False
      break
  count+=1
  
print(count-1)
Problem p03636 (python)

Fixed submission:
sA =[]
sA += input()
print("{}{}{}".format(sA[0],len(sA)-2,sA[len(sA)-1]))

Buggy submission (verdict: Runtime Error):
sA =[]
sA += input()
print("{}{}{}".format(sA[0],len(sA)-2,sA[len(sA-1)]))
Problem p04045 (python)

Fixed submission:
N,K = map(int,input().split())
D = set(list(map(int,input().split())))
for i in range(N,10*N):
  ans = []
  ans += str(i)
  sA =set(map(int,ans))
  if sA&D == set():
    break

print(i)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
D = input().split()
i = 0
money = N-1

while money < N:
  i = i+1
  ans = []
  ans += str(money+i)
  for j in range(len(ans)):
    for k in range(len(D)):
      if D[k] == ans[j]:
        flag = True
        break
    if flag:
      break
  if not(flag):
    money = money + i

print(money)
Problem p02641 (python)

Fixed submission:
import numpy as np
X, N = (int(i) for i in input().split())
p = sorted([int(i) for i in input().split()])
if X in p:
    s = p.index(X)
    i = 1
    while True:
        if (s-i)<0:
            print(p[0]-1)
            break
        elif p[s-i] != (X-i):
            print(X-i)
            break
        elif (s+i)>=N:
            print(p[N-1]+1)
            break
        elif p[s+i] != (X+i):
            print(X+i)
            break
        else:
            i = i + 1
else:
    print(X)

Buggy submission (verdict: Runtime Error):
import numpy as np
X, N = (int(i) for i in input().split())
p = sorted([int(i) for i in input().split()])
if X in p:
    s = p.index(X)
    i = 0
    while ((s-i)>=0) or ((s+i)<N):
        if p[s-i] != (X-i):
            print(X-i)
            break
        if p[s+i] != (X+i):
            print(X+i)
            break
        i = i + 1
    else:
        print(p[0]-1)
else:
    print(X)
Problem p02755 (python)

Fixed submission:
import math
a, b = (int(i) for i in input().split())
x = math.ceil(a / 0.08)
flag = False
while math.floor(x * 0.08) == a:
    if (math.floor(x * 0.1) == b):
        flag = True
        break
    x = x + 1
if flag:
    print(int(x))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math
a, b = (int(i) for i in input().split())
x = math.ceil(a / 0.08)
flag = False
if (math.floor(x * 0.1) == b):
    flag = True
else:
    while math.floor(x * 0.08) == a:
        x = x + i
        if (math.floor(x * 0.1) == b):
            flag = True
            break
if flag:
    print(int(x))
else:
    print(-1)
Problem p02928 (python)

Fixed submission:
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
bit = Bit(2000)
ans = 0
hist = [0] * 3
for i in range(min(K, 3)):
    for j in range(N):
        ans = ans + i*N + j - bit.sum(A[j])
        bit.add(A[j], 1)
    hist[i] = ans
if K <= 3:
    print(ans)
else:
    ans = hist[0]
    a = (hist[1] - hist[0])
    d = (hist[2] - hist[1]) - (hist[1] - hist[0])
    ans = ans + (K-1) * (2*a + (K-2)*d) // 2
    print(int(ans % (1000000007)))

Buggy submission (verdict: Runtime Error):
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
bit = Bit(N*4)
ans = 0
hist = [0] * 3
for i in range(min(K, 3)):
    for j in range(N):
        ans = ans + i*N + j - bit.sum(A[j])
        bit.add(A[j], 1)
    hist[i] = ans
if K <= 3:
    print(ans)
else:
    ans = hist[0]
    a = (hist[1] - hist[0])
    d = (hist[2] - hist[1]) - (hist[1] - hist[0])
    ans = ans + (K-1) * (2*a + (K-2)*d) // 2
    print(int(ans % (10e+9 + 7)))
Problem p03105 (python)

Fixed submission:
a, b, c = (int(i) for i in input().split())  
print(min(c,(int)(b/a)))

Buggy submission (verdict: Runtime Error):
a, b, k = (int(i) for i in input().split())
x = []
c = max(a, b)
for i in  range(1, c+1):
    if (a % i == 0) and (b % i == 0):
        x.append(i)

print(x[-k])

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, raw_input().split())
d = (int)(b/a)
print(min(d, c))
Problem p03106 (python)

Fixed submission:
a, b, k = (int(i) for i in input().split())
x = []
c = max(a, b)
for i in  range(1, c+1):
    if (a % i == 0) and (b % i == 0):
        x.append(i)

print(x[-k])

Buggy submission (verdict: Runtime Error):
a, b, k = (int(i) for i in input().split())
x = []
c = max(a, b)
for i in  range(1, c):
    if (a % i == 0) and (b % i == 0):
        x.append(i)

print(x[-k])
Problem p02621 (python)

Fixed submission:
a = int(input())

ans = a + a**2 + a**3
print(int(ans))

Buggy submission (verdict: Runtime Error):
a = int(input())

ans = a(1+a+a**2)
print(int(ans))
Problem p02628 (python)

Fixed submission:
N,K = map(int,input().split())
price = list(map(int,input().split()))
priceN = sorted(price)
total = 0
for i in range(K):
  total += priceN[i]
print(total)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
price = list(map(int,input().split()))
priceN = sorted(price)
total = 0
for i in range(K):
  total += priceN[i]
price(total)
Problem p02697 (python)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    used = [0 for _ in range(N)]
    cur = 0
    pairs = []
    used = set()
    if N % 2 == 0:
        a = 1
        b = N
        while len(pairs) < M:
            if b-a in used or N + a -b in used or b - a == N//2:
                b -= 1
            pairs.append((a, b))
            used.add(b-a)
            used.add(N+a - b)
            a += 1
            b -= 1

    else:
        a = 1
        b = N - 1
        while len(pairs) < M:
            pairs.append((a, b))
            a += 1
            b -= 1
    for p in pairs:
        print(p[0], p[1])



main()

Buggy submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    pairs = []
    used = [0 for _ in range(N)]
    cur = 0
    for gap in range(1, M+1):
        while used[cur] or used[(cur + gap) % N]:
            cur += 1
        pairs.append((cur, cur + gap))
        used[cur] = 1
        used[(cur+gap) % N] = 1
    for p in pairs:
        print(p[0]+1, p[1]+1)



main()

Buggy submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    pairs = []
    used = [0 for _ in range(N)]
    cur = 0
     
    for gap in range(1, M+1):
        while used[cur] or used[(cur + gap) % N]:
            cur += 1
        pairs.append((cur, cur + gap))
        used[cur] = 1
        used[cur+gap] = 1
    for p in pairs:
        print(p[0]+1, p[1]+1)



main()
Problem p02789 (python)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, m = LI()
    if n == m:
        print("Yes")
    else:
        print("No")

main()

Buggy submission (verdict: Runtime Error):
def LI(): return [int(x) for x in sys.stdin.readline().split()]
n, m = LI()
if n == m:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n, m = list(int, input().split())
if n == m:
  print("Yes")
else:
  print("No")