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

Fixed submission:
from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

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

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

x_sorted = x
x_sorted.append(X)
x_sorted.sort()

diff = []
for i, xi in enumerate(x_sorted):
    if i == 0:
        continue
    else:
        diff.append(xi - x_sorted[i-1])

print(gcd_list(diff))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(nums):
    return reduce(math.gcd, nums)

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

x_sorted = x
x_sorted.append(X)
x_sorted.sort()

diff = []
for i, xi in enumerate(x_sorted):
    if i == 0:
        continue
    else:
        diff.append(xi - x_sorted[i-1])

print(gcd(diff))
Problem p03547 (python)

Fixed submission:
x, y = list(input().split())

if x > y:
  print('>')
elif x < y:
  print('<')
else:
  print('=')

Buggy submission (verdict: Runtime Error):
x, y = list(input())

if x > y:
  print('>')
elif x < y:
  print('<')
else:
  print('=')
Problem p03556 (python)

Fixed submission:
N = int(input())
print(int(N**0.5)**2)

Buggy submission (verdict: Runtime Error):
N=gets.to_i
ans = 0
sq = (N**(0.5)).to_i
(sq..sq+10).each do |i|
    ans = i*i if i*i <= N
end
puts ans
Problem p03999 (python)

Fixed submission:
s = list(map(int,list(input())))

if len(s) == 1:
    print(s[0])
    exit()

from collections import deque

cands=deque([[0],[1]])

while len(cands[0]) != len(s)-1:
    newcands = []
    for cand in cands:
        newcands.append(cand+[0])
        newcands.append(cand+[1])
    cands = newcands

memo = []
while cands:
    pos = cands.pop()
    siki = ''
    for i, p in enumerate(pos):
        siki += str(s[i])
        if p == 1:
            siki += '+'
    siki += str(s[-1])
    memo.append(eval(siki))

print(sum(memo))

Buggy submission (verdict: Runtime Error):
s = list(map(int,list(input())))

if len(s) == 1:
    print(s[0])
    exit(1)

from collections import deque

cands=deque([[0],[1]])

while len(cands[0]) != len(s)-1:
    newcands = []
    for cand in cands:
        newcands.append(cand+[0])
        newcands.append(cand+[1])
    cands = newcands

memo = []
while cands:
    pos = cands.pop()
    siki = ''
    for i, p in enumerate(pos):
        siki += str(s[i])
        if p == 1:
            siki += '+'
    siki += str(s[-1])
    memo.append(eval(siki))

print(sum(memo))
Problem p02690 (python)

