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

Fixed submission:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
import time
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
#    n = 500
    cos = [[min(i,j,n-1-i,n-1-j) for i in range(n)] for j in range(n)]
#    p = [(i//n,i%n) for i in range(n**2)]
    p = [((int(i)-1)//n,(int(i)-1)%n) for i in ipt().split()]
    ans = 0
    q = []
    al = [[True]*n for i in range(n)]

    for px,py in p:
        ans += cos[px][py]
        q.append((px,py,cos[px][py]))
        al[px][py] = False
        while q:
            qx,qy,qc = q.pop()
            if qx != 0 and cos[qx-1][qy] > qc:
                cos[qx-1][qy] = qc
                q.append((qx-1,qy,qc+al[qx-1][qy]))
            if qx != n-1 and cos[qx+1][qy] > qc:
                cos[qx+1][qy] = qc
                q.append((qx+1,qy,qc+al[qx+1][qy]))
            if qy != 0 and cos[qx][qy-1] > qc:
                cos[qx][qy-1] = qc
                q.append((qx,qy-1,qc+al[qx][qy-1]))
            if qy != n-1 and cos[qx][qy+1] > qc:
                cos[qx][qy+1] = qc
                q.append((qx,qy+1,qc+al[qx][qy+1]))

    print(ans)

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
import time
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
#    n = 500
    cos = [[min(i,j,n-1-i,n-1-j) for i in range(n)] for j in range(n)]
#    p = [(i//n,i%n) for i in range(n**2)]
    p = [((int(i)-1)//n,((int(i)-1)%n) for i in ipt().split()]
    ans = 0
    q = []
    al = [[True]*n for i in range(n)]

    for px,py in p:
        ans += cos[px][py]
        q.append((px,py,cos[px][py]))
        al[px][py] = False
        while q:
            qx,qy,qc = q.pop()
            if qx != 0 and cos[qx-1][qy] > qc:
                cos[qx-1][qy] = qc
                q.append((qx-1,qy,qc+al[qx-1][qy]))
            if qx != n-1 and cos[qx+1][qy] > qc:
                cos[qx+1][qy] = qc
                q.append((qx+1,qy,qc+al[qx+1][qy]))
            if qy != 0 and cos[qx][qy-1] > qc:
                cos[qx][qy-1] = qc
                q.append((qx,qy-1,qc+al[qx][qy-1]))
            if qy != n-1 and cos[qx][qy+1] > qc:
                cos[qx][qy+1] = qc
                q.append((qx,qy+1,qc+al[qx][qy+1]))

    print(ans)

    return

if __name__ == '__main__':
    main()
Problem p02687 (python)

Fixed submission:
import numpy as np
import math
s = input()
if s == "ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
s = input()
if s == "ABC"
    print("ARC")
else:
    print("ABC")
Problem p02690 (python)

Fixed submission:
import numpy as np
import math
x = int(input())
ys = []
i = 1
while i**2 < x:
    if x%i == 0:
        ys.append(i)
        ys.append(x//i)
    i += 1
if i**2 == x:
    ys.append(i)

f = False

for j in ys:
    for i in range(10**3):
        if i**5-(i-j)**5 == x:
            print(i,i-j)
            break
        elif i**5-(i-j)**5 > x and i-j > 0:
            break
    if f:
        break

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
x = int(input())
flag = False
for i in range(10**10):
    for j in range(1,10**10):
        if (i+j)**5-i**5 == x:
            print(i+j,j)
            flag = True
            break
        elif (i+j)**5-i**5 > x:
            break
    if Flag:
        break

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
x = int(input())
flag = False
for i in range(10**10):
    for j in range(1,10**10):
        if (i+j)**5-i**5 == x:
            print(i+j,j)
            flag = True
            break
    if Flag:
        break
Problem p02697 (python)

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

if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+i+1)
else:
    ni = 1
    l = 1
    r = n
    while ni <= n//4 and ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
    r -= 1
    while ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())

if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+i+1)
else:
    ni = 1
    while ni < n//4 and ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
    r -= 1
    while ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())

if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+i+1)
else:
    ni =1
    while ni < n//4 and ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
    r -= 1
    while ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
Problem p02702 (python)

Fixed submission:
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    s = list(map(int,ipt()))[::-1]
    d = defaultdict(int)
    ans = 0
    ni = 0
    mod = 2019
    d[0] = 1
    n10 = 1
    for i in s:
        ni = (ni+i*n10)%mod
        d[ni] += 1
        n10 = (n10*10)%mod
    for i in d.values():
        ans += i*(i-1)//2
    print(ans)

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    s = list(map(int,ipt()))[::-1]
    d = defaultdict(int)
    ans = 0
    ni = 0
    mod = 2019
    d[0] = 1
    n10 = 1
    for i in s:
        ni = (ni+i*n10)%mod
        d[ni] += 1
        n10 = (n10*10)%mod
    for i in d.values():
        ans += i*(i-1)//2
    print(ans)

    return

