TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
N,A,B = map(int,input().split())
if N>A/B:
    print(A/B)
else:
    print(N)

N,A,B = map(int,input().split())
if N*A>B:
    print(B)
else:
    print(N*A)

Verdicts: Wrong Answer

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
N,A,B = map(int,input().split())

print(min(N*A,B)

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

print(min(N*A,B))

Verdicts: Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
n,a,b = list(map(int, input().split()))
d = n*a
t = n*b
print(np.min([d, t]))

n,a,b = list(map(int, input().split()))
taxi = n*a
densya = n*b
print(np.min([taxi, densya]))

n,a,b = list(map(int, input().split()))
d = n*a
t = n*b
print(int(np.min([d, t])))

import numpy as np
n,a,b=map(int, input().split())
print([n*a, n*b].min())

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = asc.nextInt();
    if(n*a>=b){
      System.out.println(b);
    }else{
      System.out.println(n*a);
    }
  }
}

n, tr, tx = [int(x) for x in input().split()]

tr_sum = n * tr

print(min(tr_sum, tx))

Verdicts: Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
N, a, b = map(int,input().split())
print(max(N * a, b))
      

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

Verdicts: Wrong Answer

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
n,a,b=map(int input.split())
print(max(n*a,b))

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

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):

#include<string>
using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if(n*a < b) {
        cout << n*a;
    } else {
        cout << b;
    }
}

n, a, b = [int(i) for i in input("").split(" ")]
if (n*a) < b:
  print(n*a)
else:
  print(b)

Verdicts: Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(len(A)-1):
  X.append((A[i]-X[i]/2)*2)

print(" ".join(repr(int(e)) for e in X))


L, R = map(int,input().split())
L_mod = L%2019
if L_mod ==0:
  print(0)
else:
  R_mod = R%2019
  if R_mod ==0:
    print(0)
  else:
    if L_mod<R_mod:
      list =[]
      for i in range(L_mod,R_mod,1):
        mod_i = i%2019
        for j in range(i+1,R_mod+1,1):
          mod_j = j%2019
          mod = (mod_i *mod_j)%2019
          list.append(mod)

      print(min(list))
      
    else:
      print(0)

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

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(1,len(A)):
  X.append((A[i]-X1by2/2)*2)

print(" ".join(repr(int(e)) for e in X))


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

train = N*A
taxi = B

if train>=taxi:
  print(taxi)
else:
  print(train)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
nums = list(map(int, input().split()))

if nums[0]*nums[1] > nums[2]:
    print(nums[0]*nums[1])
    
elif nums[0]* nums[1] <= nums[2]: 
    print(nums[2])

nums = list(map(int, input().split()))

if nums[0]*nums[1] > nums[2]:
    print(nums[2])
    
elif nums[0]* nums[1] <= nums[2]: 
    print(nums[0] * nums[1])

Verdicts: Wrong Answer

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
print("hello world!!")

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

print(min(n*a,b))

Verdicts: Wrong Answer

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
def minimizer(n,a,b):
  first=n*a
  second=b
  if first>second:
    return second
  else: 
    return first

inputing=input("enter your value")
input_sep=inputing.split(" ")
input_sep=[int(i) for i in input_sep]
print(minimizer(int(input_sep[0]),int(input_sep[1]),int(input_sep[2])))

def minimizer(n,a,b):
  first=n*a
  second=n*b
  if first>second:
    return second
  elif first<second:
    return first
  else:
    return first
inputing=input("enter your value")
input_sep=inputing.split(" ")
input_sep=[int(i) for i in input_sep]
print(minimizer(int(input_sep[0]),int(input_sep[1]),int(input_sep[2])))


def minimizer(n,a,b):
  first=n*a
  second=b
  if first>second:
    return second
  else: 
    return first

inputing=input()
input_sep=inputing.split(" ")
input_sep=[int(i) for i in input_sep]
print(minimizer(int(input_sep[0]),int(input_sep[1]),int(input_sep[2])))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
N A B = list(map(int, input().split()))

