jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var card = o.getArray(0);
    var A = card[0];
    var B = card[1];
    var C = card[2];
    var K = o.getValue(1);

    var i = 0;
    while(K > i++) {
        if (A >= B) {
            B = 2 * B;
            continue;
        }
        C = 2 * C;
    }
    return  (B > A && C > B) ? 'Yes' : 'No';
}
//  [javascript]
//let input = "7 4 2\n3";

function main(input){
  input = input.trim();
  let l1 = input.split("\n")[0];
  let l2 = input.split("\n")[1];
  let r = parseInt(l1.split(" ")[0]);
  let g = parseInt(l1.split(" ")[1]);
  let b = parseInt(l1.split(" ")[2]);
  let n = parseInt(l2);

  function hantei(){
    return(r<g && g<b);
  }
  
  function magic(){
    if(r>g){
      g = g*2;
    }else if(g>b){
      b = b*2
    }
  }
  
  for(i=0; i<n; i++){
    magic();
  }
  let answer = "";
  if(hantei()===true){
    answer = "Yes";
  }else{
    answer = "No";
  }
  console.log(answer);
}

//main(input);

main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [javascript]
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const line_one = input[0].split(" ");
  const K = parseInt(input[1]);
  let line_one_arr = [];

  for (let i in line_one) {
    line_one_arr.push(parseInt(line_one[i]));
  }

  let i = 0;
  let can = false;
  while (line_one_arr[0] >= line_one_arr[1]) {
    if (i > K) break;
    line_one_arr[1] = line_one_arr[1] * 2;
    i++;
  }
  while (line_one_arr[1] >= line_one_arr[2]) {
    if (i > K) break;
    line_one_arr[2] = line_one_arr[2] * 2;
    i++;
  }
  console.log(line_one_arr);
  if (
    line_one_arr[0] < line_one_arr[1] &&
    line_one_arr[1] < line_one_arr[2] &&
    i <= K
  ) {
    can = true;
  }

  if (can) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));
//  [javascript]
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const line_one = input[0].split(" ");
  const K = parseInt(input[1]);
  let line_one_arr = [];

  for (let i in line_one) {
    line_one_arr.push(parseInt(line_one[i]));
  }

  let i = 0;
  let can = false;
  while (line_one_arr[0] >= line_one_arr[1]) {
    if (i > K) break;
    line_one_arr[1] = line_one_arr[1] * 2;
    i++;
  }
  while (line_one_arr[1] >= line_one_arr[2]) {
    if (i > K) break;
    line_one_arr[2] = line_one_arr[2] * 2;
    i++;
  }

  if (line_one_arr[0] < line_one_arr[1] && line_one_arr[1] < line_one_arr[2]) {
    can = true;
  }

  if (can) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));
