Problem:
Sum of 4 Integers Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:   a + b + c + d = n  For example, for n = 35, we have 4 different combinations of ( a, b, c, d ): ( 8, 9, 9, 9 ), ( 9, 8, 9, 9 ), ( 9, 9, 8, 9 ), and ( 9, 9, 9, 8 ). Input The input consists of several datasets. Each dataset consists of n (1 ≤ n ≤ 50) in a line. The number of datasets is less than or equal to 50. Output Print the number of combination in a line. Sample Input 35
1 Output for the Sample Input 4
4

Solution (Python):
import sys
a=[0]*51
for i in range(19):a[i]=a[36-i]=(i+3)*(i+2)*(i+1)//6-[0,a[i-10]*4][i>9]
for e in sys.stdin:print(a[int(e)])

Solution (Python):
import sys

def ans(num):
    ans = 0

    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d == num:
                        ans += 1

    return ans


def main():
    a = []

    for line in sys.stdin:
        a.append(int(line))

    for line in a:
        print(ans(line))

if __name__ == "__main__":
    main()

Solution (Python):
while True:
    try:
        n = int(input())
    except:
        break
    x = 0
    for a in range(0, 10):
        for b in range(0, 10):
            for c in range(0, 10):
                for d in range(0, 10):
                    x += (a + b + c + d == n)
    print(x)

Solution (Python):
x = [0]*51
for a in range(10):
    for b in range(10):
        for c in range(10):
            for d in range(10):
                x[sum([a, b, c, d])] += 1
while True:
    try:
        print(x[int(input())])
    except:
        break

Solution (Python):
ans=[0]*51
for a in range(10):
	for b in range(10):
		for c in range(10):
			for d in range(10):
				ans[sum([a,b,c,d])] += 1 
while True:
	try:print(ans[int(input())])
	except:break

Solution (Python):
import sys

lines = sys.stdin.readlines()
for line in lines:
    a = int(line)
    sets = 0
    for i in range(0, 10):
        for k in range(0, 10):
            for l in range(0, 10):
                for m in range(0, 10):
                    if(i+k+l+m == a):
                        sets += 1
    print(sets)

Solution (Python):
import itertools
while True:
	try: n=int(input())
	except EOFError: break
	ans=0
	for (i,j,k) in itertools.product(range(10),range(10),range(10)):
		ans+=(0<=n-(i+j+k)<=9)
	print(ans)

Solution (Python):

import math 
import sys
     
for line in sys.stdin:
    N = int(line.rstrip())
    count = 0
    for a in range(10):
       for b in range(10):
          for c in range(10):
             for d in range(10):
                 if sum([a,b,c,d]) == N:
                     count += 1
                     break
    print(count)

Solution (Python):
import sys
a=[0]*51
for i in range(19):a[i]=a[36-i]=(i+3)*(i+2)*(i+1)//6-a[i-10]*4*(i>9)
for e in sys.stdin:print(a[int(e)])

Solution (Python):
import sys
a=[0]*51
for i in range(19):a[i]=a[36-i]=(i+3)*-~-~i*-~i//6-a[i-10]*4*(i>9)
for e in sys.stdin:print(a[int(e)])

Solution (Python):
import sys
a=[0]*51
for i in range(19):a[i]=a[36-i]=(i+3)*-~-~i*-~i//6-a[i-10]*4*(i>9)
for e in sys.stdin:print(a[int(e)])

Solution (Python):
def count_combinations(n, d):
    if d == 0:
        if n == 0:
            return 1
        else:
            return 0
    else:
        r = 0
        for i in range(0, 10):
            r += count_combinations(n - i, d - 1)
        return r

while True:
    try:
        n = input()
        print count_combinations(n, 4)
    except EOFError:
        break

Solution (Python):
while True:
  try:
    n = int(input())
    count = 0
    for a in range(10):
      for b in range(10):
        for c in range(10):
          for d in range(10):
            if a + b + c + d == n:
              count += 1
    print(count)
  except EOFError:
    break

Solution (Python):
while True:
    try:
        r = int(input())

        count = 0

        for x in range(10):
            for y in range(10):
                for z in range(10):
                    for w in range(10):
                        if x + y + z + w == r:
                            count += 1
        print(count)
        
    except EOFError:
        break

