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

Fixed submission:
import sys

sys.setrecursionlimit(10**6)

a,b,c = map(int, input().split())
k = int(input())

m = [[] for _ in range(8)]
m[0].append([a,b,c])

for i in range(k):
    for j in m[i]:
        m[i+1].append([j[0]*2, j[1],j[2]])
        m[i+1].append([j[0], j[1]* 2, j[2]])
        m[i+1].append([j[0], j[1], j[2]* 2])

ans = 'No'

for t in m[k]:
    if t[0] < t[1] and t[1] < t[2]:
        ans = 'Yes'
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**6)

a,b,c = map(int, input().split())
k = int(input())

m = [[] for _ in range(7)]
m[0].append([a,b,c])

for i in range(k):
    for j in m[i]:
        m[i+1].append([j[0]*2, j[1],j[2]])
        m[i+1].append([j[0], j[1]* 2, j[2]])
        m[i+1].append([j[0], j[1], j[2]* 2])

ans = 'No'

for t in m[k]:
    if t[0] < t[1] and t[1] < t[2]:
        ans = 'Yes'
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**6)

a,b,c = map(int, input().split())
k = int(input())

m = [[] for _ in range(7)]
m[0].append([a,b,c])

for i in range(k):
    for j in m[i]:
        m[i+1].append([j[0]*2, j[1],j[2]])
        m[i+1].append([j[0], j[1]* 2, j[2]])
        m[i+1].append([j[0], j[1], j[2]* 2])

ans = 'No'
for t in m[k]:
    if t[0] < t[1] and t[1]<t[2]:
        ans = 'Yes'
        break
    else:
        continue
print(ans)

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

m = [[] for _ in range(7)]
m[0].append([a,b,c])

for i in range(k):
    for j in m[i]:
        m[i+1].append([j[0]*2, j[1],j[2]])
        m[i+1].append([j[0], j[1]* 2, j[2]])
        m[i+1].append([j[0], j[1], j[2]* 2])

ans = 'No'
for t in m[k]:
    if t[0] < t[1] and t[1]<t[2]:
        ans = 'Yes'
        break
    else:
        continue
print(ans)
Problem p02675 (python)

Fixed submission:
n = input()
hon = ['2','4','5','7','9']
pon = ['0','1','6','8']
if n[-1] in hon:
    print('hon')
elif n[-1] in pon:
    print('pon')
else:
    print('bon')

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

def main():
    N,M = map(int, input().split())
    r = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        r[a-1].append(b-1)
        r[b-1].append(a-1)
    print(r)

    p=[-1]*N
    q=deque([0])
    while q:
        i=q.popleft()
        for j in r[i]:
            if p[j] == -1:
                p[j] = i
                q.append(j)
    print('Yes')
    for i in range(1,N):
        print(p[i]+1)

main()
Problem p02713 (python)

Fixed submission:
import math

n = int(input())
answer = 0

for a in range(1,n+1):
    for b in range(1,n+1):
        t = math.gcd(a,b)
        for c in range(1,n+1):
            answer += math.gcd(t,c)
print(answer)

Buggy submission (verdict: Runtime Error):
import itertools

def gcd(i):
    print(i)
    while i[1]:
        i[0], i[1] = i[1], i[0]%i[1]
    while i[2]:
        i[0], i[2] = i[2], i[0]%i[2]
    return i[0]

n = int(input())
if n == 1:
    print(1)
elif n==2:
    print(9)
else:
    l = [int(x) for x in range(1,n+1)]
    p = list(itertools.product(l,repeat=3))
    result = 0
    for i in p:
        result += gcd(list(i))
print(result)
Problem p02607 (python)

Fixed submission:
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

n = rri()
arr = rrm()
ans = 0
for i in range(0, n,2):
    if arr[i]&1:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

n = rri()
arr = rrm()
ans = 0
for i in range(0, n,2):
    if arr[i]&1:
        ans+=1
print(ans)
Problem p03456 (python)

Fixed submission:
import math

a, b =map(str, input().split())
c=a+b
c=int(c)
if math.sqrt(c)==int(math.sqrt(c)):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if b >= 10:
    x = a*100+b
else:
    x = a*10+b
for i in range(100):
    if x % i == 0:
        print("Yes")
        exit()
print("No")
Problem p02641 (python)

Fixed submission:
x,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(x)
else:
    for i in range(0,101):
        if x-i not in p:
            print(x-i)
            break
        elif x+i not in p:
            print(x+i)
            break

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
p=list(map(int,input().split()))
c=0
ans=[]
if n==0:
    print(0)
