Harryxun/stf_run huggingface dataset:
n = int(input())
S = list(map(int, input().split()))
a = sorted(S)
print(a[-1] - a[0])


### FIXED CODE ###

n = int(input())

if n%2==0:
    print(n)

else:
    print(2 * n)
n=int(input())
lst=[int(input()) for i in range(n)]
print(max(lst)-min(lst))

### FIXED CODE ###

n=int(input())
lst=list(map(int,input().split()))
print(max(lst)-min(lst))
x, k, d = map(int, input().split())
if x < 0:
    x *= -1
if x - k // d >= 0:
    print(x-k*d)
else:
    k -= x // d
    x %= d
    if k % 2 == 0:
        print(x)
    else:
        print(abs(x-d))


### FIXED CODE ###

print(max(map(len, input().split('S'))))
x, a, b = map(int,input().split())
if b < a:
    print('delicious')
elif b <= a + x:
    print('safe')
else:
    print('dangerous')

### FIXED CODE ###

x=input()
if x[0] =='9' or x[1] == '9':
    print('Yes')
else:
    print('No')
#069_A
n,m=map(input().split())
print((n-1)*(m-1))

### FIXED CODE ###

#069_A
n,m=map(int,input().split())
print((n-1)*(m-1))
import sys
sys.setrecursionlimit(100000)
n,q = map(int,input().split())
dic = {}

for _ in range(n-1):
    a, b = map(int, input().split())
    if not (a in dic):
        dic[a] = []
    dic[a].append(b)

v_list = [0 for _ in range(n)]
print(dic)


def add_v(num, value):
    v_list[num] = v_list[num]+value
    if num in dic:
        for root in dic[num]:
            add_v(root-1, value)


for i in range(q):
    p,x=map(int,input().split())
    add_v(p, x)

print(*v_list)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n, q = map(int, input().split())
dic = {}

for _ in range(n - 1):
    a, b = map(int, input().split())
    if not (a in dic):
        dic[a] = []
    dic[a].append(b)

v_list = [0 for _ in range(n)]

for _ in range(q):
    a, b = map(int, input().split())
    v_list[a-1] += b

key_list = list(dic.keys())
key_list.sort()

for a in key_list:
    for b in dic[a]:
        v_list[b-1] = v_list[a-1] + v_list[b-1]

print(*v_list)
from collections import deque
import sys
import functools
sys.setrecursionlimit(10000000)
@functools.lru_cache(maxsize=None)
def stairs(n):
  if n==1:
    return 1
  if n==2:
    return 2
  return stairs(n-1)+stairs(n-2)
N,M=map(int,input().split())
A=deque()
for _ in range(M):
  A.append(int(input()))
pos=0
ans=0
while A:
  x=A.popleft()-1
  if len(A)!=0:
    if x+2==A[0]:
      print(0)
      exit()
  ans+=(stairs(x-pos)-1)
  ans%=1000000007
  pos=x+2
ans+=stairs(N-pos)
print(ans+1)

### FIXED CODE ###

N,M=map(int,input().split())
broken=[0]*N
for _ in range(M):
  a=int(input())
  broken[a]=1
dp=[0]*(N+2)
dp[N]=1
for i in range(N-1,-1,-1):
  if broken[i]==1:
    dp[i]=0
  else:
    dp[i]=(dp[i+1]+dp[i+2])%1000000007
print(dp[0])
x, y = input().split()

if y % 2 == 1:
    print('No')

max_num = 4 * x
min_num = 2 * x

if (min_num <= y) and (max_num >= y):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

x, y =  map(int, input().split())

max_num = 4 * x
min_num = 2 * x

if y % 2 == 1:
    print('No')
elif (min_num <= y) and (max_num >= y):
    print('Yes')
else:
    print('No')
n = int(input)
present_list = [0]*n
for i in range(n):
	present_list[i] = int(input())