Solution (Python):
lst=[0 for i in range(51)]
for a in range(10):
    for b in range(10):
        for c in range(10):
            for d in range(10):
                lst[a+b+c+d] += 1
while 1:
    try:
        print(lst[int(input())])
    except:
        break

Solution (Python):
import itertools

c=list(itertools.product(range(10),repeat=4))

while True:
	try:
		n=input()
		cnt=0
		for i in c:
			if sum(i)==n:
				cnt+=1
		print cnt

	except EOFError:
		break

Solution (Python):
import sys
[print([670, 660, 633, 592, 540, 480, 415, 348, 282, 220, 165, 120, 84, 56, 35, 20, 10, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][abs(18 - int(e))]) for e in sys.stdin]

Solution (Python):
import sys
d = [sum((10 - abs(9 - i)) * (10 - abs(9 + i - j)) for i in range(j + 1)) for j in range(19)[:: -1]] + [0] * 14
[print(d[abs(18 - int(e))]) for e in sys.stdin]

Solution (Python):
import sys
d=[sum((10-abs(9-i))*(10-abs(9+i-j))for i in range(j+1))for j in range(19)[::-1]]+[0]*14
[print(d[abs(18-int(e))])for e in sys.stdin]

Solution (Python):
while True:
    try:
        N = int(input())
        count = 0
        for a in range(10):
            for b in range( 10):
                for c in range(10):
                    for d in range(10):
                        if a + b + c + d == N:
                            count += 1
        print(count)
    except EOFError:
        break

Solution (Python):
while True:
    try:
        N = int(input())
        count = 0
        for a in range(10):
            for b in range( 10):
                for c in range(10):
                    for d in range(10):
                        if a + b + c + d == N:
                            count += 1
        print(count)
    except EOFError:
        break

Solution (Python):
import sys
for line in sys.stdin:
    count = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                if 0 <= int(line) - (a + b + c) <= 9:
                    count += 1
    print(count)

Solution (Python):
import sys
def sum_n(n):
    if n>36:return 0
    return sum([1 for i in range(10) for j in range(10) for k in range(10) for l in range(10) if i+j+k+l==n])
    
[print(sum_n(i)) for i in [int(line) for line in sys.stdin]]

Solution (Python):
a = []
while True:
    try:
        a.append(int(input()))
    except EOFError:
        break
for i in a:
    frag = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a + b + c + d == i:
                        frag += 1
    print(frag)

Solution (Python):



ans = [0 for i in range(51)]
for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				ans[i+j+k+l] += 1


	
while True:
    try:
        print(ans[int(input())])
    except EOFError:
        break

Solution (Python):
while True:
    try:
        n=int(input())
    except:
        break
    s=0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d==n:
                        s+=1
    print(s)

Solution (Python):
import sys
from itertools import combinations_with_replacement as comb

def get_nums(n, pos):
    N = [1 for _ in range(n)]
    a = sum(N[:pos[0]])
    b = sum(N[pos[0]:pos[1]])
    c = sum(N[pos[1]:pos[2]])
    d = sum(N[pos[2]:])
    if a > 9 or b > 9 or c > 9 or d > 9:
        return None
    return (a,b,c,d)

def run():
    for _n in sys.stdin:
        n = int(_n)
        probs = [get_nums(n, p) for p in comb(range(n+1), 3)]
        probs = [p for p in probs if p != None]
        print(len(probs))

if __name__ == '__main__':
    run()

Solution (Python):
import sys
 
def ans(num):
    ans = 0
 
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d == num:
                        ans += 1
 
    return ans
 
 
def main():
    a = []
 
    for line in sys.stdin:
        a.append(int(line))
 
    for line in a:
        print(ans(line))
 
if __name__ == "__main__":
    main()

Solution (Python):
import sys
  
def ans(num):
    ans = 0
  
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d == num:
                        ans += 1
  
    return ans
  
  
def main():
    a = []
  
    for line in sys.stdin:
        a.append(int(line))
  
    for line in a:
        print(ans(line))
  
if __name__ == "__main__":
    main()

Solution (Python):
import sys
  
def ans(num):
    ans = 0
  
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d == num:
                        ans += 1
  
    return ans
  
  
def main():
    a = []
  
    for line in sys.stdin:
        a.append(int(line))
  
    for line in a:
        print(ans(line))
  