else:
    for i in range(1,101):
        if x-i not in p:
            ans.append(x-i)
            c+=1
        elif x+i not in p:
            ans.append(x+i)
            c+=1
        if c!=0:
            break
print(min(ans))
Problem p02696 (python)

Fixed submission:
a,b,n=list(map(int,input().split()))
x=min(b-1,n)
ans=int(a*x/b)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,n=map(int,input().split())
List=[]
for x in range(n):
    k=math.floor((a*x)/b)-a*(math.floor(x/b))
    List.append(k)
    print(List)
print(List.index(max(List)))
Problem p02705 (python)

Fixed submission:
import math
print(int(input())*2*math.pi)

Buggy submission (verdict: Runtime Error):
import math
print(2*int(input()*math.pi))
Problem p02801 (python)

Fixed submission:
l="abcdefghijklmnopqrstuvwxyz"
print(l[l.index(input())+1])

Buggy submission (verdict: Runtime Error):
l="abcdefghijklmnopqrstuvwxy"
print(l[l.index(input())+1])

Buggy submission (verdict: Runtime Error):
L=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y"]
print(L[L.index(input())+1])
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
print("Left"if a+b>c+d else "Balanced"if a+b==c+d else "Right")

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
print("Left"if l>r else "Balanced"if l==r else "Right")
Problem p03711 (python)

Fixed submission:
g="0131212112121"
x,y=map(int,input().split())
print("Yes"if g[x]==g[y] else "No")

Buggy submission (verdict: Runtime Error):
g="013121212121"
x,y=map(int,input().split())
print("Yes"if g[x]==g[y] else "No")
Problem p02802 (python)

Fixed submission:
# M submissions
# i-th problem, pi-th problem recieved Si verdict ("AC" or "WA")
# Penalty: recieve WA before AC

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

problem_ac = set()
problem_penalty = dict()

for _ in range(M):
    problem, verdict = input().split()

    if problem in problem_ac:
        continue
    elif verdict == "WA":
        problem_penalty[problem] = problem_penalty.get(problem, 0) + 1
    elif verdict == "AC":
        problem_ac.add(problem)

num_ac = len(problem_ac)
num_penalties = sum(penalty for problem, penalty in problem_penalty.items() if problem in problem_ac)
print(num_ac, num_penalties)

Buggy submission (verdict: Runtime Error):
# M submissions
# i-th problem, pi-th problem recieved Si verdict ("AC" or "WA")
# Penalty: recieve WA before AC

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

problem_ac = set()
problem_penalty = dict()

for _ in range(M):
    problem, verdict = input().split()

    if problem in problem_ac:
        continue
    elif verdict == "WA":
        problem_penalty[problem] = problem_penalty.get(problem, 0) + 1
    elif verdict == "AC":
        problem_ac.add(problem)

print(f"{len(problem_ac)} {sum(problem_penalty.values())}")
Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split())
board = [[i for i in input()] for _ in range(h)]

def check(i, j):
    if (j-1 >= 0):
        if(board[i][j-1] == "#"):
            return False
    if (j+1 < w):
        if(board[i][j+1] == "#"):
            return False
    if (i-1 >= 0):
        if(board[i-1][j] == "#"):
            return False
    if (i+1 < h):
        if(board[i+1][j] == "#"):
            return False

    return True

def main():
    for i in range(h):
        for j in range(w):
            if (board[i][j] == "#"):
                if(check(i,j)):
                    return "No"

    return "Yes"

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
board = [[i for i in input()] for _ in range(w)]

def check(i, j):
    if (j-1 >= 0):
        if(board[i][j-1] == "#"):
            return False
    if (j+1 < w):
        if(board[i][j+1] == "#"):
            return False
    if (i-1 >= 0):
        if(board[i-1][j] == "#"):
            return False
    if (i+1 < h):
        if(board[i+1][j] == "#"):
            return False

    return True

def main():
    for i in range(h):
        for j in range(w):
            if (board[i][j] == "#"):
                if(check(i,j)):
                    return "No"

    return "Yes"

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import copy

h, w = map(int, input().split())
board = [[i for i in input()] for _ in range(w)]
c = copy.deepcopy(board)

def check(i, j):
    if (j-1 >= 0):
        if(c[i][j-1] == "#"):
            return False
    if (j+1 < w):
        if(c[i][j+1] == "#"):
            return False
    if (i-1 >= 0):
        if(c[i-1][j] == "#"):
            return False
    if (i+1 < h):
        if(c[i+1][j] == "#"):
            return False

    return True

def main():
    for i in range(h):
        for j in range(w):
            if (board[i][j] == "#"):
                if(check(i,j)):
                    return "No"

    return "Yes"

if __name__ == '__main__':
    print(main())
