Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys
import math
MOD = 1000000007  # type: int

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    matrix = [[] for _ in range(N+1)]
    for i in range(N-1):
        matrix[a[i]].append(b[i])
        matrix[b[i]].append(a[i])
    
    visited = [0]*(N+1)

    from collections import deque
    queue = deque([1])
    
    answer = K
    while queue:
        q = queue.pop()
        if q == 1 and visited[q] == 0:
            answer *= permutations_count(K-1,len(matrix[1]))
        else: #q!=1 or visited==1
            if visited[q] == 0:
                answer *= permutations_count(K-2,len(matrix[q])-1) #親ノード引いてる
                answer%=MOD
            else:
                continue

        visited[q] = 1

        for child_node in matrix[q]:
            queue.append(child_node)

    print(answer%MOD)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
MOD = 1000000007  

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    matrix = [[] for _ in range(N+1)]
    for i in range(N-1):
        matrix[a[i]].append(b[i])
        matrix[b[i]].append(a[i])
    
    visited = [0]*(N+1)

    from collections import deque
    queue = deque()
    visited[1]=1
    answer = K
    num = K-1
    for node in matrix[1]:
        answer *= num
        answer %= MOD

        num -= 1
        queue.append(node)

    while queue:
        q = queue.popleft()
        if visited[q] != 0:
            continue
        visited[q] = 1

        num = K-2
        for child_node in matrix[q]:
            if visited[child_node] == 0:
                answer *= num
                answer %= MOD
                num -= 1
                queue.append(child_node)
        answer %= MOD

    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()
N=int(input())
A=map(int,input().split())
B=map(int,input().split())
C=map(int,input().split())
A.split()
B.split()
C.split()
s=B[A[0]-1]
for i in range(1,len(S)+1):
  s+=B[A[i]-1]
  if A[i]==A[i-1]+1:
    s+=C[i-1]
print(s)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
temp=""
for i in A:
  s+=B[i-1]
  if temp==i-1:
    s+=C[temp-1]
  temp=i
print(s)
from sys import stdin
import numpy as np


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    K = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    x_arr = np.arange(1,K+1)
    cnt = np.gcd.outer(np.gcd.outer(x_arr,x_arr),x_arr).sum()
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


### FIXED CODE ###

import sys
import fractions