Fixed submission:
import math
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    if n < 0:
        break
    a = int(math.pow(n, 1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

if len(ans) != 0:
    print(*ans)
else:
    b = 0
    while True:
        n = x + b**5
        a = int(math.pow(n, 1/5))
        if a**5 == n:
           ans.append(a)
           ans.append(b)
           break
        b += 1
    print(*ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    a = int(np.power(n, 1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

print(*ans)

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    a = int(math.pow(n, 1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

print(*ans)

Buggy submission (verdict: Runtime Error):
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    a = int(n ** (1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

print(*ans)
Problem p02732 (python)

Fixed submission:
n = int(input())
list_A = list(map(int, input().split()))
list_B = list(set(list_A))
list_M = [0 for _ in range(n+1)]

for s in list_A:
    list_M[s] += 1
total = 0

for i in range(n+1):
    total += list_M[i]*(list_M[i]-1)//2

for s in list_A:
    ans = total - list_M[s] + 1
    print(ans)

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

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

list_B = list(set(list_A))
an = 0
for i in range(len(list_B)):
    c = list_A.count(list_B[i])
    an += cmb(c, 2)


for i in range(n):
    c = list_A.count(list_A[i])
    if c != 2:
        ans = an - cmb(c, 2) + cmb(c-1, 2)
    else:
        ans = an - 1
    print(ans)
Problem p02768 (python)

Fixed submission:
def cmb(n, r, p):
    r = min(r, n - r)
    upper = 1
    for i in range(n, n - r, -1):
        upper = (upper * i) % p

    lower = 1
    for i in range(1, r + 1):
        lower = (lower * i) % p

    # フェルマーの小定理よりp素数ならupper**(p-2)は逆元
    return (upper * pow(lower, p - 2, p)) % p

mod = pow(10, 9) + 7
n, a, b = map(int, input().split())
ans = (pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod))%mod
print(ans)

Buggy submission (verdict: Runtime Error):
mod = pow(10, 9) + 7

class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod

    def calc(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod

n, a, b = map(int, input().split())
C = Combination(n)
p, q = C.calc(n, a), C.calc(n, b)

ans = pow(2, n, mod) - p - q - 1
print(ans)

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
l = []
for r in range(1, n+1):
    if r != a and r != b:
        l.append(cmb(n,r,mod))

print(sum(l))
Problem p02783 (python)

Fixed submission:
a, b = map(int, input().split())
ans = 0
if a % b ==0:
    ans = a//b
else:
    ans = a//b + 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [1]

if n % 2 == 1:
    n -= 1

if n % 2 == 0:
    for i in range(int(n / 2)):
        a.append(2 * a[i])

print(a[-1]*2 - 1)
Problem p02923 (python)

Fixed submission:
n = int(input())
list_score = list(map(int, input().split()))
ans = []
score = 0
if len(list_score) == 1:
    print(0)
else:
    for i in range(n-1):
        if list_score[i] >= list_score[i+1]:
            score += 1
        else:
            ans.append(score)
            score = 0
        if i == n-2:
            ans.append(score)

        #print(score, ans)

    print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
list_score = list(map(int, input().split()))
ans = []
score = 0

for i in range(n-1):
    if list_score[i] >= list_score[i+1]:
        score += 1
    else:
        ans.append(score)
        score = 0
    if i == n-2:
        ans.append(score)

    #print(score, ans)

print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
list_score = list(map(int, input().split()))
ans = []
score = 0

for i in range(n-1):
    if list_score[i] >= list_score[i+1]:
        score += 1
    else:
        ans.append(score)
        score = 0
    if i == n-2:
        ans.append(score)

    #print(score, ans)

print(max(ans))
Problem p02947 (python)

Fixed submission:
import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)

ans = {}
for s in list_mo:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1


ans_val = []

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for s in ans:
    if ans[s] != 1:
        ans_val.append(cmb(ans[s], 2))


print(sum(ans_val))

Buggy submission (verdict: Runtime Error):
new_a = []

for k in range(n):
    a.append(str(input()))

for k in range(n):
    new_a.append( ''.join(list(sorted(a[k]))))

new_a.sort()

b = 0

for k in range(n-1):
    for m in range(k+1, n):
        if(new_a[k] == new_a[m]):
            b = b +1

print(b)

Buggy submission (verdict: Runtime Error):
n = map(int, input())
a = []
new_a = []

for k in n:
    a[k] = map(str, input())

for k in n:
    new_a[k] = ''.join(list(reversed(a[k])))

sorted(new_a)

b = 0

for k in n:
    if(new_a[k] == new_a[k+1]):
        b = b +1
        
print(b)
Problem p02995 (python)

Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def k(x):
    return x - (x//c + x//d - x//lcm(c, d))

print(k(b)-k(a-1))

Buggy submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

k = b-a+1

amri_c = a % c
if amri_c == 0:
    amri_c = c
    k_c = (k - (amri_c - 1)) // c
else:
    k_c = (k - (amri_c - 1)) // c + 1

amri_d = a % d
if amri_d == 0:
    amri_d = d
    k_d = (k - (amri_d - 1)) // d
else:
    k_d = (k - (amri_d - 1)) // d + 1

amri_cd = a % lcm(c, d)
if amri_cd == 0:
    amri_cd = lcm(c, d)
    k_cd = (k - (amri_cd - 1)) // lcm(c, d)
else:
    k_cd = (k - (amri_cd - 1)) // lcm(c, d) + 1

ans = k-k_c-k_d+k_cd

print(ans)
Problem p03001 (python)

Fixed submission:
w, h, x, y = map(int, input().split())
ans = 0
if w == 2*x and h == 2*y:
    ans = 1
print(w*h/2, ans)

Buggy submission (verdict: Runtime Error):
w, h, x, y = map(int, input().split())

are_w = min(w*y, w*(h-y))
are_h = min(x*h, (w-x)*h)

ans_are = max(are_w, are_h)
ans = 0
if are_w == are_h:
    ans = 1

if x == w and y == h:
    ans_are = w*h/2
    ans = 0

if x == 0 and y == 0:
    ans_are = w*h/2
    ans = 0
    
if x == 0 and y == h:
    ans_are = w*h/2
    ans = 0

if x == w and y == 0:
    ans_are = w*h/2
    ans = 0

if w/h == x/y:
    ans_are = w*h/2
    ans = 0

print(ans_are, ans)
Problem p03086 (python)

Fixed submission:
s = input()
list_s = list(s)
k = 0
ans = []
for i in range(len(list_s)):
    c = list_s[i]
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0
if k != 0:
    ans.append(k)
print(max(ans))

Buggy submission (verdict: Runtime Error):
s = input()
list_s = list(s)
k = 0
ans = []
for i in range(len(list_s)):
    c = list_s[i]
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0

print(max(ans))

Buggy submission (verdict: Runtime Error):
s = input()
list_s = list(s)
k = 0
ans = []
for c in list_s:
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0

print(max(ans))
Problem p03244 (python)

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

list_Vx = []
list_Vy = []

for i, s in enumerate(list_V):
    if i % 2 == 0:
        list_Vx.append(s)
    else:
        list_Vy.append(s)

list_Vx_Count = [0 for _ in range(pow(10, 5))]
list_Vy_Count = [0 for _ in range(pow(10, 5))]

for i in list_Vx:
    list_Vx_Count[i-1] += 1
for i in list_Vy:
    list_Vy_Count[i-1] += 1

ans = n - max(list_Vx_Count) - max(list_Vy_Count)

if list_Vx_Count.count(max(list_Vx_Count)) == 1 and list_Vy_Count.count(max(list_Vy_Count)):
    if list_Vx_Count.index(max(list_Vx_Count)) == list_Vy_Count.index(max(list_Vy_Count)):
        ans = n - max(max(list_Vx_Count)+sorted(list_Vx_Count)[-2], max(list_Vy_Count)+sorted(list_Vy_Count)[-2])

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []
A, B = [[-1, 0], [-1, 0]]

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

L = itertools.groupby(L)
for key, group in L:
    A.append([key, len(list(group))])

A.sort(key=lambda x:x[1], reverse=True)

R = itertools.groupby(R)
for key, group in R:
    B.append([key, len(list(group))])

B.sort(key=lambda x:x[1], reverse=True)

if A[0][0] != B[0][0]:
    print(n - A[0][1] - B[0][1])
else:
    print(min(n - A[1][1] - B[0][1], n - A[0][1] - B[1][1]))
Problem p03425 (python)

Fixed submission:
n = int(input())
list_N = [input() for _ in range(n)]
list_N = list(set(list_N))
cnt = [0 for _ in range(5)]

for i in range(len(list_N)):
    l = list(list_N[i])
    if l[0] in "M":
        cnt[0] += 1
    elif l[0] in "A":
        cnt[1] += 1
    elif l[0] in "R":
        cnt[2] += 1
    elif l[0] in "C":
        cnt[3] += 1
    elif l[0] in "H":
        cnt[4] += 1

ans = 0
l  = []
if cnt.count(0) == 2:
    for num in cnt:
        if num != 0:
            l.append(num)
    ans += l[0]*l[1]*l[2]
if cnt.count(0) == 1:
    for num in cnt:
        if num != 0:
            l.append(num)
    ans += l[0] * l[1] * l[2]
    ans += l[0] * l[1] * l[3]
    ans += l[0] * l[2] * l[3]
    ans += l[2] * l[1] * l[3]
if cnt.count(0) == 0:
    l = cnt
    ans += l[0] * l[1] * l[2]
    ans += l[0] * l[1] * l[3]
    ans += l[0] * l[1] * l[4]
    ans += l[0] * l[2] * l[3]
    ans += l[0] * l[2] * l[4]
    ans += l[0] * l[3] * l[4]
    ans += l[1] * l[2] * l[3]
    ans += l[1] * l[2] * l[4]
    ans += l[1] * l[3] * l[4]
    ans += l[2] * l[3] * l[4]

if cnt.count(0) > 2:
    print(0)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
list_N = [input() for _ in range(n)]
list_N = list(set(list_N))
cnt = [0 for _ in range(5)]

for i in range(len(list_N)):
    l = list(list_N[i])
    if l[0] in "M":
        cnt[0] += 1
    elif l[0] in "A":
        cnt[1] += 1
    elif l[0] in "R":
        cnt[2] += 1
    elif l[0] in "C":
        cnt[3] += 1
    elif l[0] in "H":
        cnt[4] += 1

ans = 0
l  = []
if cnt.count(0) == 2:
    for num in cnt:
        if num != 0:
            l.append(num)
    ans += l[0]*l[1]*l[2]
if cnt.count(0) == 1:
    for num in cnt:
        if num != 0:
            l.append(num)
    ans += l[0] * l[1] * l[2]
    ans += l[0] * l[1] * l[3]
    ans += l[0] * l[2] * l[3]
    ans += l[2] * l[1] * l[3]
if cnt.count(0) == 0:
    ans += l[0] * l[1] * l[2]
    ans += l[0] * l[1] * l[3]
    ans += l[0] * l[1] * l[4]
    ans += l[0] * l[2] * l[3]
    ans += l[0] * l[2] * l[4]
    ans += l[0] * l[3] * l[4]
    ans += l[1] * l[2] * l[3]
    ans += l[1] * l[2] * l[4]
    ans += l[1] * l[3] * l[4]
    ans += l[2] * l[3] * l[4]

if cnt.count(0) > 2:
    print(0)
else:
    print(ans)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
list_T = [int(input()) for _ in range(n)]

print(lcm_list(list_T))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
list_T = [int(input()) for _ in range(n)]

print(lcm_list(list_T))
Problem p03637 (python)

Fixed submission:
n = int(input())
list_A = list(map(int, input().split()))
list_C = [0, 0, 0]

for num in list_A:
    if num % 4 == 0:
        list_C[2] += 1
    elif num % 2 == 0:
        list_C[1] += 1
    else:
        list_C[0] += 1

ans = "Yes"

if list_C[1] == 0:
    if list_C[2] == 0:
        if list_C[0] != 0:
            ans = "No"
    if list_C[2] == 1:
        if list_C[0] > 2:
            ans = "No"
    if list_C[2] > 1:
        if list_C[0] > list_C[2] + 1:
            ans = "No"
else:
    if list_C[0] > list_C[2]:
        ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
list_AB = [ list(map(int,input().split(" "))) for i in range(m)]
list_MAP = [0]*(n+1)

for l in list_AB:
    l.sort()
    if l[0] == 1:
        list_MAP[l[1]] += 1
    if l[1] == n:
        list_MAP[l[0]] += 1

ans = "IMPOSSIBLE"

for num in list_MAP:
    if num > 1:
        ans = "POSSIBLE"

print(ans)
Problem p03673 (python)

Fixed submission:
from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque([])
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.appendleft(list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque()
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.insert(0, list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)
Problem p02698 (python)

Fixed submission:
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
import bisect

INF = 1145141919

a = []
dp = []
ans = []
T = []


def dfs(v: int, p: int):
    index = bisect.bisect_left(dp, a[v])
    dp[index], a[v] = a[v], dp[index]

    ans[v] = bisect.bisect_left(dp, INF)

    for u in T[v]:
        if u != p:
            dfs(u, v)

    dp[index], a[v] = a[v], dp[index]


def solve(N: int, tmp_a: "List[int]", tmp_T: "List[List[int]]"):
    sys.setrecursionlimit(10 ** 6)

    global dp, ans, a, T
    dp = [INF] * N
    ans = [0] * N
    a = tmp_a
    T = tmp_T

    dfs(0, -1)

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


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    T = [[] for _ in range(N)]  # type: "List[List[int]]"
    for i in range(N - 1):
        u = int(next(tokens)) - 1
        v = int(next(tokens)) - 1
        T[u].append(v)
        T[v].append(u)
    solve(N, a, T)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
import bisect

INF = 1145141919

a = []
dp = []
ans = []
T = []


def dfs(v: int, p: int):
    index = bisect.bisect_left(dp, a[v])
    dp[index], a[v] = a[v], dp[index]

    ans[v] = bisect.bisect_left(dp, INF)

    for u in T[v]:
        if u != p:
            dfs(u, v)

    dp[index], a[v] = a[v], dp[index]


def solve(N: int, tmp_a: "List[int]", tmp_T: "List[List[int]]"):
    global dp, ans, a, T
    dp = [INF] * N
    ans = [0] * N
    a = tmp_a
    T = tmp_T

    dfs(0, -1)

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


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    T = [[] for _ in range(N)]  # type: "List[List[int]]"
    for i in range(N - 1):
        u = int(next(tokens)) - 1
        v = int(next(tokens)) - 1
        T[u].append(v)
        T[v].append(u)
    solve(N, a, T)


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

Fixed submission:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys
import numpy as np

INF = float('inf')


def solve(N: int, x: "List[int]", y: "List[int]"):
    def distance(x1, y1, x2, y2):
        return np.linalg.norm(np.array([x1, y1]) - np.array([x2, y2]))

    l = [[distance(x[i], y[i], x[j], y[j]) if j >
          i else 0 for j in range(N)] for i in range(N - 1)]

    return np.average([sum(l[r[i]][r[i+1]] if r[i] < r[i+1] else l[r[i+1]][r[i]] for i in range(N-1))
                       for r in its.permutations(range(N))])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(f'{solve(N, x, y)}')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys
import numpy as np

INF = float('inf')


def solve(N: int, x: "List[int]", y: "List[int]"):
    def distance(x1, y1, x2, y2):
        return np.linalg.norm(np.array([x1, y1]) - np.array([x2, y2]))

    l = [[distance(x[i], y[i], x[j], y[j]) if j >
          i else 0 for j in range(N)] for i in range(N - 1)]

    return np.average([sum(l[r[i]][r[i+1]] if r[i] < r[i+1] else l[r[i+1]][r[i]] for i in range(N-1))
                       for r in its.permutations(range(N))])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(f'{solve(N, x, y)}')


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

Fixed submission:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int, d: "List[int]"):
    return sum(x * y for x, y in its.combinations(d, 2))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(N, d)}')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys
import numpy as np

INF = float('inf')


def solve(N: int, d: "List[int]"):
    return sum(x * y for x, y in its.combinations(d, 2))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(N, d)}')


if __name__ == '__main__':
    main()