total_cost = N * A

if total_cost > B:
  total_cost = B
  
print(total_cost)


N, A, B = list(map(int, input().split()))
 
total_cost = N * A
 
if total_cost > B:
  total_cost = B
  
print(total_cost)

Verdicts: Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
from sys import stdin

li = list(map(int,stdin.readline().rstrip.split()))

if li[1] > li[2]:
    print(li[0]*li[1])
else:
    print(li[0]*li[2])
    

from sys import stdin
li = list(map(int,stdin.readline().rstrip.split()))
if li[1] > li[2]:
    print(li[0]*li[1])
else:
    print(li[0]*li[2])

from sys import stdin
li = list(map(int,stdin.readline().rstrip().split()))
if li[1]*li[0] > li[2]:
    print(li[2])
else:
    print(li[0]*li[1])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())
if N*B>A:
    print(A)
else:
    print(N*B)


# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())
if N*B>A:
    print(N*B)
else:
    print(A)

# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())
if N*A>B:
    print(B)
else:
    print(N*A)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
L,R = map(int,input().split())

ans = 2019 ** 2

if R - L >= 2018:
  ans = 0
  print(ans)
else: 
  for i in range(L,R):
    for j in range(L + 1,R + 1):
      mod = (i * j) % 2019 
      if mod < ans:
        ans = mod
      elif mod == 0:
        ans = 0
        break
  print(ans)



L,R = map(int,input().split())



ans = 2019 ** 2

for i in range(L,R):
  for j in range(L + 1,R):
    mod = (i * j) % 2019 
    if mod < ans:
      ans = mod
    elif mod == 0:
      ans = 0
      break
print(ans)



L = list(map(int, input().split()))

N = L[0]
A = L[1]
B = L[2]


train = N * A

if train < B:
	print(train)
	
else:print(B)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
#coding: utf-8
n, a, b = map(int,input().split())
if n * a > b:
    print(n * a)
else:
    print(b)


#coding: utf-8
n, a, b = map(int,input().split())
if n * a > b:
    print(b)
else:
    print(n * a)


Verdicts: Wrong Answer

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
n, a, b = map(int, input().split())
if n*a > b:
  print(n*a)
else:
  print(b)

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

Verdicts: Wrong Answer

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
a,b,c=map(int,input()).split()
print(c if c<=a*b else a*b)

a,b,c=map(int,input().split());print(min(a*b,c))

Verdicts: Runtime Error

Accepted
Problem: N of us are going on a trip, by train or taxi.  The train will cost each of us A yen (the currency of Japan).  The taxi will cost us a total of B yen.  How much is our minimum total travel expense?

Submission attempts (in order):
n, a, b = map( int, input() )
print( min( n*a, b ) )

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

Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math
N,D = map(int,input().split())
3 2
X = [list(map(int,input().split())) for i in range(N)]
1 2
5 5
-2 8

ans = 0
for j in range(N):
    for i in range(j):
        distant2 = 0
        for k in range(D):
            distant2 += (X[j][k]-X[i][k])**2
        if math.sqrt(distant2) % 1 == 0:
            ans += 1

print(ans)


import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]

ans = 0
for j in range(N):
    for i in range(j):
        distant2 = 0
        for k in range(D):
            distant2 += (X[j][k]-X[i][k])**2
        if math.sqrt(distant2) % 1 == 0:
            ans += 1

print(ans)


Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math
n,d = map(int,input().split())
count = 0
alllist = []
for i in range(n):
    alist = list(map(int,input().split()))
    alllist.append(alist)


for i in range(n-1):
    for j in range(i+1,n):
        count1 = 0
        for s in range(d):
            count1 += (alllist[i][s]-alllist[j][s])**2
        if math.sqrt(count1) == int(math.sqrt(count1)):
            count += 1
        print(count1)
