title: Subset Sum Divisible M
signature: def subset_sum_divisible_m(arr, n, m):
source_py: def subset_sum_divisible_m(arr, n, m):
      if (n > m):
          return True
      DP = [False for i in range(m)]
      for i in range(n):
          if DP[0]:
              return True
          temp = [False for i in range(m)]
          for j in range(m):
              if (DP[j] == True):
                  if (DP[((j + arr[i]) % m)] == False):
                      temp[((j + arr[i]) % m)] = True
          for j in range(m):
              if temp[j]:
                  DP[j] = True
          DP[(arr[i] % m)] = True
      return DP[0]
source_cpp: bool subset_sum_divisible_m(vector<int> arr, int n, int m) {
    if ( n > m ) return true;
    bool DP [ m ];
    memset ( DP, false, m );
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( DP [ 0 ] ) return true;
      bool temp [ m ];
      memset ( temp, false, m );
      for ( int j = 0;
      j < m;
      j ++ ) {
        if ( DP [ j ] == true ) {
          if ( DP [ ( j + arr [ i ] ) % m ] == false ) temp [ ( j + arr [ i ] ) % m ] = true;
        }
      }
      for ( int j = 0;
      j < m;
      j ++ ) if ( temp [ j ] ) DP [ j ] = true;
      DP [ arr [ i ] % m ] = true;
    }
    return DP [ 0 ];
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr, n, m, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, n, m),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([2, 5, 7, 12, 13, 13, 15, 18, 20, 21, 22, 26, 27, 41, 41, 50, 53, 57, 58, 58, 61, 62, 62, 64, 70, 75, 78, 79, 81, 81, 81, 83, 86, 91, 93, 95, 97, 99, 99], 36, 35, True)
      print(f"TEST-0...{result}")
  
      result = driver([8, 16, 62, -24, 14, -4, 2, 50, -64, -76, 78, 66, -64, 18], 12, 11, True)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 32, 27, True)
      print(f"TEST-2...{result}")
  
      result = driver([50, 20, 79, 42, 85, 24, 20, 76, 36, 88, 40, 5, 24, 85, 7, 19, 43, 51, 94, 13, 53, 93, 92, 43, 97, 38, 80, 48, 52, 47, 77, 56, 41, 80, 32, 34, 77, 14, 70, 3], 29, 27, True)
      print(f"TEST-3...{result}")
  
      result = driver([-96, -94, -72, -58, -48, -36, -28, -26, -10, -10, -8, -8, -6, 2, 14, 30, 30, 54, 58, 60, 64, 68, 78, 84, 96, 98], 16, 18, True)
      print(f"TEST-4...{result}")
  
      result = driver([1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0], 7, 8, True)
      print(f"TEST-5...{result}")
  
      result = driver([2, 7, 8, 15, 18, 23, 24, 25, 27, 35, 40, 42, 43, 46, 48, 50, 53, 64, 66, 69, 70, 71, 72, 77, 78, 80, 81, 81, 81, 82, 82, 82, 84, 87, 97, 98], 23, 32, True)
      print(f"TEST-6...{result}")
  
      result = driver([46, 54, 24, -10], 3, 3, True)
      print(f"TEST-7...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1], 21, 34, True)
      print(f"TEST-8...{result}")
  
      result = driver([39, 21, 38, 6, 38, 44, 96, 1, 16, 1, 28, 4, 55, 8], 12, 11, True)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: subset_sum_divisible_m
question_info.test_list: [{"idx": 0, "outputs": true, "inputs": {"arr": [2, 5, 7, 12, 13, 13, 15, 18, 20, 21, 22, 26, 27, 41, 41, 50, 53, 57, 58, 58, 61, 62, 62, 64, 70, 75, 78, 79, 81, 81, 81, 83, 86, 91, 93, 95, 97, 99, 99], "n": 36, "m": 35}}, {"idx": 1, "outputs": true, "inputs": {"arr": [8, 16, 62, -24, 14, -4, 2, 50, -64, -76, 78, 66, -64, 18], "n": 12, "m": 11}}, {"idx": 2, "outputs": true, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 32, "m": 27}}, {"idx": 3, "outputs": true, "inputs": {"arr": [50, 20, 79, 42, 85, 24, 20, 76, 36, 88, 40, 5, 24, 85, 7, 19, 43, 51, 94, 13, 53, 93, 92, 43, 97, 38, 80, 48, 52, 47, 77, 56, 41, 80, 32, 34, 77, 14, 70, 3], "n": 29, "m": 27}}, {"idx": 4, "outputs": true, "inputs": {"arr": [-96, -94, -72, -58, -48, -36, -28, -26, -10, -10, -8, -8, -6, 2, 14, 30, 30, 54, 58, 60, 64, 68, 78, 84, 96, 98], "n": 16, "m": 18}}, {"idx": 5, "outputs": true, "inputs": {"arr": [1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0], "n": 7, "m": 8}}, {"idx": 6, "outputs": true, "inputs": {"arr": [2, 7, 8, 15, 18, 23, 24, 25, 27, 35, 40, 42, 43, 46, 48, 50, 53, 64, 66, 69, 70, 71, 72, 77, 78, 80, 81, 81, 81, 82, 82, 82, 84, 87, 97, 98], "n": 23, "m": 32}}, {"idx": 7, "outputs": true, "inputs": {"arr": [46, 54, 24, -10], "n": 3, "m": 3}}, {"idx": 8, "outputs": true, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1], "n": 21, "m": 34}}, {"idx": 9, "outputs": true, "inputs": {"arr": [39, 21, 38, 6, 38, 44, 96, 1, 16, 1, 28, 4, 55, 8], "n": 12, "m": 11}}]
question_info.entry_cls_name: Solution