if __name__ == "__main__":
    main()

Solution (Python):
while True:
    try:
        n = int(raw_input())
        
        cnt = 0;
        for i in range(0, 10):
            for j in range(0, 10):
                for k in range(0, 10):
                    for l in range(0, 10):
                        if n == i+j+k+l: cnt+=1
        print cnt

    except EOFError:
        break

Solution (Python):
while True: 
  try:
    n=0
    x = int(input())
    for a in range(10):
      for b in range(10):
        for c in range(10):
          for d in range(10):
           if a+b+c+d == x:  n += 1


    print n
  except EOFError:
    break

Solution (Python):
ans = []
while True:
    try:
        n = input()
    except EOFError:
        break
    if n == 0 or n >= 37:
        ans.append(0)
    else:
        count = 0
        for a in range(0,10):
            for b in range(0,10):
                for c in range(0,10):
                    for d in range(0,10):
                        if a+b+c+d == n:
                            count += 1
        ans.append(count)

for i in ans:
    print i

Solution (Python):
import sys

for s in sys.stdin:
    a = (int)(s)
    c = 0
    for i in range(0,10):
        for j in range(0,10):
            for k in range(0,10):
                for l in range(0,10):
                    if i + j + k + l == a:
                        c += 1
    print c

Solution (Python):
import sys

def search(n):
    result = list()
    for a in xrange(10):
        for b in xrange(10):
            for c in xrange(10):
                if a + b + c <= n:
                    if n - (a+b+c) < 10:
                        result.append([a, b, c, n - (a+b+c)])
                    else:
                        pass
                else:
                    pass
    return len(result)

for line in sys.stdin.readlines():
    line = line.strip()
    n = int(line)
    print search(n)

Solution (Python):

while True:
    try:
        n = int(raw_input())
        case = 0
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if a + b + c + d == n:
                            case += 1
        print(case)
    except EOFError:
        break

Solution (Python):
def keta_sum(n):
	a = int(n*0.001)
	b = int(n*0.01) % 10
	c = int(n*0.1) % 10
	d = n % 10
	return a+b+c+d

while 2>1:
	try:
		n_try = int(raw_input())
		count = 0
		for n in range(10000):
			if n_try == keta_sum(n):
				count += 1
		print count
	except EOFError:
		break
	except ValueError:
		break

Solution (Python):


while True:
    try:
        n = int(raw_input())

        count=0

        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if a+b+c+d==n:
                            count+=1

        print count

    except Exception:
        break

Solution (Python):
import sys
for x in sys.stdin.readlines():
    n=int(x)
    if(n>36):
        n=0
    elif(n>18):
        n=38-n
    else:
        n=n+2

    if(n>11):
        m=n-10
    else:
        m=0
    print (n**3-n-4*(m**3)+4*m)/6

Solution (Python):
import sys
for i in sys.stdin.readlines():
    n=int(i)
    m=0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d==n:
                        m=m+1
    print m

Solution (Python):
while 1:
    try:
        n = input()
        c = 0
        if n < 37:
            for i in range(10):
                for j in range(10):
                    for k in range(10):
                        for l in range(10):
                            if i+j+k+l == n:
                                c += 1
        print c
    except EOFError:
        break

Solution (Python):


while True:
    try:
        x = input()
        
        
        count = 0
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if a+b+c+d == x :
                            count += 1
        
        print count

    except EOFError:
        break

Solution (Python):
import sys
def dfs(a,b):
    if a==0:return 1
    if b==0 or a < 0:return 0
    return sum([dfs(a-i,b-1) for i in xrange(10)])
for line in sys.stdin.readlines():
    print dfs(int(line.strip()),4)

Solution (Python):
import sys
table={}
def dfs(a,b):
    global table
    if not a in table:
        if a==0:return 1
        elif b==0 or a < 0:return 0
        table[(a,b)]=sum([dfs(a-i,b-1) for i in xrange(10)])
    return table[(a,b)]
for i in sys.stdin.readlines():
    print dfs(int(i.strip()),4)

Solution (Python):
import sys
def dfs(a,b):
    if a==0:return 1
    elif b==0 or a < 0:return 0
    return sum([dfs(a-i,b-1) for i in xrange(10)])
for line in sys.stdin.readlines():
    print dfs(int(line.strip()),4)

