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

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
l = sorted(L)

t = 0

for a in range(N):
    for b in range(a + 1, N):
        for c in range(b + 1, N):

            if l[a] < l[b] < l[c] and l[a] + l[b] > l[c]:
                t += 1

print(t)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = int(input())
L = list(map(int, input().split()))
t = 0

for a in range(N - 2):
    for b in range(N - 2):
        for count in range(N - 2):
            x = L[a], L[a + b + 1], L[a + 1 + count]
            mylist = list(x)
            mylist.sort()
            if mylist[0] + mylist[1] > mylist[2]:
                t += 1

print(t)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = sorted(p)
new = []
t = x in l

if t == False:
    re = x #n = 0でよかった。ここでは、listの中にxがなかったときにreにxを入れている。
else:
    for i in range(len(l)):
        TorF_1 = x + i + 1 in l
        TorF_2 = x - i - 1 in l
        if TorF_2 == False:
            re = x - i - 1
            break

        elif TorF_1 == False:
            re = x + i + 1
            break
    
print(re)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = sorted(p)
new = []
t = x in l

if n == 0: 
#t == False:
#re = x #n = 0でよかった。ここでは、listの中にxがなかったときにreにxを入れている。
else:
    for i in range(len(l)):
        TorF_1 = x + i + 1 in l
        TorF_2 = x - i - 1 in l
        if TorF_1 == False:
            re = x + i + 1
            break
        elif TorF_2 == False:
            re = x - i - 1
            break

print(re)
Problem p02791 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
min = 10 ** 100
count = 0


for i in range(n):
    if p[i] < min:
        min = p[i]
        count += 1

print(count)

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

for i in range(1, n):
    new = p[:i]
    m = max(new)
    print(new)
    if p[i] < m:
        count += 1

print(count)
Problem p04025 (python)

Fixed submission:
n = int(input())
x = sorted(list(map(int, input().split())), reverse = True)
x_2 = list(map(lambda x:x ** 2, x))
ichi = sum(x)
jijou = sum(x_2)
re = 10 ** 100


#def ji(p, x):
#    ans = p * (p - 2 * x)
#    return ans

for p in range(x[-1], x[0] + 1):
    second = n * (p ** 2)
    third = -2 * p * ichi
    summ = jijou + second + third

    if re > summ:
        re = summ

print(re)

#for i in range(x[i]):

Buggy submission (verdict: Runtime Error):
n = int(input())
x = sorted(list(map(int, input().split())), reverse = True)
x_2 = list(map(lambda x:x ** 2, x))
ichi = sum(x)
jijou = sum(x_2)
re = 10 ** 100


#def ji(p, x):
#    ans = p * (p - 2 * x)
#    return ans

for p in range(x[n], x[0] + 1):
    second = n * (p ** 2)
    third = -2 * p * ichi
    summ = jijou + second + third

    if re > summ:
        re = summ

print(re)

#for i in range(x[i]):
Problem p03030 (python)

Fixed submission:
import numpy as np
n = int(input())
SP=[]
SPs=[]
for i in range(n):
    SP=[i]
    for j in input().split():
        SP.append(j)
    SPs.append(SP)
SPs=np.array(SPs)

SPs2=SPs[SPs[:,2].astype(int).argsort(kind="mergesort")[::-1],:]
SPs3=SPs2[SPs2[:,1].argsort(kind="mergesort"),:][:,0]

for i in range(n):
    print(int(SPs3[i])+1)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
SP=[]
SPs=[]
for i in range(n):
    SP=[i]
    for j in input().split():
        SP.append(j)
    SPs.append(SP)

SPs=np.array(SPs)
SPs2=SPs[SPs[:,2].astype(int).argsort()[::-1],:]
SPs3=SPs2[SPs2[:,1].argsort(),:][:,0]

for i in range(n):
    print(int(SPs3[i])+1)
Problem p02553 (python)

Fixed submission:
import sys

def dump(x):
    print(x, file=sys.stderr)

a,b,c,d = [int(i) for i in input().split()]
ans = max(a*c,a*d,b*c,b*d)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

def dump(x):
    print(x, file=sys.stderr)


a,b,c,d = [int(i) for i in input()]
ans = max(a*c,a*d,b*c,b*d,)
print(ans)
Problem p02548 (python)

Fixed submission:
N=int(input())
from math import floor
a=floor(N**(1/2))
i=1
summ=0
for i in range(1,a+1):
    if N%i==0:
        b=N//i
        if b>i:
            summ=summ+(b-i)*2-1
    else:
        b=N//i
        summ=summ+(b-i+1)*2-1
    i+=1