print(count)

import math
n,d = map(int,input().split())
count = 0
alllist = []
for i in range(n):
    alist = list(map(int,input().split()))
    alllist.append(alist)


for i in range(n-1):
    for j in range(i+1,n):
        count1 = 0
        for s in range(d):
            count1 += (alllist[i][s]-alllist[j][s])**2
        if math.sqrt(count1) == int(math.sqrt(count1)):
            count += 1
print(count)

Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import numpy

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

l = []
for v in range(n):
    l.append(list(map(int, input().split())))

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        a = numpy.array(l[i])
        b = numpy.array(l[j])
        c = numpy.linalg.norm(b - a)
        if (c.is_integer()):
            ans += 1

print(ans / 2)


import numpy

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

l = []
for v in range(n):
    l.append(list(map(int, input().split())))

ans = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        a = numpy.array(l[i])
        b = numpy.array(l[j])
        c = numpy.linalg.norm(b - a)
        if (c.is_integer()):
            ans += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math

# 0924 start
inputted = list(map(int, input().split()))
N = inputted[0]
D = inputted[1]

X = []
for i in range(N):
    print(i)
    X.append(list(map(int, input().split())))
print(X)

calculate = lambda y, z : math.sqrt(sum([(yi - zi) ** 2 for yi, zi in zip(y, z)]))

answer = 0
for i in range(N):
    for j in range(N):
        if i >= j: continue

        distance = calculate(X[i], X[j])
        if distance.is_integer(): answer += 1

print(answer)


import math

# 0924 start
inputted = list(map(int, input().split()))
N = inputted[0]
D = inputted[1]

X = []
for i in range(N):
    X.append(list(map(int, input().split())))

calculate = lambda y, z : math.sqrt(sum([(yi - zi) ** 2 for yi, zi in zip(y, z)]))

answer = 0
for i in range(N):
    for j in range(N):
        if i >= j: continue

        distance = calculate(X[i], X[j])
        if distance.is_integer(): answer += 1

print(answer)


Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
n, d = [int(s) for s in input().split(" ")]
pts = []
for _ in range(n):
  pts.append([int(s) for s in input().split(" ")])

def dist(x, y):
  sum = 0
  for xx, yy in zip(x, y):
    sum += (xx - yy)**2
  return math.sqrt(sum)

cnt = 0
for i in range(n):
  for j in range(i + 1, n):
    d = dist(pts[i], pts[j])
    if int(d) == d:
      cnt += 1

print("%d" % cnt)

import math
n, d = [int(s) for s in input().split(" ")]
pts = []
for _ in range(n):
  pts.append([int(s) for s in input().split(" ")])

def dist(x, y):
  sum = 0
  for xx, yy in zip(x, y):
    sum += (xx - yy)**2
  return math.sqrt(sum)

cnt = 0
for i in range(n):
  for j in range(i + 1, n):
    d = dist(pts[i], pts[j])
    if int(d) == d:
      cnt += 1

print("%d" % cnt)

Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
from math import sqrt


def calc(pos_x, pos_y):
  sum = 0
  for i in range(0, len(pos_x)):
    sum += (pos_x[i] - pos_y[i]) ** 2

  return sqrt(sum).is_integer()



# items = []

#   items.append(list(map(int, input().split())))

items = []
items.append(list(map(int, "-3 7 8 2".split())))
items.append(list(map(int, "-12 1 10 2".split())))
items.append(list(map(int, "-2 8 9 3".split())))

count = 0

for i in range(0, len(items)):
  for j in range(i + 1, len(items)):
    count += 1 if calc(items[i], items[j]) else 0

print(count)


from math import sqrt


def calc(pos_x, pos_y):
  sum = 0
  for i in range(0, len(pos_x)):
    sum += (pos_x[i] - pos_y[i]) ** 2

  return sqrt(sum).is_integer()