Problem p02602 (python)

Fixed submission:
N, K=map(int,input().split())
scores=input().split()
for i in range(N):
  scores[i]=int(scores[i])
new=K
old=0
while new<N:
  if scores[new]>scores[old]:
    print("Yes")
  else:
    print("No")
  new+=1
  old+=1

Buggy submission (verdict: Runtime Error):
N, K=map(int,input().split())
scores=input().split()
for i in range(N):
  scores[i]=int(scores[i])
new=K
old=0
for new<N:
  if scores[new]>scores[old]:
    print("Yes")
  else:
    print("No")
  new+=1
  old+=1
Problem p02663 (python)

Fixed submission:
H1,M1,H2,M2,K = map(int,input().split())
print((H2-H1)*60+(M2-M1)-K)

Buggy submission (verdict: Runtime Error):
H1,M1,H2,H2,K = map(int,input().split())
print((H2-H1)*60+(M2-M1)-K)
Problem p02677 (python)

Fixed submission:
import math

A,B,H,M = map(int,input().split())

x = 360//12
y = 360//60

a = M*y
b = (H+M/60)*x
T = 1
if a>=b:
  if a-b>180:
    k = 360 - a+b
  elif a - b == 180:
    print(A+B)
    T = 0
  else:
    k = a-b
else:
  if b-a>180:
    k = 360 - b+a
  elif b-a == 180:
    print(A+B)
    T = 0
  else:
    k = b-a

if T == 1:
  k = math.radians(k)

  ans = A*A + B*B - 2*A*B*math.cos(k)

  print(math.sqrt(ans))

Buggy submission (verdict: Runtime Error):
import math

A,B,H,M = map(int,input().split())

x = 360//12
y = 360//60

a = M*y
b = (H+M/60)*x
T = 1
if a>=b:
  if a-b>180:
    k = 360 - a+b
  elif a - b == 180:
    print(A+B)
    T = 0
  else:
    k = a-b
else:
  if b-a>180:
    k = 360 - b+a
  elif b-a == 180:
    print(A+B)
    T = 0
  else:
    k = b-a
if T = 1:
  k = math.radians(k)

  ans = A*A + B*B - 2*A*B*math.cos(k)

  print(math.sqrt(ans))

Buggy submission (verdict: Runtime Error):
import math

A,B,H,M = map(int,input().split())

x = 360//12
y = 360//60

a = M*y
b = (H+ M/60)*x

if a>=b:
  if a-b>180:
    k = 360 - a+b
  elif a - b == 180:
    print(A+B)
  else:
    k = a-b
else:
  if b-a>180:
    k = 360 - b+a
  elif b-a == 180:
    print(A+B)
  else:
    k = b-a
    
k = math.radians(k)

ans = A*A + B*B - 2*A*B*math.cos(k)

print(math.sqrt(ans))

Buggy submission (verdict: Runtime Error):
import math

A,B,H,M = map(int,input().split())

x = 360//12
y = 360//60

a = M*y
b = (H+ M/60)*x

if a>=b:
  if a-b>180:
    k = 360 - a+b
  elif a - b == 180:
    print(A+B)
  else:
    k = a-b
else:
  if b-a>1800:
    k = 360 - b+a
  elif b-a == 180:
    print(A+B)
  else:
    k = b-a
    
k = math.radians(k)

ans = A*A + B*B - 2*A*B*math.cos(k)

print(math.sqrt(ans))
Problem p02713 (python)

Fixed submission:
import math
K =int(input())
L = [0 for _ in range(K)]
for a in range(1,K+1):
  for b in range(1,K+1):
    L[math.gcd(a,b)-1] +=1
s = 0
for c in range(1,K+1):
    for k in range(K):
        for _ in range(L[k]):
            s += math.gcd(c,k+1)
print(s)

Buggy submission (verdict: Runtime Error):
import math
K = int(input())
s = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    x = math.gcd(a,b)
    for c in range(1,K+1):
      s += gcd(x,c)
print(s)
Problem p02732 (python)

Fixed submission:
from math import factorial
import collections

N = int(input())
A = input().split()
A = [int(x) for x in A]

L = collections.Counter(A)

c = 0
for i in range(1,N+1):
    n = L[i]
    if n >=2:
        c += factorial(n) // factorial(2) // factorial(n - 2)