if __name__ == '__main__':
    main()
Problem p02717 (python)

Fixed submission:
x,y,z = map(int,input().split())
print(z,x,y)

Buggy submission (verdict: Runtime Error):
x,y,z = map(int,input())
print(z,x,y)
Problem p02720 (python)

Fixed submission:
import queue
k = int(input())
q = queue.Queue()

for i in range(1,10):
    q.put(i)

for i in range(k):
    x = q.get()
    if not x%10 == 0:
        q.put(10*x+(x%10)-1)
    q.put(10*x+(x%10))
    if not x%10 == 9:
        q.put(10*x+(x%10)+1)

print(x)

Buggy submission (verdict: Runtime Error):
import queue
k = int(input)
q = queue.Queue()

for i in range(1,10):
    q.put(i)

for i in range(k):
    x = q.get()
    if not x%10 == 0:
        q.put(10*x+(x%10)-1)
    q.put(10*x+(x%10))
    if not x%10 == 9:
        q.put(10*x+(x%10)+1)

print(x)
Problem p02721 (python)

Fixed submission:
n,k,c = map(int,input().split())
s = input()
fro = []
bac = []

for i in range(n):
    if s[i] == "o" and (len(fro) == 0 or fro[-1]+c < i):
        fro.append(i)
    if s[n-i-1] == "o" and (len(bac) == 0 or bac[-1]-c > n-i-1):
        bac.append(n-i-1)

for i in range(k):
    if fro[i] == bac[k-i-1]:
        print(fro[i]+1)

Buggy submission (verdict: Runtime Error):
n,k,c = map(int,input().split())
s = input()
fro = []
bac = []

for i in range(n):
    if s[i] == "o" and (len(fro) == 0 or fro[-1]+c < i):
        fro.append(i)
    if s[n-i-1] == "o" and (len(bac) == 0 or bac[-1]-c > n-i):
        bac.append(n-i-1)

for i in range(k):
    if fro[i] == bac[-i-1]:
        print(fro[i]+1)
Problem p02732 (python)

Fixed submission:
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
sum = 0

kn = [0 for i in range(n+1)]
for i in range(n):
    kn[a[i]] += 1
for i in range(n+1):
    sum += kn[i]*(kn[i]-1)//2

for i in range(n):
    x = kn[a[i]]
    print(sum-x+1)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
sum = 0

kn = [0 for i in range(n)]
for i in range(n):
    kn[a[i]] += 1
for i in range(n):
    sum += kn[i]*(kn[i]-1)//2

for i in range(n):
    x = kn[a[i]]
    print(sum-x+1)
Problem p02755 (python)

Fixed submission:
import math
a, b = map(int,input().split())
e = 10**-7
mi = max(math.ceil(a*12.5),b*10)
ma = min(int(math.ceil((a+1)*12.5)-1),(b+1)*10-1)
if mi > ma:
    print(-1)
else:
    print(mi)

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int,input().split())
e = 10**-7
mi = max(math.ceil(a*12.5),b*10)
ma = min(int((a-1)+*12.5),b*10-1)
if mi > ma:
    print(-1)
else:
    print(mi)
Problem p02756 (python)

Fixed submission:
import numpy as np
s = input()
q = int(input())
rbef = []
aft = []
sgn = 1
for i in range(q):
    qi = np.array(input().split(),dtype=str)
    if qi[0] == "1":
        sgn *= -1
    else:
        if (qi[1] == "1" or sgn == -1) and (qi[1] == "2" or sgn == 1):
            rbef.append(qi[2])
        else:
            aft.append(qi[2])

bef = "".join(reversed(rbef))
taft = "".join(aft)
ans = bef + s + taft

if sgn == 1:
    print(ans)
else:
    rans = ''.join(list(reversed(ans)))
    print(rans)

Buggy submission (verdict: Runtime Error):
import numpy as np
s = input()
q = int(input())
rbef = []
aft = []
sgn = 1
for i in range(q):
    qi = np.array(input().split(),dtype=str)
    if qi[0] == "1":
        sgn *= -1
    else:
        if (qi[1] == "1" or sgn == -1) and (qi[1] == "2" or sgn == 1):
            rbef.append(qi[2])
        else:
            aft.append(qi[2])