Solution (Python):
import sys
table={}
def memorize(f):
    global table
    def func(*args):
        if not args in table:
            table[args]=f(*args)
        return table[args]
    return func
@memorize
def dfs(a,b):
    if a==0:return 1
    elif b==0 or a < 0:return 0
    return sum([dfs(a-i,b-1) for i in xrange(10)])
for i in sys.stdin.readlines():
    print dfs(int(i.strip()),4)

Solution (Python):
import sys
table={}
def dfs(a,b):
    global table
    if not (a,b) in table:
        if a==0:return 1
        elif b==0 or a < 0:return 0
        table[(a,b)]=sum([dfs(a-i,b-1) for i in xrange(10)])
    return table[(a,b)]
for i in sys.stdin.readlines():
    print dfs(int(i.strip()),4)

Solution (Python):




def count_pattern(i):
    n = 0
    for a in xrange(10):
        for b in xrange(10):
            for c in xrange(10):
                for d in xrange(10):
                    if (a + b + c + d) == i:
                        n += 1
    return n


def main():
    while 1:
        try:
            s = raw_input()
        except EOFError:
            return
        print count_pattern(int(s))


if __name__ == '__main__':
    main()

Solution (Python):
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    count = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a + b + c + d == n:
                        count += 1
    print count

Solution (Python):
while True:
    try:
        n = int(raw_input())
        print len([(a,b,c,d) for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == n])
    except (EOFError):
        break

Solution (Python):
import sys
table={}
def dfs(a,b):
    global table
    if not (a,b) in table:
        if a==0:return 1
        elif b==0 or a < 0:return 0
        table[(a,b)]=sum([dfs(a-i,b-1) for i in xrange(10)])
    return table[(a,b)]
for i in sys.stdin.readlines():
    print dfs(int(i.strip()),4)

Solution (Python):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
for line in stdin:
    n = int(line)
    cnt = 0
    for a in xrange(10):
        if n < a:
            break
        for ab in xrange(a, a + 10):
            if n < ab:
                break
            for abc in xrange(ab, ab + 10):
                if n < abc:
                    break
                for abcd in xrange(abc, abc + 10):
                    if n == abcd:
                        cnt += 1
                        break
                    if n < abcd:
                        break
    print(cnt)

Solution (Python):
import sys
def f(x,n):return sum([f(x-i,n-1) for i in range(10)]) if n else x==0
for r in iter(sys.stdin.readline,""):print f(int(r),4)

Solution (Python):
'''
Created on Mar 11, 2013

@author: wukc
'''
import sys
import itertools


for l in sys.stdin:
    n=int(l)
    cnt=0
    for x,y,z in itertools.product(range(10),repeat=3):
        if n-(x+y+z) in range(10): cnt+=1
    print cnt

Solution (Python):
while True:
	try:
		list = []
		for a in xrange(10):
			for b in xrange(10):
				for c in xrange(10):
					for d in xrange(10):
						list.append(a+b+c+d)
		print list.count(input())
	except: break

Solution (Python):
while True:
	try:
		list = []
		for a in xrange(10):
			for b in xrange(10):
				for c in xrange(10):
					for d in xrange(10):
						list.append(a+b+c+d)
		print list.count(input())
	except: break

Solution (Python):
import sys
def f(x,n):
    return sum([f(x-i,n-1) for i in range(10)]) if n else x==0
for n in sys.stdin:
    print f(int(n),4)

Solution (Python):
while True:
    try:
        a = raw_input()
        count = 0
        for i in range(10):
            for j in range(10):
                for k in range(10):
	            for l in range(10):
                        b = i+j+k+l
			if b == int(a):
                            count += 1
	print count
    except EOFError:
	break

Solution (Python):
import sys


def foo(n):
    ts = [(a,b,c,d) for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == n]
    return len(ts)





for line in sys.stdin:
    n = int(line)
    print foo(n)

Solution (Python):
import itertools

try :
  while True :
    n = int(raw_input())

    c = 0
    for x in itertools.product(range(10), repeat=4) :
      if sum(x) == n :
        c += 1
    print c

except EOFError :
  pass

Solution (Python):
while True:
    try:
        n = input()
        a = xrange(10)
        print [i+j+k+l for i in a for j in a for k in a for l in a].count(n)
    except:
        break

