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):
while True:
    try:
        n=int(input())
        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==n:ans+=1
        print(ans)
    except:break

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

Solution (Python):
while True:
	try:
		n = int(input())
	except EOFError:
		break
	ret=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:
						ret+=1
	print(ret)

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

Solution (Python):
try:
    while True:
        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:
    pass

Solution (Python):
import sys

x = [0]*51
for a in xrange(0,10):
  for b in xrange(0,10):
    for c in xrange(0,10): 
      for d in xrange(0,10):
        x[a+b+c+d]+=1
for i in sys.stdin:
  print x[int(i)]

Solution (Python):


from itertools import product

if __name__ == "__main__":
    while True:
        try:
            col = 0
            n = int(input())
            
            if n > 36:
                print(0)
            else:
                for a, b, c, d in product(range(0, 10), repeat=4):
                    if a + b + c + d == n:
                        col += 1
                    else:
                        pass
                print(col)

        except EOFError:
            break  

pass

Solution (Python):
while(True):
    try:
        ans = 0
        n = input()
        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):
                            ans += 1
        print(ans)
    except Exception:
        break

Solution (Python):
while True:
	ans = 0
	try:
		n = input()
		
	except (EOFError):
		break
	
	for a in range(10):
		atmp = n - a
		if(-1 < atmp and atmp<28):
			for b in range(10):
				btmp = atmp - b
				if(-1 < btmp and btmp<19):
					for c in range(10):
						d = btmp  - c
						if(-1 < d and d<10):
							ans += 1
							
	print ans

Solution (Python):
while True:
    try:
        
        n=input()
        cnt=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==n:
                            cnt+=1
        print(cnt)
    except EOFError: break

Solution (Python):



import sys

money = 100000

for s in sys.stdin:
  count = 0
  d = int(s)
  for i1 in range(10):
    if i1 > d:
      pass
    for i2 in range(10):
      if i1 + i2 > d:
        pass
      for i3 in range(10):
        if i1 + i2 + i3 > d:
          pass
        for i4 in range(10):
          if i1 + i2 + i3 + i4 > d:
            pass
          if i1 + i2 + i3 + i4 == d:
            count += 1
  print count

Solution (Python):
import math
def sum_of(v_cnt, n):
    if v_cnt == 1:
        if 0 <= n <= 9:
            return 1
        else:
            return 0
    else:
        result = 0
        for v in range(10):
            result += sum_of(v_cnt - 1, n - v)
        return result

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

Solution (Python):
while True:
	try:
		cnt=0
		i=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==i:
							cnt+=1
		print(cnt)
	except:
		break

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[a+b+c+d]+=1
while True:
	try:
		print(x[int(input())])
	except:
		break

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

        print(cnt)

    except:
        break

Solution (Python):
import sys
import itertools
for line in sys.stdin:
    n = int(line)
    cnt = 0
    for i in itertools.product([i for i in range(10)], repeat=4):
        if n == sum(i):cnt += 1
    print(cnt)

Solution (Python):


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

Solution (Python):
while True:
    count = 0
    try:
        n = int(input())
    except:
        break
    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())
    except EOFError:
        break
    x = [0]*51
    for a in xrange(0,10):
        for b in xrange(0,10):
            for c in xrange(0,10):
                for d in xrange(0,10):
                    x[a+b+c+d] +=1
    print x[n]

Solution (Python):
import sys
for n in sys.stdin:
    n=int(n)
    count=0
    for i1 in xrange(10):
        for i2 in xrange(10):
            for i3 in xrange(10):
                for i4 in xrange(10):
                    if(i1+i2+i3+i4 == n): count+=1
    print count

Solution (Python):
while True:
    try:
        n = int(input())
        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
        print(count)
    except:
        break

Solution (Python):
from itertools import product
while True:
    try:
        n = int(input())
    except:
        break
    print(sum(a+b+c+d==n for a,b,c,d in product(range(10), repeat=4)))

Solution (Python):
import sys

for line in sys.stdin:
    n = int(line)
    cnt = 0

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

    print cnt

Solution (Python):

import sys

money = 100000

for s in sys.stdin:
    count = 0
    d = int(s)
    for i in range(10):
        if i > d :
            pass
        for j in range(10):
            if i + j > d:
                pass
            for k in range(10):
                if i + j + k :
                    pass
                for l in range(10):
                    if i + j + k + l > d :
                        pass
                    if i + j + k + l == d :
                        count += 1
    print count