print(summ)

Buggy submission (verdict: Runtime Error):
N=int(input())
from sympy import divisor_count
c=1
summ=0
for c in range(1,N):
    a=divisor_count(c)
    summ+=a
    c+=1
print(summ)
Problem p02765 (python)

Fixed submission:
N,R=input().split()
N=int(N)
R=int(R)
if (R>4111)or(R<0):
  None
if 1<=N<=9:
  R_internal=R+100*(10-N)
  print(R_internal)
elif N>=10:
  R_internal=R
  print(R_internal)
else:
  None

Buggy submission (verdict: Runtime Error):
N,R=input().split()
N=int(N)
R=int(R)
if 1<=N<=9:
    R_exhibit=R-100*(10-N)
    print(R_exhibit)
elif N>=10:
    R_exibit=R
    print(R_exhibit)
Problem p02696 (python)

Fixed submission:
#!/usr/bin/python3

import math
#標準出力からの読み込み
input_1 = input()
a = int(input_1.split(" ")[0])
b = int(input_1.split(" ")[1])
n = int(input_1.split(" ")[2])


#判定ロジック
score = math.floor(a/b*min(b-1, n))
print(score)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3

import math
#標準出力からの読み込み
input_1 = input()
a = int(input_1.split(" ")[0])
b = int(input_1.split(" ")[1])
n = int(input_1.split(" ")[2])


#判定ロジック
score = math.floor(a/b*math.min(b-1, n))
print(score)
Problem p03701 (python)

Fixed submission:
N = int(input())
S = sorted([int(input()) for _ in range(N)])

non_10s = None
for s in S:
    if s % 10 != 0:
        non_10s = s
        break

answer = sum(S)

if answer % 10 == 0 and non_10s != None:
  answer -= non_10s
elif answer % 10 == 0:
  answer = 0
else:
  answer = answer
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = sorted([int(input()) for _ in range(N)])

non_10s = None
for s in S:
    if s % 10 != 0:
        non_10s = s
        break

answer = sum(S)

if answer % 10 ==0 and non_10s != None:
  answer -= non_10s
elif answer % 10 == 0:
  answer -= non_10s
else:
  answer = answer
print(answer)
Problem p02641 (python)

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

ans = X
for i in range(N+1):
    if not X - i in p:
        ans = X - i
        break
    elif not X + i in p:
        ans = X + i
        break

print(ans)

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

if N == 0:
    ans = X
else:
    for i in range(N):
        if not X - i in p:
            ans = X - i
            break
        elif not X + i in p:
            ans = X + i
            break
        else:
            continue

print(ans)

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

if N == 0:
    ans = X
else:
    for i in range(N):
        if not X - i in p:
            ans = X - i
            break
        elif not X + i in p:
            ans = X + i
            break

print(ans)
Problem p02801 (python)

Fixed submission:
imp = input()
alp = ['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','z']
print(alp[alp.index(imp) + 1])

Buggy submission (verdict: Runtime Error):
imp = imput()
alp = ['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','z']
print(alp[alp.index(str(imp)) + 2])

Buggy submission (verdict: Runtime Error):
imp = imput()
alp = ['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','z']
print(alp[alp.index(imp) + 2])
Problem p02811 (python)

Fixed submission:
a = list(map(int,input().split()))
if 500*a[0] >= a[1] :
  print('Yes')
else :
  print('No')

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
if 500 * a[0] >= a[1] :
  print(Yes)
else :
  print(No)
Problem p02813 (python)

Fixed submission:
a = list(map(int,input().split()))
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))

def kaijo(a) :
    k = 1
    for i in range(1,a+1) :
        k = k * i
    return k

def zyunretsu(N) :
    len_N = len(N) - 1
    c = 1
    for i in range(0,len(N)) :
        if len_N == 0 :
            break
        a = N[0]
        N_C = sorted(N)
        b = N_C.index(a)
        c = c + kaijo(len_N) * b
        N.remove(a)
        len_N = len_N - 1
    return c

print(abs(zyunretsu(a_1)-zyunretsu(a_2)))

Buggy submission (verdict: Runtime Error):
import numpy as np

def monji(a) :
    D = []
    STR = ''
    for i in range(0,len(a)) :
        for j in range(len(a[i])) :
            if a[i][j] == " " :
                D.append(int(STR))
                STR = ''
            else :
                STR = STR + a[i][j]
    return D