for k in range(N):
    c1 = c
    n = L[A[k]]
    if n >= 3:
        c1 -= n-1
    elif n == 2:
        c1 -= factorial(n) // factorial(2) // factorial(n-2)
    print(c1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()

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

for i in range(N):
  L[int(A[i])-1] +=1

c = 0
for i in range(N):
  n = L[i]
  if n >= 2:
    c += factorial(n) // factorial(2) // factorial(n - 2)

for i in range(N):
  n = L[A[i]-1]
  if n >= 2:
    print(c - n + 1)
  else:
      print(c)
Problem p02767 (python)

Fixed submission:
N = int(input())
X = input().split()
X = [int(l) for l in X]

s = 0
for x in X:
    s += (x-X[0])**2
S = s

if N == 1:
    print(S)
else:
    m = max(X)
    n = min(X)
    for P in range(n,m+1):
        s = 0
        for x in X:
            s += (x-P)**2
        if s < S:
            S = s
    print(S)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = input().split()
X = [int(l) for l in X]

s = 0
for x in X:
    s += (x-1)**2

S = s

if N == 1:
    print(0)
else:
    m = max(X)
    n = min(X)
    for P in range(n,m+1):
        s = 0
        for x in X:
            s += (x-P)**2
        if s < S:
            S = s
	print(S)
Problem p02658 (python)

Fixed submission:
import sys

n = int(input())
l = [int(x) for x in input().split()]

ans = 1

if 0 in l:
    print(0)
    sys.exit()

for i in l:
  ans *= i
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

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

ans = 1

for i in l:
  a *= i
  if a > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)
Problem p02743 (python)

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

if 4*a*b - (c - a - b) ** 2 < 0 and c-a-b > 0:
    print("Yes")
    # print("{}, {}".format(4*a*b, (c - a - b) ** 2))
else:
    print("No")
    # print("{}, {}".format(4*a*b, (c - a - b) ** 2))
    # 249999999 250000000 999999998

Buggy submission (verdict: Runtime Error):
import numpy

s = input().split()
a, b, c = int(s[0]), int(s[1]), int(s[2])

if 4*a*b - (c - a - b) ** 2 < 0:
    print("Yes")
    # print("{}, {}".format(4*a*b, (c - a - b) ** 2))
else:
    print("No")
    # print("{}, {}".format(4*a*b, (c - a - b) ** 2))
    # 249999999 250000000 999999998

Buggy submission (verdict: Runtime Error):
import numpy

s = input().split()
a, b, c = int(s[0]), int(s[1]), int(s[2])

k = max(float(a), float(b))
if float(a) + float(b) - float(c) + 2.0 * numpy.sqrt(a*k * b*k) / k < 0.0:
    print("Yes")
    # print("{} {} {}".format(numpy.sqrt(a), numpy.sqrt(b), numpy.sqrt(c)))
else:
    print("No")
    # print("{} {} {}".format(numpy.sqrt(a), numpy.sqrt(b), numpy.sqrt(c)))
Problem p02817 (python)

Fixed submission:
a = input().split()
print(a[1]+a[0])

Buggy submission (verdict: Runtime Error):
n = int(input())


def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(n**0.5) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1


ans = prime(n)
print(ans)
Problem p02830 (python)

Fixed submission:
n = int(input())
s = input().split()
l = ""
for i in range(n):
    l += s[0][i]
    l += s[1][i]

print(l)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
t = input()
l = ""
for i in range(n):
    l += s[i]
    l += t[i]

print(l)
Problem p02837 (python)

Fixed submission:
import copy
from itertools import permutations, product

n = int(input())
al = []
xyl = []
for i in range(n):
    a = int(input())
    al.append(a)
    tl = []
    for j in range(a):
        t = [int(i) for i in input().split()]
        tl.append(t)
    xyl.append(tl)

l = [i for i in product([0, 1], repeat=n)]

ans_list = []

for ll in l:
    ans_flag = 1
    for i in range(n):
        flag = 1
        for j in range(al[i]):
            if ll[xyl[i][j][0]-1] != xyl[i][j][1]:
                flag = 0
        if flag != ll[i]:
            ans_flag = 0
    if ans_flag == 1:
        ans_list.append(copy.deepcopy(ll))

ans = 0
for i in ans_list:
    k = i.count(1)
    if ans < k:
        ans = k

print(ans)

Buggy submission (verdict: Runtime Error):
import copy
from itertools import permutations, product

n = int(input())
al = []
xyl = []
for i in range(n):
    a = int(input())
    al.append(a)
    tl = []
    for j in range(a):
        t = [int(i) for i in input().split()]
        tl.append(t)
    xyl.append(tl)

l = [i for i in product([0, 1], repeat=n)]

ans_list = []

for ll in l:
    ans_flag = 1
    for i in range(n):
        flag = 1
        for j in range(a):
            if ll[xyl[i][j][0]-1] != xyl[i][j][1]:
                flag = 0
        if flag != ll[i]:
            ans_flag = 0
    if ans_flag == 1:
        ans_list.append(copy.deepcopy(ll))