print(sum(present_list)-present_list[-1]//2)


### FIXED CODE ###

n = int(input())
present_list = [0]*n
for i in range(n):
	present_list[i] = int(input())
present_list = sorted(present_list)
print(sum(present_list)-present_list[-1]//2)
n = int(input())
print(print(0 if n%1000 == 0 else 1000*((n//1000)+1) - n)

### FIXED CODE ###

n = int(input())
print(0 if n%1000 == 0 else 1000*((n//1000)+1) - n)
# -*- coding: utf-8 -*-
 
N = int(input())
 
ans = int(N(N-1)/2)

### FIXED CODE ###

N = int(input())

ans = (N * (N-1) // 2)
print(ans)
x,y = map(int, input().split())

while True:

    if x == 0 and y == 0 : break

    list = [x, y]
    print(sort(list, reverse=True))
       


### FIXED CODE ###

while True:
    x,y = map(int, input().split())

    if x == 0 and y == 0:
        break

    elif x <= y:
        print(str(x) + " " + str(y))
    else:
        print(str(y) + " " + str(x))
sys.setrecursionlimit(10**6)
n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append([b,i])

ans = [None]*(n-1)
def rec(cur,color):

    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1
rec(0, 0)
print(max(ans))
print(*ans, sep="\n")


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append([b,i])

ans = [None]*(n-1)
def rec(cur,color):

    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1
rec(0, 0)
print(max(ans))
print(*ans, sep="\n")
def main():
    S = input()
    if S[0] == S[1] and S[2] == S[3]:
        ans = "Yes"
    elif S[0] == S[2] and S[1] == S[3]:
        ans = "Yes"
    elif S[0] == S[3] and S[1] == S[2]:
        ans = "Yes"
    else:
    else:
        ans = "No"
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    S = input()
    if S[0] == S[1] == S[2] == S[3]:
        ans = "No"
    elif S[0] == S[1] and S[2] == S[3]:
        ans = "Yes"
    elif S[0] == S[2] and S[1] == S[3]:
        ans = "Yes"
    elif S[0] == S[3] and S[1] == S[2]:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == '__main__':
    main()
import math

A,B,C,D=map(int, input().split())

def lcm(x, y):
    return ((x * y)//math.gcd(x, y))

cc = (B//C)-((A-1)//C)
dd = (B//D)-((A-1)//D)

x = lcm(C,D)
ee = (B//x)-((A-1)//x)

ans = (B-A+1)-(cc + dd - ee)
print(ans)

### FIXED CODE ###

import fractions

A,B,C,D=map(int, input().split())

cc = (B//C)-((A-1)//C)
dd = (B//D)-((A-1)//D)

x= (C * D // fractions.gcd(C, D))
ee = (B//x)-((A-1)//x)

ans = (B-A+1)-(cc + dd - ee)
print(int(ans))
def insertionSort(A,n,g):
	cnt = 0
	for i in range(g,n):
		v = A[i]
		j = i - g
		while j >= 0 and A[j] > v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
		A[j+g] = v

def shellsort(A,n):
	cnt = 0
	h = 0
	while(h <= n / 9):
	    h = 3*h + 1
	G = []
	while h > 0:
		G.append(h)
		h /= 3
	print(len(G))
    print(" ".join(map(str,G)))
    
	for i in range(len(G)):
		insertionSort(A,n,G[i])
	for i in A:
		print(i)
		
n = int(input())
A = []
for _ in range(n):
	A.append(int(input()))
shellsort(A,n)



### FIXED CODE ###

def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
            A[j+g] = v
    return cnt
    
def shellsort(A,n):
    cnt = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    G.reverse()
    m = len(G)
    print(m)

    print(" ".join(map(str,G)))
    for i in range(m):
        cnt += insertionSort(A,n,G[i])
    print(cnt)
    for i in A:
        print(i)
        
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
shellsort(A,n)
N = int(input())

for i in 11:
    ans = (1000*i - N) % 1000

print(ans)

### FIXED CODE ###

N = int(input())

for i in range(1,11):
    x = 1000 * i - N
    if x < 0:
        continue
    else:
        print(x)
        exit()
def z_argorithm(s):
    s_len=len(s)
    a=[0]*s_len
    c=0
    for i in range(1,s_len):
        if i+a[i-c] < c+a[c]:
            a[i]=a[i-c]
        else:
            j=max(0,c+a[c]-i)
            while i+j<s_len and s[j]==s[j+i]:
                j += 1
            a[i]=j
            c=i
    return a
def main():
    n=int(input())
    s=input()
    ans = 0
    for i in range(n-1):
        a = z_argorithm(s[i:])
        A=len(a)
        for i in range(A):
            ans=max(ans,min(i,a[i]))
    print(ans)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def Z(s):
    """
    s: str
    return list of int with length len(s)
    """
    # initialization
    n=len(s)
    z=[0]*n
    z[0]=n
    # construct
    L,R=0,0
    for i in range(1,n):
        if i>=R: # 過去の結果が全く使えない
            L=R=i
            while(R<n and s[R-L]==s[R]): R+=1
            z[i]=R-L
        elif z[i-L]<R-i: # 過去の結果が全て使える
            z[i]=z[i-L]
        else: # 過去の結果が一部使える
            L=i
            while(R<n and s[R-L]==s[R]): R+=1
            z[i]=R-L
    return z
def resolve():
    n=int(input())
    s=input()
    ans=0
    for i in range(n):
        z=Z(s[i:])
        k=len(z) # k=n-i
        for j in range(k):
            ans=max(ans,min(j,z[j]))
    print(ans)
resolve()
def solve(string):
    a, *_, e, k = map(int, string.split())
    return "Yay!" if e - a <= k else ":("


if __name__ == '__main__':
    print(solve(input()))


### FIXED CODE ###

def solve(string):
    a, *_, e, k = map(int, string.split())
    return "Yay!" if e - a <= k else ":("


if __name__ == '__main__':
    print(solve('\n'.join([input() for _ in range(6)])))
import sys
input = sys.stdin.readline

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = map(int,input().split())
l = [-1]+[int(input())]
for i in range(m-1):
    a = int(input())
    if a == l[-1]+1:
        print(0)
        exit()
    l.append(a)
l.append(n+1)
# print(l)

ans = 1
for i in range(m+1):
    cnt = 0
    steps = l[i+1] - l[i] -2
    for j in range(steps//2+1):
        if j == 0:
            cnt += 1
        else:
            seat = steps - j
            cnt += combinations_count(seat,j)
    ans *= cnt

print(ans % (10**9+7))

### FIXED CODE ###

import sys
input = sys.stdin.readline

n,m = map(int,input().split())
oks = [True]*(n+1)
for i in range(m):
    a = int(input())
    oks[a] = False

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1,min(n,i+2)+1):
        if oks[j]:
            dp[j] += dp[i]
            dp[j] %= (10**9+7)
print(dp[n])
a1 = int(input())
a2 = int(input())
a3 = int(input())
 
A = a1 + a2 + a3
 
if A >= 22:
  print('bust')
else:
   print('win')

### FIXED CODE ###

a1, a2, a3 = map(int, input().split())
 
if a1 + a2 + a3 >= 22:
  print('bust')
else:
  print('win')
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
if sum(b)>sum(a):
    print(-1)
d=[0]
ans=chk=0
print(d[1])


### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
if sum(b)>sum(a):
    print(-1)
    exit()

j,k=[],[]
for i in range(n):
    if a[i]>b[i]:
        j.append(a[i]-b[i])
    elif a[i]<b[i]:
        k.append(b[i]-a[i])
ans=len(k)

j.sort()
t=sum(k)
while t>1:
    t-=j.pop()
    ans+=1
print(ans)
import math
from functools import reduce

n,m = map(int, input().split())
A = list(map(int, input().split()))

def lcm_base(x,y):
  return x*y//math.gcd(x,y)

def lcm(target_list):
  return reduce(lcm_base, target_list)

A_gcd = reduce(math.gcd, A)
flg = True

for a in A:
  if a//A_gcd%2==0:
    flg = False
    break

if flg:
  min_x = int(lcm(A)*0.5)
  ans = m//min_x - m//(2*min_x)
  print(ans)
else:
  print(0)

### FIXED CODE ###

import math
from functools import reduce

n,m = map(int, input().split())
A = list(map(int, input().split()))

def lcm_base(x,y):
  return x*y//math.gcd(x,y)

def lcm(target_list):
  return reduce(lcm_base, target_list)

A_gcd = reduce(math.gcd, A)
flg = True

for a in A:
  if a//A_gcd%2==0:
    flg = False
    break
    
if flg:
  min_x = int(lcm(A))//2
  ans = m//min_x - m//(2*min_x)
  print(ans)
else:
  print(0)
from functools import reduce

x,y=list(map(int,input().split()))
mod = 10 ** 9 + 7

if (2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0:
  print("0")
  exit()
  
a,b = (2 * y - x) // 3, (2 * x - y) // 3 

r = min(a,b)

if r == 0:
  print("1")
else:
  numerator = reduce(lambda x, y: x * y % mod, [a + b - r + k + 1 for k in range(r)])
  denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
  print(numerator * pow(denominator, mod - 2, mod) % mod)

### FIXED CODE ###

from functools import reduce

x,y=list(map(int,input().split()))
mod = 10 ** 9 + 7

if (2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0:
  print("0")
  exit()
  
a,b = (2 * y - x) // 3, (2 * x - y) // 3 

r = min(a,b)

if r == 0:
  print("1")
elif r < 0:
  print("0")
else:
  numerator = reduce(lambda x, y: x * y % mod, range(a + b - r + 1, a + b + 1))
  denominator = reduce(lambda x, y: x * y % mod, range(1,r + 1))
  print(numerator * pow(denominator, mod - 2, mod) % mod)
import sys

from scipy.misc import comb #scipy.special

#import numpy as np

n = int(input())

a = [int(i) for i in input().split()]

dict = {}

asort = sorted(a)

#print(asort)

sum = 0
i = 0
while i < n-1:
    counter = 1
    index = asort[i]
    while  i < n-1 and asort[i] == asort[i+1]:
        #print("yes")
        counter +=1
        i+=1
    #print("no")
    i+=1
    dict[(index)] = [counter,comb(counter,2),comb(counter-1,2)]
    sum+=dict[(index)][1]




for i in a:
    print(int(sum-dict[(i)][1]+dict[(i)][2]))


### FIXED CODE ###

import sys

#from scipy.misc import comb #scipy.special

#import numpy as np

def choose(n):
    return n*(n-1)/2

n = int(input())

a = [int(i) for i in input().split()]

bunpu = [0]*(n+1)

for i in range(len(a)):
    bunpu[a[i]]+=1


sum = 0
for i in bunpu:
    sum+=choose(i)
i = 0
for i in a:
    print(int(sum-choose(bunpu[i])+choose(bunpu[i]-1)))
# coding: utf-8

s = input()

sum = int(0)

if s[0] = 1:
    sum++
if s[1] = 1:
    sum++
if s[2] = 1:
    sum++

print(sum)

### FIXED CODE ###

# coding: utf-8

s = input()

sum = 0

if s[0] == "1":
    sum = sum + 1
if s[1] == "1":
    sum = sum + 1
if s[2] == "1":
    sum += 1

print(sum)
a=int(input());x=n//2;print((n-x)*x)

### FIXED CODE ###

a=int(input())
print((a//2)*((a+1)//2))
import math
s = list(str(input()))
lis = ""
li = ""
num = 0
cou = [0 for i in range(26)]
for i in range(len(s)):
  if s[i] != "x":
    lis += s[i]
    li = s[i] + li
  else:
    num += 1
if lis != li:
  print(-1)
  exit()
point = lis[len(lis)//2]
ss = ["1"]
tt = ["1"]
nu = 0
while s[nu] != point:
  ss.append(s[nu])
  nu += 1
nu = 0
while s[-1-nu] != point:
  tt.append(s[-1-nu])
  nu += 1
ans = 0
for i in range(max(len(ss),len(tt))):
  try:
    if ss[i] != tt[i]:
      ans += 1
  except:
    ans += 1
print(ans)

### FIXED CODE ###

import math
s = str(input())
cou = 0
co = 0
ans = 0
while cou + co +2 <= len(s):
  if s[cou] == "x":
    if s[-1-co] == "x":
      cou += 1
      co += 1
    else:
      cou += 1
      ans += 1
  else:
    if s[-1-co] == "x":
      co += 1
      ans += 1
    else:
      if s[cou] == s[-1-co]:
        cou += 1
        co += 1
      else:
        print(-1)
        exit()
print(ans)
s=input()
l=len(s)
for _ in range(l)
  s.pop(l-1)
  if(s[:l//2]*2==s)
  print(l)

### FIXED CODE ###

s=input()
l=len(s)
for _ in range(l):
  s=s[:-1]
  if(len(s)%2==1):
    continue
  if(s[:len(s)//2]*2==s):
    print(len(s))
    break
def chec(s):
    llis = []
    rlis = []
    clis = 0
    lef = 1
    rig = 1
    rtmp = 0
    ltmp = 0
    flg = 0
    na = len(s)
    for i in range(na):
        if na - i != 1 and s[na-i-1] == '#' and s[na-i] == '.' :
            #clis+= 1
            #print(i)
            rtmp = na - i
            ltmp = na - i-1
            while ltmp != 0 and s[ltmp] == s[ltmp-1]:
                lef += 1
                ltmp -= 1
            llis.append(lef)
            while rtmp != na and s[rtmp] == s[rtmp+1]:
                rig += 1
                rtmp += 1
            rlis.append(rig)
            lef = 1
            rig = 1
            rtmp = 0
            ltmp = 0
    #print(llis)
    #print(rlis)

    clis = min(sum(llis),sum(rlis))
    return clis


n = int(input())
s = list(input())
print(chec(s))

### FIXED CODE ###

a,b,c = map(int, input().split())
if (a <= c and c <= b) or (a >= c and c >= b):
    print('Yes')
else:
    print('No')
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    g = math.gcd(a, b)

    def search(n):
        i = 2
        so = []
        while n != 1:
            while n % i == 0:
                n //= i
                so.append(i)
            i += 1
        return so

    print(len(set(search(g))) + 1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    g = fractions.gcd(a, b)

    def search(n):
        i = 2
        so = []
        while not(n == 1 or i * i > n):
            while n % i == 0:
                n //= i
                so.append(i)
            i += 1
        if n != 1:
            so.append(n)

        return so

    ans = set(search(g))
    print(len(ans) + 1)


if __name__ == '__main__':
    main()
n, d = map(int, input().split())
i = (n // 2*r) + 1
print(i)

### FIXED CODE ###

n, d = map(int, input().split())
if n % (2*d + 1) == 0:
  print(n // (2*d + 1))
else:
  print(n // (2*d + 1) + 1)
N,K = map(int, input().split())
List = list(map(int, input().split()))

a=[]
b=1
for i in range(N):
    if not b in a:
        a[i]=b
        b=List[b-1]
    else:
        c=i
        break
#print(a)
#print(b,c)
num=a.index(b)
#print(T,num)
T=c-num
if K<num:
    print(a[K])
else:
    print(a[num:][(K-num)%T])

### FIXED CODE ###

N,K = map(int, input().split())
List = list(map(int, input().split()))

a=[]

for i in range(N):
    a.append(-1)
#print(a)
b=1
for i in range(N):
    if a[b-1]==-1:
        a[b-1]=i+1
        b=List[b-1]
        
    else:
        c=i
        break
#print(a)
#print(b,c)

num=a[b-1]-1
T=c-num
#print(T)
e=1
if K<num:
    for i in range(K):
        e=List[e-1]
    print(e)
else:
    qw=(K-num)%T
    List_new=[]
    for i in range(T):
        List_new.append(b)
        b=List[b-1]
    print(List_new[qw])
N,M=input().split()

ans=((N-M)*100+M*1900)*pow(2,M)

print(str(ans))


### FIXED CODE ###

N,M=map(int,input().split())

ans=((N-M)*100+M*1900)*pow(2,M)

print(str(ans))
n,m = map(int, input().split())

A = [input() for i in range(n)]
B = [intpu() for j in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    if A[i][j:j+m] == B[0]:
      if all(A[i+k][j:j+m] == B[k] for k in range(1,M)):
        print("Yes")
        exit()
print("No")

### FIXED CODE ###

n,m = map(int, input().split())

A = [input() for i in range(n)]
B = [input() for j in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    if A[i][j:j+m] == B[0]:
      if all(A[i+k][j:j+m] == B[k] for k in range(1,m)):
        print("Yes")
        exit()
print("No")
a = set(range(ord(a), ord(z) + 1))
b = set([ord(i) for i in input()])
print('None' if a==b else chr(min(a-b)))

### FIXED CODE ###

s = input()
for i in range(ord('a'), ord('z')+1):
  if chr(i) not in s:
    print(chr(i))
    break
else:
  print('None')
N, M = map( int, input().split())
A = list( map( int, input().split()))
C = [0,2,5,5,4,5,6,3,7,6]
dp = [(0,0)]*(N+1)
for i in range(M):
    dp[C[A[i]]] = (1,0)
Z = list( set( C[a] for a in A))
Z.sort()
for i in range(2,N+1):
    for z in Z:
        if i > z:
            if dp[i-z][0] == 1:
                dp[i] = (1, i-z)
                break
s = N
ANS = [0]*10
while s != 0:
    _, b = dp[s]
    ANS[s-b] += 1
    s = b
ans = ""
for i in range(9,0,-1):
    if ANS[C[i]] > 0:
        if i in A:
            ans = ans + str(i)*ANS[C[i]]
            ANS[C[i]] = 0
print( ans)

### FIXED CODE ###

N, M = map( int, input().split())
A = list( map( int, input().split()))
Needs = [0,2,5,5,4,5,6,3,7,6]
A.sort(reverse = True)
V = [0]*10
Check = []
for a in A:
    if V[Needs[a]] == 0:
        Check.append(Needs[a])
        V[Needs[a]] = a
Check.sort()
dp = [-100000]*(N+1)
dp[0] = 0

for x in Check:
    if x <= N:
        dp[x] = 1
for i in range(1,N):
    t = dp[i]
    for x in Check:
        if x + i <= N:
            if dp[x+i] < t + 1:
                dp[x+i] = t+1
ans = ""
t = N
W = [0]*10
while t > 0:
    for a in A:
        x = Needs[a]
        if t-x>=0:
            if dp[t-x]+1 == dp[t]:
                W[V[x]] += 1
                t -= x
                break
for i in range(9,0,-1):
    ans += str(i)*W[i]
print(ans)
n, a, b = (int(i) for i in input().split())
count = 0
for i in range(1, n):
    res = sum([int(j) for j in str(n)])
    if(a <= res && res <= b):
        count = count + 1
print(count)

### FIXED CODE ###

n, a, b = (int(i) for i in input().split())
result = 0
for i in range(1, n + 1):
    res = sum([int(j) for j in str(i)])
    if(a <= res & res <= b):
        result = result + i
print(result)
while(True):
    a = 0
    n = int(input())

    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
            #print("(%d,0,0,0)"%(i))
            break
        for j in range(10):
            if n-i-j==0:
                a=a+1
                #print("(%d,%d,0,0)"%(i,j))
                break
            for k in range(10):
                b = n-i-j-k
                if b>=0 and b<=9:
                    a=a+1
                    #print("(%d,%d,%d,%d)"%(i,j,k,b))
                    continue
                elif b > 9:
                    continue
                else:
                    break
                    
    
    print(a)
return 0

### FIXED CODE ###

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
            #print("(%d,0,0,0)"%(i))
            break
        for j in range(10):
            if n-i-j==0:
                a=a+1
                #print("(%d,%d,0,0)"%(i,j))
                break
            for k in range(10):
                b = n-i-j-k
                if b>=0 and b<=9:
                    a=a+1
                    #print("(%d,%d,%d,%d)"%(i,j,k,b))
                    continue
                elif b > 9:
                    continue
                else:
                    break


    print(a)
N,M,Q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(Q):
  ta,tb,tc,td=map(int,input().split())
  a+=[ta]
  b+=[tb]
  c+=[tc]
  d+=[td]
maxs=0
A=[0 for i in range(N)]
for i in intertools.combination_with_replacement(A,N):
  s=0
  for k in range(Q):
    if i[b[k]-1]-i[a[k]-1]==c[k]:
      s+=d[k]
  maxs=max(maxs,s)
      
print(maxs)


### FIXED CODE ###

N,M,Q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(Q):
  ta,tb,tc,td=map(int,input().split())
  a+=[ta]
  b+=[tb]
  c+=[tc]
  d+=[td]
maxs=0
A=[0 for i in range(10)]
for i in range(M):
  for j in range(i,M):
    for k in range(j,M):
      for l in range(k,M):
        for m in range(l,M):
          for n in range(m,M):
            for o in range(n,M):
              for p in range(o,M):
                for q in range(p,M):
                  for r in range(q,M):
                    A[0]=i
                    A[1]=j
                    A[2]=k
                    A[3]=l
                    A[4]=m
                    A[5]=n
                    A[6]=o
                    A[7]=p
                    A[8]=q
                    A[9]=r
                    su=0
                    for z in range(Q):
                      if A[b[z]-1]-A[a[z]-1]==c[z]:
                        su+=d[z]
                    if su>maxs:
                      maxs=su
print(maxs)