title: Count Distinct Non Negative Pairs X Y Satisfy Inequality Xx Yy N 2 1
signature: function countDistinctNonNegativePairsXYSatisfyInequalityXxYyN21(n: number): number {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(72, 64);
    console.log(`TEST-0...${result}`);
  
    result = driver(75, 69);
    console.log(`TEST-1...${result}`);
  
    result = driver(92, 83);
    console.log(`TEST-2...${result}`);
  
    result = driver(30, 30);
    console.log(`TEST-3...${result}`);
  
    result = driver(45, 41);
    console.log(`TEST-4...${result}`);
  
    result = driver(40, 37);
    console.log(`TEST-5...${result}`);
  
    result = driver(81, 71);
    console.log(`TEST-6...${result}`);
  
    result = driver(17, 17);
    console.log(`TEST-7...${result}`);
  
    result = driver(81, 71);
    console.log(`TEST-8...${result}`);
  
    result = driver(99, 86);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
source_py: def count_distinct_non_negative_pairs_x_y_satisfy_inequality_xx_yy_n_2_1(n):
      x = 0
      res = 0
      yCount = 0
      while ((yCount * yCount) < n):
          yCount = (yCount + 1)
      while (yCount != 0):
          res = (res + yCount)
          x = (x + 1)
          while ((yCount != 0) and (((x * x) + ((yCount - 1) * (yCount - 1))) >= n)):
              yCount = (yCount - 1)
      return res
source_cpp: int count_distinct_non_negative_pairs_x_y_satisfy_inequality_xx_yy_n_2_1(int n) {
    int x = 0, yCount, res = 0;
    for ( yCount = 0;
    yCount * yCount < n;
    yCount ++ );
    while ( yCount != 0 ) {
      res += yCount;
      x ++;
      while ( yCount != 0 && ( x * x + ( yCount - 1 ) * ( yCount - 1 ) >= n ) ) yCount --;
    }
    return res;
  }