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

Fixed submission:
import numpy as np
k,x = map(int,input().split())

result = np.arange(x-k+1,x+k,1,dtype = 'int')

for i in range(len(result)):
    print(result[i],end = " ")

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

for i in range(x-k-1,x+k-1)
	print(i)

Buggy submission (verdict: Runtime Error):
import numpy as np
k,x = map(int,input().split())

result = np.linspace(x-k+1,x+k-1,k*2-1,dtype = 'int')

for i in range(k*2-1):
    print(str(result[i]),end = " ")

Buggy submission (verdict: Runtime Error):
import numpy as np
k,x = map(int,input().split())

result = np.linspace(x-k+1,x+k-1,k*2-1,dtype = 'int')

for i in range(k*2-1):
    print(str(result[i]),end = "　")

Buggy submission (verdict: Runtime Error):
import numpy as np
k,x = map(int,input().split())

result = np.linspace(x-k+1,x+k-1,k*2-1,dtype = 'int')

for i in range(k*2-1):
    print(result[i],end = "　")

Buggy submission (verdict: Runtime Error):
import numpy as np
k,x = map(int,input().split())

result = np.linspace(x-k+1,x+k-1,k*2-1,dtype = 'int')

for i in range(k*2-1):
    print(result[i],end = " ")

Buggy submission (verdict: Runtime Error):
import numpy as np
k,x = map(int,input().split())

result = np.linspace(x-k+1,x+k-1,k*2-1,dtype = 'int')
print(result)
Problem p02952 (python)

Fixed submission:
N = int(input())
 
ans = 0
for i in range(1,N+1):
        if len(str(i))%2 == 1:
                ans += 1
 
print(ans)

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

N = int(len(n))
result = 0

if N == 1:
    result = n
