Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# coding=utf-8
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


# N = 3
# A = [[1, 1], [5, 1], [5, 5]]

# N = 2
# A = [[10, 20], [20, 20]]

N = get()
A = getss(N)
UF = {}


def find(x):
    if x != UF[x]:
        UF[x] = find(UF[x])
    return UF[x]


def union(x, y):
    UF.setdefault(x, x)
    UF.setdefault(y, y)
    UF[find(x)] = find(y)


for i, j in A:
    union(i, -j)


count = {}
for x in UF:
    root = find(x)
    if root not in count:
        count[root] = [0, 0]
    if x > 0:
        count[root][0] += 1
    else:
        count[root][1] += 1

print sum(u[0] * u[1] for u in count) - N

Fixed submission:
# coding=utf-8


get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


# N = 3
# A = [[1, 1], [5, 1], [5, 5]]

# N = 2
# A = [[10, 20], [20, 20]]

N = get()
A = getss(N)
UF = {}


def find(x):
    if x != UF[x]:
        UF[x] = find(UF[x])
    return UF[x]


def union(x, y):
    UF.setdefault(x, x)
    UF.setdefault(y, y)
    UF[find(x)] = find(y)


for i, j in A:
    union(i, -j)


count = {}
for x in UF:
    root = find(x)
    if root not in count:
        count[root] = [0, 0]
    if x > 0:
        count[root][0] += 1
    else:
        count[root][1] += 1

res = 0
for x in count:
    pos, neg = count[x]
    if pos > 1 and neg > 1:
        res += pos * neg
    else:
        res += max(pos, neg)
print res - N
Buggy python submission (verdict: Runtime Error):
# # # coding=utf-8
# # # Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

# 2019-03-30 20:14

A, B, C = gets()


def solve(A, B, C):
    if set([A, B, C]) < 3:
        print 'Yes'
    else:
        print 'N0'

solve(A, B, C)


Fixed submission:
# # # coding=utf-8
# # # Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

# 2019-03-30 20:14

A, B, C = gets()


# def solve(A, B, C):
#     if len(set([A, B, C])) < 3:
#         print 'Yes'
#     else:
#         print 'No'



def solve(A, B, C):
    if len(set([A, B, C])) == 1:
        print 'Yes'
    else:
        print 'No'

solve(A, B, C)

Buggy python submission (verdict: Runtime Error):
# # # coding=utf-8
# # # Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

# 2019-03-30 20:14

A, B, C = gets()


def solve(A, B, C):
    if A == B == C
        print 'YES'
    else:
        print 'NO'

solve(A, B, C)


Fixed submission:
# # # coding=utf-8
# # # Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

# 2019-03-30 20:14

A, B, C = gets()


# def solve(A, B, C):
#     if len(set([A, B, C])) < 3:
#         print 'Yes'
#     else:
#         print 'No'



def solve(A, B, C):
    if len(set([A, B, C])) == 1:
        print 'Yes'
    else:
        print 'No'

solve(A, B, C)
Buggy python submission (verdict: Runtime Error):
n = list(input())
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    else:
        n[i] = '1'
print(int(n[0]+n[1]+n[2]))

Fixed submission:
n = list(raw_input())
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    else:
        n[i] = '1'
print(int(n[0]+n[1]+n[2]))

Buggy python submission (verdict: Runtime Error):
L = readline()
m = {"1":"9","9","1"}:
res = [m.get(i,i) for i in L]
print "".join(L)

Fixed submission:
n = list(raw_input())
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    else:
        n[i] = '1'
print(int(n[0]+n[1]+n[2]))
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
A = map(int, raw_input().split(" "))

c1 = collections.Counter(A[::2])
c2 = collections.Counter(A[1::2])

res = n
for i in c1:
    for j in c2:
        if i != j:
            res = min(res, n - c1[i] - c2[j])
print res


Fixed submission:
import collections
n = int(raw_input())
A = map(int, raw_input().split(" "))

c1 = collections.Counter(A[::2]).most_common(2)
c2 = collections.Counter(A[1::2]).most_common(2)

res = n
for i, x in c1:
    for j, y in c2:
        if i != j:
            res = min(res, n - x - y)
        res = min(res, n - y)
        res = min(res, n - x)
print res
Buggy python submission (verdict: Runtime Error):
K = int(input())
A, B = list(map(int, input().split()))
 
