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

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

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

Solution (Python):
import itertools
def combination(n):
 m=0
 for i in itertools.product(range(10),repeat=4):
  (a,b,c,d)=i
  if a+b+c+d==n:
   m+=1
 return m

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

Solution (Python):
import sys

def count_combination(n):
    count = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                l = n - (i + j + k)
                if l >= 0 and l < 10:
                    count += 1
    return count

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

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

Solution (Python):


import sys

def sum_intergers(n, k=4, last=True):
    clip_9 = lambda x: x if x < 10 else 9

    if k > 1:
        c = sum_intergers(n, k=k-1, last=False)
    else:
        return [(s,) for s in range(clip_9(n)+1)]

    ret = []
    for cc in c:
        sum_cc = sum(cc) 
        for s in range(clip_9(n-sum_cc)+1):
            if not last or s+sum_cc==n:
                r = [p for p in cc]
                r.append(s)
                ret.append(tuple(r))
    return ret


def main():
    ns = [int(n) for n in sys.stdin]
    for n in ns:
        c = len(sum_intergers(n, k=4))
        print(c)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
for n in sys.stdin:
    num = 0
    n = int(n.replace("\n",""))
    for i in range(0, 10000):
        s = sum([i%10, int(i/10)%10, int(i/100)%10, int(i/1000)])
        if n == s:
            num += 1
    print(num)

Solution (Python):
def sumint(n,num):
    if num==2:
        if n>18: return 0
        else:
            c=0
            for i in range(10):
                if 0<=n-i<10:c+=1
            return c
    ret=0
    for i in range(10):
        ret=ret+sumint(n-i,num-1)
    return ret
while True:
    try:n=int(input())
    except:break
    if n>36:print(0)
    else:
        print(sumint(n,4))

Solution (Python):
while True:
    try:
        n = int(input())
        c = 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 : c+=1
        print(c)
    except:
        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):
                for d in range(10):
                    if (a+b+c+d)==int(line): count += 1
    print(count)

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

Solution (Python):
answermap=[0]*51
answermap[0] = 1
answermap[1] = 4
answermap[2] = 10
answermap[3] = 20
answermap[4] = 35
answermap[5] = 56
answermap[6] = 84
answermap[7] = 120
answermap[8] = 165
answermap[9] = 220
answermap[10] = 282
answermap[11] = 348
answermap[12] = 415
answermap[13] = 480
answermap[14] = 540
answermap[15] = 592
answermap[16] = 633
answermap[17] = 660
answermap[18] = 670
answermap[19] = 660
answermap[20] = 633
answermap[21] = 592
answermap[22] = 540
answermap[23] = 480
answermap[24] = 415
answermap[25] = 348
answermap[26] = 282
answermap[27] = 220
answermap[28] = 165
answermap[29] = 120
answermap[30] = 84
answermap[31] = 56
answermap[32] = 35
answermap[33] = 20
answermap[34] = 10
answermap[35] = 4
answermap[36] = 1
answermap[37] = 0
answermap[38] = 0
answermap[39] = 0
answermap[40] = 0
answermap[41] = 0
answermap[42] = 0
answermap[43] = 0
answermap[44] = 0
answermap[45] = 0
answermap[46] = 0
answermap[47] = 0
answermap[48] = 0
answermap[49] = 0
answermap[50] = 0

inputs = []

while True:
  try:
    inputs.append(int(input()))
  except EOFError:
    break

for i in inputs:
  print(answermap[i])

Solution (Python):
import sys
[print(len([True 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(x)])) for x in sys.stdin]

Solution (Python):
import sys
[print(sum([1 if sum([a, b, c, d]) == int(x) else 0 for a in range(10) for b in range(10) for c in range(10) for d in range(10)])) for x in sys.stdin]

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

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

Solution (Python):
def rec(i,n):
    r=0
    if i==4:
        return 1 if n==0 else 0
    for m in range(10):
        r+=rec(i+1,n-m)
    return r
while True:
    try:
        n=int(input())
        print(rec(0,n))
    except:
        break

Solution (Python):

memo=[[0]*51 for i in range(5)]
def rec(i,n):
    if memo[i][n]!=0:
        return memo[i][n]
    if i==4:
        return 1 if n==0 else 0
    for m in range(10):
        memo[i][n]+=rec(i+1,n-m)
    return memo[i][n]
    
while True:
    try:
        n=int(input())
        print(rec(0,n))
    except:
        break

Solution (Python):
memo=[[-1]*51 for i in range(5)]
def rec(i,n):
    if memo[i][n]!=-1:
        return memo[i][n]
    r=0
    if i==4:
        return 1 if n==0 else 0
    for m in range(10):
        r+=rec(i+1,n-m)
    memo[i][n]=r
    return r
     
