title: Subsequences Size Three Array Whose Sum Divisible M
signature: function subsequencesSizeThreeArrayWhoseSumDivisibleM(a: Array<number>, n: number, m: number): number {
source_py: def subsequences_size_three_array_whose_sum_divisible_m(A, N, M):
      sum = 0
      ans = 0
      for i in range(0, N):
          for j in range((i + 1), N):
              for k in range((j + 1), N):
                  sum = ((A[i] + A[j]) + A[k])
                  if ((sum % M) == 0):
                      ans = (ans + 1)
      return ans
source_cpp: int subsequences_size_three_array_whose_sum_divisible_m(vector<int> A, int N, int M) {
    int sum = 0;
    int ans = 0;
    for ( int i = 0;
    i < N;
    i ++ ) {
      for ( int j = i + 1;
      j < N;
      j ++ ) {
        for ( int k = j + 1;
        k < N;
        k ++ ) {
          sum = A [ i ] + A [ j ] + A [ k ];
          if ( sum % M == 0 ) ans ++;
        }
      }
    }
    return ans;
  }
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"a": [14, 35, 56, 70, 88], "n": 3, "m": 4}}, {"idx": 1, "outputs": 0, "inputs": {"a": [-50, -92, 16, -68, -36], "n": 3, "m": 4}}, {"idx": 2, "outputs": 1, "inputs": {"a": [0, 0, 0, 1, 1, 1], "n": 4, "m": 5}}, {"idx": 3, "outputs": 19, "inputs": {"a": [76, 43, 22, 41, 49, 99, 25, 40, 3, 45, 60, 16, 83, 62, 26, 93, 64, 73, 72, 53, 6, 32, 35, 67, 17], "n": 14, "m": 21}}, {"idx": 4, "outputs": 207, "inputs": {"a": [-90, -86, -86, -66, -50, -48, -44, -42, -42, -38, -24, -22, -20, -18, -8, 8, 24, 28, 34, 48, 60, 62, 66, 68, 74, 76, 80, 82, 88], "n": 24, "m": 20}}, {"idx": 5, "outputs": 120, "inputs": {"a": [1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0], "n": 24, "m": 30}}, {"idx": 6, "outputs": 85, "inputs": {"a": [4, 5, 8, 9, 10, 12, 13, 16, 17, 18, 21, 21, 25, 27, 28, 30, 36, 36, 54, 55, 56, 57, 60, 62, 67, 67, 68, 71, 72, 72, 73, 73, 77, 77, 83, 86, 86, 86, 87, 89, 92, 92, 96, 97, 97, 98], "n": 24, "m": 23}}, {"idx": 7, "outputs": 2, "inputs": {"a": [-64, 52, -32, 38, 8, -62, -56, 20, 72, -12, 32, 44], "n": 6, "m": 6}}, {"idx": 8, "outputs": 220, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 12, "m": 15}}, {"idx": 9, "outputs": 92, "inputs": {"a": [77, 68, 45, 6, 27, 19, 29, 95, 21, 2, 39, 48, 72, 67, 49, 45, 1, 16, 56, 78, 25, 22, 27, 40, 31, 34, 26, 35, 12], "n": 25, "m": 25}}]
question_info.entry_cls_name: Solution
question_info.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(a: Array<number>, n: number, m: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(a, n, m),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver([14, 35, 56, 70, 88], 3, 4, 0);
    console.log(`TEST-0...${result}`);
  
    result = driver([-50, -92, 16, -68, -36], 3, 4, 0);
    console.log(`TEST-1...${result}`);
  
    result = driver([0, 0, 0, 1, 1, 1], 4, 5, 1);
    console.log(`TEST-2...${result}`);
  
    result = driver([76, 43, 22, 41, 49, 99, 25, 40, 3, 45, 60, 16, 83, 62, 26, 93, 64, 73, 72, 53, 6, 32, 35, 67, 17], 14, 21, 19);
    console.log(`TEST-3...${result}`);
  
    result = driver([-90, -86, -86, -66, -50, -48, -44, -42, -42, -38, -24, -22, -20, -18, -8, 8, 24, 28, 34, 48, 60, 62, 66, 68, 74, 76, 80, 82, 88], 24, 20, 207);
    console.log(`TEST-4...${result}`);
  
    result = driver([1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0], 24, 30, 120);
    console.log(`TEST-5...${result}`);
  
    result = driver([4, 5, 8, 9, 10, 12, 13, 16, 17, 18, 21, 21, 25, 27, 28, 30, 36, 36, 54, 55, 56, 57, 60, 62, 67, 67, 68, 71, 72, 72, 73, 73, 77, 77, 83, 86, 86, 86, 87, 89, 92, 92, 96, 97, 97, 98], 24, 23, 85);
    console.log(`TEST-6...${result}`);
  
    result = driver([-64, 52, -32, 38, 8, -62, -56, 20, 72, -12, 32, 44], 6, 6, 2);
    console.log(`TEST-7...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 12, 15, 220);
    console.log(`TEST-8...${result}`);
  
    result = driver([77, 68, 45, 6, 27, 19, 29, 95, 21, 2, 39, 48, 72, 67, 49, 45, 1, 16, 56, 78, 25, 22, 27, 40, 31, 34, 26, 35, 12], 25, 25, 92);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: subsequencesSizeThreeArrayWhoseSumDivisibleM
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js