class Solution {
    public int countTriples(int n) {
        int count = 0;
        for (int i = n; i > 0; i--) {
            for (int j = i - 1; j > 0; j--) {
                int sum = i * i - j * j;
                int num = (int) Math.sqrt(sum);
                if (sum == num * num) {
                    count++;

                }
            }
        }
        return count;
    }
}
//runtime:8 ms
//memory:35.3 MB
