Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations,product

n,k = map(int,input().split())
l = list(map(int,input().split()))

ln = [x for x in l if x<0]
lz = [x for x in l if x==0]
lp = [x for x in l if x>0]

a = len(ln)
b = len(lz)
c = len(lp)

nn = a*c
nz = int(b*(a+c) + b*(b-1)/2)
np = int(a*(a-1)/2 + c*(c-1)/2)

if k<=nn:
    resl = [x*y for x,y in product(ln,lp)]
    resl.sort()
    print(resl[k-1])
elif nn<k<=nn+nz:
    print(0)
else:
    resl = [x*y for x,y in combinations(ln,2)] + [x*y for x,y in combinations(lp,2)]
    resl.sort()
    print(resl[k-nn-nz-1])

Fixed submission:
import numpy as np

n,k = map(int,input().split())
a = np.array(list(map(int,input().split())))

a.sort()
pos = a[a>0]
zero = a[a==0]
neg = a[a<0]
negpos = (neg*(-1))[::-1]

lenn = len(neg)
lenz = len(zero)
lenp = len(pos)

nnres = lenn * lenp
nzres = int(lenz*(lenn+lenp)+lenz*(lenz-1)/2)
npres = int(lenn*(lenn-1)/2 + lenp*(lenp-1)/2)