elif N % 2 != 0:
    result += (int(n) - (10 ** (N-1))) + 1
    count = 0
    for i in range(N // 2):
        count += 1 
        a = "9" * count
        result += int(a)
else:
    for i in range(N // 2):
        count += 1 
        a = "9" * count
        result += int(a)

print(result)
Problem p02953 (python)

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

falg = 0

for i in range(n - 1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        print("No")
        exit()
            
print("Yes")

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

falg = 0

for i in range(len(h) - 1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        flag = 1
        break
            
print("Yes" if flag == 0 else "No")

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

falg = 0

for i in range(1,n):
    
    if h[i] > max_h:
        max_h = h[i]-1
    elif h[i] < max_h:
        flag = 1
            
print("Yes" if flag == 0 else "No")
Problem p03263 (python)

Fixed submission:
HW = list(map(int, input().split()))
H = HW[0]
W = HW[1]
a = []
ans = []

for i in range(H):
  a.append(list(map(int, input().split())))
  
for i in range(H):
  for j in range(W):
    if a[i][j] % 2 == 1:
      if j+1 < W:
        a[i][j] -= 1
        a[i][j+1] += 1
        ans.append((i, j, i, j+1))
      elif i+1 < H:
        a[i][j] -= 1
        a[i+1][j] += 1
        ans.append((i, j, i+1, j))

print(len(ans))
for (y1, x1, y2, x2) in ans:
  print("%d %d %d %d" % (y1+1, x1+1, y2+1, x2+1))

Buggy submission (verdict: Runtime Error):
HW = list(map(int, input().split()))
H = HW[0]
W = HW[1]
a = []

for i in range(H):
  a.append(list(map(int, input().split())))
  
for i in range(H):
  for j in range(W):
    if a[i][j] % 2 == 1:
      if j+1 < W:
        a[i][j] -= 1
        a[i][j+1] += 1
      	print("%d %d %d %d" % (j+1, i+1, j+2, i+1))
      elif i+1 < H:
        a[i][j] -= 1
        a[i+1][j] += 1
        print("%d %d %d %d" % (j+1, i+1, j+1, i+2))
Problem p02657 (python)

Fixed submission:
nums = input().split()
print(int(nums[0]) * int(nums[1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
As = map(int, input().split())
result = 1
 
for a in As:
  result = result * a
 
if a >= 10**18:
  print(-1)
else:
  print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
As = map(int, input().split())
result = 1
 
for a in As:
  result *= a
 
if a >= 10**18:
  print(-1)
else:
  print(result)

Buggy submission (verdict: Runtime Error):
nums = input().split()
print(nums[0] * nums[1])
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
result = 1
 
if 0 in A:
  print(0)
  exit()

for a in A:
  result *= a
  if result > 10**18:
    print(-1)
    exit()

print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
As = map(int, input().split())
result = 1
 
for a in As:
  result *= a
  
if 0 in As:
  print(0)
  return
if result > 10**18:
  print(-1)
else:
  print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
As = map(int, input().split())
result = 1
 
for a in As:
  result *= a
 
if result >= 10**18:
  print("-1")
 else:
  print(result)
Problem p02657 (python)

Fixed submission:
A,B=map(int,input().split())
print(A*B)

Buggy submission (verdict: Runtime Error):
int A,B
A=6
B=6
print(A*B)
Problem p02657 (python)

Fixed submission:
A,B = map(int,input().split())
print(A*B)

Buggy submission (verdict: Runtime Error):
A,B = map(input,input.split())
return A*B

Buggy submission (verdict: Runtime Error):
A=input()
B=input()

print(int(A)*int(B))
Problem p02657 (python)

Fixed submission:
a,b=input().split()
print(int(a)*int(b))

Buggy submission (verdict: Runtime Error):
num1=input()
num1=int(num1)
num2=input()
num2=int(num2)
print(num1*num2)

Buggy submission (verdict: Runtime Error):
num1=input()
num1=(int)num1
num2=input()
num2=(int)num2
print(num1*num2)
Problem p02772 (python)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
f=True
for i in a:
  if i%2==0:
    if i%3==0 or i%5==0:
      f=True
    else:
      f=False
      break
if f:
  print("APPROVED")
else:
  print("DENIED")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
flag=True
for i in a:
  if i%2==0:
    if i%3==0 or i%5==0:
      f=True
    else:
      f=False
      break
if f:
  print("APPROVED")
else:
  print("DENIED")
Problem p03386 (python)

Fixed submission:
a,b,k = map(int, input().split())
tmp = []
for i in range(k):
    if a + i <= b:
        tmp.append(a+i)
    if b - i >= a:
        tmp.append(b-i)

for i in sorted(set(tmp)):
    print(i)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
nums = list(range(a,b+1))
ans = nums[:k] + nums[len(nums)-k:]
for a in sorted(set(ans)):
    print(a)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
nums = list(range(a,b+1))
ans = nums[:k] + nums[len(nums)-k:]
for a in sorted(list(set(ans))):
    print(a)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
nums = list(range(a,b+1))
ans = nums[:k] + list(reversed(nums))[:k]
print(ans)
for a in set(sorted(ans)):
    print(a)
Problem p03544 (python)

Fixed submission:
n = int(input())
a,b = 2,1
for _ in range(n):
    a,b = b,a+b

print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
tmp1 = 2
tmp2 = 1
for i in range(n-1):
    luc = tmp1 + tmp2
    tmp1,tmp2 = tmp2,luc

print(luc)
Problem p02687 (python)

Fixed submission:
S = input()

if S == "ABC" :
  print("ARC")
else :
  print("ABC")

Buggy submission (verdict: Runtime Error):
S = input()

if S == ABC :
  print("ARC")
else :
  print("ABC")

Buggy submission (verdict: Runtime Error):
S = input()

if S == ABC :
  print(ARC)
else :
  print(ABC)
Problem p02718 (python)

Fixed submission:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
S = sum(A)
if A[M-1] >= S / (4*M):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
S = sum(A)
if A[M-1] >= S / (4*M):
print("Yes")
else:
print("No")
Problem p02731 (python)

Fixed submission:
L = int(input())

c = float(L) / 3
print(c * c * c)

Buggy submission (verdict: Runtime Error):
L = int(input())
s = []
for i in range(1,L+1):
    for j in range(1,L - i + 1):
        for k in range(1, L - i - j + 1):
            s.append(i * j * k)
print(max(s))
Problem p02791 (python)

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

m = A[0]
cnt = 1
for i in range(1,N):
    m = min(m, A[i])
    if A[i] <= m:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
from typing import List

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

aa = list(reversed(A))

cnt = 0
for i in range(0,N):
    if aa[i] == min(aa[i:]):
        cnt += 1
print(cnt)
Problem p02801 (python)

Fixed submission:
alphabet = input()
print(chr(ord(alphabet) + 1))

Buggy submission (verdict: Runtime Error):
N, K, M =map(int, input().split())
A = list(map(int, input().split()))


if K >= N * M - sum(A) >= 0:
    print(N * M -sum(A))
elif sum(A) >= N * M - M:
    print("0")
else:
    print("-1")

#達成できる
#もう達成している
#無理
Problem p02657 (python)

Fixed submission:
import sys

a,b = list(map(int,input().split()))
print(a*b)

Buggy submission (verdict: Runtime Error):
import sys

n = list(map(int,input().split()))
a_list = list(map(int,input().split()))

zero_search = 0 in a_list
ans = 1

if zero_search:
    ans = 0
else:
    for i in a_list:
        ans *= i
        if ans > 10**18:
            ans = -1
            break
            
print(ans)
Problem p02658 (python)

Fixed submission:
import sys

n = list(map(int,input().split()))
a_list = list(map(int,input().split()))

zero_search = 0 in a_list
ans = 1

if zero_search:
    ans = 0
else:
    for i in a_list:
        ans *= i
        if ans > 10**18:
            ans = -1
            break
            
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

n = list(map(int,input().split()))
a_list = list(map(int,input().split()))

zero_search = 0 in a_list
ans = 1

if zero_search:
    ans = 0
else:
    for i in a_list:
        ans *= i
        if ans > 10**18;
            ans = -1
            break
            
print(-1)
Problem p02658 (python)

Fixed submission:
n = int(input())

a = list(int(i) for i in input().split(" "))

prod = 1

if 0 in a:
  prod = 0
else:
  for i in a:
    prod *= i
    if prod > (10 ** 18):
      prod = -1
      break


print(prod)

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

a = list(int(i) for i in input().split(" "))

prod = 1

for i in a:
  prod *= i
  if prod > (10 ** 18):
  	prod = -1
    break


print(prod)
Problem p02706 (python)

Fixed submission:
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

tot = np.sum(A)
if N < tot:
	print(-1)
else:
	print(N-tot)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
tot = np.sum(A)

if tot > N:
	print(-1)
else:
	print(N-tot)
Problem p02716 (python)

Fixed submission:
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from collections import defaultdict

N, *A = map(int, read().split())

INF = 10**18
dp_not = defaultdict(lambda : -INF)
dp_take = defaultdict(lambda: -INF)
dp_not[(0,0)] = 0

for i,x in enumerate(A,1):
	j = (i-1)//2
	for n in (j,j+1):
		dp_not[(i,n)] = max(dp_not[(i-1,n)], dp_take[(i-1,n)])
		dp_take[(i,n)] = dp_not[(i-1,n-1)] + x

print(max(dp_not[(N, N//2)], dp_take[(N, N//2)]))

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(input())
A = [0] + list(map(int, input().split()))
if N <= 3:
	print(max(A))
	sys.exit()

dp = np.zeros([N//2+1, N+1], np.int64)
for i in range(1,4):
	dp[1,i] = max(A[1:i+1])

for j in range(2,(N//2)+1):
	for i in range(j*2-1, min(N+1, j*2+2)):
		dp[j,i] = max(dp[j,i-1],dp[j-1,i-2] + A[i])

print(max(dp[-1,-4:]))
Problem p02730 (python)

Fixed submission:
import sys
s=input()
n=len(s)
s_pre = s[:(n-1)//2]
s_epi = s[(n+1)//2:]
if s != s[::-1]:
    print('No')
    sys.exit()
if s_pre != s_pre[::-1]:
    print('No')
    sys.exit()
if s_epi != s_epi[::-1]:
    print('No')
    sys.exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
s=input()
s_pre = s[:(n-1)//2]
s_epi = s[(n+1)//2:]
n = len(s)
if s != s[::-1]:
    print('No')
    sys.exit()
if s_pre != s_pre[::-1]:
    print('No')
    sys.exit()
if s_epi != s_epi[::-1]:
    print('No')
    sys.exit()
print('Yes')
Problem p02788 (python)

Fixed submission:
import numpy as np
import sys
N, D, A = map(int, input().split())
L = 2 * D
I = np.array(sys.stdin.read().split(), np.int64)
X = I[::2]
H = I[1::2]
sort_ind = np.argsort(X)
X = X[sort_ind]
H = H[sort_ind]
S = np.zeros(N+1, np.int64)
ind = np.searchsorted(X,X+L+1,side = 'left')

atack = 0
ans = 0
for i in range(N):
	atack += S[i]
	H[i] -= atack
	if H[i] > 0:
		atack_cnt = -(-H[i]//A)
		ans += atack_cnt
		tmp = atack_cnt * A
		S[i+1] += tmp
		S[ind[i]] -= tmp

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

I = np.array(read().split(), np.int64)
X = I[::2]
H = I[1::2]

sort_ind = np.argsort(X)
X = X[sort_ind]
H = H[sort_ind]

atack = np.zeros(N+1)
cover = np.searchsorted(X, X + (2 * D), side = 'right')

ans = 0
cnt = 0
for i in range(N):
	cnt += atack[i]
	H[i] -= cnt
	if H[i] > 0:
		tmp = -(-H[i]//A)
		ans += tmp
		cnt += tmp * A
		atack[cover[i]] -= tmp * A

print(ans)
Problem p02804 (python)

Fixed submission:
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
mod = 10**9+7
A.sort()

fact = np.zeros(N+1, np.int64)
inv = np.zeros(N+1, np.int64)

fact[0], fact[1] = 1, 1
inv[0], inv[1] = 1, 1

for i in range(2,N+1):
	fact[i] = fact[i-1] * i
	fact[i] %= mod
	inv[i] = inv[i-1] * pow(i, mod-2, mod)
	inv[i] %= mod

ans = 0
lim = N - K + 1
for ind, a in enumerate(A,1):
	if ind < K:
		tmp_max = 0
	else:
		r_cnt = ind - 1
		r_comb = fact[r_cnt]
		r_comb *= inv[K - 1]
		r_comb %= mod
		r_comb *= inv[r_cnt - K + 1]
		r_comb %= mod

		tmp_max= r_comb * a % mod

	if ind > lim:
		tmp_min = 0
	else:
		l_cnt = N - ind
		l_comb = fact[l_cnt]
		l_comb *= inv[K - 1]
		l_comb %= mod
		l_comb *= inv[l_cnt - K + 1]
		l_comb %= mod

		tmp_min = l_comb * a % mod

	ans += (tmp_max - tmp_min) % mod
	ans %= mod

ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9 + 7
A.sort()

keisuu = [1]
for i in range(N-K):
	tmp = keisuu[-1] * (k-1-i) // (i+1)
	tmp %= mod
	keisuu.append(tmp)

tot = keisuu

tmp = 0
keisuu_sumup = []
for i in range(len(keisuu)):
	tmp += keisuu[i]
	tmp %= 0
	kesuu_sumup.append(tmp)

ans = 0
for i in range(N):
	ans -= tot * A[i]
	ans += keisuu_sumup[i] * A[K-1+i]
	ans %= mod

print(ans)
Problem p02811 (python)

Fixed submission:
k,x = map(int,input().split())

if 500*k >= x:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
import sys

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

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

GCD = 1
t = a[0]
cond = 0
while t%2 == 0:
	t //= 2
	cond += 1
	
mod = 2**cond
for i in range(len(a)):
	t,tt = divmod(a[i], mod)
	if t == 0 or tt != 0:
		print(0)
		sys.exit()
	if t % 2 == 1:
		print(0)
		sys.exit()

	GCD = GCD*a[i] // gcd(GCD,a[i])
	
A = (2*m) // GCD
if A%2 == 1:
	A+=1

print(A//2)
Problem p02813 (python)

Fixed submission:
import sys

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))


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

a,b = 0,0

l = [i+1 for i in range(n)]
if l == p:
	a = 1
if l == q:
	b = 1

if a == b == 1:
	print(0)
	sys.exit()
cnt = 1
while True:
	cnt += 1
	for i in range(n-1,-1,-1):
		if l[i] < l[i-1]:
			continue
		else:
			obj = l[i-1]
			tmp = sorted(l[i-1:])
			switch = tmp.pop(tmp.index(obj)+1)
			l = l[:i-1] + [switch] + sorted(tmp)

			#print(l)

			break
	
	if l == p:
		a = cnt
	if l == q:
		b = cnt

	if a != 0 and b != 0:
		break

print(abs(a-b))

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

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

a,b = 0,0

l = [i+1 for i in range(n)]
if l == p:
	a = 1
elif l == q:
	b = 1
cnt = 1
while True:
	cnt += 1
	for i in range(n-1,-1,-1):
		if l[i] < l[i-1]:
			continue
		else:
			obj = l[i-1]
			tmp = sorted(l[i-1:])
			switch = tmp.pop(tmp.index(obj)+1)
			l = l[:i-1] + [switch] + sorted(tmp)

			#print(l)

			break
	
	if l == p:
		a = cnt
	elif l == q:
		b = cnt

	if a != 0 and b != 0:
		break

print(abs(a-b))
Problem p02845 (python)

Fixed submission:
import sys

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

mod = (10**9) + 7
abc = [0] * 3
ans = 1
for i in range(N):
	pos = abc.count(A[i])
	if pos == 0:
		print(0)
		sys.exit()
	ind = abc.index(A[i])
	ans *= pos
	ans %= mod
	abc[ind] += 1

print(ans)

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

mod = (10**9) + 7
abc = [0] * 3
ans = 1
for i in range(N):
	pos = abc.count(A[i])
	ind = abc.index(A[i])
	ans *= pos
	ans %= mod
	abc[ind] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
mod = (10**9) + 7
abc = [0] * 3
ans = 1
for i in range(N):
	pos = abc.count(A[i])
	ind = abc.index(A[i])
	ans *= pos
	ans %= mod
	abc[ind] += 1

print(ans)
Problem p02855 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W,K = map(int, readline().split())
grid = np.frombuffer(read(), 'S1').reshape(H,-1)[:,:W]

X,Y = np.where(grid == b'#')

A = np.zeros((H,W), np.int32)
A[X,Y] = np.arange(1,K+1)

np.maximum.accumulate(A, axis = 1, out = A)

for w in range(W-2, -1, -1):
	A[:,w] += A[:,w+1] * (A[:,w] == 0)

for h in range(1,H):
	if A[h,-1] == 0:
		A[h] += A[h-1]
for h in range(H-1,-1,-1):
	if A[h,-1] == 0:
		A[h] += A[h+1]

print('\n'.join(' '.join(row) for row in A.astype(str)))

Buggy submission (verdict: Runtime Error):
H,W,K = map(int, input().split())
S = [list(map(str,input())) for _ in range(H)]

ans = [[-1]*W for _ in range(H)]

cnt = 1
cnt_max = 0
for i in range(H):
	ichigo = S[i].count("#")
	if ichigo == 0:
		ans[i].clear()
		continue
	cnt_max = cnt + ichigo - 1
	for j in range(W):
		if S[i][j] == ".":
			ans[i][j] = min(cnt,cnt_max)
		else:
			ans[i][j] = min(cnt,cnt_max)
			cnt += 1
	cnt = cnt_max+1
cond = 1
while cond:
	cond = 0
	for i in range(H):
		if ans[i] == []:
			cond = 1
			if i == H-1:
				ans[i] = ans[i-1]
			else:
				ans[i] = ans[i+1]

for i in range(H):
	for j in range(W):
		if j == W-1:
			print(ans[i][j])
		else:
			print(ans[i][j], end = " ")
Problem p02861 (python)

Fixed submission:
import math

N = int(input())
x, y = [], []
for _ in range(N):
	xt, yt = map(int, input().split())
	x.append(xt)
	y.append(yt)

def bfs(flg, cp, tot):
	if flg.count(0) == 0:
		return tot

	ans = 0
	for np in [i for i in range(N) if flg[i] == 0]:
		d = ((x[cp]-x[np])**2 + (y[cp]-y[np])**2) ** (1/2)
		flg[np] = 1
		ans += bfs(flg, np, tot+d)
		flg[np] = 0

	return ans

flg = [0] * N

A = 0

for i in range(N):
	flg[i] = 1
	A += bfs(flg,i,0)
	flg[i] = 0

for i in range(1,N+1):
	A /= i

print(A)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
import itertools
read = sys.stdin.buffer.read
N = int(input())
XY = np.array(read().split(), np.int64).reshape(-1,2)

ans = 0
for ditour in itertools.permutations(range(N)):
	distance = 0
	for i in range(1,N):
		u = XY[ditour[i]] - XY[ditour[i-1]]
		distance += np.linalg.norm(u)

	ans += distance

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

print(ans)
Problem p02917 (python)

Fixed submission:
N = int(input())
B = list(map(int, input().split()))

A = []

for i in range(N):
	if i == 0:
		A.append(B[0])
	elif 1 <= i <= N-2:
		A.append(min(B[i],B[i-1]))
	else:
		A.append(B[-1])

print(sum(A))

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

B=[]
for i in range(N-1):
    B.append(min(A[i],A[i+1]))
B.append(A[-1])

print(sum(B))
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N, Q = map(int ,input().split())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
	at,bt = map(int ,input().split())
	E[at].append(bt)
	E[bt].append(at)
cnt = [0 for _ in range(N+1)]
for _ in range(Q):
	pt,xt = map(int, input().split())
	cnt[pt] += xt

flg = [0 for _ in range(N+1)]
q = [[1,-1]]
while q:
	cp, root = q.pop()
	for np in E[cp]:
		if np == root:
			continue
		cnt[np] += cnt[cp]
		q.append([np,cp])

cnt.pop(0)
for c in cnt:
	print(c, end = " ")
print()

Buggy submission (verdict: Runtime Error):
N, Q = map(int ,input().split())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
	at,bt = map(int ,input().split())
	E[at].append(bt)
cnt = [0 for _ in range(N+1)]
for _ in range(Q):
	pt,xt = map(int, input().split())
	cnt[pt] += xt

q = [1]
def dfs(q):
	if not q:
		return
	cp = q.pop()
	for np in E[cp]:
		cnt[np] += cnt[cp]
		q.append(np)

	dfs(q)
dfs(q)
cnt.pop(0)
for c in cnt:
	print(c, end = " ")
print()
Problem p02953 (python)

Fixed submission:
import sys
n = int(input())
h = list(map(int, input().split()))[::-1]

for i in range(1,n):
    if h[i] > h[i-1] + 1:
        print("No")
        sys.exit()
    elif h[i] == h[i-1] + 1:
        h[i] -= 1




print("Yes")

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

for i in range(n-1):
    if h[i] > h[i+1] + 1:
        print("No")
        sys.exit()
    
    elif h[i] == h[i+1] + 1 and h[i+1] > h[i+2]:
        print("No")
        sys.exit()

print("Yes")
Problem p02975 (python)

Fixed submission:
import collections as c
import sys

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

A = c.Counter(a)

if list(A.keys()) == [0]:
	print("Yes")
	sys.exit()

if len(A.keys()) == 2:
	if 0 not in A.keys():
		print("No")
		sys.exit()
	else:
		if list(A.values())[0]*2 == list(A.values())[1]:
			print("Yes")
			sys.exit()
		else:
			print("No")
			sys.exit()

if len(A.keys()) != 3:
	print("No")
	sys.exit()

x,y,z = A.keys()
if x^y != z:
	print("No")
	sys.exit()

x,y,z = A.values()
if x == y == z:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
import collections as c
import sys

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

A = c.Counter(a)

if list(A.keys()) == [0]:
	print("Yes")
	sys.exit()

if len(A.keys()) == 2:
	if 0 not in A.keys():
		print("No")
		sys.exit()
	else:
		if A.values()[0]*2 == A.values()[1]:
			print("Yes")
			sys.exit()
		else:
			print("No")
			sys.exit()

if len(A.keys()) != 3:
	print("No")
	sys.exit()

x,y,z = A.keys()
if x^y != z:
	print("No")
	sys.exit()

x,y,z = A.values()
if x == y == z:
	print("Yes")
else:
	print("No")
Problem p02981 (python)

Fixed submission:
n,a,b = map(int,input().split())
print(min([n*a,b]))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
print(min([n*a,b])

Buggy submission (verdict: Runtime Error):
a,b,n = map(int,input().split())
print(min([n*a,b])
Problem p03029 (python)

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

print(((a * 3) + p) // 2)

Buggy submission (verdict: Runtime Error):
n = int(input())
book=[]
for i in range(n):
    a,b=input().split()
    temp=[a,int(b),i+1]
    book.append(temp)

book.sort(key=lambda x:x[0])
book.sort(key=lambda x:x[1])

for j in range[len(book)]:
    print(book[j][3])