while True:
    try:
        n=int(input())
        print(rec(0,n))
    except:
        break

Solution (Python):
from collections import deque
import sys

def solve(n, target):
    """ 0-9?????§?????°???n???????¶?????????¨??§???target??????????????????????????? """
    if n <= 1:
        if 0 <= target <=9:
            Q.append(target)
            return target
        else:
            return None
    else:
        for i in range(10):
            res = solve(n - 1, target - i)


Q = deque()
if __name__ == '__main__':
    
    for line in sys.stdin:
        target = int(line)

        result = solve(4, target)
        print(len(Q))
        Q.clear()

Solution (Python):
import sys
values = []
for line in sys.stdin:
    values.append(int(line))
    
for v in values:
    ans = [1 for i in range(10) for j in range(10) for k in range(10) for l in range(10) if v == i + j + k + l]
    print(ans.count(1))

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

Solution (Python):
import sys

p = [0] * 51
v = 0
for i in range(10):
    p[i] = p[36-i] = (i+3)*(i+2)*(i+1)//6

for i in range(10,19):
    p[i] = p[36-i] = (i+1)*(i+2)*(i+3)//6 - 2*(i-9)*(i-8)*(i-7)//3

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

Solution (Python):
import sys

p = [0] * 51
v = 0
for i in range(10):
    p[i] = p[36-i] = (i+3)*(i+2)*(i+1)//6

for i in range(10,19):
    p[i] = p[36-i] = (i+1)*(i+2)*(i+3)//6 - 2*(i-9)*(i-8)*(i-7)//3

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

Solution (Python):
import sys

p = [0] * 51
for i in range(10):
    p[i] = p[36-i] = (i+3)*(i+2)*(i+1)//6

for i in range(10,19):
    p[i] = p[36-i] = (i+1)*(i+2)*(i+3)//6 - 2*(i-9)*(i-8)*(i-7)//3

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

Solution (Python):
import sys

p = [0] * 51
for i in range(10):
    p[i] = p[36-i] = (i+3)*(i+2)*(i+1)//6

for i in range(10,19):
    p[i] = p[36-i] = (i+1)*(i+2)*(i+3)//6 - 2*(i-9)*(i-8)*(i-7)//3

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

Solution (Python):
import sys

p = [0] * 51
for i in range(19):
    p[i] = p[36-i] = (i+3)*(i+2)*(i+1)//6 - max(2*(i-9)*(i-8)*(i-7)//3,0)

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

Solution (Python):
import sys

def getsum(n):
  if n > 36: return 0
  else:
    i = n if n < 19 else 36-n
    return (i+3)*(i+2)*(i+1)//6 - max(2*(i-9)*(i-8)*(i-7)//3,0)

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

Solution (Python):
import sys

def getsum(n):
  if n > 36: return 0
  else:
    i = n if n < 19 else 36-n
    return (i+3)*(i+2)*(i+1)//6 - max(2*(i-9)*(i-8)*(i-7)//3,0)

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

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

Solution (Python):

import sys

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

array = []
for i in sys.stdin:
    array.append(i)

for k in range(len(array)):
    n = array[k]
    print(x[int(n)])

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

Solution (Python):
import sys

while True:
  n = sys.stdin.readline()
  if not n: break
  n = int(n.rstrip())
  count=0
  for a in range(10):
    for b in range(10):
      for c in range(10):
        if 0 <= n-a-b-c and n-a-b-c <= 9:
          count+=1
  print count

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

        print(str(cnt))
    except:
        break

Solution (Python):
import sys
import itertools

for line in sys.stdin:
    n = int(line)
    cnt = 0;
    for element in itertools.product(range(10), repeat=4):
        if sum(element) == n:
            cnt += 1
    print(cnt)

Solution (Python):


import itertools
import sys
import math

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

Solution (Python):


import itertools
import sys
import math

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n > 36:
        print(0)
        continue
    elif n == 36:
        print(1)
        continue
    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 and d <= 9:
                    cnt += 1
    print(cnt)

Solution (Python):


import sys

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n > 36:
        print(0)
        continue
    elif n == 36:
        print(1)
        continue
    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 and d <= 9:
                    cnt += 1
    print(cnt)

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

Solution (Python):
import sys
import math as mas

x=[0]*60
for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				x[i+j+k+l]+=1
for i in sys.stdin:
	print(x[int(i)])

Solution (Python):
import sys
from collections import defaultdict
from itertools import product

d = defaultdict(int)
for x in product(range(10), repeat=4):
    d[sum(x)] += 1

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

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

Solution (Python):


import sys
import os
import math


lst = sys.stdin.readlines()