N = (B // K)  * K
if (A <= N):
  print(‘OK’)
else:
  print(‘NG’)

Fixed submission:
K = int(input())
A, B = list(map(int, input().split()))
 
N = (B // K)  * K
if (A <= N):
  print('OK')
else:
  print('NG')

Buggy python submission (verdict: Runtime Error):
K = int(input())
A, B = list(map(int, input().split()))

N = (B // K)  * K
if (A <= N):
  print(‘OK’)
else:
  print(‘NG’)

Fixed submission:
K = int(input())
A, B = list(map(int, input().split()))
 
N = (B // K)  * K
if (A <= N):
  print('OK')
else:
  print('NG')
Buggy python submission (verdict: Runtime Error):
a=int(input)
b=int(input)

print(6-a-b)

Fixed submission:
a=int(input())
b=int(input())

print(6-a-b)

Buggy python submission (verdict: Runtime Error):
a,b=(int(i)for i in input().split())

print(6-a-b)

Fixed submission:
a=int(input())
b=int(input())

print(6-a-b)
Buggy python submission (verdict: Runtime Error):
import math 

A,B=(int(i)for i in input().split())

print((A * B) // math.gcd(A, B))


Fixed submission:
import fractions 

A,B=(int(i)for i in input().split())

print((A * B) // fractions.gcd(A, B))
Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv
S=args[1]
K=int(args[2])
result=0

a=S[0]
renzoku=0
sumInS=0
for s in S:
    if a==s:
        renzoku=renzoku+1
    else:
        sumInS=sumInS+renzoku//2
        renzoku=1
    a=s
sumInS=sumInS+renzoku//2
result = sumInS*K

if S[0]==S[-1]:
    rst=0
    for s in S:
        if s==S[0]:
            rst=rst+1
        else:
            break
    ren=0
    for s in S[::-1]:
        if s==S[-1]:
            ren=ren+1
        else:
            break
    if rst%2==1 and ren%2==1:
        result=result+(K-1)

if renzoku==len(S):
    total=len(S)*K
    result=total//2

print(result)

Fixed submission:
import sys

S=input()
K=int(input())
result=0

a=S[0]
renzoku=0
sumInS=0
for s in S:
    if a==s:
        renzoku=renzoku+1
    else:
        sumInS=sumInS+renzoku//2
        renzoku=1
    a=s
sumInS=sumInS+renzoku//2
result = sumInS*K

if S[0]==S[-1]:
    rst=0
    for s in S:
        if s==S[0]:
            rst=rst+1
        else:
            break
    ren=0
    for s in S[::-1]:
        if s==S[-1]:
            ren=ren+1
        else:
            break
    if rst%2==1 and ren%2==1:
        result=result+(K-1)

if renzoku==len(S):
    total=len(S)*K
    result=total//2

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
a = input().split(" ")
N = eval(a[0])
K = eval(a[1])
dic = {}
b = input().split(" ")
for i in range(1, N + 1):
    dic[i] = eval(b[i - 1])
ans = 1
lst = []
length = 0
while K > 0:
    if ans in lst:
        left = lst.index(ans)
        right = length
        zq = right - left
        K = K % zq
        if K == 0:
            break
    else:
        lst.append(ans)
        length += 1
    ans = dic[ans]
    K -= 1

print(ans)

Fixed submission:
a = input().split(" ")
N = eval(a[0])
K = eval(a[1])
dic = {}
b = input().split(" ")
n_lst = [-1]
for i in range(1, N + 1):
    dic[i] = eval(b[i - 1])
    n_lst.append(-1)
ans = 1
lst = []
length = 0
while K > 0:
    if n_lst[ans] != -1:
        left = n_lst[ans]
        zq = length - left
        K = K % zq
        if K == 0:
            break
    else:
        n_lst[ans] = length
        length += 1
    ans = dic[ans]
    K -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
a = input().split(" ")
N = eval(a[0])
M = eval(a[1])
b = input().split(" ")
hight_lst = list(map(eval, b))
lst = []
for i in range(N):
    lst.append([])

for i in range(M):
    c = input().split(" ")
    lst[eval(c[0])-1].append(eval(c[1])-1)
    lst[eval(c[1])-1].append(eval(c[0])-1)
    
count = 0
for i in range(0, M):
    for j in lst[i]:
        if hight_lst[j] >= hight_lst[i]:
            break
        count += 1

print(count)

Fixed submission:
a = input().split(" ")
N = eval(a[0])
M = eval(a[1])
b = input().split(" ")
hight_lst = list(map(eval, b))
lst = []
for i in range(N):
    lst.append(1)
for i in range(M):
    c = input().split(" ")
    c1 = eval(c[0]) - 1
    c2 = eval(c[1]) - 1
    if hight_lst[c1] > hight_lst[c2]:
        lst[c2] = 0
    elif hight_lst[c1] < hight_lst[c2]:
        lst[c1] = 0
    else:
        lst[c1] = 0
        lst[c2] = 0
count = 0
for i in lst:
    if i == 1:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
X = int(input())
flag = False
for a in range(-1000,1000):
    for b in range(-1000,1000):
        if a**5 - b**5 == X:
            print("{0} {1}".format(a,b))
            flag = True
            break
    if flag:
        break

Fixed submission:
S = input()
if 'ABC' == S:
    print('ARC')
elif 'ARC' == S:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
X = int(input())
flag = False
for ai in range(-119,120):
    for bi in range(-120,119):
    	if ai**5 - bi**5 ==X:
        	print(int(ai),int(bi))
            flag = True
            break
    if flag:
        break

Fixed submission:
X = int(input())
# X = a**5 - b**5 
#   = (a-b)(a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4)
# よって、X は　a-b　の倍数 X%(a-b) = 0

# a**5  = b**5 + X
#   a   = ( b**5 + X )**(1/5)
# X< 10**9 を満たす a,bの最大値は、120 , 119
flag = False
for ai in range(-119,120):
    for bi in range(-120,119):
        if ai - bi != 0 and X > (ai - bi):
            if X % (ai - bi) == 0:
                if ai**5 - bi**5 ==X:
                    print(int(ai),int(bi))
                    flag = True
                    break
        else:
            if ai**5 - bi**5 ==X:
                print(int(ai),int(bi))
                flag = True
                break
    if flag:
        break

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
i = 1
a = 0
b = 0
while a==0 and b==0:
    for j in range(-i,i):
        if j**5 - i**5 ==X:
            a = j
            b = i
    i = i + 1

Fixed submission:
X = int(input())
# X = a**5 - b**5 
#   = (a-b)(a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4)
# よって、X は　a-b　の倍数 X%(a-b) = 0

# a**5  = b**5 + X
#   a   = ( b**5 + X )**(1/5)
# X< 10**9 を満たす a,bの最大値は、120 , 119
flag = False
for ai in range(-119,120):
    for bi in range(-120,119):
        if ai - bi != 0 and X > (ai - bi):
            if X % (ai - bi) == 0:
                if ai**5 - bi**5 ==X:
                    print(int(ai),int(bi))
                    flag = True
                    break
        else:
            if ai**5 - bi**5 ==X:
                print(int(ai),int(bi))
                flag = True
                break
    if flag:
        break

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
flag = False
for a in range(-10000,10000):
    for b in range(-10000,10000):
        if a**5 - b**5 == X:
            print("{0} {1}".format(a,b))
            flag = True
            break
    if flag:
        break

Fixed submission:
X = int(input())
# X = a**5 - b**5 
#   = (a-b)(a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4)
# よって、X は　a-b　の倍数 X%(a-b) = 0

# a**5  = b**5 + X
#   a   = ( b**5 + X )**(1/5)
# X< 10**9 を満たす a,bの最大値は、120 , 119
flag = False
for ai in range(-119,120):
    for bi in range(-120,119):
        if ai - bi != 0 and X > (ai - bi):
            if X % (ai - bi) == 0:
                if ai**5 - bi**5 ==X:
                    print(int(ai),int(bi))
                    flag = True
                    break
        else:
            if ai**5 - bi**5 ==X:
                print(int(ai),int(bi))
                flag = True
                break
    if flag:
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
An = list(map(int,input().split()))
resultDict = {}
resultDict['diff'] = []
resultDict['sum'] = []
for num in range(1,N+1):
    resultDict['diff'].append(int(num - An[num-1]))
    resultDict['sum'].append(int(num + An[num-1]))
countN = 0
for i, name in enumerate(resultDict['diff']):        
    countN = countN + resultDict['sum'].count(name)
    if name == resultDict['sum'][i]:
        countN = countN - 1
print(countN)

Fixed submission:
N = int(input())
An = list(map(int,input().split()))
countN = 0
sum = [0]*N
for i, name in enumerate(An):
    if i + name < N:
        sum[i+name] = sum[i+name] + 1
    if i - name >= 0:
        countN = countN + sum[i-name]
print(countN)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools
import math
N = int(input())
An = list(map(int,input().split()))
#組み合わせ nC2
numList = list(itertools.combinations(range(1,N+1), 2))
count = 0
for pair in numList:
    #　数字のdiff (絶対値) float型
    numDiff = int(math.fabs(pair[1] - pair[0]))
    # 身長の和
    sumHeight = An[pair[0]-1] + An[pair[1]-1]
    if numDiff == sumHeight:
        count = count + 1
print(count)

Fixed submission:
N = int(input())
An = list(map(int,input().split()))
countN = 0
sum = [0]*N
for i, name in enumerate(An):
    if i + name < N:
        sum[i+name] = sum[i+name] + 1
    if i - name >= 0:
        countN = countN + sum[i-name]
print(countN)
Buggy python submission (verdict: Runtime Error):
import itertools
n,m,q = map(int,input().split())
a = []
b = []
c = []
d = []
for i in range(1,q+1):
    ai,bi,ci,di = map(int,input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)
AList =  list(itertools.combinations(range(1,m+1), n))
PointList = []
for array in AList:
    point = 0
    for j in range(q):
        if array[b[j]-1] - array[a[j]-1] == c[j]:
            point = point + d[j]
    PointList.append(point)
print(max(PointList))


Fixed submission:
import itertools
n,m,q = map(int,input().split())
inputList = []
for i in range(1,q+1):
    abcd = list(map(int,input().split()))
    inputList.append(abcd)
AList =  list(itertools.combinations_with_replacement(range(1,m+1), n))
PointList = []
for array in AList:
    point = 0
    for iList in inputList:
        if array[iList[1]-1] - array[iList[0]-1] == iList[2]:
            point = point + iList[3]
    PointList.append(point)
print(max(PointList))
Buggy python submission (verdict: Runtime Error):
import numpy as np
A,B,N = map(int,input().split())
def f(x):
    return floor(A * x / B) - A * floor(x / B)
def floor(x):
    return x.astype(np.int64)
xArray = np.asarray(range(1,N+1))
score = np.zeros(len(xArray),np.int64)
score += f(xArray)
print(score.max())

Fixed submission:
A,B,N = map(int,input().split())
def f(x):
    return int((A *( x % B ) - (A * x % B)) / B)
if N >= B-1:
    print(f(B-1))
else:
    print(f(N))

Buggy python submission (verdict: Runtime Error):
import numpy as np
A,B,N = map(int,input().split())
narray = np.asarray(range(1,N+1))
store = np.zeros(len(narray),np.int64)
AxPerB = (A * narray) / B
xPerB = (narray / B)
store += AxPerB.astype(np.int64) - A * xPerB.astype(np.int64)
print(store.max())


Fixed submission:
A,B,N = map(int,input().split())
def f(x):
    return int((A *( x % B ) - (A * x % B)) / B)
if N >= B-1:
    print(f(B-1))
else:
    print(f(N))

Buggy python submission (verdict: Runtime Error):
import numpy as np
A,B,N = map(int,input().split())
narray = np.asarray(range(1,N+1))
store = np.zeros(len(narray),np.int32)
AxPerB = (A * narray) / B
xPerB = (narray / B)
store += AxPerB.astype(np.int32) - A * xPerB.astype(np.int32)
print(store.max())


Fixed submission:
A,B,N = map(int,input().split())
def f(x):
    return int((A *( x % B ) - (A * x % B)) / B)
if N >= B-1:
    print(f(B-1))
else:
    print(f(N))
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))

data=[]
for n1 in range(N):
  data.append([])
  for n2 in range(N):
    data[n1].append(0)
    
for m in range(M):
  a,b=map(int,input().split(' '))
  data[a-1][b-1]=H[b-1]
  data[b-1][a-1]=H[a-1]
ans=0
for n in range(N):
  if H[n-1]>max(data[n-1]):
    ans+=1
print(ans)

Fixed submission:
N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))

data=[]
for n in range(N):
  data.append(H[n]-1)
    
for m in range(M):
  a,b=map(int,input().split(' '))
  data[a-1]=max(data[a-1],H[b-1])
  data[b-1]=max(data[b-1],H[a-1])
  
ans=0
for n in range(N):
  if H[n-1]-1==data[n-1]:
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))

