title: Subsequences Size Three Array Whose Sum Divisible M
signature: subsequences_size_three_array_whose_sum_divisible_m <- function(a, n, m) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(a, n, m, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(a, n, m), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(14L, 35L, 56L, 70L, 88L), 3L, 4L, 
          0L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-50L, -92L, 16L, -68L, -36L), 3L, 4L, 
          0L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 1L, 1L, 1L), 4L, 5L, 
          1L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(76L, 43L, 22L, 41L, 49L, 99L, 25L, 40L, 3L, 45L, 60L, 16L, 83L, 62L, 26L, 93L, 64L, 73L, 72L, 53L, 6L, 32L, 35L, 67L, 17L), 14L, 21L, 
          19L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-90L, -86L, -86L, -66L, -50L, -48L, -44L, -42L, -42L, -38L, -24L, -22L, -20L, -18L, -8L, 8L, 24L, 28L, 34L, 48L, 60L, 62L, 66L, 68L, 74L, 76L, 80L, 82L, 88L), 24L, 20L, 
          207L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L), 24L, 30L, 
          120L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(4L, 5L, 8L, 9L, 10L, 12L, 13L, 16L, 17L, 18L, 21L, 21L, 25L, 27L, 28L, 30L, 36L, 36L, 54L, 55L, 56L, 57L, 60L, 62L, 67L, 67L, 68L, 71L, 72L, 72L, 73L, 73L, 77L, 77L, 83L, 86L, 86L, 86L, 87L, 89L, 92L, 92L, 96L, 97L, 97L, 98L), 24L, 23L, 
          85L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-64L, 52L, -32L, 38L, 8L, -62L, -56L, 20L, 72L, -12L, 32L, 44L), 6L, 6L, 
          2L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 12L, 15L, 
          220L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(77L, 68L, 45L, 6L, 27L, 19L, 29L, 95L, 21L, 2L, 39L, 48L, 72L, 67L, 49L, 45L, 1L, 16L, 56L, 78L, 25L, 22L, 27L, 40L, 31L, 34L, 26L, 35L, 12L), 25L, 25L, 
          92L
      )))
  
  }
  
  main()
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;
  }