Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N,K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
mod = 10**9+7

E = [[] for _ in [0]*N]
for a,b in AB:
    E[a-1].append(b-1)
    E[b-1].append(a-1)

ans = K
q = [0]
V = [-1]*N
V[0] = [0,0]
while q:
    qq = []
    for i in q:
        cSet = set(range(K))-set(V[i])
        for j in E[i]:
            if V[j]!=-1:continue
            ans = ans * len(cSet) % mod
            if ans == 0:break
            qq.append(j)
            V[j] = [cSet.pop(),V[i][0]]
    q = qq
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
mod = 10**9+7

E = [[] for _ in [0]*N]
for a,b in AB:
    E[a-1].append(b-1)
    E[b-1].append(a-1)

ans = K
q = [0]
V = [False for _ in [0]*N]
V[0] = True
while q:
    qq = []
    for i in q:
        #tmp = sorted(set(V[i]))
        #cSet = list(range(tmp[0])) + list(range(tmp[0]+1,tmp[-1])) + list(range(tmp[-1]+1,K))
        l = K-2+(i==0)
        for j in E[i]:
            if V[j]:continue
            ans = ans * l % mod
            if ans == 0:break
            qq.append(j)
            V[j] = True
            l -= 1
    q = qq
print(ans)
### BUGGY CODE ###

s = [len(x) for x in input().split('T')]
x, y = map(int, input().split())
len_s = len(s)
sx = [s[i] for i in range(len_s) if i % 2 == 0]
sy = [s[i] for i in range(len_s) if i % 2 == 1]

x -= sx[0]
sx = sx[1:]



def is_reachable(p, s):
    origin = 8000
    if origin+p < 0:
        return False
        
    n = len(s)
    reachable = [[False for _ in range(origin * 2 + 1)] for i in range(n + 2)]
    reachable[0][origin] = True

    for i in range(n):
        for j in range(origin * 2 + 1):
            if not reachable[i][j]:
                continue
            if j - s[i] >= 0:
                reachable[i + 1][j - s[i]] = True
            if j + s[i] <= origin * 2:
                reachable[i + 1][j + s[i]] = True
    return reachable[n][p + origin] or reachable[n][-p + origin]


if is_reachable(x, sx) and is_reachable(y, sy):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s = [len(x) for x in input().split('T')]
x, y = map(int, input().split())
len_s = len(s)
sx = [s[i] for i in range(len_s) if i % 2 == 0]
sy = [s[i] for i in range(len_s) if i % 2 == 1]

x -= sx[0]
sx = sx[1:]



def is_reachable(p, s):
    origin = 8000
    if origin+p < 0:
        return False
        
    n = len(s)
    reachable = [set() for i in range(n + 1)]
    reachable[0].add(origin)

    for i in range(n):
        for j in list(reachable[i]):
            if j - s[i] >= 0:
                reachable[i + 1].add(j - s[i])
            if j + s[i] <= origin * 2:
                reachable[i+1].add(j + s[i])
    return (origin+p) in reachable[n] or (origin-p) in reachable[n]


if is_reachable(x, sx) and is_reachable(y, sy):
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

N = int(input())

buttons = {}
for i in range(N):
    buttons[i+1] = int(input())
    
pushed = []

b = 1
cnt = 0
while True:
    cnt += 1
    next_button = buttons[b]
    if next_button == 2:
        flag = True
        break
    pushed.append(b)
    b = next_button
    if b in pushed:
        flag = False
        break
        
if flag:
    print(cnt)
else :
    print(-1)

### FIXED CODE ###

N = int(input())

buttons = {}
for i in range(N):
    buttons[i+1] = int(input())
    
pushed = []

b = 1
cnt = 0
flag = False
for i in range(N):
    cnt += 1
    next_button = buttons[b]
    if next_button == 2:
        flag = True
        break
    b = next_button
        
if flag:
    print(cnt)
else :
    print(-1)
### BUGGY CODE ###

import bisect

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

A=list(map(int,input().split()))
A.sort()

for w in range(M):
    max2=A.pop(N-1)/2
    #A[N-1]=A[N-1]/2
    #max=A[N-1]
    
    bisect.insort_left(A,max2)
    #print(A)

