Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math

x = int(input())


def check(x):
    i = 1
    while True:
        for j in range(1, i + 1):
            if (i == j):
                continue
            elif (x % (i - j) == 0) and (x == ((i ** 5) - (j ** 5))):
                print(i, j)
                return
            elif (x % (i + j) == 0) and ( x == ((i ** 5) + (j ** 5))):
                print(i, -j)
                return
        i = i + 1

check(x)

Fixed submission:
import math

x = int(input())


def check(x):
    i = 1
    while True:
        for j in range(i):
            if (i == j):
                continue
            elif (x % (i - j) == 0) and (x == ((i ** 5) - (j ** 5))):
                print(i, j)
                return
            elif (x % (i + j) == 0) and ( x == ((i ** 5) + (j ** 5))):
                print(i, -j)
                return
        i = i + 1

check(x)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(x) for x in input().split()]

B = {}
for i, a in enumerate(A):
    aa1 = i + 1 - a
    if aa1 > 0:
        if aa1 not in B:
            B[aa1] = []
        B[aa1].append((i + 1, a))

count = 0
for i, a in enumerate(A):
    aa1 = i + 1 + a
    if aa1 in B:
        for b in B[aa1]:
            if b[0] > i + 1:
                count += 1
print(count)

Fixed submission:
n = int(input())
A = [int(x) for x in input().split()]

B = {}
for i, a in enumerate(A):
    aa1 = i + 1 - a
    if aa1 > 0:
        if aa1 not in B:
            B[aa1] = []
        B[aa1].append((i + 1, a))

count = 0
for i, a in enumerate(A):
    aa1 = i + 1 + a
    if aa1 in B:
        count += len(B[aa1])
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(x) for x in input().split()]

count = 0
for i in range(n):
    for j in range(i, n):
        if i == j:
            continue
        if abs(i - j) == A[i] + A[j]:
            count += 1
print(count)

Fixed submission:
n = int(input())
A = [int(x) for x in input().split()]

B = {}
for i, a in enumerate(A):
    aa1 = i + 1 - a
    if aa1 > 0:
        if aa1 not in B:
            B[aa1] = []
        B[aa1].append((i + 1, a))

count = 0
for i, a in enumerate(A):
    aa1 = i + 1 + a
    if aa1 in B:
        count += len(B[aa1])
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import math

a, b, n = [int(x) for x in input().split()]

m = 0
for i in range(1, n + 1):
    m = max(m, math.floor(a * i / b) - a * math.floor(i / b))

print(m)

Fixed submission:
import math

a, b, n = [int(x) for x in input().split()]
# a = 10 ** 6
# b = 10 ** 12
# n = 10 ** 12

m = 0
if (n < b):
    # math.floor(x / b) = 0
    m = math.floor(a * n / b) # - a * math.floor(n / b)
else:
    m = math.floor(a * (b - 1) / b) - a * math.floor((b - 1) / b)
    #for i in range(n // b - 1, n + 1, b):
    # for i in range(n):
    #     print(i, math.floor(a * i / b),  a * math.floor(i / b), math.floor(a * i / b) - a * math.floor(i / b))
    #     m = max(m, math.floor(a * i / b) - a * math.floor(i / b))

print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = input().split()

b = {}
for a in A:
    if a not in b:
        b[a] = 0
        
    b[a] += 1


for a in A:
    count = 0
    for c in b:
        n = b[c]
        if a == c:
            n -= 1
        
        count += n * (n - 1) // 2
    print(count)

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

B = {}
for a in A:
    if a not in B:
        B[a] = 0
    B[a] += 1

sum = 0
for b in B:
    sum += B[b] * (B[b] - 1) // 2

for a in A:
    print(sum - (B[a] - 1))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())

direction = 1
for i in range(Q):
    T = input()
    if T == '1':
        direction = direction * -1
    else:
        T = T.split()
        if T[1] == '1':
            if direction == 1:
                S = T[2] + S
            else:
                S = S + T[2]
        else:
            if direction == 1:
                S = S + T[2]
            else:
                S = T[2] + S

S = S[::direction]

print(S)

Fixed submission:
S = input()
Q = int(input())