size, z = map(int, input().split())
items = []
for i in range(0, size):
  items.append(list(map(int, input().split())))

# items = []
# items.append(list(map(int, "-3 7 8 2".split())))
# items.append(list(map(int, "-12 1 10 2".split())))
# items.append(list(map(int, "-2 8 9 3".split())))

count = 0

for i in range(0, len(items)):
  for j in range(i + 1, len(items)):
    count += 1 if calc(items[i], items[j]) else 0

print(count)


Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
n,d=map(int,input().split())

x=[list(map(int,input().split())) for i in range(n)]

lis=[False for i in range(16001)]
for i in range(1264):
  lis[i*i]=True
  
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(x[i][k]-x[j][k])*(x[i][k]-x[j][k]) for k in range(d)])
    print(dis)
    if lis[dis]:
      ans += 1
print(ans)

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

x=[list(map(int,input().split())) for i in range(n)]

lis=[False for i in range(5000)]
for i in range(65):
  lis[i*i]=True
  
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(x[i][k]-x[j][k])*(x[i][k]-x[j][k]) for k in range(d)])
    print(dis)
    if lis[dis]:
      ans += 1
print(ans)

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

x=[list(map(int,input().split())) for i in range(n)]

lis=[False for i in range(16001)]
i=0
while(i*i<16000):
  lis[i*i]=True
  i+=1
  
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(x[i][k]-x[j][k])*(x[i][k]-x[j][k]) for k in range(d)])
 #   print(dis)
    if lis[dis]:
      ans += 1
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
N, D = map(int, input().split())
​

X = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    X.append(array)
var = 0
for i in range(N-1):
  for k in range(N-1-i):
    s = 0
    for j in range(D):      
      s = s + (X[i+1+k][j] - X[i+k][j])*(X[i+1+k][j] - X[i+k][j])
    if s**0.5 - (int(s**0.5)) ==0:
      var = var+1
print(var)

N, D = map(int, input().split())
import math
X = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    X.append(array)
var = 0
for i in range(N-1):
  for k in range(N-1-i):
    s = 0
    for j in range(D):      
      s = s + (X[i+1+k][j] - X[i][j])*(X[i+1+k][j] - X[i][j])
    if math.sqrt(s) - (int(math.sqrt(s))) ==0:
      var = var+1
print(var)

Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math


def is_distance_integer(p1, p2):
    n = len(p1)

    total = 0
    for i in range(n):
        total += ((p1[i] - p2[i])**2)

    dist = math.sqrt(total)

    return (dist**2) == total


def count_pairs(points):
    cnt = 0
    n = len(points)

    for i in range(n):
        for j in range(i + 1, n):
            if is_distance_integer(points[i], points[j]):
                cnt += 1

    return cnt


def main():
    N, D = map(int, input().split())

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

    ans = count_pairs(points)

    print(ans)


main()
 


import math


def is_distance_integer(p1, p2):
    n = len(p1)

    total = 0
    for i in range(n):
        total += ((p1[i] - p2[i])**2)

    dist = int(math.sqrt(total))

    return (dist**2) == total


def count_pairs(points):
    cnt = 0
    n = len(points)

    for i in range(n):
        for j in range(i + 1, n):
            if is_distance_integer(points[i], points[j]):
                cnt += 1

    return cnt


def main():
    N, D = map(int, input().split())

    points = []
    for _ in range(N):
        points.append(list(map(int, input().split())))

    ans = count_pairs(points)

    print(ans)


main()




Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
Thank you for your comment.
When I run the above code, it just displays the text "Loading...." and doesn't jump to the "login" or "home" page.
I'm not sure which part of the code is the cause, but I'm wondering if initState wasn't called

import math
N,D = map(int,input().split())
X = []
c = 0
s = 0
for i in range(N):
    X.append(list(map(int,input().split()))) 
