
#!/bin/python3

import math
import os
import random
import re
import sys

N = 251
M = 51
cache = [[-1] * M for _ in range(N)]

# Complete the getWays function below.
def getWaysRecursive(n, c):
    print("start:", n, c)
    ret = cache[n][len(c)]
    if ret != -1:
        return ret

    ret = 0
    for i in range(len(c)):
        if n > c[i]:
            ret += getWaysRecursive(n-c[i], c[i:])
        elif n == c[i]:
            ret += 1
            break
        elif n < c[i]:
            break

    cache[n][len(c)] = ret
    return ret


def getWays(n, c):
    return getWaysRecursive(n, tuple(sorted(c)))


if __name__ == '__main__':

    nm = input().split()

    n = int(nm[0])

    m = int(nm[1])

    c = list(map(int, input().rstrip().split()))

    # Print the number of ways of making change for 'n' units using coins having the values given by 'c'

    ways = getWays(n, c)
    print("result:", ways)


7459aac74cb06b7e0f455481abc2b3595c7d3eef
<mask token>


def getWaysRecursive(n, c):
    print('start:', n, c)
    ret = cache[n][len(c)]
    if ret != -1:
        return ret
    ret = 0
    for i in range(len(c)):
        if n > c[i]:
            ret += getWaysRecursive(n - c[i], c[i:])
        elif n == c[i]:
            ret += 1
            break
        elif n < c[i]:
            break
    cache[n][len(c)] = ret
    return ret


def getWays(n, c):
    return getWaysRecursive(n, tuple(sorted(c)))


<mask token>

<mask token>


def getWaysRecursive(n, c):
    print('start:', n, c)
    ret = cache[n][len(c)]
    if ret != -1:
        return ret
    ret = 0
    for i in range(len(c)):
        if n > c[i]:
            ret += getWaysRecursive(n - c[i], c[i:])
        elif n == c[i]:
            ret += 1
            break
        elif n < c[i]:
            break
    cache[n][len(c)] = ret
    return ret


def getWays(n, c):
    return getWaysRecursive(n, tuple(sorted(c)))


if __name__ == '__main__':
    nm = input().split()
    n = int(nm[0])
    m = int(nm[1])
    c = list(map(int, input().rstrip().split()))
    ways = getWays(n, c)
    print('result:', ways)

<mask token>
N = 251
M = 51
cache = [([-1] * M) for _ in range(N)]


def getWaysRecursive(n, c):
    print('start:', n, c)
    ret = cache[n][len(c)]
    if ret != -1:
        return ret
    ret = 0
    for i in range(len(c)):
        if n > c[i]:
            ret += getWaysRecursive(n - c[i], c[i:])
        elif n == c[i]:
            ret += 1
            break
        elif n < c[i]:
            break
    cache[n][len(c)] = ret
    return ret


def getWays(n, c):
    return getWaysRecursive(n, tuple(sorted(c)))


if __name__ == '__main__':
    nm = input().split()
    n = int(nm[0])
    m = int(nm[1])
    c = list(map(int, input().rstrip().split()))
    ways = getWays(n, c)
    print('result:', ways)

import math
import os
import random
import re
import sys
N = 251
M = 51
cache = [([-1] * M) for _ in range(N)]


def getWaysRecursive(n, c):
    print('start:', n, c)
    ret = cache[n][len(c)]
    if ret != -1:
        return ret
    ret = 0
    for i in range(len(c)):
        if n > c[i]:
            ret += getWaysRecursive(n - c[i], c[i:])
        elif n == c[i]:
            ret += 1
            break
        elif n < c[i]:
            break
    cache[n][len(c)] = ret
    return ret


def getWays(n, c):
    return getWaysRecursive(n, tuple(sorted(c)))


if __name__ == '__main__':
    nm = input().split()
    n = int(nm[0])
    m = int(nm[1])
    c = list(map(int, input().rstrip().split()))
    ways = getWays(n, c)
    print('result:', ways)


#!/bin/python3

import math
import os
import random
import re
import sys

N = 251
M = 51
cache = [[-1] * M for _ in range(N)]

# Complete the getWays function below.
def getWaysRecursive(n, c):
    print("start:", n, c)
    ret = cache[n][len(c)]
    if ret != -1:
        return ret

    ret = 0
    for i in range(len(c)):
        if n > c[i]:
            ret += getWaysRecursive(n-c[i], c[i:])
        elif n == c[i]:
            ret += 1
            break
        elif n < c[i]:
            break

    cache[n][len(c)] = ret
    return ret


def getWays(n, c):
    return getWaysRecursive(n, tuple(sorted(c)))


if __name__ == '__main__':

    nm = input().split()

    n = int(nm[0])

    m = int(nm[1])

    c = list(map(int, input().rstrip().split()))

    # Print the number of ways of making change for 'n' units using coins having the values given by 'c'

    ways = getWays(n, c)
    print("result:", ways)