direction = 1
head = []
tail = []
for i in range(Q):
    T = input()
    if T == '1':
        direction = direction * -1
    else:
        T = T.split()
        if T[1] == '1':
            if direction == 1:
                head.append(T[2])
            else:
                tail.append(T[2])
        else:
            if direction == 1:
                tail.append(T[2])
            else:
                head.append(T[2])

head = head[::(-1)]
head.append(S)
head.extend(tail)
S = "".join(head)[::direction]

print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())

for i in range(Q):
    T = input()
    if T == '1':
        S = S[::-1]
    else:
        T = T.split()
        if T[1] == '1':
            S = T[2] + S
        else:
            S = S + T[2]

print(S)

Fixed submission:
S = input()
Q = int(input())

direction = 1
head = []
tail = []
for i in range(Q):
    T = input()
    if T == '1':
        direction = direction * -1
    else:
        T = T.split()
        if T[1] == '1':
            if direction == 1:
                head.append(T[2])
            else:
                tail.append(T[2])
        else:
            if direction == 1:
                tail.append(T[2])
            else:
                head.append(T[2])

head = head[::(-1)]
head.append(S)
head.extend(tail)
S = "".join(head)[::direction]

print(S)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cl=[0 for i in range(n+1)]
for i in a:
    cl[i]+=1
for i in cl[1:]:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = [input() for l in range(2)]
    N, A = int(s[0]), [int(x) for x in s[1].split()]
    results = []

    for i in range(0, (N), 1):
        flag = 0
        for j in range(0, (N), 1):
            if i == j:
                pass
            else:
                if A[i] % A[j] == 0:
                    flag = 1
                    break
                else:
                    pass
        if flag == 1:
            results.append(0)
        else:
            results.append(1)
    cnt = 0
    for x in results:
        if x == 1:
            cnt += 1
    print(cnt)



if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = [input() for l in range(2)]
    N, A = int(s[0]), [int(x) for x in s[1].split()]
    """
    results = []

    for i in range(0, (N), 1):
        flag = 0
        for j in range(0, (N), 1):
            if i == j:
                pass
            else:
                if A[i] % A[j] == 0:
                    flag = 1
                    break
                else:
                    pass
        if flag == 1:
            results.append(0)
        else:
            results.append(1)
    cnt = 0
    for x in results:
        if x == 1:
            cnt += 1
    print(cnt)
    """
    # 最大値
    maxA = max(A)
    # 要素の個数を管理
    C = {a: 0 for a in A}
    # 同じ要素が複数ある時点で必ず割り切れる
    # c[a] > 1なら無視できるよ
    for a in A:
        C[a] += 1
    # D
    D = {a: 0 for a in A}
    for a in A:
        if C[a] > 0:
            t = 2
            while a * t <= maxA:
                D[a*t] = 1
                t+= 1

    ans = 0
    for a in A:
        # 重複なし&約数なし
        if C[a] == 1 and D[a] == 0:
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = [input() for l in range(2)]
    N, A_dct, A = int(s[0]), {int(x): int(x) for x in s[1].split()}, [int(x) for x in s[1].split()]
    if 0 in A_dct:
        print(0)
    else:
        tmp = 1
        for k in A:
            tmp *= k
        if tmp > 10**18: tmp = -1
        print(tmp)
    

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = [input() for l in range(2)]
    N, A_dct, A = int(s[0]), {int(x): int(x) for x in s[1].split()}, [int(x) for x in s[1].split()]
    if 0 in A_dct:
        print(0)
    else:
        tmp = 1
        for k in A:
            tmp *= k
            if tmp > 10**18:
                tmp = -1
                break
        print(tmp)
    

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = [input() for l in range(2)]
    N, A = int(s[0]), [int(x) for x in s[1].split()]
    tmp = 1
    for a in A:
        tmp *= a
        if a == 0:
            break
    if tmp > 10**18: tmp = -1
    print(tmp)
    

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = [input() for l in range(2)]
    N, A_dct, A = int(s[0]), {int(x): int(x) for x in s[1].split()}, [int(x) for x in s[1].split()]
    if 0 in A_dct:
        print(0)
    else:
        tmp = 1
        for k in A:
            tmp *= k
            if tmp > 10**18:
                tmp = -1
                break
        print(tmp)
    

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a = int(input()).split()
print(a[0] * a[1])

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

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