def kaijo(a) :
    k = 1
    for i in range(1,a+1) :
        k = k * i
    return k
  
def zyunretsu(N) :
    len_N = len(N) - 1
    c = 1
    for i in range(0,len(N)) :
        if len_N == 0 :
            break
        a = N[0]
        N_C = sorted(N)
        b = N_C.index(a)
        c = c + kaijo(len_N) * b
        N.remove(a)
        len_N = len_N - 1
    return c
  
a_1 = input()
a_2 = input()
a_3 = input()
b = monji(a_2)
c = monji(a_3)
print(abs(b-c))
Problem p02612 (python)

Fixed submission:
m= int(input())
while m> 1000 :
            m -= 1000
print(1000 - m)

Buggy submission (verdict: Runtime Error):
    m= int(input())
    while m> 1000 :
        m -= 1000
    print(1000 - m)
Problem p02583 (python)

Fixed submission:
n = int(input())
line = input().split()

length = [int(line[i]) for i in range(n)]
length.sort(reverse = True)

count = 0

for i in range(n-2):
  long = length[i]
  
  for j in range(i+1,n-1):
    middle = length[j]
    if middle == long:
      continue
    if middle*2 <= long :
      break
      
    for k in range(j+1,n):
      short = length[k]
      if short == middle:
        continue
      if short + middle > long:
        count += 1
      else:
        break

print(count)

Buggy submission (verdict: Runtime Error):

count = 0

for i in range(n-2):
  long = length[i]
  
  for j in range(i+1,n-1):
    middle = length[j]
    if middle == long:
      continue
    if middle*2 <= long :
      break
      
    for k in range(j+1,n):
      short = length[k]
      if short == middle:
        continue
      if short + middle > long:
        count += 1
      else:
        break

print(count)
Problem p02642 (python)

Fixed submission:
from collections import Counter
n=int(input())
inp = list(map(int,input().split()))
c=Counter(inp)
arr=[1]*(max(inp)+1)
inp.sort()
d=Counter([])
for i in range(len(arr)):
    if c[i]>=1 and arr[i]==1:
        if d[i]==0:
            d[i]+=1
        else:
            continue
        k=2
        while k*i<len(arr):
            arr[k*i]=0
            k+=1
ans=0
for item in d.keys():
    if c[item]==1:
        ans+=1
