先找出规律,然后用factorial来解

import math
while True:
    try:
        n,m=map(int, input().split())
        print(math.factorial(n+m)//(math.factorial(n)*math.factorial(m)))
    except:
        break