void backTrace(const vector<int> &nums, vector<bool> &used, int counter, int num_edge, int &max_value, int current_sum) {
if(num_edge == 3) {
num_edge = 0;
counter ++;
current_sum = 0;
max_value = std::max(counter, max_value);
}
int n = nums.size();
for(int i = 0; i < n; ++i) {
if(!used[i] &&(num_edge < 2 || (num_edge == 2 && current_sum == nums[i]))) {
used[i] = true;
backTrace(nums, used, counter, num_edge + 1, max_value, current_sum + nums[i]);
used[i] = false;
}
}
}
int rightTriangle(vector<int> &nums) {
int n = nums.size();
vector<bool> used(n, false);
for(int i = 0; i < n; ++i) {
nums[i] = nums[i] *nums[i];
}
int max_value = INT_MIN;
backTrace(nums, used, 0, 0, max_value, 0);
return max_value;
}