print (ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
inp = list(map(int,input().split()))
c=Counter(inp)
inp=[]
for item in c.keys():
  if c[item]==1:
    inp.append(item)
arr=[1]*len(inp)
inp.sort()
ans=0
for i in range(len(inp)):
  if arr[i]==0:
    continue
  else:
    ans+=1
   	for j in range(i+1,len(inp)):
      if inp[j]%inp[i]==0:
        arr[j]=0
print (ans)
Problem p02760 (python)

Fixed submission:
dic={}
a=[]
for i in range(1,100):
    dic[i]=[-1,-1]
for i in range(3):
    a.append(list(map(int,input().split())))
    for j in range(3):
        dic[a[i][j]]=[i,j]
n=int(input())
for i in range(n):
    x=int(input())
    if(dic[x]!=[-1,-1]):
        a[dic[x][0]][dic[x][1]]=0
flag=0
for i in range(3):
    if(max(a[i][1],a[i][2],a[i][0])==0):
        flag=1
        break
    elif(max(a[1][i],a[2][i],a[0][i])==0):
        flag=1
        break
if(max(a[0][0],a[1][1],a[2][2])==0):
    flag=1
elif(max(a[0][2],a[1][1],a[2][0])==0):
    flag=1
if(flag==1):
    print ('Yes')
else:
    print ('No')

Buggy submission (verdict: Runtime Error):
dic={}
a=[[0 for i in range(3)]for j in range(3)]
for i in range(1,100):
    dic[i]=[-1,-1]
for i in range(3):
    a[i]= list(map(int,input().split()))
    for j in range(3):
        dic[a[i][j]]=[i,j]
n=int(input())
for i in range(n):
    x=int(input())
    if(dic[x]!=[-1,-1]):
        a[dic[x][0],dic[x][1]]=0
flag=0
for i in range(3):
    if(max(a[i][1],a[i][2],a[i][0])==0):
        flag=1
        break
    elif(max(a[1][i],a[2][i],a[0][i])==0):
        flag=1
        break
if(max(a[0][0],a[1][1],a[2][2])==0):
    flag=1
elif(max(a[0][2],a[1][1],a[2][0])==0):
    flag=1
if(flag==1):
    print ('Yes')
else:
    print ('No')

Buggy submission (verdict: Runtime Error):
dic={}
a=[[0 for i in range(3)]for j in range(3)]
for i in range(1,100):
    dic[i]=[-1,-1]
for i in range(3):
    for j in range(3):
        x=int(input())
        a[i][j]=3
        dic[x]=[i,j]
n=int(input())
for i in range(n):
    x=int(input())
    if(dic[x]!=[-1,-1]):
        a[dic[x][0],dic[x][1]]=0
flag=0
for i in range(3):
    if(max(a[i][1],a[i][2],a[i][0])==0):
        flag=1
        break
    elif(max(a[1][i],a[2][i],a[3][i])==0):
        flag=1
        break
if(max(a[0][0],a[1][1],a[2][2])==0):
    flag=1
elif(max(a[0][2],a[1][1],a[2][0])==0):
    flag=1
if(flag==1):
    print ('Yes')
else:
    print ('No')

Buggy submission (verdict: Runtime Error):
dic={}
a=[[0 for i in range(3)]for j in range(3)]
for i in range(1,100):
  dic[i]=[-1,-1]
for i in range(3):
  for j in range(3):
    x=int(input())
    a[i][j]=3
    dic[x]=[i,j]
n=int(input())
for i in range(n):
  x=int(input())
  if(dic[x]!=[-1,-1]):
    a[dic[x][0],dic[x][1]]=0
flag=0
for i in range(3):
  if(max(a[i][1],a[i][2],a[i][0])==0):
    flag=1
    break
  elif(max(a[1][i],a[2][i],a[3][i])==0):
    flag=1
    break
if(max(a[0][0],a[1][1],a[2][2])==0):
  flag=1
elif(max(a[0][2],a[1][1],a[2][0])==0):
  flag=1
if(flag==1):
  print ('Yes')
else:
  print ('No')
Problem p02910 (python)

Fixed submission:
odd='RUD'
even='LUD'
s=input()
flag=0
for i in range(len(s)):
  a=i+1
  if a%2==0:
    if s[i] not in even:
      flag=1
      break
  else:
    if s[i] not in odd:
      flag=1
      break
if flag==1:
  print ('No')
else:
  print ('Yes')

Buggy submission (verdict: Runtime Error):
odd='RUD'
even='LUD'
s=int(input())
flag=0
for i in range(len(s)):
  a=i+1
  if a%2==0:
    if s[i] not in even:
      flag=1
      break
  else:
    if s[i] not in odd:
      flag=1
      break
if flag==1:
  print ('No')
else:
  print ('Yes')
Problem p02911 (python)

Fixed submission:
inp=list(map(int,input().split()))
n=inp[0]
k=inp[1]
q=inp[2]
arr=[k-q]*n
for i in range(q):
        x=int(input())
        arr[x-1]+=1
if q<k:
    for i in range(n):
        print ('Yes')
else:
    z=[]
    for i in range(len(arr)):
        if arr[i]>0:
            print ('Yes')
        else:
            print ('No')

Buggy submission (verdict: Runtime Error):
inp=list(map(int,input().split()))
n=inp[0]
k=inp[1]
q=inp[2]
if q<k:
  for i in range(n):
    print ('Yes')
else:
  arr=[k-q]*(n)
  z=[]
  for i in range(n):
    x=int(input())
    arr[x-1]+=1
for i in range(len(arr)):
  if arr[i]>0:
    print ('Yes')
  else:
    print ('No')
Problem p02947 (python)

Fixed submission:
n=int(input())
arr=[]
from collections import Counter
c=Counter([])
for _ in range (n):
    s=input()
    z=[item for item in s]
    z.sort()
    z=tuple(z)
    c[z]+=1
ans=0
for item in c.values():
    ans+=(item*(item-1))//2
print (ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=[]
from collections import Counter
c=Counter([])
for _ in range n:
  s=input()
  z=[item for item in s]
  z.sort()
  z=tuple(z)
  c[z]+=1
ans=0
for item in c.values():
  ans+=(item*(item-1))//2
print (ans)
Problem p02983 (python)

Fixed submission:
from collections import Counter
inp=list(map(int,input().split()))
l=inp[0]
r=inp[1]
c=Counter([])
arr=[]
for i in range(l,r+1):
    if c[(i%2019)]==0:
        c[(i%2019)]+=1
        arr.append((i%2019))
        continue
    else:
        break
if c[0]!=0:
    print (0)
else:
    ans=99999999999
    for i in range(len(arr)):
        for j in range(i+1,len(arr)):
            ans=min(ans,(arr[i]*arr[j])%2019)
            if ans==0:
                break
        if ans==0:
            break
    print (ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
inp=list(map(int,input().split()))
l=inp[0]
r=inp[1]
c=Counter([])
arr=[]
for i in range(l,r+1):
  if c[i]==0:
    c[i]+=1
    arr.append(i)
    continue
  else:
    break
if c[0]!=0:
  print (0)
ans=99999999999
for i in range(len(arr)):
  for j in range(i+1,len(arr)):
    ans=min(ans,(i*j)%2019)
   	if ans==0:
      break
  if ans==0:
    break
print (ans)
Problem p03167 (python)

Fixed submission:
v=pow(10,9)+7
arr=[]
inp = list(map(int,input().split()))
row=inp[0]
col=inp[1]
for i in range(row):
    s=input()
    arr.append(s)
ans=[[0 for i in range(col)]for j in range(row)]
for i in range(col):
    if arr[0][i]=='#':
        break
    else:
        ans[0][i]=1
for i in range(row):
    if arr[i][0]=='#':
        break
    else:
        ans[i][0]=1
for i in range(1,row):
    for j in range(1,col):
        if arr[i][j]=='#':
            continue
        else:
            ans[i][j]=(ans[i-1][j]+ans[i][j-1])%v
print (ans[-1][-1])

Buggy submission (verdict: Runtime Error):
v=pow(10,9)+7
arr=[]
inp = list(map(int,input().split()))
row=inp[0]
col=in[1]
for i in range(row):
  s=input()
  arr.append(s)
ans=[[0 for i in range(col)]for j in range(row)]
for i in range(col):
  if arr[0][i]=='#':
    break
  else:
    ans[0][i]=1
for i in range(row):
  if arr[i][0]=='#':
    break
  else:
    ans[i][0]=1
for i in range(1,row):
  for j in range(1,col):
    if arr[i][j]=='#':
      continue
    else:
      arr[i][j]=(arr[i-1][j]+arr[i][j-1])%v
print (arr[-1][-1])
Problem p02784 (python)

Fixed submission:
H, N = input().split()
H = int(H)
N = int(N)
A= input().split()
total=0
for i in A:
    total += int(i)
if total >= H:
    print("Yes")
elif total < H:
    print("No")

Buggy submission (verdict: Runtime Error):
H, N = input().split()
H = int(H)
N = int(N)
A= input()
total=0
for i in A:
    total += int(i)
if total >= H:
    print("Yes")
elif total < H:
    print("No")
Problem p02608 (python)

Fixed submission:
N = int(input())
ans = [0]*N
if N > 3:
    n = int((N-3)**(0.5))+1
    nums = [i for i in range(1, n)]
    for x in range(1, n):
        for y in range(1, n):
            for z in range(1, n):
                i = x**2+y**2+z**2+x*y+x*z+y*z
                if i > N:
                    break
                else:
                    ans[i-1] += 1
for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = [0]*N
n = int((N)**(0.5))+1
for x in range(1, n):
    for y in range(1, n):
        for z in range(1, n):
            i = x**2+y**2+z**2+x*y+x*z+y*z
            if i > N:
                break
            else:
                ans[i] += 1
for a in ans:
    print(a)
Problem p02675 (python)

Fixed submission:
one = int(input()) % 10


hon_list = [2, 4, 5, 7, 9]

if one in hon_list:
    print('hon')
elif 3 == one:
    print('bon')
else:
    print('pon')

Buggy submission (verdict: Runtime Error):
import math
# A, B, H, M = 3, 4, 9, 0
A, B, H, M = map(int, input().split())

deg = 0
deg += 5.5 * M
deg -= 30 * H

print(math.sqrt(A**2 + B**2 - 2*A*B* math.cos(math.radians(abs(deg)))))

Buggy submission (verdict: Runtime Error):
import math
 
a, b, h, m = map(int, input().split())
 
deg = 0
 
deg += 5.5 * m
deg -= 30 * h
 
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(abs(deg)))))