def in_ctrl():
    _input = [_.rstrip() for _ in sys.stdin.readlines()]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    K = int(_input[0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return K


def out_ctrl(s):
    print(s)


if __name__ == "__main__":
    K = in_ctrl()
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    dict_ = {}
    for a in range(1,K+1):
        cnt += a
        for b in range(a+1,K+1):
            if '{}_{}'.format(a,b) in dict_:
                ans = dict_['{}_{}'.format(a,b)]
            else:
                ans = fractions.gcd(a,b)
                dict_['{}_{}'.format(a,b)] = ans
            cnt += 6*ans
            for c in range(b+1,K+1):
                if '{}_{}'.format(ans,c) in dict_:
                    _ans = dict_['{}_{}'.format(ans,c)]
                else:
                    _ans = fractions.gcd(ans, c)
                    dict_['{}_{}'.format(ans,c)] = _ans
                cnt += 6*_ans
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    out_ctrl(cnt)
# coding: utf-8
# Your code here!
from math import gcd

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

temp=A[0]
for item in A:
    temp=temp*item//gcd(temp,item)

ans=0
for item in A:
    ans+=temp//item
    ans%=10**9+7
#print(temp)
print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

import functools

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)


N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12


ans=0
for index,item in enumerate(a):
    ans+=(calc)//item

print(int((ans)%(10**9+7)))
s1, s2, s3 = map(int, input().split())
ans = str(chr(ord(s1[0])-32)) + str(chr(ord(s2[0])-32)) + str(chr(ord(s3[0])-32))
print(ans)

### FIXED CODE ###

s1, s2, s3 = input().split()
ans = str(chr(ord(s1[0])-32)) + str(chr(ord(s2[0])-32)) + str(chr(ord(s3[0])-32))
print(ans)
s = input()
for i in range(len(s)):
  if s[i] == "K" ans i == 0:
    s = s[:i] + "A" + s[i:]
  elif s[i] == "H" and s[i+1] !=  "A":
    s = s[:i] + "A" + s[i:]
  elif s[i] == "B" and s[i+1] !=  "A":
    s = s[:i] + "A" + s[i:]
  elif s[i] == "R" and s[i+1] !=  "A":
    s = s[:i] + "A" + s[i:]

if s == "AKIHABARA":
  print("YES")
else:
  print("NO")

### FIXED CODE ###

s = input()
rep = s.replace("A","")

if rep == "KIHBR" and "AA" not in s and "KIH" in s :
  print("YES")
else:
  print("NO")
from sys import stdin

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

for i in s:
    if i != "1":
        zantei = int(i)
        break

if zantei == 1:
    print(1)
else:
    print(zantei)

### FIXED CODE ###

from sys import stdin

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

zantei = 1
kai = 0
for i in s:
    if i == "1":
        kai += 1
    else:
        zantei = int(i)
        break

if zantei == 1:
    print(1)

elif kai >= k:
    print(1)
else:
    print(zantei)
a,b,c=map(int,input().split())
if a+b>=c>=a
  print("YES")
else:
  print("NO")


### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b>=c>=a:
  print("YES")
else:
  print("NO")
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n,m = m()

l = [l() for i in range(n)]
l.sort(key = lambda x:x[2])
ans = [-1]*m
ju = [-1]*m
d = [onem() for i in range(m)]
for s,t,x in l:
    ore = bs.bisect_left(d,s-x)
    o = s.bisect_left(d,t-x)
    while (ore < o):
        k = ju[ore]
        if k == -1:
            ans[ore] = x
            ju[ore] = o
            ore += 1
        else:
            ore = k
for i in range(m):
    print(ans[i])


### FIXED CODE ###

import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n,m = m()

l = [l() for i in range(n)]
l.sort(key = lambda x:x[2])
ans = [-1]*m
ju = [-1]*m
d = [onem() for i in range(m)]
for s,t,x in l:
    ore = bs.bisect_left(d,s-x)
    o = bs.bisect_left(d,t-x)
    while (ore < o):
        k = ju[ore]
        if k == -1:
            ans[ore] = x
            ju[ore] = o
            ore += 1
        else:
            ore = k
for i in range(m):
    print(ans[i])
k = int(input())
s = list(input())
if k=>len(s):
    print(s)
else print(s[for k i in range k+1]+"...")

### FIXED CODE ###

k = int(input())
s =input()
if k>=len(s):
    print(s)
else:
    for i in range (k):
        print(s[i],end="")
    print("...")
params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount[i] = 0

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penaltyCount += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)

### FIXED CODE ###