for l in range(N):
    # print(str(l) + "l")
    if l == N - 1:
        break
    for i in range(l+1,N):
        for j in range(D):
            s += abs(X[l][j] - X[i][j]) ** 2
        s = math.sqrt(s)
        if s % 1 == 0:
            c += 1
        # print(str(i) + "i")
        s = 0

print(c)




Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        length' = 0.0
        for d in range(D) :
            length' += (x[i][d] - x[j][d]) ** 2
        length = length' ** (1/2)
        if length.is_integer() :
            s += 1
print(s)


N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        l = 0.0
        for d in range(D) :
            l += (x[i][d] - x[j][d]) ** 2
        length = l ** (1/2)
        if length.is_integer() :
            s += 1
print(s)

N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]

s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        length' = 0.0
        for d in range(D) :
            length' += (x[i][d] - x[j][d]) ** 2
        length = length' ** (1/2)
        if length.is_integer() :
        
            s += 1
print(s)


N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        l = 0.0
        for d in range(D) :
            l' += (x[i][d] - x[j][d]) ** 2
        length = l ** (1/2)
        if length.is_integer() :
            s += 1
print(s)


N, D = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        l = 0.0
        for d in range(D) :
            l += (x[i][d] - x[j][d]) ** 2
        length = l ** (1/2)
        if length.is_integer() :
            s += 1
print(s)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
N,D = map(int, input().split())
X  = []
for n in range(N):
    x = list(map(int, input().split()))
    X.append(x)
    
import numpy as np
def distance(a,b):
    dis = 0
    for i in range(D):
        dis += (a[i]-b[i])**2
    return np.sqrt(dis)

count = 0
for i in range(N):
    print(distance(X[i],X[(i+1)%(N-1)]))
    if distance(X[i],X[(i+1)%(N-1)]).is_integer():
        count += 1
print(count)

N,D = map(int, input().split())
X  = []
for n in range(N):
    x = list(map(int, input().split()))
    X.append(x)
    
import numpy as np
def distance(a,b):
    dis = 0
    for i in range(D):
        dis += (a[i]-b[i])**2
    return np.sqrt(dis)

count = 0
for i in range(N):
    for j in range(1,N-i):
        if distance(X[i],X[i+j]).is_integer():
            count += 1
print(count)

Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
c=0
for i in range(N-1):
    for j in range(i+1,N):
        c += (sum((a-b)**2) for a,b in zip(X[i],X[j]))**0.5.is_integer()
print(c)

N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
c=0
for i in range(N-1):
    for j in range(i+1,N):
        c += (sum((a-b)**2 for a,b in zip(X[i],X[j]))**0.5).is_integer()
print(c)


Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math

N,D=map(int,input().split())
X=[]
for _ in range(N):
  X.append(list(map(int, input().split())))
count=0
for i in range(N-1):
  for j in range(i+1,N):
    a=0
    for k in range(D):
      a+=(X[i][k]-X[j][k])**2
    if math.sqrt(a).is_integer():
      coutn+=1
print(count)

import math
 
N,D=map(int,input().split())
X=[]
for _ in range(N):
  X.append(list(map(int, input().split())))
count=0
for i in range(N-1):
  for j in range(i+1,N):
    a=0
    for k in range(D):
      a+=(X[i][k]-X[j][k])**2
    if math.sqrt(a).is_integer():
      count+=1
print(count)

Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
yandy
N, D = map(int, input().split())
array = []
for _ in range(N):
    array.append([int(i) for i in input().split()])
 
ans = 0
for i in range(N):
    for j in range(i+1, N):
        s = 0
        for d in range(D):
            s += (array[i][d]-array[j][d]) ** 2
        if s ** (1/2) % 1 == 0:
            ans += 1
 
print(ans)

N, D = map(int, input().split())
l = [list(map(int, input().split())) for i in range(N)]

ans=0
s=0
for i in range(N):
  for j in range(i+1,N):
    s=0
    for d in range(D):
      s+=(l[i][d]-l[j][d])**2
      if s**(1/2)%1==0:
        ans+=1
