title: Modular Exponentiation Power In Modular Arithmetic
signature: function modularExponentiationPowerInModularArithmetic(x: number, y: number, p: 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(x: number, y: number, p: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(x, y, p),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(45, 5, 68, 61);
    console.log(`TEST-0...${result}`);
  
    result = driver(67, 25, 49, 18);
    console.log(`TEST-1...${result}`);
  
    result = driver(26, 91, 44, 4);
    console.log(`TEST-2...${result}`);
  
    result = driver(33, 61, 9, 0);
    console.log(`TEST-3...${result}`);
  
    result = driver(35, 8, 13, 3);
    console.log(`TEST-4...${result}`);
  
    result = driver(68, 41, 5, 3);
    console.log(`TEST-5...${result}`);
  
    result = driver(14, 76, 20, 16);
    console.log(`TEST-6...${result}`);
  
    result = driver(5, 89, 13, 5);
    console.log(`TEST-7...${result}`);
  
    result = driver(23, 42, 45, 19);
    console.log(`TEST-8...${result}`);
  
    result = driver(37, 63, 56, 29);
    console.log(`TEST-9...${result}`);
  
  };
  
  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;
  }