Harryxun/testdata huggingface dataset:
Buggy python 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()


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 python submission (verdict: Runtime Error):
l = input()
mod = 10**9+7

def dfs(ni,t1,na):
    if ni == len(l):
        return (na+pow(2,t1,mod))%mod
    if l[ni] == "0":
        return dfs(ni+1,t1,na)
    else:
        na = (na+pow(2,t1,mod)*pow(3,len(l)-1-ni,mod)%mod)%mod
        return dfs(ni+1,t1+1,na)

ans=dfs(0,0,0)

print(ans)


Fixed submission:
l = str(input())
ll = len(l)
mod = 10**9+7

ans = 0
t1 = 0
for i in range(ll):
    if l[i] == "0":
        continue
    ans = (ans+pow(2,t1,mod)*pow(3,ll-i-1,mod)%mod)%mod
    t1 += 1

ans = (ans+pow(2,t1,mod))%mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())
a = []
ai = 0
bs = 0
for i in range(q):
    ipt = list(map(int,input().split()))
    if ipt[0] == 1:
        a.append(ipt[1])
        bs += ipt[2]
        ai += 1
    else:
        a.sort()
        an = a[(ai-1)//2]
        bn = bs
        for j in a:
            bn += abs(j-an)
        print(an,bn)


Fixed submission:
import heapq
q = int(input())
l = []
r = []
ai = 0
bs = 0
for i in range(q):
    ipt = list(map(int,input().split()))
    if ipt[0] == 1:
        al = heapq.heappushpop(l,-ipt[1])
        ar = heapq.heappushpop(r,ipt[1])
        ai -= (al+ar)
        heapq.heappush(l,-ar)
        heapq.heappush(r,-al)
        bs += ipt[2]
    else:
        an = heapq.heappop(l)
        print(-an,bs+ai)
        heapq.heappush(l,an)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
x,y,z,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
al = [[[0 for i in range(z)] for j in range(y)] for jj in range(x)]

hq = []
heapq.heappush(hq,(-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    hqi,ai,bi,ci = heapq.heappop(hq)
    print(-hqi)
    if ai+1 < x and al[ai+1][bi][ci] == 0:
        heapq.heappush(hq,(-(a[ai+1]+b[bi]+c[ci]),ai+1,bi,ci))
        al[ai+1][bi][ci] = -1
    if bi+1 < y and al[ai][bi+1][ci] == 0:
        heapq.heappush(hq,(-(a[ai]+b[bi+1]+c[ci]),ai,bi+1,ci))
        al[ai][bi+1][ci] = -1
    if ci+1 < z and al[ai][bi][ci+1] == 0:
        heapq.heappush(hq,(-(a[ai]+b[bi]+c[ci+1]),ai,bi,ci+1))
        al[ai][bi][ci+1] = -1


Fixed submission:
import heapq
x,y,z,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
al = []

hq = []
heapq.heappush(hq,(-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    hqi,ai,bi,ci = heapq.heappop(hq)
    print(-hqi)
    if ai+1 < x and not (ai+1,bi,ci) in al:
        heapq.heappush(hq,(-(a[ai+1]+b[bi]+c[ci]),ai+1,bi,ci))
        al.append((ai+1,bi,ci))
    if bi+1 < y and not (ai,bi+1,ci) in al:
        heapq.heappush(hq,(-(a[ai]+b[bi+1]+c[ci]),ai,bi+1,ci))
        al.append((ai,bi+1,ci))
    if ci+1 < z and not (ai,bi,ci+1) in al:
        heapq.heappush(hq,(-(a[ai]+b[bi]+c[ci+1]),ai,bi,ci+1))
        al.append((ai,bi,ci+1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
ps = [1]
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nm <= mi:
    ps.append(nw)

print(max(ps))


Fixed submission:
n, m = map(int,input().split())
ps = [1]
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nw <= mi:
    ps.append(nw)

print(max(ps))

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
ps = []
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nm <= mi:
    ps.append(nw)

print(max(ps))


Fixed submission:
n, m = map(int,input().split())
ps = [1]
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nw <= mi:
    ps.append(nw)

print(max(ps))
Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = map(int,input().split())
ways = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r = map(int,input().split())
    ways[l][r] += 1

sgways = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(i,n+1):
        for k in range(i,j+1):
            sgways[i][j] += ways[k][j]


ans = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(i,n+1):
        for k in range(i,j+1):
            ans[i][j] += sgways[i][k]
for i in range(q):
    pi,qi = map(int,input().split())
    print(ans[pi][qi])


Fixed submission:
n, m, q = map(int,input().split())
ways = [[0 for i in range(n+2)] for j in range(n+2)]
for i in range(m):
    l,r = map(int,input().split())
    ways[l][r] += 1

sgways = [[0 for i in range(n+2)] for j in range(n+2)]
for j in range(1,n+1):
    for i in range(j):
        sgways[j-i][j] = sgways[j-i+1][j] +ways[j-i][j]

ans = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(i,n+1):
        ans[i][j] = ans[i][j-1]+sgways[i][j]
for i in range(q):
    pi,qi = map(int,input().split())
    print(ans[pi][qi])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n = int(input())
s = input()
ls = s[:n:]
rs = s[:n-1:-1]
dl = defaultdict(int)
dr = defaultdict(int)

for i in range(2**n):
    lr = ""
    rr = ""
    lb = ""
    rb = ""
    ii = i
    for j in range(n):
        if ii&1 == 1:
            lr += ls[j]
            rr += rs[j]
        else:
            lb += ls[j]
            rb += rs[j]
        ii >>= 1
    dl[(lr,lb)] += 1
    dr[(rr,rb)] += 1

ans = 0
for dlk,dlv in dl.items():
    ans += dlv*dr[dlk]

print(ans)


Fixed submission:
#https://atcoder.jp/contests/agc026/submissions/10971924を参考にした

from collections import defaultdict
n = int(input())
s = input()
ls = s[:n:]
rs = s[:n-1:-1]
d = defaultdict(int)

def full_research(sa,r,b,t):
    if t == n:
        d[(r,b)] += 1
        return
    full_research(sa,r+sa[t],b,t+1)
    full_research(sa,r,b+sa[t],t+1)

full_research(ls,"","",0)
dl = d
d = defaultdict(int)
full_research(rs,"","",0)

ans = 0
for dlk,dlv in dl.items():
    ans += dlv*d[dlk]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ls = s[:n:]
rs = s[:n-1:-1]
dl = dict()
dr = dict()

for i in range(2**n):
    lr = ""
    rr = ""
    lb = ""
    rb = ""
    ii = i
    for j in range(n):
        if ii&1 == 1:
            lr += ls[j]
            rr += rs[j]
        else:
            lb += ls[j]
            rb += rs[j]
        ii >>= 1
    dl[(lr,lb)] = dl.get((lr,lb),0)+1
    dr[(rr,rb)] = dr.get((rr,rb),0)+1

ans = 0
for dlk,dlv in dl.items():
    ans += dlv*dr.get(dlk,0)

print(ans)


Fixed submission:
#https://atcoder.jp/contests/agc026/submissions/10971924を参考にした

from collections import defaultdict
n = int(input())
s = input()
ls = s[:n:]
rs = s[:n-1:-1]
d = defaultdict(int)

def full_research(sa,r,b,t):
    if t == n:
        d[(r,b)] += 1
        return
    full_research(sa,r+sa[t],b,t+1)
    full_research(sa,r,b+sa[t],t+1)

full_research(ls,"","",0)
dl = d
d = defaultdict(int)
full_research(rs,"","",0)

ans = 0
for dlk,dlv in dl.items():
    ans += dlv*d[dlk]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ls = s[:n:]
rs = s[:n-1:-1]
dl = dict()
dr = dict()

for i in range(2**n):
    lr = ""
    rr = ""
    lb = ""
    rb = ""
    ii = i
    for j in range(n):
        if ii%2 == 1:
            lr += ls[j]
            rr += rs[j]
        else:
            lb += ls[j]
            rb += rs[j]
        ii >>= 1
    dl[(lr,lb)] = dl.get((lr,lb),0)+1
    dr[(rr,rb)] = dr.get((rr,rb),0)+1

ans = 0
for dlk,dlv in dl.items():
    ans += dlv*dr.get(dlk,0)

print(ans)


Fixed submission:
#https://atcoder.jp/contests/agc026/submissions/10971924を参考にした

from collections import defaultdict
n = int(input())
s = input()
ls = s[:n:]
rs = s[:n-1:-1]
d = defaultdict(int)

def full_research(sa,r,b,t):
    if t == n:
        d[(r,b)] += 1
        return
    full_research(sa,r+sa[t],b,t+1)
    full_research(sa,r,b+sa[t],t+1)

full_research(ls,"","",0)
dl = d
d = defaultdict(int)
full_research(rs,"","",0)

ans = 0
for dlk,dlv in dl.items():
    ans += dlv*d[dlk]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
'''
自宅用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)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = [0,a[0]]
    for i in a[1::]:
        sa.append(sa[-1]+i)

    mi = 10**18
    ll = 1
    rr = 3
    for ci in range(2,n-1):
        ls = sa[ci]
        rs = sa[-1]
        nms = []
        pld = 10**18
        for l in range(ll,ci):
            al = sa[l]
            d = abs(ls-2*al)
            if pld > d:
                pld = d
                sl = (al,ls-al)
            else:
                ll = l-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        pld = 10**18
        for r in range(rr,n):
            ar = sa[r]
            d = abs(rs+ls-2*ar)
            if pld > d:
                pld = d
                sl = (rs-ar,ar-ls)
            else:
                rr = r-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        d = max(nms)-min(nms)
        if mi > d:
            mi = d

    print(mi)


    return None

if __name__ == '__main__':
    main()


Fixed submission:
'''
自宅用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)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = [0,a[0]]
    for i in a[1::]:
        sa.append(sa[-1]+i)

    mi = 10**18
    ll = 1
    rr = 3
    for ci in range(2,n-1):
        ls = sa[ci]
        rs = sa[-1]
        nms = []
        pld = 10**18
        for l in range(ll,ci):
            al = sa[l]
            d = abs(ls-2*al)
            if pld > d:
                pld = d
                sl = (al,ls-al)
                if l == ci:
                    ll = ci-1
            else:
                ll = l-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        pld = 10**18
        for r in range(rr,n):
            ar = sa[r]
            d = abs(rs+ls-2*ar)
            if pld > d:
                pld = d
                sl = (rs-ar,ar-ls)
                if r == n-1:
                    rr = n-1
            else:
                rr = r-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        d = max(nms)-min(nms)
        if mi > d:
            mi = d

    print(mi)


    return None

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
bbr = []
bbr.append([1,int(input())])
for i in range(n-1):
    p = int(input())
    for j in range(n):
        if bbr[j][1]+1 == p:
            bbr[j][1] += 1
            bbr[j][0] += 1
            break
        if j == len(bbr)-1:
            bbr.append([1,p])
            break

bbr.sort(reverse=True)
print(n-bbr[0][0])


Fixed submission:
n = int(input())
cn = [0 for i in range(n+1)]
for i in range(n):
    p = int(input())
    cn[p] = cn[p-1]+1

print(n-max(cn))
Buggy python submission (verdict: Time Limit Exceeded):
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():
    s = input()
    k = int(input())
    ss = set()
    alp = "abcdefghijklmnopqrstuvwxyz"
    for ai in alp:
        for i,si in enumerate(s):
            if si != ai:
                continue
            nw = ""
            for sj in s[i::]:
                nw += sj
                ss.add(nw)
        if len(ss) >= k:
            break
    print(sorted(ss)[k-1])



    return

if __name__ == '__main__':
    main()


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():
    s = input()
    k = int(input())
    ss = set()
    alp = "abcdefghijklmnopqrstuvwxyz"
    for ai in alp:
        for i,si in enumerate(s):
            if si != ai:
                continue
            nw = ""
            for sj in s[i::]:
                nw += sj
                if len(nw) > 5:
                    break
                ss.add(nw)
        if len(ss) >= k:
            break
    print(sorted(ss)[k-1])



    return

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
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():
    s = input()
    k = int(input())
    ss = set()
    for i in range(len(s)):
        nw = ""
        for sj in s[i::]:
            nw += sj
            ss.add(nw)

    print(sorted(ss)[k-1])



    return

if __name__ == '__main__':
    main()


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():
    s = input()
    k = int(input())
    ss = set()
    alp = "abcdefghijklmnopqrstuvwxyz"
    for ai in alp:
        for i,si in enumerate(s):
            if si != ai:
                continue
            nw = ""
            for sj in s[i::]:
                nw += sj
                if len(nw) > 5:
                    break
                ss.add(nw)
        if len(ss) >= k:
            break
    print(sorted(ss)[k-1])



    return

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
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():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = np.zeros(n,dtype=int)
    ans = 0
    for i,ai in enumerate(a):
        sa[:i+1:] += ai
        ans += np.count_nonzero(sa[:i+1:]==0)
    print(ans)

    return

if __name__ == '__main__':
    main()


Fixed submission:
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():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    d = defaultdict(int)
    sa = 0
    for i in a:
        sa += i
        d[sa] += 1
    ans = 0
    for iv in d.values():
        ans += iv*(iv-1)//2
    print(ans+d[0])
    return

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
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():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = np.zeros(n)
    for i,ai in enumerate(a):
        sa[i] = sa[i-1]+ai
    ans = np.count_nonzero(sa == 0)
    for i,ai in enumerate(a):
        sa = sa[1::]-ai
        ans += np.count_nonzero(sa == 0)
    print(ans)

    return

if __name__ == '__main__':
    main()


Fixed submission:
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():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    d = defaultdict(int)
    sa = 0
    for i in a:
        sa += i
        d[sa] += 1
    ans = 0
    for iv in d.values():
        ans += iv*(iv-1)//2
    print(ans+d[0])
    return

if __name__ == '__main__':
    main()
Buggy python 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():
    n = int(ipt())
#    n = 20000
    tn = (n//4)*4
    sm = 0
    nm = 0
    ans = []
    for i in range(1,30001):
        if i%2 == 0 or i%3 == 0:
            ans.append(i)
            sm += i
            nm += 1
        if nm == tn:
            break

    if n%4 == 0:
        pass
    elif n%4 == 1:
        ans.append(ans[-1]+6)
    elif n%4 == 2:
        ans.append(ans[-1]+2)
        ans.append(ans[-1]+2)
    else:
        ans.append(ans[-1]+2)
        ans.append(ans[-1]+2)
        ans.append(ans[-1]+2)

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


    return None

if __name__ == '__main__':
    main()


Fixed submission:
'''
自宅用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():
    n = int(ipt())
#    n = 20000
    if n == 3:
        print("2 3 25")
        exit()
    elif n == 4:
        print("2 5 20 63")
        exit()
    tn = (n//8)*8
    sm = 0
    nm = 0
    ans = []
    la = 0
    for i in range(1,30001):
        if i%2 == 0 or i%3 == 0:
            ans.append(i)
            sm += i
            nm += 1
        if nm == tn:
            if ans:
                la = ans[-1]
            break

    if n%8 == 0:
        pass
    elif n%8 == 1:
        ans.append(la+6)
    elif n%8 == 2:
        ans.append(la+2)
        ans.append(la+4)
    elif n%8 == 3:
        ans.append(la+2)
        ans.append(la+4)
        ans.append(la+6)
    elif n%8 == 4:
        ans.append(la+2)
        ans.append(la+4)
        ans.append(la+6)
        ans.append(la+12)
    elif n%8 == 5:
        ans.append(la+2)
        ans.append(la+3)
        ans.append(la+4)
        ans.append(la+6)
        ans.append(la+9)
    elif n%8 == 6:
        ans.append(la+2)
        ans.append(la+3)
        ans.append(la+4)
        ans.append(la+9)
        ans.append(la+8)
        ans.append(la+10)
    elif n%8 == 7:
        ans.append(la+2)
        ans.append(la+3)
        ans.append(la+4)
        ans.append(la+9)
        ans.append(la+8)
        ans.append(la+10)
        ans.append(la+12)


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


    return None

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math
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
input = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(input())
    a = [0]+list(map(int,input().split()))+[0]
    lc = [0 for i in range(n)]
    sum = abs(a[0]-a[1])
    for i in range(n):
        lc[i] = abs(a[i]-a[i+1])+abs(a[i+1]-a[i+2])-abs(a[i]-a[i+2])
        sum += abs(a[i+1]-a[i+2])
    for i in range(n):
        print(sum-lc[i])



if __name__ == '__main__':
    main()


Fixed submission:
import math
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
input = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(input())
    a = [0]+list(map(int,input().split()))+[0]
    lc = [0 for i in range(n)]
    sum = abs(a[0]-a[1])
    for i in range(n):
        lc[i] = abs(a[i]-a[i+1])+abs(a[i+1]-a[i+2])-abs(a[i]-a[i+2])
        sum += abs(a[i+1]-a[i+2])
    for i in range(n):
        print(sum-lc[i])



if __name__ == '__main__':
    main()