B=list(map(int, A))
#print(B)
print(sum(B))

### FIXED CODE ###

import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))
#print(A)
A =[-a for a in A]
#print(A)
heapq.heapify(A)

for w in range(M):
    max=heapq.heappop(A)
    heapq.heappush(A,max/2)
   
B=list(map(int, A))
#print(B)
print(sum(B)*-1)
### BUGGY CODE ###

n, m= list(map(int, input().split()))
key=[]
for i in range(m):
    a,b= list(map(int, input().split()))
    c= list(map(int, input().split()))
    s=0
    for j in range(b):
        s|=1<<c[j]-1
    tmp=[s,a]
    key.append(tmp)
inf=1001001001
dp=[inf for _ in range(1<<n)]
dp[0]=0
for s in range(1<<n):
    for i in range(m):
        t = s|key[i][0]
        cost=dp[s]+key[i][1]
        dp[t]=min(dp[t],cost)
ans=dp[-1]
if ans==inf:
    ans=-1
print(ans)

### FIXED CODE ###

n, m= list(map(int, input().split()))
key=[]
for i in range(m):
    a,b= list(map(int, input().split()))
    c= list(map(int, input().split()))
    s=0
    for j in range(b):
        s|=1<<c[j]-1
    tmp=[s,a]
    key.append(tmp)
inf=1001001001
dp=[inf for _ in range(1<<n)]
dp[0]=0
for s in range(1<<n):
    for i in range(m):
        t = s|key[i][0]
        cost=dp[s]+key[i][1]
        dp[t]=min(dp[t],cost)
ans=dp[-1]
if ans==inf:
    ans=-1
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import defaultdict,deque
n,q=map(int, input().split())
c=list(map(int, input().split()))
c=[i-1 for i in c]
lr=[]
for i in range(q):
    l,r=map(int, input().split())
    lr.append((l-1,r-1))
lrsort=sorted(lr, key=lambda x:x[0])
lrsort=sorted(lr, key=lambda x:x[1])
lrsort=deque(lrsort)
#print(lrsort)
goodball=[-1]*n
d=defaultdict(int)
s=0
while lrsort:
    l,r=lrsort.popleft()
    for i in range(s,r+1):
        goodball[c[i]]=i
    s=r+1
    d[(l,r)]=sum([1 for g in goodball if l<=g])

for l,r in lr:
    print(d[(l,r)])

### FIXED CODE ###

import sys
input = sys.stdin.readline
# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

n,q=map(int,input().split())
c=list(map(int,input().split()))
ques=[]
from collections import defaultdict
ans=defaultdict(int)
for _ in range(q):
    l,r=map(int,input().split())
    ques.append((l,r))

sortques=sorted(ques, key=lambda x:x[1])

good=BIT(n+1)
goodind=[-1]*n
last=0
for x in range(q):
    l,r=sortques[x]
    if last!=r:
        for i in range(last, r):
            if goodind[c[i]-1]==-1:
                goodind[c[i]-1]=i
                good.add(i+1, 1)
            else:
                j=goodind[c[i]-1]
                good.add(j+1, -1)
                goodind[c[i]-1]=i
                good.add(i+1, 1)
    ans[(l,r)]=good.get(l-1,r)
    last=r

for i in range(q):
    print(ans[ques[i]])
### BUGGY CODE ###

import sys
from itertools import permutations
from math import factorial
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XY = np.array([list(map(int, readline().split())) for _ in range(N)])

dist = 0
for route in permutations(XY, N):
    acc = 0
    dists = [
        np.sqrt(sum(pow(route[i] - route[i + 1], 2))) for i in range(N - 1)
    ]
    dist += sum(dists)
print(dist / factorial(N))

### FIXED CODE ###

import sys
from itertools import permutations
from math import factorial
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XY = [list(map(int, readline().split())) for _ in range(N)]

dist = 0
for route in permutations(XY, N):
    acc = 0
    dists = [
        np.sqrt(
            pow(route[i][0] - route[i + 1][0], 2) +
            pow(route[i][1] - route[i + 1][1], 2)) for i in range(N - 1)
    ]
    dist += sum(dists)