//  [go]
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &c)
	fmt.Scanf("%d", &k)

	var ans bool
	for i := 0; i < k; i++ {

		if b >= c {
			c = c * 2
		} else if a >= b {
			b = b * 2
		}

		if a < b && b < c {
			ans = true
			break
		}
	}

	if ans == true {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	a := sc.ReadInt()
	b := sc.ReadInt()
	c := sc.ReadInt()
	k := sc.ReadInt()

	count := 0

	bBig := b
	for bBig <= a {
		bBig *= 2
		count++
	}

	cBig := c
	for cBig <= bBig {
		cBig *= 2
		count++
	}

	if count <= k {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}
//  [go]
package main

import "fmt"

func main() {
	a := 0
	b := 0
	c := 0
	k := 0

	fmt.Scanf("%d %d %d", &a, &b, &c)
	fmt.Scanf("%d", &k)

	for i := 0; i < k; i++ {
		if c <= b {
			c *= 2
		} else if b <= a {
			b *= 2
		} else {
			c *= 2
		}

	}

	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

/*-----------Main-----------*/

func main() {
	a, b, c := readI(), readI(), readI()
	k := readI()
	for i := 0; i < k; i++ {
		switch {
		case a > b:
			b *= 2
		case b > c:
			c *= 2
		}
	}
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

/*-----------Main-----------*/

func main() {
	a, b, c := readI(), readI(), readI()
	k := readI()
	for i := 0; i < k; i++ {
		if a > b {
			b *= 2
			continue
		} else if b > c {
			c *= 2
			continue
		} else {
			break
		}
	}
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}
//  [ruby]
r,g,b = gets.split.map(&:to_i)
k = gets.to_i

k.times do
    if r>=g
        g*=2
    elsif g>=b
        b*=2
    end
    #p r,g,b
end

puts (r<g and g<b) ? "Yes" : "No"
//  [ruby]
a, b, c = gets.split.map &:to_i
k = gets.to_i
while a>=b
  b*=2
  k -= 1
end
while b>=c
  c*=2
  k -= 1
end
puts ((k>=0) ? :Yes : :No)
//  [ruby]
a,b,c = gets.split.map(&:to_i)
k = gets.to_i
k.times do
  if b <= a
    b *= 2
  elsif c <= b
    c *= 2
  end
end
if a < b && b < c
  puts 'Yes'
else
  puts 'No'
end
//  [ruby]
a, b, c = gets.split.map { |t| t.to_i }

k = gets.to_i

[0, 1].repeated_permutation(k) do |bits|
  x, y, z = a, b, c
  bits.each do |bit|
    if bit.zero?
      y **= 2
    else
      z **= 2
    end
  end
  
  if x < y && y < z
    puts "Yes"
    exit
  end
end

puts "No"
//  [ruby]
a, b, c = gets.split.map(&:to_i)
K = gets.to_i
cnt = 0
while true do
  if b < a
    b *= 2
    cnt += 1
  else
    break
  end
end

while true do
  if c < b
    c *= 2
    cnt += 1
  else
    break
  end
end
puts cnt <= K ? "Yes" : "No"
//  [ruby]
a, b, c = gets.split.map(&:to_i)
K = gets.to_i
cnt = 0
while true do
  if b < a
    b *= 2
    cnt += 1
  else
    break
  end
end

while true do
  if c < b
    c *= 2
    cnt += 1
  else
    break
  end
end
puts cnt <= K "Yes" : "No"
//  [rust]
fn main() {
    proconio::input! {
        a: usize,
        mut b: usize,
        mut c: usize,
        mut k: usize,
    }
    while a>=b && k>0 {
        b*=2;
        k-=1;
    }
    while b>=c && k>0 {
        c*=2;
        k-=1;
    }
    println!("{}",if a<b && b<c {"Yes"} else {"No"});
}
//  [rust]
use input::Input;

fn main() {
    let mut input = Input::default();

    let a: u32 = input.parse();
    let b: u32 = input.parse();
    let c: u32 = input.parse();
    let k: u32 = input.parse();

    if c > b && b > a {
        println!("Yes");
        return;
    }

    for i in 0..(1 << k) {
        let (red, mut green, mut blue) = (a, b, c);
        for j in 0..k {
            if i >> j & 1 == 1 {
                green *= 2;
            } else {
                blue *= 2;
            }
            if blue > green && green > red {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}
//  [rust]
fn main() {
  proconio::input! {a:u8,mut b:u8,mut c:u8,k:u8}
  for _ in 0..k {
    if a>=b {
      b*=2;
    } else if b>=c {
      c*=2;
    } else {
      break;
    }
  }
  println!("{}",if a<b && b<c {"Yes"} else {"No"});
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        a: i32,
        mut b: i32,
        mut c: i32,
        K: usize,
    }

    let mut flag = false;
    for i in 0..K {
        for j in 0..K {
            for k in 0..K {
                let x = a * (1 << i);
                let y = b * (1 << j);
                let z = c * (1 << k);
                if i + j + k <= K && x < y && y < z {
                    flag = true;
                }
            }
        }
    }

    let ans = if flag { "Yes" } else { "No" };

    println!("{}", ans);
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        a: i32,
        mut b: i32,
        mut c: i32,
        k: usize,
    }

    for _ in 0..k {
        if a > b {
            b *= 2;
        } else if b > c {
            c *= 2;
        }
    }

    let ans = if a < b && b < c { "Yes" } else { "No" };

    println!("{}", ans);
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        a: i32,
        mut b: i32,
        mut c: i32,
        k: usize,
    }

    for _ in 0..k {
        if a > b {
            b *= 2;
        }
        if b > c {
            c *= 2;
        }
    }

    let ans = if a < b && b < c { "Yes" } else { "No" };

    println!("{}", ans);
}
//  [swift]
func main() {
    var abc = readLine()!.split(separator: " ").map{Int($0)!}
    var k = Int(readLine()!)!
    while abc[1] <= abc[0] {
        abc[1] *= 2
        k -= 1
    }
    while abc[2] <= abc[1] {
        abc[2] *= 2
        k -= 1
    }
    print(k>=0 ? "Yes" : "No")
}

main()
//  [swift]
let inp = readLine()!.split(separator: " ").map { Int($0)! }

var a = inp[0]
var b = inp[1]
var c = inp[2]

var k = Int(readLine()!)!

while k > 0 && (b <= a || c <= b) {
  if b <= a {
    b *= 2
  } else if c <= b {
    c *= 2
  }
  k -= 1
}
print(b > a && c > b ? "Yes" : "No")
//  [swift]
fileprivate struct Scanner {
    private var elements = [String]()
    private var index = 0
    
    mutating func peek() -> String {
        while elements.count == index {
            elements = readLine()!.split(separator: " ").map(String.init)
            index = 0
        }
        return elements[index]
    }
    
    mutating func next() -> String {
        let value = peek()
        index += 1
        return value
    }
    
    mutating func nextInt() -> Int {
        return Int(next())!
    }
    
    mutating func nextDouble() -> Double {
        return Double(next())!
    }
}

func main() {
    var scanner = Scanner()
    let A = scanner.nextInt()
    var B = scanner.nextInt()
    var C = scanner.nextInt()
    let K = scanner.nextInt()
    
    var need = 0
    
    while A >= B {
        B *= 2
        need += 1
    }
    while B >= C {
        C *= 2
        need += 1
    }
    
    if need <= K {
        print("Yes")
    } else {
        print("No")
    }
}

main()
//  [swift]
import Foundation

let abc = readLine()!.split(separator: " ").compactMap { Int($0) }
let a = abc[0]
let b = abc[1]
let c = abc[2]
var bb:Int
var cc:Int
let k = Int(readLine()!)!
var tf = true
for i in 0..<k{
  bb = b
  cc = c
  cc *= Int(pow(Double(2),Double(i)))
  bb *= Int(pow(Double(2),Double((k-i))))
  if cc>bb && bb>a{
    tf = false
    print("Yes")
    break
  }
}
if tf{
  print("No")
}
//  [swift]

import Foundation

let input = readLine()!.components(separatedBy: " ").map{ Int($0)! }
let N = input[0]
let K = input[1]
var pointArray = readLine()!.components(separatedBy: " ").map{ Int($0)! }
let evaluationNum = N - K


var thisTerm = 1
var prevTerm = 1

for j in 0...evaluationNum {
    thisTerm = 1
    for i in j...K - 1 + j {
        thisTerm *= pointArray[i]
        }
    if j == 0 {
        prevTerm = thisTerm
    } else if prevTerm < thisTerm {
        print("Yes")
        prevTerm = thisTerm
    } else if prevTerm >= thisTerm {
        print("No")
        prevTerm = thisTerm
    }
}
//  [swift]
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func readThreeInts(separator: String.Element = " ") -> (a: Int, b: Int, c: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1], c: ints[2])
}

func mainB() {
    let (A, B, C) = readThreeInts()
    let K = readInt()

    for k in 0...K {
        for i in 0...k {
            let Bd = B * max(2 * (k - i), 1)
            let Cd = C * max(2 * i, 1)

            if A < Bd, Bd < Cd {
                print("Yes")
                return
            }
        }
    }

    print("No")
}

mainB()
//  [typescript]
import * as fs from 'fs';

 const input = fs.readFileSync('/dev/stdin', 'utf8');
//const input = fs.readFileSync('./input.txt', 'utf8');

_b(input);

function _b(input: string) {
  const [ABC, _K] = input.split('\n');
  const K = parseInt(_K);
  const [A, B, C] = ABC.split(' ').map((s) => parseInt(s));
  // console.log(A, B, C, K);

  // A は B の何倍か？を 2^n で表す
  const n = Math.max(0, Math.ceil(Math.log2((A + 1) / B)));
  const b = B * 2 ** n;

  // b は C の何倍か？を 2^m で表す
  const m = Math.max(0, Math.ceil(Math.log2((b + 1) / C)));

  // console.log(n, m, b);

  console.log(n + m <= K ? 'Yes' : 'No');
}
//  [python]
n,d = map(int,input().split())
pnt = [list(map(int,input().split())) for _ in range(n)]

def dst(i, j):
    a = pnt[i]
    b = pnt[j]
    ret = 0
    for p, q in zip(a, b):
        ret += (p - q) ** 2
    r = int(ret ** (0.5))
    if r ** 2 == ret:
        return True
    else:
        return False

ret = 0
for i in range(n):
    for j in range(i + 1, n):
        tmp = dst(i, j)
        if tmp:
            ret += 1
print(ret)
//  [python]
import sys
sys.setrecursionlimit(10 ** 6)


def calc_dist(x, y):
    dist = 0
    for xi, yi in zip(x, y):
        dist += (yi - xi) ** 2
    return dist ** (1/2)


def main():
    N, D = map(int, sys.stdin.readline().rstrip().split())
    X = [list(map(int, sys.stdin.readline().rstrip().split())) for _ in range(N)]

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            dist = calc_dist(X[i], X[j])
            if dist.is_integer():
                ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()
//  [python]
from math import sqrt
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        Y = X[i]
        Z = X[j]
        d = sqrt(sum([(y - z) ** 2 for y, z in zip(Y, Z)]))
        if float(int(d)) == d:
            ans += 1
print(ans)
//  [python]
n,d=map(int,input().split())
point=[]
for _ in range(n):
    point.append(list(map(int,input().split())))
ans=0
for i in range(n-1):
    for l in range(1,n):
        if i==l:
            continue
        dis=0
        for f in range(d):
            dis+=(point[i][f]-point[l][f])**2
        dis=dis**0.5
        #print(dis)
        if dis.is_integer():
            ans+=1
print(ans)
//  [python]
#ABC133 B

import math
N,D = map(int,input().split())
point = []
count = 0
for i in range(N):
    X = list(map(int,input().split()))
    point.append(X)
for i in range(1,N):
    for j in range(i+1,N+1):
        for k in range(D):
            S = 0
            square = []
            square.append(((point[i-1][k])-(point[j-1][k]))**2)
            S += math.sqrt(sum(square))
            if S % 1 ==0:
                count += 1
        

print(count)
//  [python]
#ABC133 B

import math
N,D = map(int,input().split())
point = []
count = 0
for i in range(N):
    X = list(map(int,input().split()))
    point.append(X)
for i in range(1,N):
    for j in range(i+1,N+1):
        S = 0
        for k in range(D):
            square = []
            square.append(((point[i-1][k])-(point[j-1][k]))**2)
            S += math.sqrt(sum(square))
            if S % 1 ==0:
                count += 1
        

print(count)
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int D = sc.nextInt();

		int[][] x = new int[N + 1][D + 1];
		for (int i = 1; i < N + 1; i++) {
			for (int j = 1; j < D + 1; j++)
				x[i][j] = sc.nextInt();
		}
		int s = 0;
		int count = 0;
		for (int i = 1; i < N + 1; i++) {
			for (int j = i + 1; j < N + 1; j++) {
				for (int d = 1; d < D + 1; d++) {
					s += Math.pow(x[i][d] - x[j][d], 2);
				}
				int a = (int) Math.sqrt(s);
				if (s == a * a)
					count++;
				s=0;
			}
		}
		System.out.println(count);

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		String[] tmpArray = br.readLine().split(" ");

		int n = Integer.parseInt(tmpArray[0]);
		int d = Integer.parseInt(tmpArray[1]);

		int input[][] = new int[n][d];

		HashSet<Integer> square = new HashSet<Integer>();

		for(int i = 0; i < 150; i++){
			square.add(i*i);
		}
		for(int i = 0; i < n; i++){
			tmpArray = br.readLine().split(" ");

			for(int j = 0; j < d; j++){
				input[i][j] = Integer.parseInt(tmpArray[j]);
			}
		}

		int count = 0;

		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				int distSq = 0;

				for(int k = 0; k < d; k++){
					distSq += Math.pow(input[i][k] - input[j][k], 2);
				}

				if(square.contains(distSq)){
					count++;
				}
			}
		}

		System.out.println(count);
	}

}
//  [java]

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int D = scanner.nextInt();

        int[][] X = new int[N][D];

        for (int i = 0 ; i < N ; i++) {
            for (int j = 0 ; j < D ; j++) {
                X[i][j] = scanner.nextInt();
            }
        }

        Set<Integer> pow = new HashSet<>();
        for (int i = 1 ; i <= 64 ; i++) {
            pow.add(i * i);
        }

        int count = 0;
        for (int i = 0 ; i < N ; i++) {
            for (int j = i + 1 ; j < N ; j++) {
                int dist = 0;
                for (int k = 0 ; k < D ; k++) {
                    dist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }
                if (pow.contains(dist)) {
                    count++;
                }
            }
        }

        System.out.println(count);
    }
}
//  [java]

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int D = Integer.parseInt(lines[1]);
		int[][] X = new int[N][D];
		int count = 0;

		for (int i = 0; i < N; i++) {
			line = sc.nextLine();
			lines = line.split(" ");
			for (int j = 0; j < D; j++) {
				X[i][j] = Integer.parseInt(lines[j]);
			}
		}


		for (int n = 0; n < N; n++) {
			for(int n2 = n+1; n2 < N; n2++) {
				double sum = 0;
				for (int i = 0; i < D; i++) {
					int diff = Math.abs(X[n][i] - X[n+1][i]);
					sum += diff * diff;
				}

				if(isSquareNumber(sum)) {
					count++;
				}
			}
		}

		System.out.println(count);
	}

    static // 平方数かどうかを調べる。
    boolean isSquareNumber (double number) {
        double sqrtOfNumber = Math.sqrt(number);
//    	System.out.println(sqrtOfNumber);
        return (isInteger(sqrtOfNumber));
    }

    static // 整数かどうかを調べる。
    boolean isInteger (double number) {
        return (number == Math.floor(number));
    }

}
//  [java]
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		Set<Integer>  set = new HashSet<Integer>();
		for (int i=1;i<1000;i++) {
			set.add(i*i);
		}
		int count =0;
		int a[][] = new int[N][D];
		for (int i=0;i<N;i++) {
			for (int j=0;j<D;j++) {
				a[i][j] = sc.nextInt();
			}
		}
		for (int i=0;i<N;i++) {
			for (int j=i+1;j<N;j++) {
				int temp =0;
				for (int k=0;k<D;k++) {
					temp +=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
					if(set.contains(temp)) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

int main () {
	int N, D, c = 0;
	cin >> N >> D;
	vector<vector<int>> S(N);
	for (int i = 0; i < N; i++) {
		S[i].resize(D);
		for (int j = 0; j < D; j++) {
			cin >> S[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < i; j++) {
			int m = 0;
			for (int k = 0; k < D; k++) {
				int e = S[i][k] - S[j][k];
				m += (e * e);
			}
			int r = floor(sqrt((double)m));
			if (r * r == m) {
				c++;
			}
		}
	}
	cout << c << endl;
}
//  [cpp]
        #include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007

        using namespace std;
         //int g[105][105];
        //vector < int > wt(100004);
       // vector < int > a;
        //vector < int > v(30500);
        //int cst[102][100005];
        //int ansr[100005];
     //ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0;


         /* rep(i,0,50)
          {
              if(ck[i]) cout<<i<< " o"<<endl;
              else cout<<i<<" e"<<endl;
          }*/
     bool isp( int n)
      {
          int k=sqrt(n); //cout<<k<<"K"<<endl;
          if(k*k==n) return true;
          return false;
      }

        void solve()
        {
           int  i,j=0,r=200,p,q,k=0,ans=0,d,y=0,h,flag=0,n,m=0,a,b,id,c,h1,h2,a1,b1;
           cin>>n>>d;
           vector < vector < int  > > v(n,vector < int > (d));
           rep(i,0,n)
             {
                 rep(j,0,d)
                   {
                       cin>>v[i][j];
                   }
             }
             rep(i,0,n)
                {
                    rep(j,i+1,n)
                       {   y=0;
                           rep(k,0,d)
                             {
                                 y+=((v[i][k]-v[j][k])*(v[i][k]-v[j][k]));

                             }
                            // cout<<y<<" ";
                             if(isp(y)) m++;
                             //cout<<m<<" ";
                       }
                }
      cout<<m;








        }


        int main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
          //  cin>>t;
            while(t--)
            solve();
        }

           /*

      void bfs( int i , int j)
           {
               vis[i][j]= true;
             queue < int > que;
             que.push(k);
             while(!que.empty())
             {
                int x= que.front();
                que.pop();
                 for ( int i=1;i<=n;i++)
                 {
                     if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                     {
                       if(!vis[i])
                       {
                           que.push(i);
                           level[i]=level[x]+1;
                           vis[i]= true;
                       }
                     }
                 }
             }
           }

          ll int por(ll int a,ll int b)
             {
                ll int k=1;
                while(b>0)
                {
                    if(b%2) k=k*a,k%=hell;
                    b/=2;
                    a*=a; a%=hell;
                }
                return k;
             } */
//  [cpp]
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));
	for(int i = 0; i < N; i ++){
		for(int j = 0; j < D; j ++){
			cin >> X[i][j];
		}
	}
	ll ddist, dist, ans = 0;
	for(int i = 0; i < N - 1; i ++){
	for(int j = i + 1; j < N; j ++){
		ddist = 0;
		for(int k = 0; k < D; k ++){
			ddist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
		}
		dist = sqrt(ddist);
		if(ddist == dist * dist){
			ans ++;
		}
	}
	}
	cout << ans << endl;

	return 0;
}
//  [cpp]
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int N, D;
  cin >> N >> D;
  int X[N][D];
  for (int i = 0; i < N; i++){
    for (int j = 0; j < D; j++){
      cin >> X[i][j];
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      if(i != j){
        int s = 0;
        for (int k = 0; k < D; k++) s += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
        int ss = sqrt(s);
        if(s%ss == 0) ans++;
      }  
    }
    
  }
  
  printf("%d\n", ans);
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N,D;
  cin >> N >> D;
  
  vector<vector<int>> matrix(N, vector<int>(D));
  for (int i=0; i<N; i++){
    for (int j=0; j<D; j++){
      cin >> matrix.at(i).at(j);
    }
  }
  
  int ans = 0;
  
  int distance_squared = 0;
  for (int i=0; i<N-1; i++){
    for (int j=i+1;j<N; j++){
      for(int k=0;k<D;k++){
        distance_squared +=  pow((matrix.at(i).at(k) - matrix.at(j).at(k)),2);
      }
      for(int l=1; l<130; l++){
        if(distance_squared  == l*l){
          ans++;
        }
        break;
      }
      distance_squared  = 0;
    }
  }
  
  cout << ans << endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N,D;
  cin >> N >> D;
  
  vector<vector<int>> matrix(N, vector<int>(D));
  for (int i=0; i<N; i++){
    for (int j=0; j<D; j++){
      cin >> matrix.at(i).at(j)
    }
  }
  
  int ans = 0;
  
  int distance_squared = 0;
  for (int i=0; i<N-1; i++){
    for (int j=i+1;j<N; j++){
      for(int k=0;k<D;k++){
        distance_squared +=  pow((matrix.at(i).at(k) - matrix.at(j).at(k)),2);
      }
      for(int l=1; l<130; l++){
        if(distance_squared  == l*l){
          ans++;
        }
        break;
      }
      distance_squared  = 0;
    }
  }
  
  cout << ans << endl;
}
//  [c]
#include <stdio.h>
#include <math.h>

