title: Modular Exponentiation Power In Modular Arithmetic
signature: modularExponentiationPowerInModularArithmetic(x, y, p) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(x, y, p, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(x, y, p), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          45, 5, 68, 
          61)
      }");
  
      print("TEST-1...${driver(
          67, 25, 49, 
          18)
      }");
  
      print("TEST-2...${driver(
          26, 91, 44, 
          4)
      }");
  
      print("TEST-3...${driver(
          33, 61, 9, 
          0)
      }");
  
      print("TEST-4...${driver(
          35, 8, 13, 
          3)
      }");
  
      print("TEST-5...${driver(
          68, 41, 5, 
          3)
      }");
  
      print("TEST-6...${driver(
          14, 76, 20, 
          16)
      }");
  
      print("TEST-7...${driver(
          5, 89, 13, 
          5)
      }");
  
      print("TEST-8...${driver(
          23, 42, 45, 
          19)
      }");
  
      print("TEST-9...${driver(
          37, 63, 56, 
          29)
      }");
  
      return 0;
  }
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;
  }