title: Modular Exponentiation Power In Modular Arithmetic
signature: function modularExponentiationPowerInModularArithmetic($x, $y, $p) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($x, $y, $p, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($x, $y, $p), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        45, 5, 68, 
        61));
      
      printf("TEST-1...%s\n",driver(
        67, 25, 49, 
        18));
      
      printf("TEST-2...%s\n",driver(
        26, 91, 44, 
        4));
      
      printf("TEST-3...%s\n",driver(
        33, 61, 9, 
        0));
      
      printf("TEST-4...%s\n",driver(
        35, 8, 13, 
        3));
      
      printf("TEST-5...%s\n",driver(
        68, 41, 5, 
        3));
      
      printf("TEST-6...%s\n",driver(
        14, 76, 20, 
        16));
      
      printf("TEST-7...%s\n",driver(
        5, 89, 13, 
        5));
      
      printf("TEST-8...%s\n",driver(
        23, 42, 45, 
        19));
      
      printf("TEST-9...%s\n",driver(
        37, 63, 56, 
        29));
      
  }
  
  main();
  ?>
source_py: def modular_exponentiation_power_in_modular_arithmetic(x, y, p):
      res = 1
      x = (x % p)
      while (y > 0):
          if ((y & 1) == 1):
              res = ((res * x) % p)
          y = (y >> 1)
          x = ((x * x) % p)
      return res
source_cpp: int modular_exponentiation_power_in_modular_arithmetic(int x, unsigned int y, int p) {
    int res = 1;
    x = x % p;
    while ( y > 0 ) {
      if ( y & 1 ) res = ( res * x ) % p;
      y = y >> 1;
      x = ( x * x ) % p;
    }
    return res;
  }