Buggy submission (verdict: Runtime Error):
import math
# A, B, H, M = 3, 4, 9, 0
A, B, H, M = map(int, input().split())

deg = 0
deg += 5.5 * M
deg -= 30 * H

print(math.sqrt(A**2 + B**2 - 2*A*B* math.cos(math.radians(abs(deg)))))

Buggy submission (verdict: Runtime Error):
import math
# A, B, H, M = 3, 4, 9, 0
A, B, H, M = map(int, input().split())

sa = abs(H* 30-M*5.5)
cos = math.cos(math.radians(sa))
ans = math.sqrt(A**2 + B**2 - 2*A*B*cos)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
# A, B, H, M = 3, 4, 9, 0
A, B, H, M = map(int, input().split())

sa = abs(H* 30-M*5.5)
cos = abs(math.cos(math.radians(sa)))
ans = math.sqrt(A**2 + B**2 - 2*A*B*cos)
print(ans)
Problem p02861 (python)

Fixed submission:
import itertools
N = int(input())
xy_list = [list(map(int, input().split())) for _ in range(N)]

ans = 0
num = 0
for xy in itertools.permutations(xy_list):
    ans_pre = 0
    for i in range(N-1):
        ans_pre += ((xy[i][0]-xy[i+1][0])**2 + (xy[i][1]-xy[i+1][1])**2)**(0.5)
    num += 1
    ans += ans_pre