Fixed submission:
a = input().split()
print(int(a[0]) * int(a[1]))
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
r=4*x
if r>=y y>=2*x and (r-y)%2==0:
  print('Yes')
else:
  print('No')


Fixed submission:
x,y=map(int,input().split())
r=4*x
if r>=y and y>=2*x and (r-y)%2==0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
r=[i-x for i in map(int,input())]
for i in range(100):
  if not -(i+1) in r:
    print(x-i-1)
    break
  elif not i+1 in r:
    print(x+i+1)
    break

Fixed submission:
x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(n+1):
  if not -(i) in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
    break

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
r=[i-x for i in map(int,input())]
for i in range(100):
  if not -(i+1) in r:
    print(x-i)
  elif not (i+1) in r:
    print(x+i)


Fixed submission:
x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(n+1):
  if not -(i) in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
    break

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
r=[i-x for i in map(int,input())]
for i in range(100):
  if not -i in r:
    print(x-i)
  elif not i in r:
    print(x+i)

Fixed submission:
x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(n+1):
  if not -(i) in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
    break

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
r=[i-x for i in map(int,input())]
i=1
while True:
  if not -i in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
  else:
    i+=1

Fixed submission:
x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(n+1):
  if not -(i) in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
    break
Buggy python submission (verdict: Runtime Error):
N=int(input())

a=[]
for i in range(N):
    a.append([m-1 for m in map(int,input().split())])

b=[]
for i in range(N):
    b.append(a[i].pop(0))

an=0

while True:
    note=[]
    x=0
    for i in range(N):
        if b[i]!=N and b[b[i]]==i:
            x=1
            note.append(i)
    for i in note:
        try:
            b[i]=a[i].pop(0)
        except:
            b[i]=N
    if x==1:
        an+=1
    elif b==[N for i in range(N)]:
        print(an)
        break
    else:
        print(-1)
        break

Fixed submission:
S=input()
T=input()
an=0
for i in range(3):
    if S[i]==T[i]:
        an+=1
print(an)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
x=0
for i in range(1,N):
    x+=i

print(x)