Solution (Python):
import itertools

l = [0,1,2,3,4,5,6,7,8,9]

while True:
    try:
        N = int(raw_input())
        res = 0
        for element in itertools.product(l,repeat=4):
            if sum(element) == N:
                res += 1
        print res
    except EOFError:
        break

Solution (Python):


import itertools

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

Solution (Python):
while(True):
    a = 0
    try:
        n = input()
    except EOFError:
        break

    n=int(n)

    if n > 36:
        print(0)
        continue
    elif n==36:
        print(1)
        continue
    b = n
    for i in range(10):
        if n-i==0:
            a=a+1
            
            break
        for j in range(10):
            if n-i-j==0:
                a=a+1
                
                break
            for k in range(10):
                b = n-i-j-k
                if b>=0 and b<=9:
                    a=a+1
                    
                    continue
                elif b > 9:
                    continue
                else:
                    break


    print(a)

Solution (Python):
while True:
    try:
        s=int(input())
        i=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==s:
                            i+=1

        print(i)
    except:
        break

Solution (Python):


while(True):
    try:
        n = int(raw_input())
        sum = 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):
                            sum += 1
        print sum
    except EOFError:
        break

Solution (Python):
def get_input():
    while True:
        try:
            yield ''.join(raw_input())
        except EOFError:
            break

ar = [0] * 51

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

for a in list(get_input()):

	print ar[int(a)]

Solution (Python):
import sys
import itertools
for l in sys.stdin:
	k=[a for a in range(10)]
	print[sum(x) for x in list(itertools.product(k,k,k,k))].count(int(l))

Solution (Python):
import sys
import itertools
for l in sys.stdin:
	k=[a for a in xrange(10)]
	print[sum(x) for x in list(itertools.product(k,k,k,k))].count(int(l))

Solution (Python):
import sys,itertools
k=[0,1,2,3,4,5,6,7,8,9]
for l in sys.stdin:print[sum(x) for x in list(itertools.product(k,k,k,k))].count(int(l))

Solution (Python):
import sys,itertools
k=range(10)
for l in sys.stdin:print[sum(x)for x in list(itertools.product(k,k,k,k))].count(int(l))

Solution (Python):
import sys
def f(s,d,g,c):
	if d>3:return c
	for n in range(10):
		if s+n==g:return c+1
		elif s+n>g:return c
		else:c=f(s+n,d+1,g,c)
	return c
for l in sys.stdin:
	print f(0,0,int(l),0)

Solution (Python):
import sys
def f(s,d,g,c):
	if d>3:return c
	for n in xrange(10):
		if s+n==g:return c+1
		elif s+n>g:return c
		else:c=f(s+n,d+1,g,c)
	return c
for l in sys.stdin:
	print f(0,0,int(l),0)

Solution (Python):
import sys
r=range(10)
x=[0]*51
for a in r:
	for b in r:
		for c in r:
			for d in r:
				x[a+b+c+d]+=1
for l in sys.stdin:
	print x[int(l)]

Solution (Python):
import sys
r=xrange(10)
x=[0]*51
for a in r:
	for b in r:
		for c in r:
			for d in r:
				x[a+b+c+d]+=1
for l in sys.stdin:
	print x[int(l)]

Solution (Python):
import sys
x=[0]*51
for a in xrange(10):
	for b in xrange(10):
		for c in xrange(10):
			for d in xrange(10):
				x[a+b+c+d]+=1
for l in sys.stdin:
	print x[int(l)]

Solution (Python):
import sys
s=[0]*51
for a in range(10):
	for b in range(10):
		for c in range(10):
			for d in range(10):
				s[a+b+c+d]+=1
for l in sys.stdin:print s[int(l)]

Solution (Python):
import sys,itertools
k=range(10)
s=[0]*51
for n in [sum(x)for x in list(itertools.product(k,k,k,k))]:s[n]+=1
for l in sys.stdin:print s[int(l)]

Solution (Python):
import sys,itertools
k=xrange(10)
s=[0]*51
for n in [sum(x)for x in list(itertools.product(k,k,k,k))]:s[n]+=1
for l in sys.stdin:print s[int(l)]

Solution (Python):
import sys,itertools
k=xrange(10)
s=[0]*51
for n in [sum(x)for x in list(itertools.product(k,k,k,k))]:s[n]+=1
for l in sys.stdin:print s[int(l)]