Solution (Python):
import sys


for line in sys.stdin:
    n = int(line)
    ret = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                tmp = n - a - b - c
                if tmp < 0:
                    break
                if tmp <= 9:
                    ret += 1
    print ret

Solution (Python):
while (True):
    try:
        n=input()
    except:
        break
    count=0
    for i1 in range(10):
        n1=n-i1
        if n1<0 or n1>27: continue
        for i2 in range(10):
            n2=n1-i2
            if n2<0 or n2>18: continue
            for i3 in range(10):
                n3=n2-i3
                if n3<0 or n3>9: continue
                count+=1
    print count

Solution (Python):
import itertools

while True:
    try:
        n = int(raw_input())
        c = 0
        for a in itertools.product(range(10), repeat=4):
            if sum(a) == n:
                c += 1
        print c
    except EOFError:
        break

Solution (Python):


import sys

datas = []

for line in sys.stdin:
	datas.append(int(line))

for data in datas:
	count = 0
	for a in xrange(10):
		for b in xrange(10):
			for c in xrange(10):
				for d in xrange(10):
					if data == a + b + c + d:
						count += 1
	print count

Solution (Python):
while 1:
        try:
                n = input()
        except EOFError:
                break

        x = 0
        for a in range(10):
                for b in range(10):
                        for c in range(10):
                                for d in range(10):
                                        if a+b+c+d == n:
                                                x += 1
        print x

Solution (Python):
import sys

def countSumOf(vNum, n):
    if n < 0 or vNum * 9 < n: return 0
    if vNum == 1: return 1
    
    result = 0
    for x in range(10):
        result += countSumOf(vNum-1, n-x)
    return result

for line in sys.stdin:
    n = int(line)
    print countSumOf(4, n)

Solution (Python):
import sys

for line in sys.stdin:
	r = 0
	n = int(line)
	for i in range(10):
		for j in range(10):
			for k in range(10):
				for l in range(10):
					if i+j+k+l == n:
						r += 1
	print(r)

Solution (Python):
import sys
import itertools

for s in sys.stdin:
	input = int(s)
	sum = 0
	for i,j,k,l in itertools.product(xrange(0, 10), repeat=4):
		if i + j + k + l == input:
			sum += 1
	print sum

Solution (Python):
import sys
import itertools

for s in sys.stdin:
	input = int(s)
	cnt = 0
	for i in itertools.product(xrange(10), repeat=4):
		if sum(i) == input:
			cnt += 1
	print cnt

Solution (Python):
import sys
import itertools

for s in sys.stdin:
	input = int(s)
	cnt = 0
	for i in itertools.product(range(10), repeat=4):
		if sum(i) == input:
			cnt += 1
	print cnt

Solution (Python):
import sys
import itertools

for s in sys.stdin:
	input = int(s)
	cnt = 0
	for i in itertools.product(xrange(10), repeat=4):
		if sum(i) == input:
			cnt += 1
	print cnt

Solution (Python):
import sys

nums = []
count = 0

for num in sys.stdin:
	nums.append(int(num))

for num in nums:
	for a in range(0, 10):
		for b in range(0, 10):
			for c in range(0, 10):
				for d in range(0, 10):
					if a+b+c+d == num:
						count += 1
	print count
	count = 0

Solution (Python):
while 1:
	try:
		n = input()
		x = 0
		if n < 37:
			for a in range(10):
				for b in range(10):
					for c in range(10):
						for d in range(10):
							if a + b + c + d == n:
									x += 1
		print x
	except EOFError:
		break

Solution (Python):
import sys,itertools
for n in map(int,sys.stdin):
  x=0
  for num in itertools.product("0123456789",repeat=4):
    eq="{}+{}+{}+{}".format(*(num))
    if eval(eq)==n:x+=1
  print x

Solution (Python):
import sys
A=range(10)
for n in map(int,sys.stdin):
  x=0
  for a in A:
    d=n-a
    if 0>d or d>27:continue
    for b in A:
      e=d-b
      if 0>e or e>18:continue
      for c in A:
        if (e-c)in A:x+=1
  print x

Solution (Python):
import sys
def f(a,b):
  A=range(10)
  if b==1:x=1 if a in A else 0
  else:x=sum([f(a-e,b-1)for e in A])
  return x