print(ans)

a,b=map(int,input().split())
n = [list(map(int, input().split())) for i in range(a)]
for (i,j) in range()


N, D = map(int, input().split())
l = [list(map(int, input().split())) for i in range(N)]

ans=0
s=0
for i in range(N):
  for j in range(i+1,N):
    s=0
    for d in range(D):
      s+=(l[i][d]-l[j][d])**2
    if s**(1/2)%1==0:
      ans+=1
print(ans)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
n, d = map(int, input().split())
distances = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n):
    for j in range(i + 1, n):
        diff_total = 0
        for k in range(d):
            diff = abs(distances[i][k] - distances[j][k])
            diff_total = diff * diff

        flag = False
        for k in range(diff_total + 1):
            if (k ** 2) == diff_total:
                flag = True
        if flag:
            ans += 1
print(ans)


n, d = map(int, input().split())
distances = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n):
    for j in range(i + 1, n):
        diff_total = 0
        for k in range(d):
            diff = abs(distances[i][k] - distances[j][k])
            diff_total += diff * diff

        flag = False
        for k in range(diff_total + 1):
            if (k * k) == diff_total:
                flag = True
        if flag:
            ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import numpy as np
N, D = [int(i) for i in input().split()]

list_coord = list()
for i in range(N):
  list_coord.append([int(i) for i in input().split()])
arr_coord = np.array(list_coord)

cnt = 0
for i in range(N):
    for j in range(N-i-1):
        a = np.array(list_coord[i])
        b = np.array(list_coord[N-j-1])
        dist = (abs(np.sum((a-b)**2)))**0.5
        print(a, b, dist)
        if dist.is_integer():
            cnt+=1
            
print(cnt)

import numpy as np
N, D = [int(i) for i in input().split()]

list_coord = list()
for i in range(N):
  list_coord.append([int(i) for i in input().split()])
arr_coord = np.array(list_coord)

cnt = 0
for i in range(N):
    for j in range(N-i-1):
        a = np.array(list_coord[i])
        b = np.array(list_coord[N-j-1])
        dist = (abs(np.sum((a-b)**2)))**0.5
        #print(a, b, dist)
        if dist.is_integer():
            cnt+=1
            
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
n, d = map(int, input().split())
x_l = [list(map(int, input().split))) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)


n, d = map(int, input().split())
x_l = [list(map(int, input().split)) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)


n, d = map(int, input().split())
x_l = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
N,D=map(int,input().split())
c=0
X=[]
for i in range(N):
  X.append(list(map(int,input().split())))

for j in range(N):
  for k in range(j+1,N):
    tmp=sum([(X[j][l]-X[k][l])**2 for l in range(N)])
    if tmp in [y**2 for y in range(21)]:
      c +=1
print(c)

N,D=map(int,input().split())
c=0
X=[]
for i in range(N):
  X.append(list(map(int,input().split())))

for j in range(N):
  for k in range(j+1,N):
    tmp=sum([(X[j][l]-X[k][l])**2 for l in range(D)])
    if tmp in [y**2 for y in range(130)]:
      c +=1
print(c)

Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math

N,D=map(int, input().split())
X=[list(map(int, list(input().split()))) for i in range(0,N)]
sum=0
ans=0

print(X)

for i in range(0,N-1):
  for j in range(i+1,N):
    sum=0
    for k in range(0,D):
      sum+=(X[j][k]-X[i][k])**2
    M=math.sqrt(sum)
    if M.is_integer():
      ans+=1 
  
print(ans)

import math

N,D=map(int, input().split())
X=[list(map(int, list(input().split()))) for i in range(0,N)]
sum=0
ans=0

for i in range(0,N-1):
  for j in range(i+1,N):
    sum=0
    for k in range(0,D):
      sum+=(X[j][k]-X[i][k])**2
    M=math.sqrt(sum)
    if M.is_integer():
      ans+=1 
  
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math 
N,D = map(int,input().split())
X=[]
count=0
for i in range(N):
    x = list(map(int,input().split()))
    X.append(x)