print(dist / factorial(N))
### BUGGY CODE ###

from collections import deque


def solvemaze(y, x, num):
    maps.append([])
    dx, dy = (-1, 0, 1, 0), (0, -1, 0, 1)
    maze[y][x] = num
    que = deque()
    que.append((y, x))
    while que:
        y_, x_ = que.popleft()
        maps[num].append((y_, x_))
        for i in range(4):
            y2 = y_ + dy[i]
            x2 = x_ + dx[i]
            if 0 <= y2 < h and 0 <= x2 < w and maze[y2][x2] == '.':
                maze[y2][x2] = num
                que.append((y2, x2))

def makeroute(s_maps, num):
    res = []
    for y, x in s_maps:
        for i in range(-2, 3):
            for j in range(-2, 3):
                y2 = y + i
                x2 = x + j
                if 0 <= y2 < h and 0 <= x2 < w and not maze[y2][x2] in (num,'#') and not maze[y2][x2] in res:
                    res.append(maze[y2][x2])
    
    return res
    

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [[x for x in input()] for _ in range(h)]
maps = []

num = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            solvemaze(i, j, num)
            num += 1

E = [[] for _ in range(num)]
for i in range(num):
    E[i] = makeroute(maps[i], i)

s = maze[Ch-1][Cw-1]
g = maze[Dh-1][Dw-1]
used = [False] * num
used[s] = True
que = deque()
que.append((0, s))
cost = [float('inf')] * num
cost[s] = 0
while que:
    c, v = que.popleft()
    for e in E[v]:
        if not used[e]:
            que.append((c+1, e))
            cost[e] = c+1
            used[e] = True
if not used[g]:
    print(-1)
else:
    print(cost[g])

### FIXED CODE ###

from collections import deque


h, w = map(int, input().split())
Ch, Cw = map(lambda x: int(x)-1, input().split())
Dh, Dw = map(lambda x: int(x)-1, input().split())
dy, dx = (-1, 0, 1, 0), (0, -1, 0, 1)
maze = [[float('inf') if x == '.' else -float('inf') for x in input()] for _ in range(h)]
maze[Ch][Cw] = 0
que = deque()
que.append((0, Ch, Cw))
while que:
    c, y, x = que.popleft()
    
    if c > maze[y][x]:
        continue
    
    if y == Dh and x == Dw:
        break
    
    for i in range(4):
        y2, x2 = y + dy[i], x + dx[i]
        if 0 <= y2 < h and 0 <= x2 < w and c < maze[y2][x2]:
            maze[y2][x2] = c
            que.appendleft((c, y2, x2))
            
    for i in range(-2, 3):
        for j in range(-2, 3):
            y3, x3, c2 = y + i, x + j, c+1
            if 0 <= y3 < h and 0 <= x3 < w and c2 < maze[y3][x3]:
                maze[y3][x3] = c2
                que.append((c2, y3, x3))

ans = maze[Dh][Dw]
if ans == float('inf'):
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

def main():
    
    K = int(input())
    if K%2 == 0:
        print('-1')
        exit()
    
    ans = len(str(K))
    while 1:
        
        num = int('7'*ans)
        
        if num%K == 0:
            print(ans)
            break
        
        ans += 1

main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    K = I()
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1
    
    else:
        print('-1')

main()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))

counter = 0
for i in range(1, N):
  for j in range(N-1):
    if A[j] == i:
      counter += 1
  print(counter)
  counter = 0
print(0)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))

l = Counter(A)
for i in range(1, N+1):
  print(l[i])
### BUGGY CODE ###

N = int(input())
An = list(map(int, input().split()))
Q = int(input())

bc = [map(int, input().split()) for _ in range(Q)]
b, c = [list(i) for i in zip(*bc)]


for i in range(Q):
    for j, name in enumerate(An):
        if An[j] == b[i]:
            An[j] = c[i]
    
    print(sum(An))


### FIXED CODE ###

N = int(input())

An = list(map(int, input().split()))
Q = int(input())

L = [0] * 100001
for item in An:
    L[item] += 1

sum = sum(An)

for i in range(Q):
    b, c = map(int, input().split())
    sum += (c-b) * L[b]
    L[c] += L[b]
    L[b] = 0
    print(sum)