bef = ''.join(list(reversed(rbef)))
ans = (''.join(reversed(rbef))+s).join(aft)

if sgn == 1:
    print(ans)
else:
    rans = ''.join(list(reversed(ans)))
    print(rans)
Problem p02761 (python)

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

ans = [-1 for i in range(n)]

pf = True
for i in range(m):
    s,c = map(int,input().split())
    if ((not ans[s-1] == -1) and (not ans[s-1] == c)) or ((not n == 1)and s == 1 and c == 0):
        print(-1)
        pf = False
        break
    else:
        ans[s-1] = c

if pf and n == 1:
    if ans[0] == -1:
        print(0)
    else:
        print(ans[0])
elif pf:
    if ans[0] == -1:
        ans[0] = 1
    for i in range(n):
        if ans[i] == -1:
            ans[i] = 0
    print(''.join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())

for i in range(n):
    ans += "x"

pf = True
for i in range(m):
    s,c = map(int,input().split())
    if (not ans[s] == "x") and (not ans[s] == str(c)):
        print(-1)
        pf = False
        break
    else:
        ans[s] = str(c)

if pf:
    if ans[0] == "x":
        ans[0] = "1"
    for i in range(n):
        if ans[i] == "x":
            ans[i] = "0"
print(ans)
Problem p02765 (python)

Fixed submission:
n, r = map(int,input().split())
if n < 10:
    print(r+100*(10-n))
else:
    print(r)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
know = 1
for i in range(n):
    if (n+0.5)//know == 0:
        print(i)
        break
    else:
        know *= k
Problem p02768 (python)

Fixed submission:
n, a, b = map(int,input().split())
mod = 10**9+7

def rev(x):
    re = 10**9+5
    num = 1
    ix = x
    while re > 0:
        if re%2 == 1:
            num = (num*ix)%mod
        re //= 2
        ix = (ix**2)%mod
    return(num)

def kaijo(x):
    num = 1
    for i in range(1,x+1):
        num = (num*i)%mod
    return(num)

re = n
ans = 1
i2 = 2
while re > 0:
    if re%2 == 1:
        ans = (ans*i2)%mod
    re //= 2
    i2 = (i2**2)%mod
nca = 1
ncb = 1
for i in range(a):
    nca = (nca*(n-i))%mod
for i in range(b):
    ncb = (ncb*(n-i))%mod

ans -= 1
ans = (ans-(nca*rev(kaijo(a)))%mod)%mod
ans = (ans-(ncb*rev(kaijo(b)))%mod)%mod

print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int,input().split())
mod = 10**9+7

def rev(x):
    re = 10**9+5
    num = 1
    ix = x
    while re > 0:
        if re%2 == 1:
            num = (num*ix)%mod
        re //= 2
        ix = (ix**2)%mod
    return(num)

def kaijo(x):
    num = 1
    for i in range(1,x+1):
        num = (num*i)%mod
    return(num)

re = n
ans = 1
i2 = 2
while re > 0:
    if re%2 == 1:
        ans = (ans*i2)%mod
    re //= 2
    i2 = (i2**2)%mod

ans -= 1
kn = kaijo(n)
ans = (ans - (((kn*rev(kaijo(a)))%mod)*rev(kaijo[n-a]))%mod)%mod
ans = (ans - (((kn*rev(kaijo(b)))%mod)*rev(kaijo[n-b]))%mod)%mod
print(ans)
Problem p02780 (python)

Fixed submission:
import numpy as np
n, k = map(int,input().split())
p = np.array(input().split(),dtype=int)

sum = 0
for i in range(k):
    sum += p[i]
max = sum
for i in range(n-k):
    sum = sum+p[k+i]-p[i]
    if max<sum:
        max = sum
print(max/2+0.5*k)

Buggy submission (verdict: Runtime Error):
import numpt as np
n, k = map(int,input().split())
p = np.array(input().split(),dtype=int)

sum = 0
for i in range(k):
    sum += p[i]
max = sum
for i in range(n-k):
    sum = sum+p[k+i]-p[i]
    if max<sum:
        max = sum
print(max/k)
Problem p02787 (python)

Fixed submission:
import numpy as np
h, n = map(int,input().split())
a = np.zeros(n,dtype=int)
b = np.zeros(n,dtype=int)
for i in range(n):
    ai ,bi = map(int,input().split())
    a[i] = ai
    b[i] = bi

mh = np.zeros(10001,dtype=int)
for i in range(1,h+1):
    mh[i] = (mh[i-a]+b).min()

print(mh[h])