for n in map(int,sys.stdin):
  print f(n,4)

Solution (Python):
import sys
def f(a,b):
  A=range(10)
  if b==1:x=1 if a in A else 0
  elif a<0 or a>b*9:x=0
  else:x=sum([f(a-e,b-1)for e in A])
  return x
for n in map(int,sys.stdin):
  print f(n,4)

Solution (Python):
import sys
def f(a,b):
  c=b*9-9
  A=range(10)
  if b==1:x=1 if a in A else 0
  else:x=sum([f(a-e,b-1)for e in A if 0<=a-e<=c])
  return x
for n in map(int,sys.stdin):print f(n,4)

Solution (Python):
import sys
def f(a,b,c):
  if b==1:x=1 if 0<=a<=9 else 0
  else:x=sum([f(a-e,b-1,c-9)for e in range(10) if 0<=a-e<=c])
  return x
for n in map(int,sys.stdin):print f(n,4,3*9)

Solution (Python):
import sys
def f(a,b,c):
  if b==1:return 1
  x=sum([f(a-e,b-1,c-9)for e in range(min(a+1,10))if a-e<=c])
  return x
for n in map(int,sys.stdin):print f(n,4,3*9)

Solution (Python):
import sys
def f(a,b,c):
  if b==1:return 1
  x=sum([f(a-e,b-1,c-9)for e in range(max(a-c,0),min(a+1,10))])
  return x
for n in map(int,sys.stdin):print f(n,4,3*9)

Solution (Python):
import sys
def f(a,b,c):
  if b==1:return 1
  x=sum([f(e,b-1,c-9)for e in range(max(0,a-9),min(a,c)+1)])
  return x
for n in map(int,sys.stdin):print f(n,4,3*9)

Solution (Python):
import sys
def f(a,b):
  if b==1:return 1
  b-=1
  A=range(max(0,a-9),min(a,b*9)+1)
  x=sum([f(e,b)for e in A])
  return x
for n in map(int,sys.stdin):print f(n,4)

Solution (Python):
import sys
def f(a,b,c):
  if b==1:return 1
  x=sum([f(e,b-1,c-9)for e in range(max(0,a-9),min(a,c)+1)])
  return x
for n in sys.stdin:print f(int(n),4,3*9)

Solution (Python):
import sys

for i in sys.stdin:
    i=int(i)
    count =0
    for a in range(9,-1,-1):
        k=i-a
        if(k==0):
            count+=1            
        if(k>0):
            for b in range(9,-1,-1):
                l=k-b
                if(l==0):
                    count+=1
                if(l>0):
                    for c in range(9,-1,-1):
                        m=l-c
                        if(m==0):
                            count+=1                            
                        if(m>0):
                            for d in range(9,-1,-1):
                                if(m-d==0):
                                    count+=1
                            
    print count

Solution (Python):


import sys

def mCn(m, n):
    ret = 1
    for i in xrange(n):
        ret *= m - i
        ret /= i + 1
    return ret


for line in sys.stdin.readlines():
    List = map(int, line.strip().split())

    n = List[0]

    ans = 0
    for i in xrange(10000):
        a = i / 1000; i %= 1000
        b = i / 100 ; i %= 100
        c = i / 10  ; i %= 10
        d = i
        if(a + b + c + d == n):
            ans += 1

    print ans

Solution (Python):
while True:
    try:
        n = int(raw_input())
        count = 0
        for i in range(10):
           for j in range(10):
                for k in range(10):
                    for l in range(10):
                         if i+j+k+l == n:
                             count += 1
        print count
    except:
        break

Solution (Python):
import sys
for n in sys.stdin: print len([None for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == int(n)])

Solution (Python):
def four_nums(n, ans, nums):
	if len(nums) == 4:
		if sum(nums) == n:
			return ans + 1
		else:
			return ans
	for i in range(10):
		nums.append(i)
		if sum(nums) <= n: ans = four_nums(n, ans, nums)
		nums.pop()
	return ans

while True:
	try:
		n = input()
		print four_nums(n, 0, [])
	except:
		break

Solution (Python):
import itertools
import sys
s=range(0,10)
chk=list(itertools.product(s,repeat=4))
for j in sys.stdin:
    ans=0
    for k in chk:
        if sum(k)==int(j):
            ans+=1
    print ans

Solution (Python):
import sys