### BUGGY CODE ###

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

x,y,z=a.count(1),a.count(2),a.count(3)
n=x+y*2+z*3


dp=[[[0 for _ in range(n+2)] for _ in range(n+2)] for _ in range(n+2)]

for j in range(n+1):
    for i in range(n+1):
        for h in range(n+1):
            if h+i+j==0 or h+i*2+j*3>n:
                continue
            dp[h][i][j]=(dp[h-1][i][j]*h/N+dp[h+1][i-1][j]*i/N+dp[h][i+1][j-1]*j/N+1)*N/(h+i+j)
            if h==x and i==y and j==z:
                print(dp[x][y][z])
                exit()


### FIXED CODE ###

import numpy as np
from numba import njit

N=int(input())
a=[int(i) for i in input().split()]
x,y,z=0,0,0
for i in a:
    if i==1:
        x+=1
    elif i==2:
        y+=1
    elif i==3:
        z+=1


dp=np.full((N+1,N+1,N+1),-1,dtype=np.float64)

dp[0][0][0]=0

@njit('f8(i8,i8,i8,i8,f8[:,:,:])', cache=True)
def calc(h,i,j,N,dp):
    if h+i+j==0:
        return 0
    if dp[h][i][j]>=0:
        return dp[h][i][j]
    A=1
    if h>=1:
        A+=calc(h-1,i,j,N,dp)*h/N
    if i>=1:
        A+=calc(h+1,i-1,j,N,dp)*i/N
    if j>=1:
        A+=calc(h,i+1,j-1,N,dp)*j/N
    A=A*N/(h+i+j)
    dp[h][i][j]=A
    return A

a=calc(x,y,z,N,dp)

print(dp[x][y][z])
### BUGGY CODE ###

K = int(input()) -1
q = list(range(1,10))
while K > 0:
    x = q.pop(0)
    if x %10 != 0:
        q.append(10*x +x%10 -1)
    q.append(10*x + x%10)
    if x % 10 != 9:
        q.append(10*x + x%10 +1)
    K -= 1
print(q[0])


### FIXED CODE ###

import queue
K = int(input()) -1
q = queue.Queue()
for i in range (1,10):
    q.put(i)
while K > 0:
    x = q.get()
    if x %10 != 0:
        q.put(10*x +x%10 -1)
    q.put(10*x + x%10)
    if x % 10 != 9:
        q.put(10*x + x%10 +1)
    K -= 1
ans = q.get()
print(ans)
### BUGGY CODE ###

from collections import Counter

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

ans = 0
num = len(A.keys())
while num > K:
  min_key = [key for key in A if A[key] == min(A.values())][0]
  ans += A[min_key]
  num -= 1
  del A[min_key]
print(ans)

### FIXED CODE ###

from collections import Counter

N,K = map(int,input().split())
A = Counter(list(map(int,input().split())))
nums = sorted(A.values(), reverse= True)
num = len(nums)
ans = 0

while num > K:
  ans += nums[-1]
  del nums[-1]
  num -= 1
print(ans)
### BUGGY CODE ###

n = int(input())
*l, = map(int,input().split())
rect = [i for i in set(l) if l.count(i)>=2]
squ = [i for i in rect if l.count(i)>=4]
rect.sort()
squ.sort()
if len(rect)>=2:
  srect = rect[-1]*rect[-2]
else:
  srect = 0
if len(squ)>=1:
  ssqu=squ[-1]**2
else:
  ssqu=0
print(max([srect,ssqu]))
  

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
l.sort()
l.reverse()
squ = 0
rec = []
count = 0
tmp = 0
for i in l:
  if i == tmp:
    count += 1
  else:
    tmp = i
    count = 1
  
  if count == 2:
    rec.append(tmp)
  elif count == 4:
    squ = max([squ,tmp])

if len(rec)<2:
  print(squ*squ)
else:
  print(max([squ*squ,rec[0]*rec[1]]))
### BUGGY CODE ###

from collections import deque

N = int(input())
# mtx = np.zeros([N, N], dtype=np.int32)
tree = [[] for i in range(N)]