Buggy submission (verdict: Runtime Error):
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    h,n = map(int,ipt().split())
    atks = [tuple(map(int,ipt().split())) for i in range(n)]
    dam = [10**18]*(h+1)
    dam[0] = 0
    for i in range(1,h+1):
        for aj,bj in atks:
            if aj > i and dam[i] > bj:
                dam[i] = bj
            elif dam[i] > dam[i-aj]+bj:
                dam[i] = dam[i-aj]+bj

    print(dam[h])

    return None

if __name__ == '__main__':
    main()
Problem p02788 (python)

Fixed submission:
import math
n, d, a = map(int,input().split())
e = [[] for i in range(n)]
for i in range(n):
    x, h = map(int,input().split())
    e[i] = [x,h]
num = 0

e.sort()
sd = [0 for i in range(n)]
l = [i for i in range(n)]
for i in range(n):
    for j in range(l[i-1],i):
        if e[i][0]-e[j][0] <= 2*d:
            l[i] = j
            break

for i in range(n):
    res = e[i][1] - sd[i-1] + sd[l[i]-1]
    if res < 0:
        sd[i] = sd[i-1]
    else:
        k = math.ceil(res/a)
        sd[i] = sd[i-1]+k*a
        num += k

print(num)

Buggy submission (verdict: Runtime Error):
import math
n, d, a = map(int,input().split())
e = [[] for i in range(n)]
for i in range(n):
    x, h = map(int,input().split())
    e[i] = [x,h]
num = 0

e.sort()
sd = [0 for i in range(n)]
l = [i for i in range(n)]
for i in range(n):
    for j in range(l[i-1],i):
        if e[i][0]-e[j][0] <= 2*d:
            l[i] = j
            break

for i in range(n):
    res = x[i][1] - sd[i-1] + sd[l[i]-1]
    if res < 0:
        sd[i] = sd[i-1]
    else:
        k = math.ceil(res/a)
        sd[i] = sd[i-1]+k*a
        num += k
        
print(num)
Problem p02789 (python)

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

if n == m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, m = map(int,input(),split())

if n == m:
    print("Yes")
else:
    print("No")
Problem p02797 (python)

Fixed submission:
n, k, s = map(int,input().split())
if s == 10**9:
    ans = [1 for i in range(n)]
    for i in range(k):
        ans[i] = 10**9
else:
    ans = [10**9 for i in range(n)]
    for i in range(k):
        ans[i] = s

