title: Count Distinct Non Negative Pairs X Y Satisfy Inequality Xx Yy N 2 1
signature: countDistinctNonNegativePairsXYSatisfyInequalityXxYyN21 :: Integer -> Integer
  countDistinctNonNegativePairsXYSatisfyInequalityXxYyN21 n = 
test_code: import Text.Printf
  import Control.Exception (catch, SomeException)
  import Data.Typeable
  import qualified Data.List as List
  import qualified Data.Map as Map
  import qualified Data.Set as Set
  
  -- SOLUTION CODE
  -- ============================================
  
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  validateSolution :: Integer -> Integer -> Bool
  validateSolution actual expected = do
      actual == expected
  
  
  driver :: Integer -> Integer -> String
  driver n expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME n) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver (72) (64) )
  
      printf "TEST-1...%s\n" (driver (75) (69) )
  
      printf "TEST-2...%s\n" (driver (92) (83) )
  
      printf "TEST-3...%s\n" (driver (30) (30) )
  
      printf "TEST-4...%s\n" (driver (45) (41) )
  
      printf "TEST-5...%s\n" (driver (40) (37) )
  
      printf "TEST-6...%s\n" (driver (81) (71) )
  
      printf "TEST-7...%s\n" (driver (17) (17) )
  
      printf "TEST-8...%s\n" (driver (81) (71) )
  
      printf "TEST-9...%s\n" (driver (99) (86) )
  
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;
  }