def countPair(n):
    count = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                    if (i + j + k + l) == n:
                        count += 1
    return count


for line in sys.stdin:
    n = int(line)
    print countPair(n)

Solution (Python):
from itertools import product

while 1:
    try:
        n = input()
        print len([1 for x in product(range(10), repeat=4) if sum(x) == n])
    except:
        break

Solution (Python):
memo = [[None for i in range(51)] for j in range(5)]
memo[0][0] = 1
for i in range(1, 51):
    memo[0][i] = 0


def f(n, sm):
    if memo[n][sm] is not None:
        return memo[n][sm]
    memo[n][sm] = 0
    for i in range(min(10, sm + 1)):
        memo[n][sm] += f(n - 1, sm - i)
    return memo[n][sm]

try:
    while True:
        print f(4, int(raw_input()))
except:
    pass

Solution (Python):
def mlist(n, *args, **keys):
    if len(args) == 0:
        return [keys.get('default')] * n
    else:
        return [mlist(*args, **keys) for i in range(n)]


def f(n, sm):
            if n == 0:
                return int(sm == 0)
            if memo[n][sm] is not None:
                return memo[n][sm]
            memo[n][sm] = 0
            for i in range(min(10, sm + 1)):
                memo[n][sm] += f(n - 1, sm - i)
            return memo[n][sm]

try:
    memo = mlist(5, 51)
    while True:
        print f(4, int(raw_input()))
except EOFError:
    pass

Solution (Python):
import sys

x = [0]*51
for i in range(0, 10):
  for j in range(0, 10):
    for k in range(0, 10):
      for l in range(0, 10):
        x[i+j+k+l] += 1

for s in sys.stdin:
  print x[int(s)]

Solution (Python):
while True:
	try:
		ans = 0
		n = int(raw_input())
		for i in xrange(10):
			for j in xrange(10):
				for k in xrange(10):
					for l in xrange(10):
						if i+j+k+l == n:
							ans += 1
		print ans
	except EOFError:
		break

Solution (Python):
from itertools import product

while True:
    try:
        n = int(input())
    except:
        break

    count = sum(a+b+c+d == n for a, b, c, d in product(range(10), repeat=4))
    print(count)

Solution (Python):
while True:
    try:
        n = int(input())
    except EOFError:
        break
    answer = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d == n:
                        answer += 1
    print(answer)

Solution (Python):
import itertools
A = list(range(10))
A_sum = []
A_pair = list(itertools.product(A,repeat=4))
for i in range(len(A_pair)):
    A_sum.append(sum(A_pair[i]))

while True:
    try:
        n = int(input())
    except:
        break
    if 36<n:
        print(0)
    else:
        print(A_sum.count(n))

Solution (Python):
while True:
    try:
        n = int(input())
    except:
        break
    ans = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                d = n - (a + b + c)
                ans += 0 <= d <= 9
    print(ans)

Solution (Python):
while True:
    try:
        n = int(input())
    except:
        break
    ans = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                d = n - (a + b + c)
                ans += 0 <= d <= 9
    print(ans)

Solution (Python):
while True:
    cnt = 0
    try:
        n = int(input())
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if a+b+c+d==n:
                            cnt+=1
        print(cnt)
    except:
        break

Solution (Python):
while True:
    try:
        n = int(input())
        if n > 18:
            n = 36 - n

        ans = (n+1)*(n+2)*(n+3)/6
        if n >= 10:
            n = n - 10
            ans = ans - 2*(n+1)*(n+2)*(n+3)/3
        
        if n < 0:
            ans = 0

        print(int(ans))

    except EOFError:
        break

Solution (Python):

import math

errerN=1

while errerN:
    try:
        r=int(input())
        p=0
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if a+b+c+d==r:
                            p+=1
        print(p)
    except :
        errerN=0

Solution (Python):
while True :
    try :
        n = int(input())
    except EOFError :
        break
    
    cnt = 0
    for a in range(10) :
        for b in range(10) :
            for c in range(10) :
                for d in range(10) :
                    if a + b + c + d == n :
                        cnt += 1
    print(cnt)

Solution (Python):
while True:
    try:
        s=int(input())
        result=0
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    for l in range(10):
                        if i+j+k+l==s:
                            result+=1
        print(result)   
    except EOFError:
        break