ans = 0
for i in ans_list:
    k = i.count(1)
    if ans < k:
        ans = k

print(ans)
Problem p02743 (python)

Fixed submission:
import bisect,collections,decimal,itertools,math,numpy,string
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    if c-a-b < 0:
        return 'No'
    if 4*a*b < (c-a-b)**2:
        return 'Yes'
    return'No'
    
a,b,c = LI()
print(main(a,b,c))

Buggy submission (verdict: Runtime Error):
import bisect,collections,decimal,itertools,math,numpy,string
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    decimal.getcontext().prec = 20
    if decimal.Decimal(math.sqrt(a))+decimal.Decimal(math.sqrt(b)) < decimal.Decimal(math.sqrt(c)):
        return 'Yes'
    else:
        return 'No'
    
a,b,c = LI()
print(main(a,b,c))

Buggy submission (verdict: Runtime Error):
import bisect,collections,itertools,math,numpy,string,sympy
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    if sympy.sqrt(a)+sympy.sqrt(b) < sympy.sqrt(c):
        return 'Yes'
    else:
        return 'No'
    
a,b,c = LI()
print(main(a,b,c))

Buggy submission (verdict: Runtime Error):
import bisect,collections,itertools,math,numpy,string,sympy
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    if sympy.sqrt(a)+sympy.sqrt(b)-sympy.sqrt(c) < 0:
        return 'Yes'
    else:
        return 'No'
    
a,b,c = LI()
print(main(a,b,c))

Buggy submission (verdict: Runtime Error):
import bisect,collections,itertools,math,numpy,string,sympy
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    if float(sympy.sqrt(a))+float(sympy.sqrt(b))-float(sympy.sqrt(c)) < 0:
        return 'Yes'
    else:
        return 'No'
    
a,b,c = LI()
print(main(a,b,c))
Problem p02780 (python)

Fixed submission:
def main(N,K,p):
    sumi = 0
    ruiseki = [0] * (N+1)
    for i in range(N):
        ruiseki[i+1] = ruiseki[i] + p[i]
    for j in range(N-K+1):
        sumi = max(sumi, (ruiseki[j+K]-ruiseki[j]))
    return (sumi + K) / 2
N,K = map(int,input().split())
p = list(map(int,input().split()))
print(main(N,K,p))

Buggy submission (verdict: Runtime Error):
def main(N,K,p):
    sumi = 0
    ruiseki = [0] * (N+1)
    for i in range(N):
        ruiseki[i+1] = ruiseki[i] + p[i]
    for j in range(K):
        sumi = max(sumi, (ruiseki[j+K]-ruiseki[j]))
    return (sumi + K) /2
N,K = map(int,input().split())
p = list(map(int,input().split()))
print(main(N,K,p))
Problem p02861 (python)

Fixed submission:
import itertools,math,numpy as np
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
xy = np.array([LI() for _ in range(N)])
sum_norm = 0
dict_norm = {}
for a in itertools.permutations(range(N)):
    for i in range(len(a)-1):
        vector = xy[a[i+1]]-xy[a[i]]
        if not tuple(vector) in dict_norm:
            dict_norm[tuple(vector)] = np.linalg.norm(vector)
        sum_norm += dict_norm[tuple(vector)]
print(sum_norm/math.factorial(N))

Buggy submission (verdict: Runtime Error):
import itertools,math,numpy as np
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
xy = np.array([LI() for _ in range(N)])
sum_norm = 0
dict_norm = {}
for a in itertools.permutations(range(N)):
    for i in range(len(a)-1):
        vector = tuple(xy[a[i+1]]-xy[a[i]])
        if not vector in dict_norm:
            dict_norm[vector] = np.linalg.norm(vector)
            vector_inverse = tuple(vector[0]*-1,vector[1]*-1)
            dict_norm[vector_inverse] = dict_norm[vector]
        sum_norm += dict_norm[vector]
print(sum_norm/math.factorial(N))
Problem p02936 (python)

Fixed submission:
import collections,copy,sys
def LI(): return list(map(int,sys.stdin.readline().split()))
N,Q = LI()
ans = [0]*(N+1)
graph = [collections.deque() for _ in range(N+1)] #1_index
for _ in range(N-1):
    a,b = LI()
    graph[a].append(b)
    graph[b].append(a)
for _ in range(Q):
    p,x = LI()
    ans[p] += x
seen = [-1]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]!=-1:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])

Buggy submission (verdict: Runtime Error):
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = {i:collections.deque() for i in range(1,n+1)} #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])