int main(){
  int n, d;  scanf("%d %d", &n, &d);
  int x[13][13];
  for(int i=1; i<=n; i++)
    for(int j=1; j<=d; j++)
      scanf("%d", &x[i][j]);
  int count = 0;
  for(int i=1; i<n; i++){
    for(int j=i+1; j<=n; j++){
      int dis = 0;
      for(int k=1; k<=d; k++)
	dis = dis + (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      if(dis == (int)sqrt(dis)*(int)sqrt(dis)){
	count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n,d,i,j,k,cnt=0;
    scanf("%d%d",&n,&d);
    int a[n][d];
    for(i=0;i<n;i++){
        for(j=0;j<d;j++) scanf("%d",&a[i][j]);
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            int sum=0;
            for(k=0;k<d;k++){
                int tmp = abs(a[i][k]-a[j][k]);
                sum+=tmp*tmp;
            }
            for(k=0;k<=sum;k++){
                if(k*k==sum) cnt++;
            }
            
        }
    }
    printf("%d",cnt);
    return 0;
}
//  [c]
#include<stdio.h>
#include<math.h>


int main(void)
{
  //dとnを入力
  int d,n;
  scanf("%d%d",&d,&n);


  //n個の座標をforで入力
  int i,j,k;
  /*
  int x[n][d];
  for(i=0;i<n;i++)
    for(k=0;k<d;k++)
      scanf("%d",&x[i][k]);
      */
  int x[d][n];
  for(i=0;i<d;i++)
    for(k=0;k<n;k++)
      scanf("%d",&x[i][k]);



  //計算開始
  double dist;
  int cnt=0;

  //i,jを決める
  for(i=0;i<d;i++)
    //for(j=i+1;j<n-(i+1);j++){
    for(j=i+1;j<d;j++){
/*
printf("(%d,%d,%d,%d) - (%d,%d,%d,%d)  ",
                x[i][0], x[i][1], x[i][2], x[i][3],
                x[j][0], x[j][1], x[j][2], x[j][3]);
                */

      //点iと点jの距離を求める
      dist = 0;
      for(k=0;k<n;k++)
        //dist += (x[i][k]-x[j][k])^2;
        dist += pow(x[i][k]-x[j][k],2);
      dist = sqrt(dist);
//   printf("%f\n", dist);

      //ceil(切り上げ関数)とfloor(切り捨て関数)を使ってdistが整数か判定
      //distが整数ならcntを1増やす
      if(ceil(dist)==floor(dist))
//      if (dist*dist==pow((int)dist,2))
        cnt++;
    }


  //cntを出力して終了
  printf("%d\n",cnt);
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

const int inf = 1012345678;
int main(){
    int n, d;
    int x[100][100];

    scanf("%d %d", &n, &d);
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            scanf("%d", &x[i][j]);
        }
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            int sum = 0;
            for(int k = 0; k < d; ++k){
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            for(int k = 1; k <= 40; ++k){
                if(sum == (k * k)){
                    cnt++;
                }
            }
        }
    }

    printf("%d\n", cnt);

    return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

const int inf = 1012345678;
int main(){
    int n, d;
    int x[100][100];

    scanf("%d %d", &n, &d);
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            scanf("%d", &x[i][j]);
        }
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            int sum = 0;
            for(int k = 0; k < d; ++k){
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            for(int k = 1; k < 70; ++k){
                if(sum == (k * k)){
                    cnt++;
                }
            }
        }
    }

    printf("%d\n", cnt);

    return 0;
}
//  [c]
#include<stdio.h>
#include<math.h>
int main(void){
        int a[10][10],n,d,i,j,k,l=0,p=0;
        double s[46],b[10][10];
        scanf("%d%d",&n,&d);
        for(i=0;i<n;i++){
            for(j=0;j<d;j++){
                scanf("%d",&a[i][j]);
                b[i][j]=a[i][j];
            }
        }
       for(i=0;i<n-1;i++){
            for(k=i+1;k<n;k++){
                for(j=0;j<d;j++){
                    s[p]=s[p]+(pow((b[i][j]-b[k][j]),2));
                }
                s[p]=sqrt(s[p]);
                if(round(s[p])-(s[p])==0){
                    l++;
                }
                p++;
            }
       }
       printf("%d",l);
       return 0;
}
//  [javascript]
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")
    var tmp = data.shift().split(' ').map(Number)
    var N = tmp[0]
    var D = tmp[1]
    data = data.map(e => e.split(' ').map(Number))

    var ans = 0

    for (var i = 0; i < N; i++) {
        for (var j = i; j < N; j++) {
            if (i === j) continue
            // console.log(`${i}:${j}`)
            var row1 = data[i]
            var row2 = data[j]
            var yz = 0
            for (var d = 0; d < D; d++) {
                // console.log(`${i}:${j}`)
                var t = Math.abs(row1[d] - row2[d])
                yz += t * t
            }
            var tAns = Math.sqrt(yz)
            if (!(String(tAns).split('.').length > 1)) {
                // console.log(tAns)
                ans++
            }
        }
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  	input = input.split("\n");
  	i = 0;
  	x = [];
	counter = 0;
  	N =1000000;
    D = 0;
   for(i=0;i<=N;i++){
      	num = input[i].split(/\s+/);
      	littleX = [];
		if(i==0){
          N = num[0];
          D = num[1];
        }else{
        	for(j=0;j<D;j++){
	          littleX.push(num[j]);
        	}
            x.push(littleX);
        }

     	//console.log("i= "+i+"N:" + N + ",D:"+D + ",littleX:" + littleX);
    }

  	for(i=0;i<N;i++){
      	for(k=i+1;k<N;k++){
	      	//console.log("check "+i+"to"+k);
          	//console.log(x[i]);
          	//console.log(x[k]);
          	sum = 0;
          	for(j=0;j<D;j++){
            	sum+= Math.abs((x[i][j] - x[k][j])*(x[i][j] - x[k][j]));
            }
          	//console.log(sum);
          	//console.log(Math.sqrt(sum));
          	//console.log(Number.isInteger(Math.sqrt(sum)));
          	if(Number.isInteger(Math.sqrt(sum)) === true){
            	counter++;
            }
        }
    }
  	console.log(counter);
  	
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
const main = input => {
    const n = parseInt(input[0].split(' ')[0]),
    d = parseInt(input[0].split(' ')[1]);
    let x = new Array();
    for(let i=0; i<n; i++) {
      x[i] = input[i+1].split(' ').map(val => parseInt(val));
    }
    // console.log(n,d,x);
    let ans=0;
    for(let i=0; i<n-1; i++) {
      for(let j=i+1; j<n; j++) {
        let value=0;
        for(let k=0; k<d; k++) {
          value+=Math.pow(Math.abs(x[i][k]-x[j][k]),2);
        }
        value=Math.pow(value,0.5);
        // console.log(value);
        if (Number.isInteger(value)) {
          ans++;
        }
      }
    }
    console.log(ans);
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));
//  [javascript]
function Main(input) {
  	input = input.split("\n");
  	i = 0;
  	x = [];
	counter = 0;
   for(i=0;i<input.length;i++){
      	num = input[i].split(" ");
      	littleX = [];
		for(j=0;j<num.length;j++){
          	littleX.push(num[j]);
        }
      	x.push(littleX);
    }

  	for(i=1;i<input.length;i++){
      	for(k=i+1;k<input.length;k++){
	      	//console.log("check "+i+"to"+k);
          	//console.log(x[i]);
          	//console.log(x[k]);
          	sum = 0;
          	for(j=0;j<x[i].length;j++){
            	sum+= Math.abs((x[i][j] - x[k][j])*(x[i][j] - x[k][j]));
            }
          	//console.log(Math.sqrt(sum));
          	//console.log(Number.isInteger(Math.sqrt(sum)));
          	if(Number.isInteger(Math.sqrt(sum)) === true){
            	counter++;
            }
        }
    }
  	console.log(counter);
  	
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  	input = input.split("\n");
  	i = 0;
  	x = [];
	counter = 0;
   for(i=0;i<input.length;i++){
      	num = input[i].split(" ");
      	littleX = [];
		for(j=0;j<num.length;j++){
          	littleX.push(num[j]);
        }
      	x.push(littleX);
    }

  	for(i=1;i<input.length;i++){
      	for(k=i+1;k<input.length;k++){
	      	//console.log("check "+i+"to"+k);
          	//console.log(x[i]);
          	//console.log(x[k]);
          	sum = 0;
          	for(j=0;j<x[i].length;j++){
            	sum+= (x[i][j] - x[k][j])*(x[i][j] - x[k][j]);
            }
          	//console.log(Math.sqrt(sum));
          	//console.log(Number.isInteger(Math.sqrt(sum)));
          	if(Number.isInteger(Math.sqrt(sum)) === true){
            	counter++;
            }
        }
    }
	console.log(counter);
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const main = (N,D,X) => {
    var count = 0

    for(var i =0;i<N;i++) {
        for(var k=i+1;k<N;k++) {
            var tmp = 0
            for(var j = 0;j<D;j++) {
                const xd = Math.abs(X[i][j] - X[k][j])
                tmp+=xd*xd
            }

            if(Number.isInteger(Math.sqrt(tmp))) {
                count++
            }
        }
    }
    return count
}




const input = require('fs').readFileSync('/dev/stdin','utf8')
                           .split("\n")
                           .filter(i => i !== '')
const lst = input.map(i => i.split(" ").map(x => Number(x)))
const N = lst[0][0]
const D = lst[0][1]
const X = lst.slice(1,lst.length)
console.log(main(N,D,X))