for s in lst:
    cnt = 0
    target_val = int(s)
    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 == target_val:
                        cnt += 1
    print(cnt)

Solution (Python):
import sys

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

Solution (Python):
import sys
def count(number) :
    Ranges = [(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 == number]
    return len(Ranges)

for make in sys.stdin : print(count(int(make)))

Solution (Python):
for _ in range(50):
    try:
        n = int(input()) 
        ans =set()
        for a in range(10):
            if (n - a) >= 1:
                for b in range(10):
                    if(n - a -b) >= 1:
                        for c in range(10):
                            if(n - a - b - c) >= 1:
                                for d in range(10):
                                    if(n - a - b - c - d) == 0:
                                        ans.add("{},{},{},{}".format(a,b,c,d))
                                        ans.add("{},{},{},{}".format(b,c,d,a))
                                        ans.add("{},{},{},{}".format(c,d,a,b))
                                        ans.add("{},{},{},{}".format(d,a,b,c))
        print(len(ans))
    except EOFError:
        break

Solution (Python):
import sys

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

Solution (Python):
import sys
import math

for line in sys.stdin:
    N = int(line.rstrip())
    count = 0
    for i0 in range(10):
        for i1 in range(10):
           for i2 in range(10):
              for i3 in range(10):
                  if sum([i0,i1,i2,i3]) == N:
                      count += 1
                      break
    print(count)

Solution (Python):
combi = []
for i in range(0, 51):
	combi.append(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):
				combi[a+b+c+d] += 1

while True:
	try:
		n = int(raw_input())
		print combi[n]
	except:
		break

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

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

Solution (Python):
import sys
t = [0 for i in range(10000)]
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                t[c] = i + j + k + l
                c += 1
for line in sys.stdin:
    print(t.count(int(line)))

Solution (Python):
import sys
t = [0 for i in range(10000)]
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                t[c] = i + j + k + l
                c += 1
for line in sys.stdin:
    print(t.count(int(line)))

Solution (Python):
import sys
t = [0 for i in range(10000)]
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                t[c] = i + j + k + l
                c += 1
for line in sys.stdin:
    n = int(line)
    print(t.count(n))

Solution (Python):
import sys
t = [None for i in range(10000)]
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                t[c] = i + j + k + l 
                c += 1
for line in sys.stdin:
    print(t.count(int(line)))

Solution (Python):



import sys

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


if __name__ == "__main__": main()

Solution (Python):
def main():
	import sys

	table = [0]*51

	for a in range(10):
		for b in range(10):
			for c in range(10):
				for d in range(10):
					table[a+b+c+d] += 1

	for line in sys.stdin:
		n = int(line)
		print(table[n])


if __name__ == '__main__':
	main()

Solution (Python):
from itertools import product
import sys

a = []
for line in sys.stdin:
        a.append(int(line.strip()))

p = list(product(range(0, 10), range(0, 10), range(0, 10), range(0, 10)))
for n in a:
    cnt = 0;
    for e in p:
        if sum(e) == n:
            cnt += 1
    print(cnt)

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

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

Solution (Python):
import sys

def count(n):
    k = 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:
                        k += 1
    return k

for line in sys.stdin:
    print(count(int(line)))

Solution (Python):
import fileinput
for n in fileinput.input():
    n = int(n)
    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)

Solution (Python):
import sys

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

    print(num)

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

Solution (Python):
import sys

def main():
    istr = sys.stdin.read()
    wi = list(map(int,istr.splitlines()))

    for n in wi:
        """ ????????? """
        cnt = 0
        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
                        if x == n:
                            cnt += 1
                        elif x > n:
                            break
        print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import itertools

v = list(range(10))

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

    for i in itertools.product(v, repeat=4):
        sum = 0
        for y in i:
            sum += y
        
        if sum == n:
            res += 1

    print(res)

Solution (Python):
while 1:
    try:
        count=0
        x=int(input())
        for i in reversed(range(10)):
            if 0<=x-i<=27:
                for j in reversed(range(10)):
                    if 0<=x-i-j<=18:
                        for z in reversed(range(10)):
                            if 0<=x-i-j-z<=9:
                                for y in reversed(range(10)):
                                    if x-i-j-z-y==0:
                                        count+=1
        print(count)
    except EOFError:
        break

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


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


mem = {}
for line in sys.stdin:
    n = int(line)
    if n in mem:
        print(mem[n])
    else:
        ans = sum4(n)
        mem[n] = ans
        print(ans)

Solution (Python):
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break

    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

Solution (Python):
import sys
for l in sys.stdin:
    n = int(l)
    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)

Solution (Python):
anss=[]
while True:
    try:
        ans=0
        goal=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==goal:
                            ans+=1
        anss.append(ans)
    except:
        break