for i in range(N-1):
    for j in range(i,N):
        s = 0
        for k in range(N):
            s += (X[i][k]-X[j][k])**2
            if math.sqrt(s).is_integer():
                count += 1
print(count)

import math 
N,D = map(int,input().split())
X=[]
count=0
for i in range(N):
    x = list(map(int,input().split()))
    X.append(x)
for i in range(N-1):
    for j in range(i+1,N):
        s = 0
        for k in range(D):
            s += (X[i][k]-X[j][k])**2
            if math.sqrt(s).is_integer():
                count += 1
print(count)

import math 
N,D = map(int,input().split())
X=[]
count=0
for i in range(N):
    x = list(map(int,input().split()))
    X.append(x)
for i in range(N-1):
    for j in range(i+1,N):
        s = 0
        for k in range(D):
            s += (X[i][k]-X[j][k])**2
        if math.sqrt(s).is_integer():
            count += 1
print(count)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
temp=input().split()
N=int(temp[0])
D=int(temp[1])

points=[]
for i in range(N):
  temp=input().split()
  points.append([int(temp[x]) for x in range(D)])
  
counter=0
for i in range(N):
  for j in range(i+1, N):
    l=pow(sum([pow(points[i, x]-points[j, x], 2) for x in range(D)]), 1/2)
    if l.is_integer():
      counter+=1
      
print(counter)

temp=input().split()
N=int(temp[0])
D=int(temp[1])

points=[]
for i in range(N):
  temp=input().split()
  points.add([int(temp[x]) for x in range(D)])
  
counter=0
for i in range(N):
  for j in range(i+1, N):
    l=pow(sum([pow(points[i, x]-points[j, x], 2) for x in range(D)]), 1/2)
    if l==int(l):
      counter+=1
      
print(counter)

temp=input().split()
N=int(temp[0])
D=int(temp[1])

points=[]
for i in range(N):
  temp=input().split()
  points.add([int(temp[x]) for x in range(D)])
  
counter=0
for i in range(N):
  for j in range(i+1, N):
    l=pow(sum([pow(points[i, x]-points[j, x], 2) for x in range(D)]), 1/2)
    if l.is_integer():
      counter+=1
      
print(counter)

import numpy as np

N, D=map(int, input().split())
a=np.zeros((N, D))
for i in range(N):
  a[i, :]=list(map(int, input().split()))
  
counter=0
for i in range(N-1):
  for j in range(i+1, N):
    temp=pow(np.sum((a[i]-a[j])**2), 1/2)
    if temp-int(temp)==0:
      counter+=1
      
print(int(counter))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
n,d=map(int,input().split())
x=[[int(a) for a in input().split(" ")] for _ in range(n)]
cnt=0
dis=0
for i in range(n-1):
  for j in range(i+1,n):
    for k in range(d):
      dis+=(x[i][k]-x[j][k])**2
      if (dis**0.5).is_integer:
        cnt+=1
print(cnt)

n,d=map(int,input().split())
x=[[int(a) for a in input().split(" ")] for _ in range(n)]
cnt=0
for i in range(n-1):
  for j in range(i+1,n):
    dis=0
    for k in range(d):
      dis+=(x[i][k]-x[j][k])**2
    if (dis**0.5).is_integer():
        cnt+=1
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):

n,d = map(int,input().split())
l = []
a = []
count = 0
sum = 0

for i in range(n):
    a = list(map(int,input().split()))
    l.append(a)

for x in range(1,n):
    for y in range(x+1,n):
        for z in range(d):
#            print((l[x][z]-l[y][z])**2)
            sum += (l[x][z]-l[y][z])**2
            print(sum)
            dis = sum ** 0.5
            dis = int(dis)
            print(dis)
            print("=======")

            if dis % 1 == 0:
                count += 1
