title: Modular Exponentiation Power In Modular Arithmetic
signature: modular_exponentiation_power_in_modular_arithmetic <- function(x, y, p) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(x, y, p, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(x, y, p), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          45L, 5L, 68L, 
          61L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          67L, 25L, 49L, 
          18L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          26L, 91L, 44L, 
          4L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          33L, 61L, 9L, 
          0L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          35L, 8L, 13L, 
          3L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          68L, 41L, 5L, 
          3L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          14L, 76L, 20L, 
          16L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          5L, 89L, 13L, 
          5L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          23L, 42L, 45L, 
          19L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          37L, 63L, 56L, 
          29L
      )))
  
  }
  
  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;
  }