data=[]
for n1 in range(N):
  data.append([])
  for n2 in range(N):
    data[n1].append(0)
    
for m in M:
  a,b=map(int,input().split(' '))
  data[a-1][b-1]=H[b-1]
  data[b-1][a-1]=H[a-1]
ans=0
for n in N:
  if H[n-1]>max(data[n-1]):
    ans+=1
print(ans)

Fixed submission:
N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))

data=[]
for n in range(N):
  data.append(H[n]-1)
    
for m in range(M):
  a,b=map(int,input().split(' '))
  data[a-1]=max(data[a-1],H[b-1])
  data[b-1]=max(data[b-1],H[a-1])
  
ans=0
for n in range(N):
  if H[n-1]-1==data[n-1]:
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split(' '))
H=map(int,input().split(' '))

data={{0 for in range(N)} for n in range(N)}

for m in range(M):
  

Fixed submission:
N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))

data=[]
for n in range(N):
  data.append(H[n]-1)
    
for m in range(M):
  a,b=map(int,input().split(' '))
  data[a-1]=max(data[a-1],H[b-1])
  data[b-1]=max(data[b-1],H[a-1])
  
ans=0
for n in range(N):
  if H[n-1]-1==data[n-1]:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    a,b,c,k = map(int, input().split())
    i = 0
    ans = 0
    while i < k:
        if a:
            a -= 1
            i += 1
            ans += 1
        elif b:
            b -= 1
            i += 1
        else:
            c -= 1
            i += 1
            ans -=1
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    a,b,c,k = map(int, input().split())
    if a > k:
        ans = k
    elif a + b < k:
        c_n = k - (a+b)
        ans = a - c_n
    else:
        ans = a
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = [e+i+1 for i,e in enumerate(a)]
    c = [i+1-e for i,e in enumerate(a) if i+1-e > 1]
    ans = 0
    for i in c:
        ans += b.count(i)
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = Counter([e+i+1 for i,e in enumerate(a)])
    c = Counter([i+1-e for i,e in enumerate(a) if i+1-e > 1])
    ans = 0
    for i in c:
        ans += b[i] * c[i]
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        c = a[i]
        for j,e in enumerate(a[:i]):
            if e + c == abs(j-i):
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = Counter([e+i+1 for i,e in enumerate(a)])
    c = Counter([i+1-e for i,e in enumerate(a) if i+1-e > 1])
    ans = 0
    for i in c:
        ans += b[i] * c[i]
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import deque
def main():
    n,m = map(int, input().split())
    if n%2==0 and 2*(m+1)==n:
        lst = deque([i for i in range(1,n+1)])
        for i in range(1,m+1):
            a = lst.popleft()
            b = a + i
            lst.remove(b)
            print(str(a)+' '+str(b))
    else:
        for i in range(1,n//2+1):
            print(str(i)+' '+str(n-i))
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n,m = map(int, input().split())
    if n%2==0 and 2*(m+1)==n:
        if n%4:
            for i in range(1,n//4+1):
                print(i,n//2-i)
            j = n

            for i in range(n//2+1,n//2+n//4+1):
                print(i,j)
                j -= 1
        else:
            for i in range(1,n//4+1):
                print(i,n//2+1-i)
            j = n-1
            for i in range(n//2+1,n//2+n//4):
                print(i,j)
                j -= 1
    else:
        for i in range(1,m+1):
            print(i,n-i)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from collections import deque
def main():
    n,m = map(int, input().split())
    lst = deque([i for i in range(1,n+1)])
    for i in range(1,m+1):
        a = lst.popleft()
        b = a + i
        lst.remove(b)
        print(str(a)+' '+str(b))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n,m = map(int, input().split())
    if n%2==0 and 2*(m+1)==n:
        if n%4:
            for i in range(1,n//4+1):
                print(i,n//2-i)
            j = n

            for i in range(n//2+1,n//2+n//4+1):
                print(i,j)
                j -= 1
        else:
            for i in range(1,n//4+1):
                print(i,n//2+1-i)
            j = n-1
            for i in range(n//2+1,n//2+n//4):
                print(i,j)
                j -= 1
    else:
        for i in range(1,m+1):
            print(i,n-i)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n,m = map(int, input().split())
    lst = [i for i in range(1,n+1)]
    for i in range(1,m+1):
        a = lst.pop(0)
        b = a + i
        lst.remove(b)
        print('{} {}'.format(a,b))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n,m = map(int, input().split())
    if n%2==0 and 2*(m+1)==n:
        if n%4:
            for i in range(1,n//4+1):
                print(i,n//2-i)
            j = n

            for i in range(n//2+1,n//2+n//4+1):
                print(i,j)
                j -= 1
        else:
            for i in range(1,n//4+1):
                print(i,n//2+1-i)
            j = n-1
            for i in range(n//2+1,n//2+n//4):
                print(i,j)
                j -= 1
    else:
        for i in range(1,m+1):
            print(i,n-i)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin

def main():
    n = int(input())
    lst = set([stdin.readline()[:-1] for _ in range(n)])
    print(len(lst)))

if __name__ == '__main__':
    main()

Fixed submission:
from sys import stdin

def main():
    n = int(input())
    lst = list(set([stdin.readline()[:-1] for _ in range(n)]))
    print(len(lst))

if __name__ == '__main__':
    main()