params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount.append(0)

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])-1
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penalties += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)
n=int(input())
CSF=[list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
  ans=0
  for c,s,f in CSF[i:]:
    if ans<s:
      ans=s
    else:
      ans+=f-t%f
    ans+=c
  print(ans)

### FIXED CODE ###

n=int(input())
CSF=[list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
  ans=0
  for c,s,f in CSF[i:]:
    if ans<s:
      ans=s
    elif ans%f!=0:
      ans+=f-ans%f
    ans+=c
  print(ans)
R=int(input())
print(2*π*R)

### FIXED CODE ###

r=int(input())
import math
print(2*math.pi*r)
from scipy.special import comb
N, K = map(int,input().split())

for i in range(1, K+1):
    ans = comb(N - K + 1, i, exact=True) * comb(K-1, i-1, exact=True)
    ans %= 10 ** 9 + 7
    print(ans)

### FIXED CODE ###

N, K = map(int,input().split())
ans = N-K+1
print(ans)
for i in range(2, K+1):
    ans = ans * (N-K+2-i) * (K+1-i) // (i - 1) // i
    print(ans % (10 ** 9 + 7))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
正則二部グラフの辺彩色
"""

import numpy as np

N,M = map(int,input().split())
grid = [[int(x) for x in input().split()] for _ in range(N)]

edge = []
for i,row in enumerate(grid):
    for j,x in enumerate(row):
        edge.append(((x-1)//M,N+i))

graph = [dict() for _ in range(N+N)] # 頂点ごろに、色->相手
rest_color = [set(range(M)) for _ in range(N+N)]

for u,v in edge:
    c = rest_color[u].pop()
    if c in rest_color[v]:
        graph[u][c] = v
        graph[v][c] = u
        rest_color[v].remove(c)
        continue
    # 交互道を作って色c,dと当てていく
    d = rest_color[v].pop()
    cd = c + d
    V = [u,v]
    next_c = c
    while next_c not in rest_color[v]:
        v = graph[v][next_c]
        V.append(v)
        next_c = cd - next_c
    rest_color[v].remove(next_c)
    rest_color[v].add(cd - next_c)
    for i,(u,v) in enumerate(zip(V,V[1:])):
        if i%2 == 0:
            graph[u][c] = v
            graph[v][c] = u
        else:
            graph[u][d] = v
            graph[v][d] = u

after = [[None] * M for _ in range(N)]

for i,row in enumerate(grid):
    mod_to_x = [[] for _ in range(N)]
    for x in row:
        mod_to_x[(x-1)//M].append(x)
    for color in range(M):
        after[i][color] = mod_to_x[graph[i][color] - N].pop()


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
正則二部グラフの辺彩色
"""

import numpy as np

N,M = map(int,input().split())
grid = [[int(x) for x in input().split()] for _ in range(N)]

edge = []
for i,row in enumerate(grid):
    for j,x in enumerate(row):
        edge.append(((x-1)//M,N+i))

graph = [dict() for _ in range(N+N)] # 頂点ごろに、色->相手
rest_color = [set(range(M)) for _ in range(N+N)]

for u,v in edge:
    common = rest_color[u] & rest_color[v]
    if common:
        c = common.pop()
        graph[u][c] = v
        graph[v][c] = u
        rest_color[u].remove(c)
        rest_color[v].remove(c)
        continue
    # 交互道を作って色c,dと当てていく
    c = rest_color[u].pop()
    d = rest_color[v].pop()
    cd = c + d
    V = [u,v]
    next_c = c
    while next_c not in rest_color[v]:
        v = graph[v][next_c]
        V.append(v)
        next_c = cd - next_c
    rest_color[v].remove(next_c)
    rest_color[v].add(cd - next_c)
    for i,(u,v) in enumerate(zip(V,V[1:])):
        if i%2 == 0:
            graph[u][c] = v
            graph[v][c] = u
        else:
            graph[u][d] = v
            graph[v][d] = u

after = [[None] * M for _ in range(N)]

for i,row in enumerate(grid):
    mod_to_x = [[] for _ in range(N)]
    for x in row:
        mod_to_x[(x-1)//M].append(x)
    for color in range(M):
        after[i][color] = mod_to_x[graph[i+N][color]].pop()

B = np.array(after)
C = B.copy()
C.sort(axis = 0)
print('\n'.join(' '.join(row) for row in B.astype(str)))
print('\n'.join(' '.join(row) for row in C.astype(str)))
n,k=map(int,raw_input().split())
c=[0]*200
r=range(n)
for i in r:c[ord(raw_input()[0])]+=1
c.sort()
p=a=0
while p<1:
 p=k;a+=1
 for i in r:
  if p*c[-i-1]:p-=1;c[-i-1]-=1
print a-1

### FIXED CODE ###

n,k=map(int,raw_input().split())
c=[0]*200
for i in[0]*n:c[ord(raw_input()[0])]+=1
p=a=0
while p<1:
 c.sort();p=k;a+=1
 for i in range(k+1):p-=c[-i]>0;c[-i]-=1
print a-1
N, M = map(int,input().split())
A = sorted([int(i) for i in input().split()])
BC = [list(map(int,input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: x[1])[::-1]
ind = 0
for b, c in BC:
  for i in range(b):
    if A[ind] < c:
      A[ind] = c
      ind += 1
    else:
      break
print(sum(A))

### FIXED CODE ###

N, M = map(int,input().split())
A = sorted([int(i) for i in input().split()])
BC = [list(map(int,input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: x[1])[::-1]
ind = 0
for b, c in BC:
  for i in range(b):
    if A[ind] < c:
      A[ind] = c
      ind += 1
      if ind == N:
        print(sum(A))
        exit()
    else:
      break
print(sum(A))
import sys
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
    for k in range(n-i-j+1):
      if i*10000+j*5000+k*1000==y:
        print(i j k)
        sys.exit()
print(-1 -1 -1)
    


### FIXED CODE ###

import sys
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
      if i*10000+j*5000+(n-i-j)*1000==y:
        print(*[i,j,n-i-j])
        sys.exit()
print(*[-1,-1,-1])
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit, maxsize


def main(readline=stdin.readline):
    n, q = (int(s) for s in readline().split())

    base = [0] * n
    midway = [0] * (n//1000 + 1)

    for _ in range(q):
        a, v = (int(s) for s in readline().split())
        a -= 1
        base[a] += v

        b = a - a % 1000

        index = value = -maxsize
        for i, v in enumerate(base[b:b+1000]):
            if value < v:
                index = i
                value = v
        midway[b] = index

        value = index = -maxsize
        for i in midway:
            if value < base[i]:
                value = base[i]
                index = i

        print(index+1, value)
    exit()


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    n, q = (int(s) for s in readline().split())

    base = [0] * n
    midway = [0] * (n//100 + 1)
    last = [0] * (n//10000 + 1)

    for _ in range(q):
        a, v = (int(s) for s in readline().split())

        a -= 1
        base[a] += v

        b = a - a % 100

        index = b
        value = base[b]
        end = b + 100 if b + 100 < n else n
        for i in range(b, end):
            if value < base[i]:
                value = base[i]
                index = i
        midway[b//100] = index

        c = a - a % 10000
        cc = c // 100

        index = c
        value = base[c]
        for i in midway[cc:cc+100]:
            if value < base[i]:
                value = base[i]
                index = i
        last[c//10000] = index

        index = last[0]
        value = base[index]
        for i in last:
            if value < base[i]:
                value = base[i]
                index = i

        print(index+1, value)
    exit()


if __name__ == '__main__':
    main()
from itertools import product

a, b, c, d, e, f = map(int, input().split())

lima = [100 * a * i for i in range(f // (100 * a) + 1)]
limb = [100 * b * i for i in range(f // (100 * b) + 1)]
setw = set([i + j for i, j in product(lima, limb) if 0 < i + j <= f])
limc = [c * i for i in range(f // c + 1)]
limd = [d * i for i in range(f // d + 1)]
sets = set([i + j for i, j in product(limc, limd) if 0 < i + j <= f])

cnt = 0
for w in setw:
    for s in sets:
        if cnt <= 100 * s / w <= e and s + w <= f:
            cnt = 100 * s / w
            ans = s + w, s
            if s == e * w // 100:
                print(*ans)
                exit()
else:
    print(*ans)


### FIXED CODE ###

from itertools import product

a, b, c, d, e, f = map(int, input().split())

lima = [100 * a * i for i in range(f // (100 * a) + 1)]
limb = [100 * b * i for i in range(f // (100 * b) + 1)]
setw = set([i + j for i, j in product(lima, limb) if 0 < i + j <= f])
limc = [c * i for i in range(f // c + 1)]
limd = [d * i for i in range(f // d + 1)]
sets = set([i + j for i, j in product(limc, limd) if 0 < i + j <= f])

cnt, ans = 0, (max(setw), 0)
for w in setw:
    for s in sets:
        if (cnt <= 100 * s / w <= e) and (s + w <= f):
            cnt = 100 * s / w
            ans = s + w, s
else:
    print(*ans)
import functools
import math
N = int(input())
A = list(map(int,input().split()))

gcd = functools.reduce(math.gcd, A)
print(gcd)

### FIXED CODE ###

import numpy as np
N = int(input())
A = list(map(int,input().split()))
flag = 0
#mi = min(A)
Q = np.array(A)
an = 1
def toku(Q):
    mi = min(Q)
    R1 = Q % mi
    if any(R1) == 0:
        flag = 1
        an = mi
        return flag, an, R1
    else:
        flag = 0
        an = 1
        ind = np.argmin(Q)
        R1[ind] = mi
        R = R1[R1!=0]
        return flag, an, R

while flag == 0:
    flag,an,PP = toku(Q)
    Q = PP

print(an)
N_K = list(map(int, input().split()))#N_K[0]=N , N_K[1]=K
h = list(map(int,input().split()))# h[N]
ans = 0
for i in range(N_K[0])
	if h[i] >= N_K[1]:
		ans+=1
print(ans)


### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
cnt=0
for i in range(n):
	if k<=h[i]:
		cnt+=1
print(cnt)
N = int(input())
D = list(map(int,input().split()))
count=0
for i in range(N):
  for j in d[i+1:]:
    A = d[i]*j
    count+=A
print(A)

### FIXED CODE ###

N = int(input())
D = list(map(int,input().split()))
count=0
for i in range(N-1):
  for j in D[i+1:]:
    A = D[i]*j
    count+=A
print(count)
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
else:
    for i in range(1,10**7+1):
        sub = val % k
        if sub == 0:
            ans = i
            break
        else:
            val = 10 * sub + 7
print(ans)

### FIXED CODE ###

k = int(input())
val = 7
if k%2 == 0:
    ans = -1
elif k%5 == 0:
    ans = -1
else:
    for i in range(1,10**12+1):
        if val >= k:
            sub = val % k
            if sub == 0:
                  ans = i
                  break
            else:
                  val = 10 * sub + 7
        else:
            val = 10 * val + 7
print(ans)
t_hp, t_ap, a_hp, a_ap = map(int,input().split())

while t_hp == 0 or a_hp == 0:
    a_hp -= t_ap
    if a_hp <= 0:
        return 'Yes'
        break

    t_hp -= a_ap
    if t_hp <= 0:
        return 'No'
        break

### FIXED CODE ###

t_hp, t_ap, a_hp, a_ap = map(int,input().split())

while t_hp > 0 or a_hp > 0:
    a_hp -= t_ap
    if a_hp <= 0:
        print('Yes')
        break

    t_hp -= a_ap
    if t_hp <= 0:
        print('No')
        break
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
ctr = Counter()
answer = 0
for s in S:
    a = ''.join(sorted(list(s)))
    print(a)
    if a in ctr:
        ans += ctr[a]
    ctr[a] += 1
print(answer)

### FIXED CODE ###

from collections import Counter
N = int(input())
S = [input() for i in range(N)]
ctr = Counter()
answer = 0
for s in S:
    a = ''.join(sorted(list(s)))
    #print(a)
    if a in ctr:
        answer += ctr[a]
    ctr[a] += 1
print(answer)
N = int(input())
def if_test:
    if N % sum(int(input())) == 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

def f(n):
  return sum(map(int, str(n)))

X = int(input())

if X % f(X) == 0: 
  print("Yes")
else:
  print("No")
ab=input(),0 
if a[0]=='1':
    b+=1
if a[1]=='1':
    b+=1
if a[2]=='1':
    b+=1
print(b)

### FIXED CODE ###

a,b=input(),0 
if a[0]=='1':
    b+=1
if a[1]=='1':
    b+=1
if a[2]=='1':
    b+=1
print(b)
a, b = list(map(int, input()))
c = a * b
d = 2*(a + b)
print("{} {}".format(c, d))


### FIXED CODE ###

a, b = map(int, input().split())
l = 2*(a+b)
s = a*b
print("{} {}".format(s, l))
import math

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)

A = [int(x) for x in input().split()]

AA = [a - (i + 1) for i, a in enumerate(A)]

AA.sort()

if len(AA) % 2 == 0:
    b = int(len(AA) / 2 - 1)
else:
    b = int((len(AA) - 1) / 2)

sadness = 0
for i, a in enumerate(A):
    # sadness1 += abs(a - (i + b1 + 1))
    # sadness2 += abs(a - (i + b2 + 1))
    sadness += abs(a - (i + AA[b] + 1))

print(sadness)


### FIXED CODE ###

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)

if n % 2 == 0:
    print(n)
else:
    print(n * 2)
n,k=map(int,input().split())
flag=0
dp=[[0 for i in range(k+1)] for j in range(n+1)]
if k==0 or n==k:
  dp[n][k]==1
  flag=1
if flag==0 and (k==1 or k==n-1):
  dp[n][k]==n
if flag==0:
  a=n-r
  if r>=a:
    r=a
  for i in range(n+1):
    dp[i][0]=1
  dp[1][1]=1
  for i in range(2,n+1):
    for j in range(1,k+1):
      dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
dp[1][1]=1
for i in range(2,n+1):
  for j in range(1,k+1):
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)
a=int(input())
b=int(input())
c=int(input())
x=int(input())
s=50*c
print(len[1 if 0<<x-500*i+100*m<<s for i in range(a+1) for m in range(b+1)])

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
x=int(input())
s=50*c
print(len([1 for i in range(a+1) for m in range(b+1) if 0<=x-500*i-100*m<=s]))
import math
print(r * 2 * math.pi)

### FIXED CODE ###

import math
print(int(input()) * 2 * math.pi)
import math

n = int(input())
wn = list(map(int, input().split()))
 
mini = math.inf
for i in range(n-1):
    new_mini = abs(sum(wn[:i+1]) -sum(wn[i+1:]))
    if new_mini < mini:
        mini = new_mini
print(mini)

### FIXED CODE ###

import math
 
n = int(input())
wn = list(map(int, input().split()))
 
mini = 10000000000
for i in range(n-1):
    new_mini = abs(sum(wn[:i+1]) -sum(wn[i+1:]))
    if new_mini < mini:
        mini = new_mini
print(mini)