print(ans/num)

Buggy submission (verdict: Runtime Error):
import math
from itertools import permutations 
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
ans_ = 0
count = 0
for x, y, z in permutations(range(N), N):
    x1, y1 = xy[x]
    x2, y2 = xy[y]
    x3, y3 = xy[z]
    ans_ += math.sqrt((x1-x2)**2+(y1-y2)**2)+math.sqrt((x3-x2)**2+(y3-y2)**2)
    count += 1
print(ans_ / count)

Buggy submission (verdict: Runtime Error):
import math
from itertools import permutations 
N = int(input())
xy = [list(map((int, input().spllit()))) for _ in range(N)]
ans_ = 0
count = 0
for x, y, z in permutations(range(N), N):
    x1, y1 = xy[x]
    x2, y2 = xy[y]
    x3, y3 = xy[z]
    ans_ += math.sqrt((x1-x2)**2+(y1-y2)**2)+math.sqrt((x3-x2)**2+(y3-y2)**2)
    count += 1
print(ans_ / count)
Problem p03436 (python)

Fixed submission:
from collections import deque
sx, sy = 0, 0
h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

def bfs():
    visited = [[-1]*w for _ in range(h)]
    queue = deque([[sx, sy]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [h-1,w-1]:
            return visited[y][x]
        
        for dy, dx in ([0,1], [1,0], [0, -1], [-1, 0]):
            ny, nx = y+dy, x+dx
            if 0<=ny<h and 0<=nx<w:
                if maze[ny][nx] == '.' and visited[ny][nx] == -1:
                    visited[ny][nx] = visited[y][x] + 1
                    queue.append([ny, nx])
                    
black_num = 0
for i in maze:
    black_num += i.count("#")
bfs = bfs()
if bfs is None:
    print(-1)
else:
    print(h*w - bfs -1 -black_num)

Buggy submission (verdict: Runtime Error):
from collections import deque
sx, sy = 0, 0
# h, w = 3, 3
# maze_ori = [["..#"],
#                ["#.."],
#                ["..."]]

# maze_ori = [list(i[0]) for i in maze]
h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

def bfs():
    visited = [[-1]*w for _ in range(h)]
    queue = deque([[sx, sy]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [h-1,w-1]:
            return visited[y][x]
        
        for dy, dx in ([0,1], [1,0], [0, -1], [-1, 0]):
            ny, nx = y+dy, x+dx
            if 0<=ny<h and 0<=nx<w:
                if maze[ny][nx] == '.' and visited[ny][nx] == -1:
                    visited[ny][nx] = visited[y][x] + 1
                    queue.append([ny, nx])
                    
black_num = 0
for i in maze:
    black_num += i.count("#")

print(h*w - bfs() -1 -black_num)

Buggy submission (verdict: Runtime Error):
from collections import deque
sx, sy = 0, 0

h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

def bfs():
    visited = [[-1]*w for _ in range(h)]
    queue = deque([[sx, sy]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [h-1,w-1]:
            return visited[y][x]
        
        for dy, dx in ([0,1], [1,0], [0, -1], [-1, 0]):
            ny, nx = y+dy, x+dx
            if 0<=ny<h and 0<=nx<w:
                if maze[ny][nx] == '.' and visited[ny][nx] == -1:
                    visited[ny][nx] = visited[y][x] + 1
                    queue.append([ny, nx])
                    
black_num = 0
for i in maze:
    black_num += i.count("#")

print(h*w - bfs() -1 -black_num)