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

Fixed submission:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
a = l()
x = a.index(1)
if n == k:
    print(1)
    sys.exit()

print(1+math.ceil((n-k)/(k-1)))

Buggy submission (verdict: Runtime Error):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
a = l()
x = a.index(1)
if x % (k-1)==0 and (n-x-1)%(k-1)==0:
    print(x//(k-1) + (n-x-1)//(k-1))
elif (x%(k-1)==0 and (n-x-1)%(k-1)!=0) or (x%(k-1)!=0 and (n-x-1)%(n-k)==0):
    print(x//(k-1)+(n-x-1)//(k-1)+1)
else:
    print(x//(k-1)+(n-x-1)//(k-1)+2)
Problem p03371 (python)

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

a,b,c,x,y = I()
p = []
for i in range(10**5+1):
    cash = 2*c*i+a*max(0,x-i)+b*max(0,y-i)
    p.append(cash)

print(min(p))

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

a,b,c,x,y = I()
p = []
for i in range(10**5+1):
    cash = 2*c*i+a*max(0,x-i)+b*max(0,y-i)
    c.append(cash)

print(min(p))

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

a,b,c,x,y = I()
p = []
for i in range(10**5+1):
    cash = 2*c*i+a*max(0,x-i)+B*max(0,y-i)
    c.append(cash)

print(min(p))
Problem p03419 (python)

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

if N == 1 or M == 1:
    if N + M == 2:
        print(1)
    else:
        print(N*M-2)
else:
    print((N-2)*(M-2))

Buggy submission (verdict: Runtime Error):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

S = s()
if len(S)==26:
    print(-1)
    sys.exit()

alpha=["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"]

for i in alpha:
    if i not in S:
        print(S+ans)
        sys.exit()

Buggy submission (verdict: Runtime Error):
def card(n,m):
    try:
        if n >= 0 and n < N and m >= 0 and m < M:
            if a[n][m] == 1:
                a[n][m] = 0
            else:
                a[n][m] = 1
    except:
        None

count = 0
N, M = map(int,input().split())
a = [[0]*N for i in range(M)]

if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M-2)
else:
    print((N-2)*(M-2))
Problem p03456 (python)

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def X(): return list(input())
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

a = L()
b = "".join(a)
b = int(b)
for i in range(1000):
    if b == i**2:
        print("Yes")
        sys.exit()

print("No")

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

a = l()
ans = " ".join(a)
for i in range(1,101):
    if ans == i**2:
        print("Yes")
        sys.exit()

print("No")
Problem p03486 (python)

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

s = X()
t = X()

s.sort()
t.sort()
t.reverse()

a = "".join(s)
b = "".join(t)

if a < b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

a = s()
t = s()

a.sort()
y = "".join(a)
t = sorted(t,reverse = True)
x = "".join(t)
if y < x:
    print("Yes")
else:
    print("No")
Problem p03543 (python)

Fixed submission:
N = list(input())

if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = list(int(input()))
a = set(N)
a = list(a)
if len(a) <= 2:
    print("Yes")
else:
    print("No")
Problem p03544 (python)

Fixed submission:
from functools import lru_cache
@lru_cache(maxsize=None)

def luca(n):
    if n==0:
        return 2
    elif n == 1:
        return 1
    else:
        return luca(n-1)+luca(n-2)

N = int(input())

print(luca(N))

Buggy submission (verdict: Runtime Error):
import functools
@fuctools.lru_cache(maxsize=None)

def luca(n):
    if n==0:
        return 2
    elif n == 1:
        return 1
    else:
        return luca(n-1)+luca(n-2)

N = int(input())

print(luca(N))

Buggy submission (verdict: Runtime Error):
import functools
@lru_cache(maxsize=None)

def luca(n):
    if n==0:
        return 2
    elif n == 1:
        return 1
    else:
        return luca(n-1)+luca(n-2)

N = int(input())

print(luca(N))
Problem p03556 (python)

Fixed submission:
import math
N = int(input())
ans = 1
for i in range(10**5):
    if i**2 <= N:
        ans = i**2
    if i**2 > N:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = 1
for i in range(10**5):
    if i**2 =< N:
        ans = i**2
    if i**2 > N:
        break

print(ans)
Problem p03563 (python)

Fixed submission:
R = int(input())
G = int(input())

sa = G-R
print(G+sa)

Buggy submission (verdict: Runtime Error):
R = int(input())
G = int(input())

sa = G-B
print(G+sa)
Problem p03606 (python)

Fixed submission:
N = int(input())
a = []

for i in range(N):
    x,b = map(int,input().split())
    sa = b-x+1
    a.append(sa)
    

print(sum(a))

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

for i in range(N):
    a,b = map(int,input().split())
    sa = b-a+1
    a.append(sa)
    
print(sum(a))
Problem p03607 (python)

Fixed submission:
import collections as cl
N = int(input())
x = []
count = 0

for i in range(N):
    a = int(input())
    x.append(a)

d = cl.Counter(x)

for i in d.values():
    if i % 2 == 1:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = [0]*100000
count = 0

for i in range(N):
    a = int(input())
    if x[a-1] == 1:
            x[a-1] = 0
    else:
        x[a-1] += 1

print(x.count(1))
Problem p03611 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
x = [0] * (10**5+2)

for i in a:
    x[i] += 1
    x[i+1] += 1
    x[i+2] += 1 
    
print(max(x))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [map(int, input().split())]
x = [0] * (10**5+2)

for i in a:
    x[i] += 1
    x[i+1] += 1
    x[i+2] += 1 
    
print(max(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
x = [0] * (10**5+2)

for i in a:
    a[i] += 1
    a[i+1] += 1
    a[i+2] +=1 
    
print(max(a))
Problem p03612 (python)

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
count = 0
i = 0

while N > i:
    if p[i]-1 == i:
        count += 1
        i += 1
    i+=1
print(count)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
p = l()
count = 0

for i in range(N):
    if p[i] == i+1:
        p[i],p[i+1] = p[i+1],p[i]
        count += 1
    else:
        pass

print(count)

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

while N > i:
    if p[i]-1 == i:
        p[i],p[i+1] = p[i+1],p[i]
        count += 1
        i += 1
    i+=1
print(count)
Problem p03625 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ch = [0]*2
i = 0
j = 2
ans = 1
a.sort()
a = a[::-1]
while True:
    if a[i] == a[i+1]:
        ch[0] = a[i]
        break
    else:
        i += 1
    if i == n-1:
        ans = 0
        break

while True:
    if ans == 0:
        break
    if a[i+j] == a[i+j+1]:
        ch[1] = a[i+j]
        break
    else:
        j += 1
    if i+j == n-1:
        ans = 0

if ans == 0:
    print(0)
else:
    print(ch[0]*ch[1])

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

A = A.sort()
b = set(A)
b = list(b)
a = [i for i in b if A.count(i) >= 2]

if len(a) <= 1:
    print(0)
else:
    a = set(a)
    a = list(a)
    a.reverse()
    print(a[0]*a[1])
Problem p03637 (python)

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

even4, even, odd = 0, 0, 0
for i in a:
    if i % 4 == 0:
        even4 += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1

if N % 2 == 0:
    if even4 >= odd:
        print("Yes")
    else:
        print("No")
else:
    if even4 >= odd - 1:
        print("Yes")
    else:
        print("No")

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

even4, even, odd = 0, 0, 0
for i in a:
    if i % 4 == 0:
        even4 += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1

if n % 2 == 0:
    if even4 >= odd:
        print("Yes")
    else:
        print("No")
else:
    if even4 >= odd + 1:
        print("Yes")
    else:
        print("No")

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

even4, ,even, odd = 0, 0, 0
for i in a:
    if i % 4 == 0:
        even4 += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1

if n % 2 == 0:
    if even4 >= odd:
        print("Yes")
    else:
        print("No")
else:
    if even4 >= odd + 1:
        print("Yes")
    else:
        print("No")
Problem p03657 (python)

Fixed submission:
A, B = map(int, input().split())
aa = A+B

if A % 3 == 0 or B%3==0 or aa%3==0:
    print("Possible")
else:
    print("Impossible")

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

ans = abs(sum(a[1:])-a[0])
X = sum(a)

for i in range(1,N):
    sa = abs(X - 2*sum(a[:i]))
    ans = min(ans,sa)

print(ans)
Problem p03658 (python)

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

l = sorted(l, reverse = True)

print(sum(l[:K]))

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

l = sorted(l. reverse = True)

print(sum(l[:K]))
Problem p03659 (python)

Fixed submission:
input()
cards = tuple(map(int, input().split(' ')))

a = sum(cards[1:])
s = cards[0]
diff_min = abs(a - s)

for card in cards[1:-1]:
    a -= card
    s += card
    diff_min = min(diff_min, abs(a - s))

print(diff_min)

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

ans = 10000000000
aa = sum(a)

for i in range(N-1):
    sum_a = sum(a[:i+1])
    sum_b = a-sum_a
    sa = abs(sum_a-sum_b)
    ans = min(ans, sa)

print(ans)
Problem p03680 (python)

Fixed submission:

N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
    
aaa = 0    
ans = A[0]
count = 1

for i in range(N):
    if ans == 2:
        aaa = 1
        break
    else:
        ans = A[ans-1]
        count += 1
if aaa == 1:
    print(count)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

a,b,c =I()
ans = min(a+b,b+c)
print(min(ans,a+c))
Problem p03693 (python)

Fixed submission:
r, g, b= map(int, input().split())

ans = 10*g+b

if ans % 4==0:
    print("YES")
else:
    print("NO")

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

cnt = [0 for i in range(8)]
count = 0

for i in range(N):
    if 1<= a[i] <= 399:
        cnt[0] = 1
    elif 400<=a[i]<=799:
        cnt[1] = 1
    elif 800<=a[i]<=1199:
        cnt[2] = 1
    elif 1200<=a[i]<=1599:
        cnt[3] = 1
    elif 1600<=a[i]<=1999:
        cnt[4] = 1
    elif 2000<=a[i]<=2399:
        cnt[5] = 1
    elif 2400<=a[i]<=2799:
        cnt[6] = 1
    elif 2800<=a[i]<=3199:
        cnt[7] = 1
    else:
        count += 1

ans_min = sum(cnt)
ans_max = ans_min + count

print("{} {}".format(max(1,ans_min), ans_max))
Problem p03695 (python)

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

cnt = [0 for i in range(8)]
count = 0

for i in range(N):
    if 1<= a[i] <= 399:
        cnt[0] = 1
    elif 400<=a[i]<=799:
        cnt[1] = 1
    elif 800<=a[i]<=1199:
        cnt[2] = 1
    elif 1200<=a[i]<=1599:
        cnt[3] = 1
    elif 1600<=a[i]<=1999:
        cnt[4] = 1
    elif 2000<=a[i]<=2399:
        cnt[5] = 1
    elif 2400<=a[i]<=2799:
        cnt[6] = 1
    elif 2800<=a[i]<=3199:
        cnt[7] = 1
    else:
        count += 1

ans_min = sum(cnt)
ans_max = ans_min + count
if ans_min == 0:
    ans_min =1

print("{} {}".format(ans_min, ans_max))

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

cnt = [0 for i in range(8)]
count = 0

for i in range(N):
    if 1<= a[i] <= 399:
        cnt[0] += 1
    elif 400<=a[i]<=799:
        cnt[1] += 1
    elif 800<=a[i]<=1199:
        cnt[2] += 1
    elif 1200<=a[i]<=1599:
        cnt[3] += 1
    elif 1600<=a[i]<=1999:
        cnt[4] += 1
    elif 2000<=a[i]<=2399:
        cnt[5] += 1
    elif 2400<=a[i]<=2799:
        cnt[6] += 1
    elif 2800<=a[i]<=3199:
        cnt[7] += 1
    else:
        count += 1

ans_min = len([s for s in cnt if s != 0])
ans_max = ans_min + count

print("{} {}".format(max(1,ans_min), min(8,ans_max))

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

cnt = [0 for i in range(8)]
count = 0

for i in range(N):
    if 1<= a[i] <= 399:
        cnt[0] += 1
    elif 400<=a[i]<=799:
        cnt[1] += 1
    elif 800<=a[i]<=1199:
        cnt[2] += 1
    elif 1200<=a[i]<=1599:
        cnt[3] += 1
    elif 1600<=a[i]<=1999:
        cnt[4] += 1
    elif 2000<=a[i]<=2399:
        cnt[5] += 1
    elif 2400<=a[i]<=2799:
        cnt[6] += 1
    elif 2800<=a[i]<=3199:
        cnt[7] += 1
    else:
        count += 1


ans_min = len([s for s in cnt if s != 0])

if ans_min == 0 and count >0:
    ans_min = 1
    ans_max = ans_min + count
else:
    if ans_max > 8:
        ans_max = 8

print("{} {}".format(ans_min, ans_max))
Problem p03699 (python)

Fixed submission:
N = int(input())
S = []

for i in range(N):
    s = int(input())
    S.append(s)

a = sum(S)
ans = 0

if a % 10 != 0:
    ans = a
else:
    T = [s for s in S if s%10!=0]
    if len(T) == 0:
       ans = 0
    else:
        ans = a-min(T)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = []

for i in range(N):
    s = int(input())
    S.append(s)

a = sum(S)

if a % 10 != 0:
    print(a)
else:
    T = [s for s in S if s%10!=0]
    if len(T) == 0:
       ans = 0
    else:
        ans = a-min(T)

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
S = []

for i in range(N):
    s = int(input())
    S.append(s)

a = sum(S)

if a % 10 != 0:
    print(a)
else:
    T = [s for s in S if s%10!=0]
    if len(T) == 0:
       ans = 0
    else:
        ans = A-min(T)

print(ans)
Problem p03720 (python)

Fixed submission:
N, M =map(int, input().split())
ans = []
for i in range(M):
    a, b = map(int, input().split())
    ans.append(a)
    ans.append(b)

for i in range(1,N+1):
    print(ans.count(i))

Buggy submission (verdict: Runtime Error):
N, M =map(int, input().split())
ans = []
for i in range(M):
    a, b = map(int, input().split())
    ans.append(a)
    ans.append(b)

for i in range(1,N+1):
    print(ans.index(i))
Problem p03729 (python)

Fixed submission:
A, B, C = map(str, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

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

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")
Problem p03777 (python)

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

if a == "H":
    print(b)
else:
    if b == "H":
        print("D")
    else:
        print("H")

Buggy submission (verdict: Runtime Error):
a, b = input(), input()

if a == "H":
    print(b)
else:
    if b == "H":
        print("D")
    else:
        print("H")
Problem p03853 (python)

Fixed submission:
a, b = map(int, input().split())
list_a = []
for i in range(a):
    x = []
    c = input()
    x.append(c)
    list_a.append(x)
  
for j in range(a):
    print(list_a[j][0])
    print(list_a[j][0])

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
list_a = []
for i in range(a):
    x = []
    a = input()
    x.append(a)
    list_a.append(x)
  
for j in range(a):
    print(list_a[j][0])
    print(list_a[j][0])

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
list_a = []
for i in range(a):
    x = []
    a = input()
    x.append(a)
    list_a.append(x)

for i in range(2):    
    for j in range(b):
        print(list_a[j][0])
Problem p02861 (python)

Fixed submission:
from itertools import permutations
from math import sqrt

def factorial(n):
  if n < 2:
    return 1
  return n * factorial(n - 1)


def distance(a, b):
  dx = a[0] - b[0]
  dy = a[1] - b[1]
  return sqrt(dx * dx + dy * dy)


def calc_len(points, perm):
  res = 0
  for i in range(1, len(perm)):
    a = points[perm[i]]
    b = points[perm[i - 1]]
    res += distance(a, b)
  return res


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

total_len = 0
for perm in permutations(list(range(n))):
  total_len += calc_len(points, perm)
print(total_len / factorial(n))

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

def factorial(n):
  if n < 2:
    return 1
  return n * factorial(n - 1)


def distance(a, b):
  dx = a[0] - b[0]
  dy = a[1] - b[1]
  return sqrt(dx * dx + dy * dy)
  

def calc_len(points, perm):
  res = 0
  for i in range(1, len(perm)):
    a = points[perm[i]]
    b = points[perm[i - 1]]
    res += distance(a, b)
  return res


n = int(input())
points = []
for _ in range(n):
  x, y = map(int, input().split())
  points.append((x, y))
  
total_len = 0
for perm in permutations(list(range(n))):
  total_len += calc_len(points, perm)
print(total_left / factorial(n))
Problem p03261 (python)

Fixed submission:
def valid(words):
  used = set()
  last = ""

  for w in words:
    if w in used:
      return False
    if last != "" and last[-1] != w[0]:
      return False
    last = w
    used.add(w)

  return True


n = int(input())
words = [input() for _ in range(n)]
print("Yes" if valid(words) else "No")

Buggy submission (verdict: Runtime Error):
def valid(words):
  used = set()
  last = ""

  for w in words:
    if w in used:
      return False
    if last != "" and last[-1] != w[0]:
      return False
    last = w
    used.append(w)
  return True

n = int(input())
words = [input() for _ in range(n)]
print("Yes" if valid(words) else "No")