key_order = [0] * (N-1)
for i in range(N-1):
    in1, in2 = map(int, input().split())
    in1 -= 1
    in2 -= 1
    tree[in1].append(in2)
    tree[in2].append(in1)

    key_order[i] = (in1, in2)

# [print(i, t) for i, t in enumerate(tree)]


def bfs(tree, p):
    seen = [False] * len(tree)
    queue = deque((p,))

    node_colors = [set() for _ in tree]
    edge_colors = dict()
    all_colors = set()
    color = 0

    while len(queue) > 0:
        q = queue.popleft()
        seen[q] = True
        for v in tree[q]:
            if not seen[v]:
                residual = all_colors - node_colors[q]
                if len(residual) > 0:
                    this_color = residual.pop()
                else:
                    color += 1
                    this_color = color
                edge_colors[(q, v)] = this_color
                node_colors[q].add(this_color)
                node_colors[v].add(this_color)
                all_colors.add(this_color)

                queue.append(v)

    return edge_colors


edge_colors = bfs(tree, 0)

print(max([c for key, c in edge_colors.items()]))
[print(edge_colors[t]) for t in key_order]
# print(edge_colors)

# show_tree(tree)


### FIXED CODE ###

from collections import deque

N = int(input())
# mtx = np.zeros([N, N], dtype=np.int32)
tree = [[] for i in range(N)]

key_order = [0] * (N-1)
for i in range(N-1):
    in1, in2 = map(int, input().split())
    in1 -= 1
    in2 -= 1
    tree[in1].append(in2)
    tree[in2].append(in1)

    key_order[i] = (in1, in2)

# [print(i, t) for i, t in enumerate(tree)]


def bfs(tree, p):
    seen = [False] * len(tree)
    queue = deque((p,))

    edge_colors = dict()
    node_colors = [0] * len(tree)
    while len(queue) > 0:
        q = queue.popleft()
        seen[q] = True

        parent_color = node_colors[q]

        cnt = 1
        for v in tree[q]:
            if not seen[v]:
                if cnt == parent_color:
                    cnt += 1

                edge_colors[(q, v)] = cnt
                node_colors[v] = cnt
                queue.append(v)
                cnt += 1



    """
    node_colors = [set() for _ in tree]
    edge_colors = dict()
    all_colors = set()
    color = 0

    while len(queue) > 0:
        q = queue.popleft()
        seen[q] = True

        for v in tree[q]:
            if not seen[v]:
                residual = all_colors - node_colors[q]
                if len(residual) > 0:
                    this_color = residual.pop()
                else:
                    color += 1
                    this_color = color
                edge_colors[(q, v)] = this_color
                node_colors[q].add(this_color)
                node_colors[v].add(this_color)
                all_colors.add(this_color)

                queue.append(v)
    """

    return edge_colors


edge_colors = bfs(tree, 0)

print(max([c for key, c in edge_colors.items()]))
[print(edge_colors[t]) for t in key_order]
# print(edge_colors)

# show_tree(tree)
### BUGGY CODE ###

from functools import reduce
from fractions import gcd

n, x_ini = map(int, input().split())
x = list(map(int, input().split()))

x += [x_ini]

# print(x)

x2 = [x[i] - min(x) for i in range(n + 1)]

# print(x2)

x_ini -= min(x)

# print(x_ini)

ans = reduce(gcd, x2)

print(ans)


### FIXED CODE ###

from functools import reduce
from fractions import gcd

n, x_ini = map(int, input().split())
x = [abs(x_ini - int(i)) for i in input().split()]

ans = reduce(gcd, x)

print(ans)
### BUGGY CODE ###

n = int(input())

loop = int(n**(1/2))

for i in range(1, n+1):
    count = 0
    for x in range(1, loop+1):
        for y in range(1, loop+1):
            for z in range(1, loop+1):
                if ((x+y+z)**2 - x*y - y*z - z*x) == i:
                    count += 1
    print(count)

### FIXED CODE ###

n = int(input())
ans = [0] * (n + 1)
 
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            val = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if val <= n:
                ans[val] += 1
 
print(*ans[1:], sep="\n")
### BUGGY CODE ###

n = int(input())

ans = 0
x = 1