Solution (Python):
import sys
s=[0]*51
for a in range(10):
	for b in range(10):
		for c in range(10):
			for d in range(10):
				s[a+b+c+d]+=1
for l in sys.stdin:print s[int(l)]

Solution (Python):
import sys,itertools
k=xrange(10)
s=[0]*51
for n in [sum(x)for x in list(itertools.product(k,k,k,k))]:s[n]+=1
for l in sys.stdin:print s[int(l)]

Solution (Python):
import sys
for input in sys.stdin:
    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 == int(input):
                        count += 1
    print(count)

Solution (Python):
while 1:
    try:
        n=int(raw_input())
    except EOFError:
        break
    print len([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])

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

Solution (Python):
import sys

while True:
    n = sys.stdin.readline()

    cnt = 0
    if n:
        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)):
                            cnt += 1
        print cnt

    else:
        break

Solution (Python):





pairs = {i: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):
                pairs[i+j+k+l] += 1
         
while True:
    try:
        n = int(raw_input())
        print pairs[n]
    except:
        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):
import sys
import math

while True:
    try:
	n = (int)(input())
	res = 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 == n):
			    res += 1
	print (res)
    except EOFError:
	break

Solution (Python):
import sys
for line in sys.stdin.readlines():
  n = int(line)
  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):
class Solution(object):
    def combinationSum(self, target):
        candidates = []
        for i in range(10):
            candidates.append(i)
        stack = [(0, 0, [])]
        result = []
        while stack:
            total, start, res = stack.pop()
            if total == target and len(res) == 4:
                result.append(res)
            elif len(res) > 4:
            	continue
            if total == 0 and len(res) == 4:
            	continue
            for i in range(start, len(candidates)):
                t = total + candidates[i]
                if t > target:
                    break
                stack.append((t, i, res + [candidates[i]]))
        return result
    def duplicated(self, nums, i, j):
        for t in range(i, j):
            if nums[t] == nums[j]:
                return False
        return True
    def recursion(self, nums, i, n, result):
        if i == n - 1:
            temp = []
            for k in range(0, n):
                temp.append(nums[k])
            result.append(temp)
        else:
            for k in range(i, n):
                if self.duplicated(nums, i ,k):
                    temp = nums[k] 
                    nums[k] = nums[i]
                    nums[i] = temp
                    self.recursion(nums, i + 1, n, result)
                    temp = nums[k] 
                    nums[k] = nums[i]
                    nums[i] = temp
    def permuteUnique(self, nums):
        result = []
        self.recursion(nums, 0, len(nums), result)
        return result







while True:
    try:
        n = int(raw_input())
        s = Solution()
        combination = s.combinationSum(n)
        m = 0
        for i in range(len(combination)):
            m += len(s.permuteUnique(combination[i]))
        print m
    except (EOFError):
        break

Solution (Python):
import sys


for n in sys.stdin:
    ret = 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 == int(n):
                        ret += 1
    print ret

Solution (Python):
while True:
	try:
		n = int(raw_input())
		ans = 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:
							ans += 1
		print ans
	except EOFError:
		break

Solution (Python):
import sys
lines = sys.stdin.readlines()
for line in lines:
    inp = int(line)
    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==inp:
                        s+=1
    print (s)

Solution (Python):
import sys
for line in sys.stdin:
    n = int(line)
    ans = 0
    a=b=c=d=0
    while True:
        if d==10:
            c+=1
            d=0
        if c==10:
            b+=1
            c=0
        if b==10:
            a+=1
            b=0
        if a == 10:
            break
        
        s = a+b+c+d
        if s == n:
            ans+=1
        d+=1
    print ans

Solution (Python):
import sys

for line in sys.stdin:
    n = int(line)
    cnt = 0
    if n <= 36:
        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:
                            cnt += 1
    print cnt

Solution (Python):
while True:
  try:
    n = int(raw_input())
  except EOFError:
    break
  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
  print count

Solution (Python):
def count(num):    
    l1=[]
    for a in range (10):
        for b in range(10):
            for c in range (10):
                for d in range (10):
                    l1.append([a,b,c,d])
    l1=list(filter(lambda x: sum(x)==num,l1))
    return(len(l1))

while True:
    try:
        print(count(int(input())))
    except:
        break

Solution (Python):
import sys

ans=[]    
def sumint(lp,ttl):
    if (ttl > lp*9) | (ttl < 0):
        return 0
    elif lp == 1:
        return 1
    else:
        a = 0
        for n in range(0,10) :
            a += sumint(lp - 1,ttl - n)
        return a