print(count)



from itertools import combinations

n,d = map(int,input().split())
count = 0

X = []
for i in range(n):
    X.append(list(map(int,input().split())))

for a,b in combinations(X,2):
    if (sum((a[i]-b[i])**2 for i in range(d))) ** (1/2) % 1 == 0:
        count += 1
print(count)





Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
n,d = map(int,input().split())
points = []
for _ in range(n):
  X = tuple(map(int,input().split()))
  points.append(X)
  
ans = 0

import math
def distance(x,y):
  dis = 0
  for i in range(d):
    dis += (x[i]-y[i])**2
  return math.sqrt(dis)

for i in range(n-1):
  for j in range(i+1,n):
    dis = distance(X[i],X[j])
    if dis == int(dis):
      ans += 1
print(ans)

n,d = map(int,input().split())
points = []
for _ in range(n):
  X = tuple(map(int,input().split()))
  points.append(X)
  
ans = 0

import math
def distance(x,y):
  dis = 0
  for i in range(d):
    dis += (x[i]-y[i])**2
  return math.sqrt(dis)

for i in range(n-1):
  for j in range(i+1,n):
    dis = distance(points[i],points[j])
    if dis == int(dis):
      ans += 1
print(ans)



Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import sys
num = [int(i) for i in input().split()]
a = [[int(c) for c in l.strip()] for l in sys.stdin]
r = 0
ans = 0
for i in range(num[0]-1):
  for j in range(num[1]):
    d = (a[i][j]**2 + a[i+1][j]**2)
    r += d
  if int(r**0.5) == r**0.5:
    ans += 1
  r = 0

for j in range(num[1]):
  d = (a[num[0]-1][j]**2 + a[0][j]**2)
  r += d
if int(r**0.5) == r**0.5:
  ans += 1
print(ans)
               

n, d = map(int, input().split())
x = []
r = 0
ans = 0
for i in range(n):
  x.append(list(map(int, input().split())))

for i in range(n-1):
  for k in range(1, n-i):
    for j in range(d):
      r_temp = (x[i][j] - x[i+k][j])**2 
      r += r_temp
    r = r**0.5
    if int(r) == r:
      ans += 1
    r = 0
    
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math

n, d = map(int,input().split())
x=[]
ans = 0
y = 0.0

for i in range(n):
    x.append(list(map(int,input().split()))) 
print(x)
    
for i in range(n):
    for j in range(i+1,n): 
        y = 0.0
        for k in range(d): 
            y = y + (x[i][k] - x[j][k])**2 
        if math.sqrt(y).is_integer() == True: 
            ans = ans + 1 

print(ans)

import math

n, d = map(int,input().split())
x=[]
ans = 0
y = 0.0

for i in range(n):
    x.append(list(map(int,input().split()))) 
    
for i in range(n):
    for j in range(i+1,n): 
        y = 0.0
        for k in range(d): 
            y = y + (x[i][k] - x[j][k])**2 
        if math.sqrt(y).is_integer() == True: 
            ans = ans + 1 

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N points in a D-dimensional space.  The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).  The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.  How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

Submission attempts (in order):
import math
n,d=map(int,input().split())
cnt=0
dlist=[list(map(int,input().split())) for _ in range(n)]
for i in range(n-1):
    for j in range(i+1:n):
        ans=0
        for k in range(d):
            ans+=(dlist[i][k]-dlist[j][k])**2
        cnt+=math.floor(ans**0.5)==math.ceil(ans**0.5):

print(cnt)    


import math
n,d=map(int,input().split())
cnt=0
dlist=[list(map(int,input().split())) for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        ans=0
        for k in range(d):
            ans+=(dlist[i][k]-dlist[j][k])**2
        cnt+=math.floor(ans**0.5)==math.ceil(ans**0.5)

print(cnt) 

Verdicts: Runtime Error

Accepted