print(" ".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
n, k, s = map(int,input().split())
if s == 10**9:
    ans = [0 for i in range(n)]
    ans[0] = 10**9-n+k
    for i in range(1,n-k+1):
        ans[i] = 1
else:
    ans = [10**9 for i in range(n)]
    ans[0] = s
    for i in range(1,k):
        ans[i] = 0

print(" ".join(map(str,ans)))
Problem p02802 (python)

Fixed submission:
n, m = map(int,input().split())
a = [[0,0] for i in range(n)]
ac = 0
wa = 0

for i in range(m):
    p, s = input().split()
    p = int(p)-1
    if s == "WA" and a[p][1] == 0:
        a[p][0] += 1
    elif s == "AC" and a[p][1] == 0:
        ac += 1
        a[p][1] = 1

for i in a:
    if i[1] == 1:
        wa += i[0]

print(ac,wa)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = [[0,0] for i in range(n)]
ac = 0
wa = 0

for i in range(m):
    p, s = input().split()
    p = int(p-1)
    if s == "WA" and a[p][1] == 0:
        a[p][0] += 1
    elif s == "AC" and a[p][1] == 0:
        ac += 1
        a[p][1] = 1

for i in a:
    if i[1] == 1:
        wa += i[0]

print(ac,wa)
Problem p02838 (python)

Fixed submission:
#https://atcoder.jp/contests/abc147/submissions/12994515を見た

import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
mod = 10**9+7
m2 = [1 for i in range(60)]
for i in range(1,60):
    m2[i] = (m2[i-1]*2)%mod

ans = 0
for i in range(60):
    ni = np.count_nonzero(a&1)
    ans = (ans+ni*(n-ni)%mod*m2[i])%mod
    a >>= 1

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
now = 1

sum = np.zeros(60,dtype=int)
for i in a:
    ii = i
    for j in range(60):
        if ii%2 == 1:
            sum[j] += 1
        ii //= 2
        if ii == 0:
            break
    sum += aa

for i in range(60):
    k = (sum[i]*(n-sum[i]))%mod
    ans = (ans+(k*now)%mod)%mod
    now = (now*2)%mod

print(ans)
Problem p02937 (python)

Fixed submission:
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    s = input()
    ls = len(s)
    t = input()
    if t[0] in s:
        idx = s.find(t[0])
    else:
        print(-1)
        exit()
    for i in t[1::]:
        nt = s.find(i,idx%ls+1)
        ntl = s.find(i)
        if ntl == -1:
            print(-1)
            exit()
        elif nt == -1:
            idx = (idx//ls)*ls+ls+ntl
        else:
            idx = (idx//ls)*ls+nt
    print(idx+1)
    return None

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    s = input()
    t = input()
    ls = len(s)
    lt = len(t)
    for i in t:
        if not i in s:
            print(-1)
            exit()
    s *= lt
    nm = 0
    for i,si in enumerate(s):
        if si == t[nm]:
            nm += 1
        if nm == lt:
            print(i+1)
            exit()

    return None

if __name__ == '__main__':
    main()
Problem p02983 (python)

Fixed submission:
l, r = map(int,input().split())
if not l//2019 == r//2019:
    print(0)
else:
    l = l%2019
    r = r%2019
    ans = 10**10
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ans > (i*j)%2019:
                ans = (i*j)%2019
    print(ans)

Buggy submission (verdict: Runtime Error):
l, r = map(int,input().split())
if not l//2019 == r//2019:
    print(0)
else:
    l %= 2019
    r %= 2019
    ans = 10**10
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ans > (i*j)%2019:
                ans = (i*j)%2019

print(ans)
Problem p03006 (python)

Fixed submission:
n = int(input())
d = dict()
p = []
for i in range(n):
    x,y = map(int,input().split())
    for j in p:
        if str(x-j[0])+" "+str(y-j[1]) in d:
            d[str(x-j[0])+" "+str(y-j[1])] += 1
        else:
            d[str(x-j[0])+" "+str(y-j[1])] = 1
        if str(j[0]-x)+" "+str(j[1]-y) in d:
            d[str(j[0]-x)+" "+str(j[1]-y)] += 1
        else:
            d[str(j[0]-x)+" "+str(j[1]-y)] = 1
    p.append([x,y])

if len(d.values()) == 0:
    ans = 0
else:
    ans = max(d.values())
print(n-ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = dict()
p = []
for i in range(n):
    x,y = map(int,input().split())
    for j in p:
        if str(x-j[0])+" "+str(y-j[1]) in d:
            d[str(x-j[0])+" "+str(y-j[1])] += 1
        else:
            d[str(x-j[0])+" "+str(y-j[1])] = 1
        if str(j[0]-x)+" "+str(j[1]-y) in d:
            d[str(j[0]-x)+" "+str(j[1]-y)] += 1
        else:
            d[str(j[0]-x)+" "+str(j[1]-y)] = 1
    p.append([x,y])

ans = max(d.values())
print(n-ans)
Problem p03007 (python)

Fixed submission:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    a.sort()

    if n == 2:
        print(a[1]-a[0])
        print(a[1],a[0])
    else:
        if a[1] > 0:
            ans = a[0]-a[-1]
            op = [(a[0],a[-1])]
        else:
            ans = a[-1]-a[0]
            op = [(a[-1],a[0])]
        f = True
        for i in range(1,n-2):
            if f and a[i+1] > 0:
                f = False
            if f:
                op.append((max(ans,a[i]),min(ans,a[i])))
                ans = max(ans,a[i])-min(ans,a[i])
            else:
                op.append((min(ans,a[i]),max(ans,a[i])))
                ans = min(ans,a[i])-max(ans,a[i])
        op.append((max(ans,a[n-2]),min(ans,a[n-2])))
        ans = max(ans,a[n-2])-min(ans,a[n-2])
        print(ans)
        for x,y in op:
            print(x,y)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [(abs(int(i)),int(i)) for i in ipt().split()]
    a.sort()
    if a[2][1] > 0:
        op = [(a[0][1],a[1][1])]
        ans = a[0][1]-a[1][1]
    else:
        ans = a[1][1]-a[0][1]
        op = [(a[1][1],a[0][1])]
    for i,ai in enumerate(a[2:n-1:]):
        if a[i+3][1] > 0:
            op.append((min(ans,ai[1]),max(ans,ai[1])))
            ans = min(ans,ai[1])-max(ans,ai[1])
        else:
            op.append((max(ans,ai[1]),min(ans,ai[1])))
            ans = max(ans,ai[1])-min(ans,ai[1])
    op.append((max(ans,a[n-1][1]),min(ans,a[n-1][1])))
    ans = max(ans,a[n-1][1])-min(ans,a[n-1][1])
    print(ans)
    for x,y in op:
        print(x,y)
    return

if __name__ == '__main__':
    main()