for i in sys.stdin:
    ans.append(sumint(4,int(i)))
print('\n'.join(map(str,ans)))

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):
while 1:
    try:
        n = input()
        x = 0
        if n < 50:
            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):
tbl = [0] * 51
for i in range(10):
    for j in range(10):
        tbl[i + j] += 1
try:
    while 1:
        n = int(input())
        res = 0
        for i in range(n + 1):
            res += tbl[i] * tbl[n - i]

        print(res)

except Exception:
    pass

Solution (Python):

while True:
	try:
		n=int(input())
		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)
	except EOFError:
		break

Solution (Python):

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

Solution (Python):

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

Solution (Python):
import sys

def output(x):
	count = 0
	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 == x:
						count += 1
	print count


if __name__ == "__main__":

	for i in sys.stdin:
		num = int(i)
		output(num)

Solution (Python):

import itertools
import sys


def operation(n):
    count = 0
    for a, b, c, d in itertools.product(range(10), repeat=4):
        if a + b + c + d == n:
            count += 1
    print(count)


def main():
    for l in sys.stdin:
        n = int(l.strip())
        operation(n)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import itertools

def func(n):
    count = 0
    for a, b, c, d in itertools.product(range(10), repeat=4):
        if a + b + c + d == n:
            count += 1
    return count

def main():
    for l in sys.stdin:
        n = int(l.strip())
        print(func(n))

if __name__ == '__main__':
    main()

Solution (Python):


while True:
    try:
        count = 0
        n = input()

        for a in xrange(0, 10):
            for b in xrange(0, 10):
                for c in xrange(0, 10):
                    for d in xrange(0, 10):
                        if a + b + c + d == n:
                            count += 1
        print(count)
    except:
        break

Solution (Python):


import sys

sum = [0]*37
for a in range(10):
    for b in range(10):
        for c in range(10):
            for d in range(10):
                sum[a+b+c+d] += 1
for line in sys.stdin:
    n = int(line)
    if n >= 0 and n <= 36:
        print sum[n]
    else:
        print "0"

Solution (Python):
import sys
from itertools import product
s = [sum(l) for l in product(range(10), repeat = 4)]

ns = sys.stdin.readlines()
for n in ns:
    print(s.count(int(n)))

Solution (Python):


count = 0
while True:
    try:
        i = 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 == i:
                            count += 1
        print(count)
        count = 0
    except:
        break

Solution (Python):
while 1:
    try:
        ct=0
        n=input()
        for a in xrange(10):
            for b in xrange(10):
                for c in xrange(10):
                    if 0<=n-(a+b+c)<=9:
                        ct+=1
        print(ct)
    except:
        break

Solution (Python):
import sys

flags = [0]*51
 
for a in range(10):
    for b in range(10):
        for c in range(10):
            for d in range(10):
                flags[a+b+c+d] += 1
 
for i in sys.stdin:
    print flags[int(i)]

Solution (Python):
cnt = 0
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

if __name__ == '__main__':
    array = list(get_input())
    for i in range(len(array)):
        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(array[i]):
                            cnt += 1
        print(cnt)
        cnt = 0

Solution (Python):





def kai(num):
	x = 0
	for i in range(10000):
		
		mk = str(i).zfill(4)
		if int(mk[0])+int(mk[1])+int(mk[2])+int(mk[3]) == num:
				x += 1
	return x

def main(): 
	while True:
		try:
			num = int(input())
		except:
			return
		else:
			print(kai(num))	
if __name__ == '__main__':
	main()

Solution (Python):
import sys
import itertools

for n in sys.stdin.readlines():
    n = int(n)
    patterns = itertools.product(range(10), range(10), range(10), range(10))
    ans = 0
    for a, b, c, d in patterns:
       if a + b + c + d == n:
           ans +=1
    print(ans)

Solution (Python):
import sys

for i in sys.stdin:
    n = int(i)
    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
                        break
    print(cnt)

Solution (Python):
import sys
from itertools import product

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

for i in sys.stdin:
    print(sum[int(i)])

Solution (Python):
import sys
from itertools import product

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

for i in sys.stdin:
    print(sum[int(i)])

Solution (Python):
import sys
from itertools import product

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

for i in sys.stdin:
    print(sum[int(i)])

Solution (Python):
import sys
import math

