Harryxun/stf_run huggingface dataset:
M = 10**9+7
import sys
input = sys.stdin.readline

N,K = map(int, input().split())
A = list(map(int, input().split()))
A_ = sorted(A, reverse = True)
ans = 0
ans_ = 0
for i in range(0,N-1):
      for j in range(i+1,N):
          if A[i] > A[j]:
            ans += 1
         if A_[i] > A_[j]:
            ans_ += 1

print(((int((K*(K-1))/2)%M)*ans_+ans*K)%M)

### FIXED CODE ###

M = 10**9+7
import sys
input = sys.stdin.readline
def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A_ = sorted(A, reverse = True)
    ans = 0
    ans_ = 0
    for i in range(0,N-1):
        for j in range(i+1,N):
            if A[i] > A[j]:
                ans += 1
            if A_[i] > A_[j]:
                ans_ += 1

    print(int((((K*(K-1)//2)%M)*ans_+ans*K)%M))

if __name__ == '__main__':
    main()
def comb(a, b):
    if(a < b or b < 0):return 0
	if(b == 0):return 1
    if(b > a - b):return comb(a, a - b)
    return comb(a, b - 1) * (a - b + 1) / b

a, b, c = map(int, raw_input().split())
c -= a * b
print comb(c + a - 1, c)

### FIXED CODE ###

def fact(x):
    res = 1
    for i in xrange(1, x + 1):
        res *= i
    return res

def comb(a, b):
    if(a < b or b < 0):return 0
    if(b == 0):return 1
    return fact(a)/fact(b)/fact(a-b)

a, b, c = map(int, raw_input().split())
c -= a * b
print comb(c + a - 1, c)
import math

r=input(int())


print(math.pi*r*r/math.pi)

### FIXED CODE ###

r=int(input())
print(r*r)
#!/usr/bin/env python
#coding: UTF-8
import sys
import math

line = []
for l in sys.stdin:
    for i in l.split(' '):
    	line.append(float(i))
a = math.sqrt((line[0]-line[2])**2+(line[1]-line[3])**2)
print '%f'%a

### FIXED CODE ###

import math

x1,y1,x2,y2 = map(float,raw_input().split())
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
print '%f'%a
n,m,q = map(int,input().split())
a = [[int(i) for i in input().split()] for _ in range(q)]
b = []
for i in range(m):
    b.append(i+1)
import itertools
l = list(itertools.combinations_with_replacement(b,n))
max=0
from math import factorial
c = factorial(m) / factorial(n) / factorial(m - n)
#print(l)                                                                      

#for _ in range(int(c)):                                                       
for ll in l:
    m=0
#    print(ll)                                                                 
    for aa in a:
#        print(ll[aa[1]-1],ll[aa[0]-1],aa[2])                                  
        if ll[aa[1]-1]-ll[aa[0]-1]==aa[2]:
 #           print(aa[3])                                                      
            m+=aa[3]
    if max < m:
        max=m
  #  print(m,max)                                                              
print(max)


### FIXED CODE ###

n,m,q = map(int,input().split())
a = [[int(i) for i in input().split()] for _ in range(q)]
b = []
for i in range(m):
    b.append(i+1)
import itertools
l = list(itertools.combinations_with_replacement(b,n))
max=0
#print(l)                                                                      
for ll in l:
    m=0
    for aa in a:
        if ll[aa[1]-1]-ll[aa[0]-1]==aa[2]:
            m+=aa[3]
    if max < m:
        max=m
print(max)
N, Q  = map(int, input().split())
tree = [0]*(N+1)
counts = [0]*(N+1)
pluses = [0]*(N+1)
for i in range(1,N):
  tree[i] = []
  a,b = map(int, input().split())
  tree[a].append(b)
tree[N] = []

i = N
while i>0:
  pluses[i] = [i]
  if len(tree[i])!=0:
    for p in tree[i]:
      for q in pluses[p]:
        pluses[i].append(q)
  i -= 1
#print(pluses)

for i in range(Q):
  p,x = map(int, input().split())
  for q in pluses[p]:
    counts[q]+=x
#print(tree)
for i in range(1,N+1):
  print(counts[i],end=' ')

  

### FIXED CODE ###

N, Q = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

ans = [0]*N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

from collections import deque

visited = [False]*N
d = deque([0])
while len(d)>0:
    v = d.popleft()
    visited[v]= True
    for u in edge[v]:
        if visited[u]==False:
            ans[u] += ans[v]
            visited[u]=True
            d.append(u)

print(*ans, sep=' ')
n = list(input())
if ((len(collections.Counter(n[:3])) == 1) | (len(collections.Counter(n[1:])) == 1)):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import collections
n = list(input())
if ((len(collections.Counter(n[:3])) == 1) | (len(collections.Counter(n[1:])) == 1)):
    print("Yes")
else:
    print("No")
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0

for bit in range(1 << N):
    flag = True
    for i in range(N):
        count = 0
        for v in ks[i]:
            if bit & (1<<(v-1)):
                cnt += 1
        if cnt %2 != p[i]:
            flag = False
    if flag:
        ans += 1

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0

for i in range(2**N):
    light = 0
    for j in range(M):
        count = 0
        for k in range(1, ks[j][0]+1):
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
        if count % 2 == p[j]:
            light += 1
    if light == M:
        ans += 1

print(ans)
import numpy as np
x,y,z,k = map(int,input().split())
a = np.array(list(map(int,input().split())))
b = np.array(list(map(int,input().split())))
c = np.array(list(map(int,input().split())))
a2,b2,c2 = np.meshgrid(a,b,c)
abc = np.c_[a2.flatten(),b2.flatten(),c2.flatten()]
ans = np.zeros(x*y*z,dtype=int)
for i in range(x*y*z):
    ans[i] = sum(abc[i])
ans = np.sort(ans)[::-1]
for i in range(k):
    print(ans[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = []
for i in range(x):
    for j in range(y):
        ans.append(a[i]+b[j])
ans.sort(reverse=True)
ans = ans[:k]
ans2 = []
for i in range(len(ans)):
    for j in range(z):
        ans2.append(ans[i]+c[j])
ans2.sort(reverse=True)
for i in range(k):
    print(ans2[i])
a= int(input())
b= int(input())
print(a*b, (a+b)2)


### FIXED CODE ###

a,b = map(int, input().split())
print(a*b, 2*(a+b))
a, b = map(int, input().split())
    c, d = map(int, input().split())
    if (a*b)==(c*d):
     print((a*b)-(c*d))
    elif (a*b) > (c*d):
     print(c*d)

### FIXED CODE ###

a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))
from collections import deque

h,w = map(int,input().split())
ch, cw = map(int,input().split())
dh, dw = map(int,input().split())

G = []
for i in range(h):
    G.append(list(input()))

queue = deque([ch-1, cw-1])
S = [[float("inf")]*w for _ in range(h)]
S[ch-1][cw-1] = 0

while queue:
    y, x = queue.popleft()
    dx_dy = [[1,0],[0,1],[-1,0],[0,-1]]
    for k in range(4):
        i, j = k[0], k[1]
        if 0 <= x+i < w and 0 <= y+j < h:
            if S[y+j][x+i] > S[y][x] and G[y+j][x+i] == ".":
                S[y+j][x+i] = S[y][x]
                queue.appendleft((y+j, x+i))

    for i in range(-2, 3):
        for j in range(-2, 3):
            if i != 0 and j != 0:
                if 0 <= x+i < w and 0 <= y+j < h:
                    if S[y+j][x+i] > S[y][x] and G[y+j][x+i] == ".":
                        S[y+j][x+i] = S[y][x] + 1
                        queue.append((y+j, x+i))


if S[dh+1][dw+1] == float("inf"):
    print(-1)
else:
    print(S[dh-1][dw-1])


### 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())

G = []
for i in range(h):
    G.append(list(input()))

queue = deque([(ch, cw)])
S = [[float("inf")]*w for _ in range(h)]
S[ch][cw] = 0

while queue:
    y, x = queue.popleft()
    dx_dy = ((1,0),(0,1),(-1,0),(0,-1))
    ans = S[y][x]

    if (y, x) == (dh, dw):
            S[y][x] = ans
            break

    for j, i in dx_dy:
        if 0 <= x+i < w and 0 <= y+j < h and S[y+j][x+i] > ans and G[y+j][x+i] == ".":
            queue.appendleft((y+j, x+i))
            S[y+j][x+i] = ans
            

    ans += 1
    for i in range(-2, 3):
        for j in range(-2, 3):
            if 0 <= x+i < w and 0 <= y+j < h and S[y+j][x+i] > ans and G[y+j][x+i] == ".":
                S[y+j][x+i] = ans
                queue.append((y+j, x+i))


if S[dh][dw] == float("inf"):
    print(-1)
else:
    print(S[dh][dw])
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

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

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

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n=  int(sys.stdin.readline())
p=list(range(2,n))
if n ==1:
    print(0)
else:
    print(n*(n-1)/2)

### FIXED CODE ###

import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

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

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

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n=  int(sys.stdin.readline())
if n ==1:
    print(0)
elif n == 2:#なぜ？
    print(1)
else:
    print(n*(n-1)//2)
#coding; utf-8


def main():
    N = int(input())
    A = list(map(int, input().split()))
    min_color = 0
    max_color = 0
    rate_criteria = 400
    rate = [0]*9
    for i in range(N):
        diva = A[i]//rate_criteria
        rate[diva] += 1

    for i in range(8):
        if rate[i] > 0:
            min_color += 1

    max_color = min_color + rate[-1]
    # print(rate)
    print(min_color, max_color)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#coding; utf-8


def main():
    N = int(input())
    A = list(map(int, input().split()))
    min_color = 0
    max_color = 0
    rate_criteria = 400
    rate = [0]*9
    for i in range(N):
        diva = A[i]//rate_criteria
        if diva > 8:
            diva = 8
        rate[diva] += 1

    for i in range(8):
        if rate[i] > 0:
            min_color += 1

    if min_color == 0 and rate[-1] > 0:
        min_color = 1
        max_color = rate[-1]
    else:
        max_color = min_color + rate[-1]
    # print(rate)
    print(min_color, max_color)


if __name__ == "__main__":
    main()
N, Q = map(int, input().split())

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

counter = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p] += x

# print(edge)
# print(counter)

visited = [False] * (N + 1)
ans = [0] * (N + 1)

def dfs(fro, p):
    visited[fro] = True
    now = counter[fro] + p
    for to in edge[fro]:
        if not visited[to]:
            dfs(to, now)
    ans[fro] = now

dfs(1, 0)

print(*ans[1:])



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def input():
    return sys.stdin.readline()

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

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

counter = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p] += x

# print(edge)
# print(counter)

visited = [False] * (N + 1)
visited[1] = True
ans = [0] * (N + 1)

def dfs(fro, p):
    visited[fro] = True
    now = counter[fro] + p
    for to in edge[fro]:
        if not visited[to]:
            dfs(to, now)
    ans[fro] = now
    return

dfs(1, 0)

print(*ans[1:])
a,b = input()
A = int(a)
B = int(b)
c=a*b
if c%2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b = input().split()
A = int(a)
B = int(b)
c=A*B
if c%2 == 0:
  print("Even")
else:
  print("Odd")
import math
import numpy as np 

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


X,Y =map(int,input().split())
x,y = np.sum(1/3.0*(np.array([[ 2., -1.],[-1.,  2.]])*np.array([X,Y])),axis=1).astype(np.int32)
print(x)
##x = int(X-(X+Y)//3)
#y = int(Y-(X+Y)//3)
if (X+Y)%3==0 and x>=0 and y>=0:
    print(int(cmb(x+y,x,mod)))
else:
    print(0)
    


### FIXED CODE ###

import math
#import numpy as np 

#参照
#https://qiita.com/derodero24/items/91b6468e66923a87f39f#%E7%95%AA%E5%A4%96%E7%B7%A8
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 5*10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


X,Y =map(int,input().split())
#x,y = np.sum(1/3*(np.array([[ 2., -1.],[-1.,  2.]])*np.array([X,Y])),axis=1).astype(np.int32)
#print(x)
x = int(X-(X+Y)//3)
y = int(Y-(X+Y)//3)
if (X+Y)%3==0 and x>=0 and y>=0:
    print(cmb(x+y,x,mod))
else:
    print(0)
n = 6;
a = [input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  #print("n-i-1: " + str(n-i-1));
  if k < a[n-i-1] - a[i]:
    ans = ":( ";
    break;

return ans;

### FIXED CODE ###

n = 6;
a = [input() for i in range(n)];
 
k = a[-1];
ans = "Yay!";
 
for i in range(n-1):
  for j in reversed(range(n-1)):
    if k < a[i] - a[j]:
      ans = ":( ";
      break;
print ans;
import itertools
import numpy as np
from math import factorial
n = list(map(int, input().split()))
x = np.array(list(map(int, input().split())))

x = x - n[1]
b = len(x) - np.count_nonzero(x)
x = [i for i in x if i != 0]
x = np.sort(x)

c = 0
for i in range(1, b + 1):
    c += factorial(b) / factorial(i) / factorial(b - i)

cnt = c
for i in range(2, n[0] + 1):
    a = np.array(list(itertools.combinations(x, i)))
    if sum(a[0]) > 0:
        break
    a = np.sum(a, axis = 1)
    cnt += (c + 1) * (len(a) - np.count_nonzero(a))
            
print(int(cnt))

### FIXED CODE ###

import sys
import numpy as np
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n, a = imap()
x = np.array(iarr()) - a
MAX = 50*50+1

dp = np.zeros((n+1, 2*MAX+1)).astype(int)
dp[0][MAX] = 1
for i in range(n):
    for j in range(2*MAX):
        if j-x[i] < 0 or j-x[i] > 2*MAX:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = dp[i][j] + dp[i][j-x[i]]
print(dp[n][MAX]-1)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and 'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and 'W' in s and 'E' in s:
        ans='Yes'
    else:
        ans='No'
    print(ans)
resolve()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ans='No'
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and \
            'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and\
            'W' in s and 'E' in s:
        ans='Yes'
    print(ans)
resolve()
i = 0
if 0 in number:
    total = 0
else:
    while i < N:
            total *= number[i]
            i = i + 1
            if total > 10**18:
                total = -1
                break
print(total)

### FIXED CODE ###

N = int(input())
liste = input().split()
number = [int(x) for x in liste]
total = 1
i = 0
if 0 in number:
    total = 0
else:
    while i < N:
            total *= number[i]
            i = i + 1
            if total > 10**18:
                total = -1
                break
print(total)
while(True):
  e = int(input())
  if e == 0:
    quit()
  ans = e
  for i in range(0,int(e ** (1/3))+1):
      for j in range(0,int((e - i ** 3)**0.5)+1):
          k = e - i ** 3 - j ** 2 + i + j
          if k < ans:
              ans = k
  print(ans)


### FIXED CODE ###

from math import floor
while(True):
  e = int(input())
  if e == 0:
    quit()
  ans = e
  for i in range(0,e):
      if i ** 3 > e:
          break
      j = floor((e - i ** 3)**0.5)
      k = e - i ** 3 - j ** 2 + i + j
      if k < ans:
          ans = k
  print(ans)
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(200000)

    N,M = map(int,input().split())
    edges = [[]for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int,input().split())
        edges[a].append(b)
        edges[b].append(a)

    colors = [-1]*(N+1)
    def paint(n,p,c):
        ret = 1
        if colors[n]!=-1 and colors[n]!=c:
            ret = 0
        else:
            colors[n] = c
            for nx in edges[n]:
                if nx != p:
                    ret = min(ret,paint(nx,n,(c+1)%2))
        return ret

    def choose(n,k):
        import math
        return math.factorial(n)//(math.factorial(n-k)*math.factorial(k))
    res = paint(1,0,1)
    if res == 0:
        ans = choose(N,2)-M
    else:
        ans = colors.count(0)*(N-colors.count(0))-M

    print(ans)

main()


### FIXED CODE ###

"""
グラフが二部グラフかどうかを判定する。
二部グラフであれば、AグループのノードとBグループのノード同士をそれぞれ結ぶことができる。
二部グラフでない場合、すべてのノード同士を結ぶことができる。
"""
import math
from collections import Counter
import sys
sys.setrecursionlimit(200000)
def choose(n):
    return math.factorial(n)//(math.factorial(n-2)*math.factorial(2))
N,M = map(int,input().split())
edges = [[]for _ in range(N+1)]
for _ in range(M):
    A,B = map(int,input().split())
    edges[A].append(B)
    edges[B].append(A)

colors = [-1]*(N+1)
def f(n,p):
    c = colors[n]
    for v in edges[n]:
        if v != p:
            if colors[v] == -1:
                colors[v] = 1 if c==0 else 0
                f(v,n)
            elif colors[v] == c:
                print(choose(N)-M)
                exit()
colors[1]=0
f(1,0)
count1 = colors.count(0)
count2 = colors.count(1)
print(count1*count2-M)
A,B=map(input().split())
if A=="H":
	print(B)
else:
	if B=="H":
		print("D")
	else:
		print("H")

### FIXED CODE ###

A,B=map(str,input().split())
if A=="H":
	print(B)
else:
	if B=="H":
		print("D")
	else:
		print("H")
N = input()
A = input().split()
A = [int(a) for a in A]

counter = 0
while sum([a % 2 for a in A]) == 0:
  A = [a / 2 for a in A]
  counter += 1
print(counter)

### FIXED CODE ###

import numpy as np

a = str(input())
s1 = int(a[0])
s2 = int(a[1])
s3 = int(a[2])

print(np.sum(s1 + s2 + s3))
N, T =map(int, input().split())
ts =map(int, input().split())



amount =0


    
for index in range(N-1):
    t_sub = ts[index+1]-ts[index]
    amount+=min(t_sub,T)

        
amount +=T

print(amount)

### FIXED CODE ###

if __name__ == '__main__':
    N, T = map(int, input().split())
    ts = list(map(int, input().split()))
    
    
amount =0


    
for index in range(N-1):
    t_sub = ts[index+1]-ts[index]
    amount+=min(t_sub,T)

        
amount +=T

print(amount)
#取り除く橋は西側が出来るだけ大きいやつから取り除いても無駄がない
#（なぜならそうでない橋を取り除いた後にも上の橋を取り除かねばならないので）
N,M = map(int,input().split())
ab =[list(map(int,input().split())) for i in range(M)]
ab.sort(reverse=True)
ans = 0
tmp = inf
for i in range(M):
    if ab[i][1] > tmp:
        continue
    else:
        ans += 1
        tmp = ab[i][0]
print(ans)


### FIXED CODE ###

inf = 10**10

N,M = map(int,input().split())
ab =[list(map(int,input().split())) for i in range(M)]
ab.sort(reverse=True)
ans = 0
tmp = inf
for i in range(M):
    if ab[i][1] > tmp:
        continue
    else:
        ans += 1
        tmp = ab[i][0]
print(ans)
input(a)
 print("a + a * 2 + a * 3")

### FIXED CODE ###

a = int(input())
print(a + a**2 + a**3)
# coding: utf-8
import sys
input = sys.stdin.readline

N = input()
S = sum(int(x) for x in N)
print("Yes" if int(N)%S==0 else "No")

### FIXED CODE ###

# coding: utf-8
N= input()
S = sum(map(int, N))
print("Yes" if int(N)%S==0 else "No")
# div2019D - DivRem Number
def divisors(n: int) -> set:
    # Compute divisors of a number.
    divs = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i)
            div.add(n // i)
    return divs


def main():
    N = int(input())
    divs = divisors(N)
    ans = 0
    for m in divs:
        if m == 1:
            continue
        m -= 1
        if N // m == N % m:
            ans += m
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# div2019D - DivRem Number
# cf. ARC026B - 完全数
def divisors(n: int) -> set:
    """
    Compute divisors of a number.
    
    Args: n (int): an integer to be evaluated.
    Returns: div (set): set of divisors
    """
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i)
            div.add(n // i)
    return div


def main():
    N = int(input())
    divs = divisors(N)
    divs.discard(1)
    ans = 0
    for m in divs:
        m -= 1
        if N // m == N % m:
            ans += m
    print(ans)


if __name__ == "__main__":
    main()
# coding: utf-8
from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
    return int(factorial(n) / (factorial(r) * factorial(n - r)) % mod)

for i in range(1, K+1):
    if i%2 == 0:
        print(combination(N-K+1, i)*2)
    else:
        print(combination(N-K+1, i))

### FIXED CODE ###

# coding: utf-8
from math import factorial
def combination(n, r):
    if n >= r and n >= 0 and r >= 0:
        return int(factorial(n) // (factorial(r) * factorial(n - r)))
    else:
        return 0
N, K = map(int, input().split())
mod = 10**9 + 7

for i in range(1, K+1):
    print(combination(N-K+1, i) * combination(K-1, i-1)%mod)
a,b,c,k=list(map(int,input().split()))
lis=[1]*a+[0]*b+[-1]*c
max=0
for i in range(k):
    max+=lis[i]
print(max)


### FIXED CODE ###

a,b,c,k=list(map(int,input().split()))
max=0
if k>=a:
    max+=a
    if k>=a+b:
        max-=k-a-b
else:
    max+=k
print(max)