while 1:
    if n % x == 0:
        m = n // x - 1
        if m <= x:
            break
        else:
            ans += m
    x += 1

print(ans)

### FIXED CODE ###

n = int(input())

if n < 100000:

    ans = 0
    x = 1

    while x < n:
        if n % x == 0:
            m = n // x - 1
            if m <= x:
                break
            else:
                ans += m
        x += 1

    print(ans)

    exit()


ans = 0
x = 1

t = int(n ** 0.5)

while x <= int(n ** 0.5):
    if n % x == 0:
        ans += n // x - 1
    x += 1

if t * t == n:
    ans -= t - 1

print(ans)
### BUGGY CODE ###

N,K,Q=map(int,input().split())
List=[int(input()) for i in range(Q)]
for j in range(1,N+1):
  if (K-Q+List.count(j)) >0:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

N,K,Q=map(int,input().split())
scores=[0 for i in range(N)]

for j in range(Q):
  A=int(input())
  scores[A-1]+=1
  
for score in scores:
  if K-Q+score>0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

s=input()
q=int(input())
is_reverse=False
for i in range(q):
    qi=list(input().split())
    if(len(qi)==1):
        is_reverse = not is_reverse
    elif(qi[1]=="1"):
        if(is_reverse):
            s=s+qi[2]
        else:
            s=qi[2]+s
    else:
        if(is_reverse):
            s=qi[2]+s
        else:
            s=s+qi[2]

if(is_reverse):
    print(s[::-1])
else:
    print(s)

### FIXED CODE ###

s=input()
q=int(input())
is_reverse=False
pre=[]
post=[]
for i in range(q):
    qi=list(input().split())
    if(len(qi)==1):
        is_reverse = not is_reverse
    elif(qi[1]=="1"):
        if(is_reverse):
            post.append(qi[2])
        else:
            pre.append(qi[2])
    else:
        if(is_reverse):
            pre.append(qi[2])
        else:
            post.append(qi[2])

if(is_reverse):
    print(''.join(post)[::-1] + s[::-1] + ''.join(pre))
else:
    print(''.join(pre)[::-1] + s + ''.join(post))
### BUGGY CODE ###

from itertools import combinations_with_replacement

n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(q)]

# n,m,q=3,4,3
# l=[[1,3,3,100], [1,2,2,10], [2,3,2,10]]

A=list(combinations_with_replacement(range(1,m+1),n))

res=0

for i in range(len(A)):
    tmp=0
    for j in range(len(l)):
        bnum=l[j][1]-1
        anum=l[j][0]-1
        c=l[j][2]
        d=l[j][3]

        if A[i][bnum]-A[i][anum]==c:
            tmp+=d

    res=max(res, tmp)

print(res)

### FIXED CODE ###

from itertools import combinations_with_replacement

n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(q)]

A=list(combinations_with_replacement(range(1,m+1),n))

res=0

for i in range(len(A)):
    tmp=0
    for j in range(len(l)):
        if A[i][l[j][1]-1]-A[i][l[j][0]-1]==l[j][2]:
            tmp+=l[j][3]

    res=max(res, tmp)

print(res)
### BUGGY CODE ###

n = int(input())
b = 0
"""def div(n):
    for k in range(2,n+1):
        if n % k == 0:
            return k
    return 1

def pf(n):
    pf=[]
    while n != 1:
        pf.append(div(n))
        n = n // div(n)
    #p = list(set(pf))
    return pf"""

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

for c in range(1,n):
    m = n - c #mの約数を数える
    b += len(make_divisors(m))
    """insu2 = list(set(insu))
    l = len(insu2)
    d = 1
    for j in range(l):
        k = insu.count(insu2[j]) + 1
        d = k * d
    b += d"""

print(b)



### FIXED CODE ###

n = int(input())
count = 0
for a in range(1,n):
    b = (n-1) // a
    count += b

print(count)
### BUGGY CODE ###

ans=0
K,S=map(int,input().split())
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z==S:
        ans+=1
print(ans)

### FIXED CODE ###

ans=0
K,S=map(int,input().split())
for x in range(K+1):
  for y in range(K+1):
    if 0<=S-x-y and S-x-y<=K:
      ans+=1
print(ans)