def nCr(n, k):
    if 0 <= k <= n:
        nk,kk = 1,1
        for t in range(1, min(k, n - k) + 1):
            nk = nk*n
            kk = kk*t
            n -= 1
        return nk // kk
    else:
        return 0

p = [0] * 51
v = 0
for i in range(19):
    t = nCr(i+3, i)
    v = v + 4 * nCr(i-8,i-10)
    p[i] = t - v
    p[36-i] = p[i]

for i in sys.stdin:
    print(p[int(i)])

Solution (Python):
ans=[]

while True:

	try:

		k=int(input())

		ct=0

		for i in range(10000):

			tmp=str(i)

			while len(tmp)<4:

				tmp="0"+tmp

			tmp_2=0

			for j in tmp:

				tmp_2+=int(j)

			if tmp_2==k:

				ct+=1

		ans.append(ct)

	except:

		break

for i in range(len(ans)):

	if i==len(ans)-1:

		print(ans[i],)

	else:

		print(ans[i])

Solution (Python):
ans=[]

while True:

	try:

		k=int(input())
		if k>18:
			k=36-k

		ct=0

		for i in range(10000):

			tmp=str(i)

			while len(tmp)<4:

				tmp="0"+tmp

			tmp_2=0

			for j in tmp:

				tmp_2+=int(j)

			if tmp_2==k:

				ct+=1

		ans.append(ct)

	except:

		break

for i in range(len(ans)):

	if i==len(ans)-1:

		print(ans[i],)

	else:

		print(ans[i])

Solution (Python):
while True:
    try:
        n = int(input())
        cnt = 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:
                            cnt += 1
        print(cnt)
    except:
        break

Solution (Python):
while True:
  try:
    ans = 0

    n = int(raw_input())

    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:
              ans += 1

    print ans

  except EOFError:
    break

Solution (Python):
import sys

def solve(n):
    ret = 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:
                        ret += 1
    return ret;

for i in sys.stdin:
    print solve(int(i))

Solution (Python):
import sys

p = [0] * 51
v = 0
for i in range(19):
    t = (i+3)*(i+2)*(i+1)//6
    v = v + 2 * (i-8) * (i-9) if i > 9 else 0
    p[i] = t - v
    p[36-i] = p[i]

for i in sys.stdin:
    print(p[int(i)])

Solution (Python):
while True:
    try:
        n = int(input())
    except:
        exit()
    m = 9
    c = 0
    def loop(n,dep):
        l = n - m*(3-dep)
        u = n
        if (l < 0):l = 0
        if (m < u):u = 9
        return l,u+1

    il,iu= loop(n,0)
    for i in range(il,iu):
        jl,ju = loop(n-i,1)
        for j in range(jl,ju):
            ij = i+j
            kl,ku = loop(n-ij,2)
            for k in range(kl,ku):
                c += 1

    print(c)

Solution (Python):
while True:
	try:
		n = eval(input())
		if n > 36:
			print(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
			print(count)
	except EOFError:
		break

Solution (Python):
import itertools
while True:
    try:
        n = int(input())
        ans = 0
        for a in itertools.product(range(10), repeat=4):
            if n == sum(a):
                ans += 1
        print(ans)
    except:
        break

Solution (Python):
import itertools
while True:
 try:print([sum(a)for a in itertools.product(range(10),repeat=4)].count(int(input())))
 except:break

Solution (Python):
import sys

for i in sys.stdin.readlines():
    n = int(i[:-1])
    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):
def solve(remains, num=4):
    if remains > 9 * num or remains < 0:
        return 0
    if num == 1:
        return 1
    return sum(solve(remains - i, num - 1) for i in range(10))


while True:
    try:
        print(solve(int(input())))
    except:
        break

Solution (Python):
while True:
    try:
        n = int(input())
        output = 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:
                            output = output + 1
        print(str(output))
    except EOFError:
        break

Solution (Python):
import sys
import itertools

def main():
    l = list(range(10))
    
    while True:
        data = sys.stdin.readline().strip()
        if data is None or data == '':
            break

        num = int(data)
        
        cnt = 0
        for elem in itertools.product(l, repeat=4):
            sum = 0
            for i in elem:
                sum += i

            if sum == num:
                cnt += 1

        print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
for line in sys.stdin:
    n=int(line)
    cnt=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:
                        cnt=cnt+1
    print(cnt)

Solution (Python):
import sys

for line in sys.stdin:
    n = int(line)
    num = 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:
                        num += 1

    print(num)