for ans in anss:
    print(ans)

Solution (Python):
import sys

for line in sys.stdin:
	count = 0
	n = int(line)
	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):
import sys


def rec(j,s):
    if s > n:
        return 0
    if s == n:
        return 1
    if j == 0:
        return 0
    v = 0
    for i in range(10):
        v += rec(j-1, s + i)
    return v

n = sys.stdin.readline()
while n:
    n = int(n)
    print(rec(4,0))
    n = sys.stdin.readline()

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):
t = 0
while t == 0:	
	p = 0
	try:
		n = int(input())
	except:
		break
	else:
		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):
							p += 1
	print(p)

Solution (Python):
num = []
while True:
    try:
        num.append(int(input()))
    except EOFError:
        break

for i in num:
    s = set()
    for a in range(10):
        if i-a > 27:
            continue
        for b in range(10):
            if i-a-b > 18:
                continue
            for c in range(10):
                if i-a-b-c > 9:
                    continue
                elif i-a-b-c < 0:
                    break
                else:
                    s.add(str(a)+str(b)+str(c)+str(i-a-b-c))
    print(len(s))

Solution (Python):
import sys
import itertools

def countcombi(n):
    r = 0
    p = list(itertools.product(range(0,10),repeat = 4))
    for tmp in p:
        if sum(tmp) == n:
            r += 1
    return r


if __name__ == '__main__':
    for line in sys.stdin:
        n = (int)(line)
        print(countcombi(n))

Solution (Python):



import fileinput

def main():

    for line in fileinput.input():
        tokens = list(map(int, line.strip().split()))

        number = tokens[0]
        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) == number):
                            ans += 1

        print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys



def solve():
    for s in map(int,sys.stdin):
        results=set()
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    d = s-a-b-c
                    if d<0:break
                    if d<=9: results.add((a,b,c,d))
        print(len(results))
solve()

Solution (Python):



def making_n(usable_numbers: int, target: int) -> int:
    if usable_numbers == 1:
        if 0 <= target <= 9:
            return 1
        return 0
    count = []
    for i in range(10):
        count.append(making_n(usable_numbers - 1, target - i))
    return sum(count)


if __name__ == '__main__':
    while True:
        try:
            n = int(input())
        except EOFError:
            break
        print(making_n(4, n))

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

Solution (Python):


while True:
	try:
		n = int(raw_input())
		cnt = 0
		for i in range(10):
			for j in range(10):
				for k in range(10):
					if n-i-j-k >= 0 and n-i-j-k <= 9:
						
						cnt += 1
		print cnt
	except EOFError:
		break

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

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

Solution (Python):
import sys

answer = [0] * 51
for a in range(10):
  for b in range(10):
    for c in range(10):
      for d in range(10):
        answer[a + b + c + d] += 1

for line in sys.stdin:
  try:
    print(answer[int(line)])
  except:
    break

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

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
    table = [[a,b,c,d] for a in range(10) for b in range(10) for c in range(10) for d in range(10)]
    for abcd in table:
        ans += sum(abcd) == n
    print(ans)

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

N = list(get_input())
for l in range(len(N)):
    n = int(N[l])
    ans = 0
    for a in range(min(n+1,10)):
        for b in range(min(n+1-a,10)):
            for c in range(min(n+1-a-b,10)):
                for d in range(min(n+1-a-b-c,10)):
                    if a+b+c+d == n:
                        
                        ans = ans + 1
    print(ans)

Solution (Python):
while True:
    try:n=int(input())
    except:break
    ans=0
    for i in range(10):
        for j in range(10):
           for f in range(10):
                for e in range(10):
                    if i+j+f+e==n:
                        ans+=1

    print(ans)

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

Solution (Python):
import sys
for e in sys.stdin:
 x=range(10)
 print(sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==int(e)]))

Solution (Python):
import sys
for e in sys.stdin:
 x=range(10)
 print(sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==int(e)]))

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

Solution (Python):
import sys
for e in sys.stdin:
 e=int(e);x=range(10)
 print(sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==e]))

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

Solution (Python):
import sys
for e in sys.stdin:
 e=int(e);x=range(10)
 print(sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==e]))

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

Solution (Python):
import sys
a=[0]*51;x=range(10)
for i in range(51):
 a[i]=sum([1 for p in x for q in x for r in x for s in x if p+q+r+s==i])
for e in sys.stdin:
 print(a[int(e)])

Solution (Python):
import sys
a=[0]*51;x=range(10)
for i in range(51):
 a[i]=sum([1 for p in x for q in x for r in x for s in x if p+q+r+s==i])
for e in sys.stdin:
 print(a[int(e)])

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

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)])