if k<=nnres:
    def count_nnres(x):
        cnt = np.searchsorted(neg,x//pos,side='right').sum()
        return int(cnt)
    left = -10**18
    right = -1
    while left+1<right:
        mid = (left+right)//2
        nebefore = count_nnres(mid)
        if nebefore >= k:
            right = mid
        elif nebefore < k:
            left = mid
    print(right)
    
elif nnres<k<=nnres+nzres:
    print(0)
    
elif nnres+nzres<k:
    def count_npres(x):
        cnt = 0
        cnt += int(np.searchsorted(pos,x//pos,side='right').sum() - ((x//pos)>=pos).sum())//2
        cnt += int(np.searchsorted(negpos,x//negpos,side='right').sum() - ((x//negpos)>=negpos).sum())//2
        return cnt
    k -= nnres+nzres
    left = 1
    right = 10**18
    while left+1<right:
        mid = (left+right)//2
        nebefore = count_npres(mid)
        if nebefore >= k:
            right = mid
        elif nebefore < k:
            left = mid
    print(right)
Buggy python submission (verdict: Runtime Error):
n,s = input().split()
print(s.count('ABC'))

Fixed submission:
n = input()
s = input()
print(s.count('ABC'))
Buggy python submission (verdict: Runtime Error):
import numpy as np

n,m = map(int,input().split())
l = list(map(int,input().split()))

lh = list(map(lambda x:x//2, l))
lcm = np.lcm.reduce(np.array(lh))
res = 0
times = [(lcm//x)%2==1 for x in lh]

if all(times):
    res = ((m // lcm) +1) // 2

print(res)

Fixed submission:
from fractions import gcd
from functools import reduce

def lcm(a,b):
    return a*b//gcd(a,b)

n,m = map(int,input().split())
l = list(map(int,input().split()))

lh = list(map(lambda x:x//2, l))
lcm = reduce(lcm,lh)
res = 0
times = [(lcm//x)%2==1 for x in lh]

if all(times):
    res = ((m // lcm) +1) // 2

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
a = list(map(int, input().split()))

st = set()

for i in range(1,m+1):
    lst = [i%x==x/2 for x in a]
    if all(lst):
        st.add(i)
        break
            
f = (((m // i) - 1) //2)
print(len(st) + f)

Fixed submission:
from fractions import gcd
from functools import reduce

def lcm(a,b):
    return a*b//gcd(a,b)

n,m = map(int,input().split())
l = list(map(int,input().split()))

lh = list(map(lambda x:x//2, l))
lcm = reduce(lcm,lh)
res = 0
times = [(lcm//x)%2==1 for x in lh]

if all(times):
    res = ((m // lcm) +1) // 2

print(res)

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

st = set()

for i in range(1,m+1):
    if test1(st,i):
        lst = [i%x==x/2 for x in a]
        if all(lst):
            st.add(i)
            break
            
f = (((m // i) - 1) //2)
print(len(st) + f)

Fixed submission:
from fractions import gcd
from functools import reduce

def lcm(a,b):
    return a*b//gcd(a,b)

n,m = map(int,input().split())
l = list(map(int,input().split()))

lh = list(map(lambda x:x//2, l))
lcm = reduce(lcm,lh)
res = 0
times = [(lcm//x)%2==1 for x in lh]

if all(times):
    res = ((m // lcm) +1) // 2

print(res)
Buggy python submission (verdict: Runtime Error):

    N = int(input())
    A = list(map(int, input().split()))

    A = sorted(A)

    ans = 0

    for i in range(N):
        Ai = A[i]
        is_divisible = False
        for j in range(i):
            Aj = A[j]
            if Aj**2 > Ai:
                break
            if Ai%Aj == 0:
                is_divisible = True
                break
        if not is_divisible:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
def main():

    N = int(input())
    A = list(map(int, input().split()))

    A = sorted(A)
    Amax = A[-1]
    count = [0 for _ in range(Amax+1)]

    for a in A:
        for i in range(1, Amax//a+1):
            count[i*a] += 1

    ans = 0
    for i in range(N):
        a = A[i]
        if count[a] == 1:
#            print(i)                                                                                                                                            
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():

    N = int(input())
    A = list(map(int, input().split()))

    count = [0 for _ in range(N)]

    for i in range(N):
        Ai = A[i]
        for j in range(i+1, N):
            Aj = A[j]
            if Ai%Aj == 0:
                count[i] += 1
            if Aj%Ai == 0:
                count[j] += 1

    ans = 0
    for i in range(N):
        if count[i] == 0:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
def main():

    N = int(input())
    A = list(map(int, input().split()))

    A = sorted(A)
    Amax = A[-1]
    count = [0 for _ in range(Amax+1)]

    for a in A:
        for i in range(1, Amax//a+1):
            count[i*a] += 1

    ans = 0
    for i in range(N):
        a = A[i]
        if count[a] == 1:
#            print(i)                                                                                                                                            
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())

A = [[] for _ in range(M)]
for i in range(M):
    Am, Bm = map(int, input().split())
    Am -= 1
    Bm -= 1
    A[Am].append(Bm)
    A[Bm].append(Am)


is_visited = [False for _ in range(N)]
ans = [0 for _ in range(N)]
def bfs():
    queue = deque()
    queue.append(0)
    is_visited[0] = True
    while queue:
        pos = queue.popleft()
        for next_pos in A[pos]:
            if is_visited[next_pos] == False:
                is_visited[next_pos] = True
                queue.append(next_pos)
                ans[next_pos] = pos

bfs()

if False in is_visited:
    print("No")
else:
    print("Yes")
    for i in range(N-1):
        print(ans[i+1]+1)


Fixed submission:
from collections import deque

N, M = map(int, input().split())

A = [[] for _ in range(N)]
for i in range(M):
    Am, Bm = map(int, input().split())
    Am -= 1
    Bm -= 1
    A[Am].append(Bm)
    A[Bm].append(Am)


is_visited = [False for _ in range(N)]
ans = [0 for _ in range(N)]
def bfs():
    queue = deque()
    queue.append(0)
    is_visited[0] = True
    while queue:
        pos = queue.popleft()
        for next_pos in A[pos]:
            if is_visited[next_pos] == False:
                is_visited[next_pos] = True
                queue.append(next_pos)
                ans[next_pos] = pos

bfs()

if False in is_visited:
    print("No")
else:
    print("Yes")
    for i in range(N-1):
        print(ans[i+1]+1)

Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())

A = [[] for _ in range(M)]
for i in range(M):
    Am, Bm = map(int, input().split())
    Am -= 1
    Bm -= 1
    A[Am].append(Bm)
    A[Bm].append(Am)


is_visited = [False for _ in range(N)]
ans = [0 for _ in range(N)]
def bfs():
    queue = deque()
    queue.append(0)
    is_visited[0] = True
    while queue:
        pos = queue.popleft()
        for next_pos in A[pos]:
            if is_visited[next_pos] == False:
                is_visited[next_pos] = True
                queue.append(next_pos)
                ans[next_pos] = pos

bfs()
#print(is_visited)                                                                                     

if False in is_visited:
    print("No")
else:
    for i in range(N-1):
        print(ans[i+1]+1)


Fixed submission:
from collections import deque

N, M = map(int, input().split())

A = [[] for _ in range(N)]
for i in range(M):
    Am, Bm = map(int, input().split())
    Am -= 1
    Bm -= 1
    A[Am].append(Bm)
    A[Bm].append(Am)


is_visited = [False for _ in range(N)]
ans = [0 for _ in range(N)]
def bfs():
    queue = deque()
    queue.append(0)
    is_visited[0] = True
    while queue:
        pos = queue.popleft()
        for next_pos in A[pos]:
            if is_visited[next_pos] == False:
                is_visited[next_pos] = True
                queue.append(next_pos)
                ans[next_pos] = pos

bfs()

if False in is_visited:
    print("No")
else:
    print("Yes")
    for i in range(N-1):
        print(ans[i+1]+1)
Buggy python submission (verdict: Runtime Error):
K = int(input())

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


print A[K-1]



Fixed submission:
K = int(input())

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


print (A[K-1])
Buggy python submission (verdict: Runtime Error):
    a, b, c = map(int, input().split())
     
    if b > a:
        temp = a
        a = b
        b = temp
     
    res = c - a
    res = res - b
    temp = 4*a*b
     
    if res**2 > temp:
        print ("Yes")
    else:
        print ("No")

Fixed submission:
import numpy as np

a, b, c = map(int, raw_input().split())

if b > a:
    temp = a
    a = b
    b = temp

res = c - a
res = res - b
temp = 4*a*b


if res <0:
    print "No"
elif res**2 > temp:
    print "Yes"
else:
    print "No"

Buggy python submission (verdict: Runtime Error):
File Edit Options Buffers Tools Python Help                                                                            
import numpy as np

a, b, c = map(int, raw_input().split())

if b > a:
    temp = a
    a = b
    b = temp

res = c - a
res = res - b
temp = 4*a*b

if res**2 > temp:
    print "Yes"
else:
    print "No"


Fixed submission:
import numpy as np

a, b, c = map(int, raw_input().split())

if b > a:
    temp = a
    a = b
    b = temp

res = c - a
res = res - b
temp = 4*a*b


if res <0:
    print "No"
elif res**2 > temp:
    print "Yes"
else:
    print "No"
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

if b > a:
    temp = a
    a = b
    b = temp

res = c - a
res = res - b
temp = 4*a*b

if res**2 > temp:
    print ("Yes")
else:
    print ("No")



Fixed submission:
N = int(raw_input())

char_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

prev = ["a"]

for i in range(1, N):
    temp = []
    for item in prev:
        item_list = []
        for j in range(len(item)):
            item_list.append(item[j])
        num_char = len(set(item_list))
        for j in range(num_char+1):
            temp.append(item+char_list[j])

    prev = temp


print ' '.join(map(str, prev))
Buggy python submission (verdict: Runtime Error):
X = int(raw_input())

nmax = 100000

array = [0]*nmax
array[0] = 1

value_list = [100,101,102,103,104,105]

for i in range(nmax):
    for value in value_list:
        if i - value >= 0:
            if array[i-value] == 1:
                array[i] = 1

print array[X]


Fixed submission:
X = int(raw_input())

nmax = 100000

array = [0]*(nmax+1)
array[0] = 1

value_list = [100,101,102,103,104,105]

for i in range(nmax+1):
    for value in value_list:
        if i - value >= 0:
            if array[i-value] == 1:
                array[i] = 1

print array[X]
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(raw_input())
S = raw_input()

ans_list = [" "]

for num in range(1000):
    cha3 = str(num%10)
    cha2 = str((num%100 - num%10)/10)
    cha1 = str(num/100)


    for i in range(N):
        if S[i] == cha1:
            for j in range(i+1, N):
                if S[j] == cha2:
                    for k in range(j+1,N):
                        if S[k] == cha3:
                            string = cha1+cha2+cha3
                            ans_list.append(string)
                            break

print len(collections.Counter(ans_list))-1

Fixed submission:
def str_find(S, target, start):
    for i in range(start, len(S)):
        if S[i] == target:
            return i

    return 10**9+7

N = int(raw_input())
S = str(raw_input())

candidates = []

for i in range(10):
    for j in range(10):
        for k in range(10):
            candi = str(i)+str(j)+str(k)
            candidates.append(candi)


ans = 0
for candi in candidates:
    x = candi[0]
    i = str_find(S, x, 0)

    y = candi[1]
    j = str_find(S, y, i+1)

    z = candi[2]
    k = str_find(S, z, j+1)

    if i+j+k< 10**8:
        ans = ans + 1

print ans
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

def modpow(a, n, mod):
    res = 1
    while(n > 0):
        if n&1:
            res = res * a % mod
            a = a * a % mod
            n >>= 1

    return res

def modinv(a, mod):
    return modpow(a, mod-2, mod)

mod = int(1e+9 + 7)

X, Y = map(int, raw_input().split())

X2 = 2*X - Y
Y2 = -X + 2*Y

if X2 < 0:
    print "0"
    exit()
elif Y2 < 0:
    print "0"
    exit()

if X2%3 != 0:
    print "0"
    exit()
elif Y2%3 != 0:
    print "0"
    exit()

X2 = X2/3
Y2 = Y2/3

ans = 1

n = X2+Y2
m = Y2

for i in range(n-m+1, n+1):
    ans = (ans*i)%mod

for i in range(2, m+1):
    new = i**(mod-2)%mod
    ans = ans*new%mod


print ans


Fixed submission:
from math import factorial
mod = int(1e+9 + 7)

X, Y = map(int, raw_input().split())

X2 = 2*X - Y
Y2 = -X + 2*Y

if X2 < 0:
    print "0"
    exit()
elif Y2 < 0:
    print "0"
    exit()

if X2%3 != 0:
    print "0"
    exit()
elif Y2%3 != 0:
    print "0"
    exit()

X2 = X2/3
Y2 = Y2/3

ans = 1

n = X2+Y2
m = Y2

for i in range(n-m+1, n+1):
    ans = (ans*i)%mod


new = 1
for i in range(2, m+1):
    new = (new*i)%mod

new = pow(new, mod-2, mod)

ans = (ans*new)%mod

print ans
Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = map(int, raw_input().split())

for i in range(N):
    print A.index(i+1)+1

Fixed submission:
N = int(raw_input())
A = map(int, raw_input().split())

new_list = []

for i in range(N):
    new_list.append((A[i],i+1))

new_list = sorted(new_list)

for i in range(N):
    print new_list[i][1]
Buggy python submission (verdict: Time Limit Exceeded):
l = raw_input().split()
N = int(l[0])
K = int(l[1])
Q = int(l[2])


A = []
for i in range(Q):
    A.append(input())

for i in range(N):
    if Q-A.count(i+1) < K:
        print "Yes"
    else:
        print "No"



Fixed submission:
N, K, Q = map(int, raw_input().split())

S = [0 for i in range(N)]

for i in range(Q):
    Ai = int(raw_input()) -1
    S[Ai] = S[Ai] + 1

for i in range(N):
    S[i] = K - (Q - S[i])


#print S                                                                                               
for i in range(N):
    if S[i] > 0:
        print "Yes"
    else:
        print "No"
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(raw_input())
W = map(int, raw_input().split())

total = sum(W)

ans = total

for i in range(N):
	total = total - W[i]
    if ans < np.abs(total):
      ans = int(np.abs(total))
      
print ans


Fixed submission:
import numpy as np

N = int(raw_input())
W = map(int, raw_input().split())

total = sum(W)

ans = total

total_r = total
total_l = 0
for i in range(N):
        total_r = total_r - W[i]
        total_l = total_l + W[i]
        ans_temp = np.abs(total_r - total_l)
        if ans > ans_temp:
                ans = ans_temp

print ans
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K = map(int, raw_input().split())

ans = 0
mi_prev = 0
for i in reversed(range(1, N+1)):
    for mi in range(mi_prev, K):
        if i*2**mi >= K:
            break

    ans += (1.0/2)**mi
    mi_prev = mi

ans = ans/N
print ans



Fixed submission:
import numpy as np
import math
N, K = map(int, raw_input().split())

ans = 0
for i in range(1, N+1):

    mi = np.log2(1.0*K/i)

    mi = max(mi,0)
    mi = math.ceil(mi)
    ans += (1.0/2)**mi

ans = ans/N
print ans

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, raw_input().split())

ans = 0
for i in range(1, N+1):
    mi = 0
    for m in range(K):
        if i*2**mi >= K:
            break
        mi += 1

    ans += (1.0/2)**mi

ans = ans/N
print ans


Fixed submission:
import numpy as np
import math
N, K = map(int, raw_input().split())

ans = 0
for i in range(1, N+1):

    mi = np.log2(1.0*K/i)

    mi = max(mi,0)
    mi = math.ceil(mi)
    ans += (1.0/2)**mi

ans = ans/N
print ans
Buggy python submission (verdict: Runtime Error):
x, y, z = map(int, raw_input().split())
return x*z/2

Fixed submission:
x, y, z = map(int, raw_input().split())
print x*y/2
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
a = list(map(int,input().split()))

mod = 1000000007

sum = 0
#普通にとく
for v in itertools.combinations(a, 2):
    sum += v[0]*v[1]


print(sum%mod)

Fixed submission:
import itertools
n = int(input())
a = list(map(int,input().split()))
mod = 1000000007

total = 0
for i in range(len(a)-1):
    if(i == 0):
        before_sum = sum(a) - a[i]
    else:
        before_sum -= a[i]
    total += a[i] * (before_sum) 


print(total%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
prev = abs(n-k)
now = abs(prev-k)
while(now < prev):
    prev = now
    now = abs(now-k)
print(prev)

Fixed submission:
n,k = map(int,input().split())
a = n%k
print(min(a,k-a))
Buggy python submission (verdict: Runtime Error):
k = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[k])

Fixed submission:
k = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[k-1])
Buggy python submission (verdict: Runtime Error):
h = int(input())
li = []
li.append(h)
c=1
while(h >  1):
    h= int(h/2)
    for i in range(2**c):   #計算量がクソ多くなる
        li.append(h)
    c += 1

#print(li)
print(len(li))

Fixed submission:
h,a = map(int,input().split())
c = 0
while(True):
    h = h - a
    if(h <= 0):
        c += 1
        break

    c += 1

print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))

#min_indexlist = [a_list.index(min(a_list))]

min_indexlist = []

m = min(a_list)

#print(m)

#ここがおかしい
"""
for i in range(len(a_list)):
    if( a_list[i] == m+1):
        m = a_list[i]
        min_indexlist.append(i)
"""


f = False

for i in range(len(a_list)):

    if(f==False):
        if(a_list[i] == 1):
            min_indexlist.append(i)
            f = True

    if(f==True):
        if( a_list[i] == m+1):
            m = a_list[i]
            min_indexlist.append(i)
            
if(len(min_indexlist)==0):
    min_indexlist.append(1)



#print(min_indexlist)

#砕いたレンガの後のリスト
crash_list = []
for i in range(len(min_indexlist)):
    crash_list.append(a_list[min_indexlist[i]])

#print(crash_list)

#砕いたレンガの数
crash = n - len(min_indexlist)


frag=True

for i in range(len(crash_list)):
    if(crash_list[i] != i+1):
        frag = False


if(frag == True):
    print(crash)
elif(frag == False):
    print(-1)












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

for i in range(3):
    if((i+1 != a) and (i+1 != b)):
        c = i+1
    
print(c)

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

min_indexlist = []

m = min(a_list)


f = False

for i in range(len(a_list)):

    if(f==False):
        if(a_list[i] == 1):
            min_indexlist.append(i)
            f = True

    if(f==True):
        if( a_list[i] == m+1):
            m = a_list[i]
            min_indexlist.append(i)
            
if(len(min_indexlist)==0):
    min_indexlist.append(1)


#砕いたレンガの後のリスト
crash_list = []
for i in range(len(min_indexlist)):
    crash_list.append(a_list[min_indexlist[i]])

#print(crash_list)

#砕いたレンガの数
crash = n - len(min_indexlist)


frag=True

for i in range(len(crash_list)):
    if(crash_list[i] != i+1):
        frag = False


if(frag == True):
    print(crash)
elif(frag == False):
    print(-1)











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

for i in range(3):
    if((i+1 != a) and (i+1 != b)):
        c = i+1
    
print(c)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())

min = a * b / gcd(a, b)

print(min)



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

min = a * b / fractions.gcd(a, b)

print(int(min))
Buggy python submission (verdict: Runtime Error):
import itertools

if __name__ == '__main__':

    n = int(input())
    town =[input() for i in range(n)]

    p = [i for i in range(n)]
  

    p_list = list(itertools.permutations(p))

    total = 0
    for i in range(len(p_list)):
        sum = 0
    
        for j in range(n-1):
            x1,y1 = int(town[p_list[i][j]][0]), int(town[p_list[i][j]][2])
            x2,y2 = int(town[p_list[i][j+1]][0]), int(town[p_list[i][j+1]][2])
    
            sum = sum + ((x2-x1)**2+(y2-y1)**2)**0.5
       

        total = total + sum
       

    
    print(total/float(len(p_list)))

Fixed submission:
import itertools

if __name__ == '__main__':

    n = int(input())
 

    town = [[]for i in range(n)]

    for i in range(n):
        x,y = map(int,input().split()) 
        town[i].append(x)
        town[i].append(y)
    

    p = [i for i in range(n)]
  

    p_list = list(itertools.permutations(p))

    total = 0
    for i in range(len(p_list)):
        sum = 0
    
        for j in range(n-1):
            x1,y1 = int(town[p_list[i][j]][0]), int(town[p_list[i][j]][1])
            x2,y2 = int(town[p_list[i][j+1]][0]), int(town[p_list[i][j+1]][1])
    
            sum = sum + ((x2-x1)**2+(y2-y1)**2)**0.5
       

        total = total + sum
       

    
    print(total/float(len(p_list)))

Buggy python submission (verdict: Runtime Error):
import itertools

if __name__ == '__main__':

    n = int(input())
    town =[input() for i in range(n)]

    p = [i for i in range(n)]
  

    p_list = list(itertools.permutations(p))

    distance = []

    total = 0
    for i in range(len(p_list)):
        sum = 0
    
        for j in range(n-1):
            x1,y1 = int(town[p_list[i][j]][0]), int(town[p_list[i][j]][2])
            x2,y2 = int(town[p_list[i][j+1]][0]), int(town[p_list[i][j+1]][2])
    
            sum = sum + ((x2-x1)**2+(y2-y1)**2)**0.5
       

        total = total + sum
       
	print(total/len(p_list))

Fixed submission:
import itertools

if __name__ == '__main__':

    n = int(input())
 

    town = [[]for i in range(n)]

    for i in range(n):
        x,y = map(int,input().split()) 
        town[i].append(x)
        town[i].append(y)
    

    p = [i for i in range(n)]
  

    p_list = list(itertools.permutations(p))

    total = 0
    for i in range(len(p_list)):
        sum = 0
    
        for j in range(n-1):
            x1,y1 = int(town[p_list[i][j]][0]), int(town[p_list[i][j]][1])
            x2,y2 = int(town[p_list[i][j+1]][0]), int(town[p_list[i][j+1]][1])
    
            sum = sum + ((x2-x1)**2+(y2-y1)**2)**0.5
       

        total = total + sum
       

    
    print(total/float(len(p_list)))