Fixed submission:
N=int(input())
x=int(N*(N-1)//2)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
x=[]
for i in range(N):
    a={}
    for s in input():
        if s in list(a.keys()):
            a[s]+=1
        else:
            a[s]=1
    x.append(a)
an=0
for i in range(N):
    for s in range(i+1,N):
        if x[i]==x[s]:
            an+=1
print(an)

Fixed submission:
from collections import defaultdict
x=defaultdict(int)
N=int(input())
for i in range(N):
    x[''.join(sorted(input()))]+=1
an=0
for i in x.values():
    an+=int(i*(i-1)/2)
print(an)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=[]
an=0
for i in range(N):
    s.append([x for x in input()])
    s[i].sort()
i=0
while i<N:
    y=1
    n=i+1
    while n<N:
        if s[i]==s[n]:
            y+=1
            del s[n]
            N-=1
        else:
            n+=1
    i+=1
    an+=int((y*(y-1)/2))
print(an)

Fixed submission:
from collections import defaultdict
x=defaultdict(int)
N=int(input())
for i in range(N):
    x[''.join(sorted(input()))]+=1
an=0
for i in x.values():
    an+=int(i*(i-1)/2)
print(an)

Buggy python submission (verdict: Time Limit Exceeded):
al='abcdefghijklmnopqrstuvwxyz'
nums=[]
N=int(input())
s=[]
an=0
for i in range(N):
    s.append([x for x in input()])
    s[i].sort()
for i in range(N):
    for n in range(i+1,N):
        if s[i]==s[n]:
            an+=1
print(an)

Fixed submission:
from collections import defaultdict
x=defaultdict(int)
N=int(input())
for i in range(N):
    x[''.join(sorted(input()))]+=1
an=0
for i in x.values():
    an+=int(i*(i-1)/2)
print(an)
Buggy python submission (verdict: Runtime Error):
x=map(int,input().split())
if x.count(7)==1 and x.count(5)==2:
  print('YES')
else:
  print('NO')

Fixed submission:
x=[i for i in map(int,input().split())]
if x.count(5)==2 and x.count(7):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
x = []
z = 1
while z != 6:
	print("Enter number"+z,":")
	x.append(input())
	z+=1
y = 0
for i in x:
	if x[y] == "0":
		print(y+1)
	else:
		print("1")
	y +=1


Fixed submission:
num = list(map(int, input().split()))
print(num.index(0)+1)

Buggy python submission (verdict: Runtime Error):
z = 1
x = []
while z != 5:
  x.append[input()]
  z+=
y = 0
while y!= 5:
  if x[y] == 0:
    print(y+1)
  else:
    y+=1
    continue

Fixed submission:
num = list(map(int, input().split()))
print(num.index(0)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N  =int(input())
la = list(map(int,input().split()))
ans = 1
if N == 0:
    print(0)
    exit()
for i in la:
    ans = ans*i

if ans > 10**18:
    print("-1")
else:
    print(ans)


Fixed submission:
N  =int(input())
la = list(map(int,input().split()))
ans = 1
if N == 0:
    print(0)
    exit()
if 0 in la:
    print(0)
    exit()
for i in la:
    if ans > 10**18:
        print("-1")
        exit()
    else:
        ans = ans*i
 
if ans > 10**18:
    print("-1")
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C,K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A+B:
    print(A)
else:
    print(2A+B-K) 


Fixed submission:
A,B,C,K = map(int,input().split())
if A >= K:
    print(K)
elif (A+B)>=K:
    print(A)
else:
    print(A*2+B-K)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input()) -1
q = list(range(1,10))
while K > 0:
    x = q.pop(0)
    if x %10 != 0:
        q.append(10*x +x%10 -1)
    q.append(10*x + x%10)
    if x % 10 != 9:
        q.append(10*x + x%10 +1)
    K -= 1
print(q[0])


Fixed submission:
import queue
K = int(input()) -1
q = queue.Queue()
for i in range (1,10):
    q.put(i)
while K > 0:
    x = q.get()
    if x %10 != 0:
        q.put(10*x +x%10 -1)
    q.put(10*x + x%10)
    if x % 10 != 9:
        q.put(10*x + x%10 +1)
    K -= 1
ans = q.get()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def cmb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
la = list(map(int,input().split()))
all = 0
for i in range(N+1):
    all += cmb(la.count(i),2)
for k in range(N):
    print(all-la.count(la[k])+1)


Fixed submission:
import collections
import math
def cmb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
la = list(map(int,input().split()))
all = 0
c = collections.Counter(la)
#print(c)
for i in range(N+1):
    all += cmb(c[i],2)
#print(all)
for k in range(N):
    print(all-c[la[k]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def cmb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
la = list(map(int,input().split()))
c = collections.Counter(la)
#print(c)
ans = 0
for i in range(N):
    c[la[i]] -= 1
    #print(c)
    for a in c:
        #print(a)
        ans += cmb(c[a],2)
    print(ans)
    ans = 0
    c[la[i]]+=1


Fixed submission:
import collections
import math
def cmb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
la = list(map(int,input().split()))
all = 0
c = collections.Counter(la)
#print(c)
for i in range(N+1):
    all += cmb(c[i],2)
#print(all)
for k in range(N):
    print(all-c[la[k]]+1)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
ln = [-1]*N
for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    if (ln[s] != c) and(ln[s] != -1):
        print("-1")
        exit()
    else:
        ln[s] = c
for j in range(1,M):
    if ln[j] == -1:
        ln[j] = 0
if ln[0] == 0:
    print("-1")
    exit()
if ln[0] == -1:
    ln[0] = 1

print("".join(map(str,ln)))


Fixed submission:
N,M = map(int,input().split())
li =[]
for i in range(M):
    li.append(list(map(int,input().split())))
    if li[i][0]>N:
        print("-1")
        exit()
st = 10**(N-1)
if N == 1:
    st = 0
for i in range(st,10**N):
    inv = True
    a = str(i)
    for j in range(M):
        if  a[li[j][0]-1] != str(li[j][1]):
            inv = False
            break
    if inv:
        print(i)
        exit()
print("-1")
Buggy python submission (verdict: Runtime Error):
import fanctions
A,B = map(int,input().split())
m = fanctions.gcd(A,B)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

l_m = prime_factorize(m)
if len(l_m) >= 1:
    ans = 2
else:
    print("1")
    exit()
for i in range(1,len(l_m)):
    if not l_m[i] == l_m[i-1]:
        ans += 1
print(ans)


Fixed submission:
import fractions
A,B = map(int,input().split())
m = fractions.gcd(A,B)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

l_m = prime_factorize(m)
if len(l_m) >= 1:
    ans = 2
else:
    print("1")
    exit()
for i in range(1,len(l_m)):
    if not l_m[i] == l_m[i-1]:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
l_a = [k]*n
for i in range(q):
    i = int(input()) -1
    if l_a[i]>=0:
        l_a[i]+= 1
    l_a = [m-1 for m in l_a]
for i in l_a:
    if i > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,k,q = map(int,input().split())
l_a = [0]*n
for i in range(q):
    i = int(input()) -1
    l_a[i]+= 1
for i in l_a:
    if q-i < k:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
l_a = list(map(int,input().split()))
l_b = list(map(int,input().split()))
l_c = list(map(int,input().split()))
all = sum(l_b)çß
for i in range (N-1):
    if l_a[i+1] - l_a[i] == 1:
        all +=l_c[l_a[i]-1]
print(all)


Fixed submission:
N = int(input())
l_a = list(map(int,input().split()))
l_b = list(map(int,input().split()))
l_c = list(map(int,input().split()))
all = sum(l_b)
for i in range (N-1):
    if l_a[i+1] - l_a[i] == 1:
        all +=l_c[l_a[i]-1]
print(all)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
s = s[::-1]
N = len(s)
mod = pow(10,9)+7
dp = [[0]*13 for i in range(N)]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    a = int(s[0])
    dp[0][a] = 1
for i in range(1,N):
    if s[i] == '?':
        for j in range(10):
            k = (j*10**i) % 13
            for m in range (13):
                 dp[i][(m+k)%13] += dp[i-1][m]
    else:
        k = (int(s[i])*(10**i)) % 13
        for m in range(13):
            dp[i][(m+k)%13] += dp[i-1][m]
print(dp[-1][5]% mod)

Fixed submission:
s =list(input())
N = len(s)
mod = pow(10,9)+7
dp = [[0]*13 for i in range(N)]
if s[0] == '?':
        dp[0][0:9] = [1 for i in range(10)]
else:
    dp[0][int(s[0])] = 1
for i in range(1,N):
    if s[i] == '?':
        for j in range(10):
            for m in range (13):
                 dp[i][(m*10+j)%13] += dp[i-1][m]%mod
    else:
        for m in range(13):
            dp[i][(m*10+int(s[i]))%13] += dp[i-1][m]%mod
print(dp[-1][5]% mod)
Buggy python submission (verdict: Runtime Error):
N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
count = 0
for n in range (N):
    for nn in range(n):
      distance == sum([all_list[n][d]-all_list[nn][d] for d in range(D)])
    for s in range(250):
      if distance == s**2:
        count += 1
print(count)

Fixed submission:
n,a,b = map(int,input().split())
if n*a <= b:
    print(n*a)
else:
    print(b)

Buggy python submission (verdict: Runtime Error):
N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
#>>>4
count = 0
for n in range (N):
    for nn in range(N):
        distance = 0
        for d in range(D):
            kou = (all_list[n][d] - all_list[nn][d])**2
            distance += kou
        for s in range(250):
            if distance == s**2:
                count += 1
                break
print(round((count - N) / 2))

Fixed submission:
n,a,b = map(int,input().split())
if n*a <= b:
    print(n*a)
else:
    print(b)

Buggy python submission (verdict: Runtime Error):
N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
#>>>4
count = 0
for n in range (N):
    for nn in range(N):
        distance = 0
        for d in range(D):
            kou = (all_list[n][d] - all_list[nn][d])**2
            distance += kou
        for s in range(250):
            if distance == s**2:
                count += 1
                break
print(round((count - N) / 2))

Fixed submission:
n,a,b = map(int,input().split())
if n*a <= b:
    print(n*a)
else:
    print(b)