title: Multiply Large Integers Under Large Modulo
signature: function multiplyLargeIntegersUnderLargeModulo($a, $b, $mod_arg2) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($a, $b, $mod_arg2, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($a, $b, $mod_arg2), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        60, 24, 58, 
        48));
      
      printf("TEST-1...%s\n",driver(
        46, 43, 29, 
        6));
      
      printf("TEST-2...%s\n",driver(
        4, 50, 71, 
        58));
      
      printf("TEST-3...%s\n",driver(
        67, 1, 66, 
        1));
      
      printf("TEST-4...%s\n",driver(
        93, 35, 73, 
        43));
      
      printf("TEST-5...%s\n",driver(
        89, 97, 8, 
        1));
      
      printf("TEST-6...%s\n",driver(
        8, 78, 55, 
        19));
      
      printf("TEST-7...%s\n",driver(
        53, 73, 22, 
        19));
      
      printf("TEST-8...%s\n",driver(
        96, 92, 83, 
        34));
      
      printf("TEST-9...%s\n",driver(
        38, 64, 83, 
        25));
      
  }
  
  main();
  ?>
source_py: def multiply_large_integers_under_large_modulo(a, b, mod):
      res = 0
      a = (a % mod)
      while b:
          if (b & 1):
              res = ((res + a) % mod)
          a = ((2 * a) % mod)
          b >>= 1
      return res
source_cpp: long long multiply_large_integers_under_large_modulo(long long a, long long b, long long mod) {
    long long res = 0;
    a %= mod;
    while ( b ) {
      if ( b & 1 ) res = ( res + a ) % mod;
      a = ( 2 * a ) % mod;
      b >>= 1;
    }
    return res;
  }