Harryxun/stf_run huggingface dataset:
import itertools

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

if n ==2:
    print(1)
    exit()

arr=[[_] for _ in range(n)]

for i in range(n):
    a,b=map(int,input().split())
    
    arr[a-1].append(b-1)
    arr[b-1].append(a-1)
for i in range(n):
    arr[i] = arr[i][1:]
#print("arr",arr)

route=list(itertools.permutations(range(1,n)))
#print("route",route) 
ans=0
for i in route:
    chk0=False
    chk=True
    if i[0] in arr[0]:
        #print(i)
        for j in range(1,n-1):
            if i[j] in arr[i[j-1]]:
                chk0=True
                #print(i[j],arr[j])
                pass
            else:
                chk=False
    if chk==True and chk0==True:
        #print(i)
        ans+=1

print(ans)

### FIXED CODE ###

import itertools

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

if n ==2:
    print(1)
    exit()

arr=[[_] for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    #print(a,b)
    
    arr[a-1].append(b-1)
    arr[b-1].append(a-1)

#print("arr",arr)

route=list(itertools.permutations(range(1,n)))
#print("route",route) 
ans=0
for i in route:
    chk0=0
    chk=True
    if i[0] in arr[0]:
        chk0 =True
        #print(i)
        for j in range(1,n-1):
            if i[j] in arr[i[j-1]]:
                chk0+=1
                
                pass
            else:
                #print(1,i[j],arr[i[j-1]])
                break
                
    if chk0==n-1:
        
        ans+=1

print(ans)
from collections import deque

def main():
    n,m = map(int,input().split())
    arr = [[] for i in range(n)]
    for _ in range(m):
        a,b = map(int,input().split())
        arr[a-1].append(b-1)
        arr[b-1].append(a-1)
    q = deque()
    q.append(0)
    ans = [-1] * n
    ans[0] = 0
    while q:
        now = q.popleft()
        for i in ab[now]:
            if ans[i] == -1:
                ans[i] = now+1
                q.append(i)
        if len(q) == 0:
            break
    print('Yes')
    for i in range(1,n):
        print(ans[i])



if __name__=='__main__':
    main()


### FIXED CODE ###

from collections import deque

def main():
    n,m = map(int,input().split())
    ab = [[] for i in range(n)]
    for _ in range(m):
        a,b = map(int,input().split())
        ab[a-1].append(b-1)
        ab[b-1].append(a-1)
    q = deque()
    q.append(0)
    ans = [-1] * n
    ans[0] = 0
    while q:
        now = q.popleft()
        for i, next in enumerate(ab[now]):
            if ans[next] == -1:
                ans[next] = now+1
                q.append(next)
        if len(q) == 0:
            break
    print('Yes')
    for i in range(1,n):
        print(ans[i])



if __name__=='__main__':
    main()
N = int(input())
S = input()
ans: list =[]
for s in S:
    c = ord(s)+N
    if c > 90:
        c -= 26
    ans.append(chr(c))
print(''.join(ans))

### FIXED CODE ###

N = int(input())
S = input()
ans =[]
for s in S:
    c = ord(s)+N
    if c > 90:
        c -= 26
    ans.append(chr(c))
print(''.join(ans))
def main():
    s, c = map(int, raw_input().split())
    count = 0
    for i in range(s):
        if(c >= 2):
            count += 1
            c -= 2
        else:
            break
    for i in range(c):
        if(c >= 4):
            count += 1
            c -= 4
        else:
            break
    return count

print main()

### FIXED CODE ###

def main():
    s, c = map(int, raw_input().split())
    count = 0
    if s > c/2:
        return c/2
    elif s == c/2:
        return s
    elif s < c/2:
        return s + ((c-2*s)/4)
print main()
n = int(input())
s,t = input().split()
u = ""
for i in range(n):
    u = u + s[i] + t[i]

print(u)

### FIXED CODE ###

a = int(input())
b = int(input())

print(6-a-b)
a = input()
b = input()

print a * b , ' ' , 2 * ( a + b )

### FIXED CODE ###

a,b = map( int , raw_input().split() )

ans1 = a * b
ans2 = 2 * ( a + b )

print ans1 , ans2
import sys
input = sys.stdin.readline
n,q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int, input().split())
    tree[a-1].append(b)
    tree[b-1].append(a)
# px = [ list(map(int,input().split())) for _ in range(q) ]
c = [0]*n
# for i in range(len(px)):
for i range(q):
    p,x = map(int,input().split())
    c[p-1] += x  
visited = [0]*n
visited[0] = 1
while sum(visited)!=n:
    for i in range(1,n):
        if visited[i]==0:
            for j in range(len(tree[i])):
                node_tmp = tree[i][j]
                if visited[node_tmp-1]==1:
                    c[i] += c[node_tmp-1]
                    visited[i] = 1
print(" ".join(map(str,c)))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int, input().split())
    tree[a-1].append(b)
    tree[b-1].append(a)
# px = [ list(map(int,input().split())) for _ in range(q) ]
c = [0]*n
# for i in range(len(px)):
for _ in range(q):
    p,x = map(int,input().split())
    c[p-1] += x  
visited = [0]*n
cnd = [1]   # current_node
while len(cnd)>0:
    nnd = []
    for j in cnd:
        visited[j-1]=1
        ko = tree[j-1]
        for k in ko:
            if visited[k-1]==0:
                c[k-1] += c[j-1]
                nnd.append(k)
    cnd = nnd
print(" ".join(map(str,c)))
a,b=input()
 
print("{0} {1}".format(a*b,a**2+b**2))


### FIXED CODE ###

a,b=[int(x) for x in input().split()]
print(a*b,2*a+2*b)
a = int(input())
b = int(input())
h = int(input())
area = 0.5(a+b)*h
print(area)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
area = 0.5*(a+b)*h
print(int(area))
from collections import deque
import math

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

N,K = [int(zz) for zz in input().split()]
A = [[] for _ in range(N)]
B = [0]*N

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

dq = deque([0])
check = [True]*N
check[0] = False
ans = K
tmp = 1
while dq:
    p = dq.pop()
    count = 0
    btmp = 0
    for i in A[p]:
        if check[i]:
            check[i] = False
            count += 1
            dq.append(i)
        else:
            btmp += 1

    if K-tmp-btmp > 0:
        ans *= permutations_count(K-tmp-btmp,count)
print(ans%(10**9+7))


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
MOD = 10**9+7

N,K = [int(zz) for zz in input().split()]
A = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = [int(zz)-1 for zz in input().split()]
    A[a].append(b)
    A[b].append(a)

dq = deque([0])
ans = K
check = [True]*N
check[0] = False
while dq:
    p = dq.popleft()
    if p == 0:
        cand = K-1
    else:
        cand = K-2
    for i in A[p]:
        if check[i]:
            check[i] = False
            ans = (ans*cand)%MOD
            cand -= 1
            dq.append(i)

print(ans)
N = int(input())
list = [int(a) for a in input().split()]

A = sum(list)//N

for k in rang(N):
    ans = (list[j] - A) ** 2

for i in range(-100:100):
    for j in range(N):
        sum = 0
        sum_new = 0
        sum = sum + (list[j] - A) ** 2
        sum_new = sum_new + (list[j] - i) ** 2
    if(sum > sum_new):
        ans = sum_new

print(ans)


### FIXED CODE ###


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

A = sum(list)//N
ans = 0

for k in range(N):
    ans = ans + (list[k] - A) ** 2

for i in range(-100,100):
    sum_new = 0
    for j in range(N):
        sum_new = sum_new + (list[j] - i) ** 2
    if(ans > sum_new):
        ans = sum_new

print(ans)
from math import gcd
from functools import reduce
input()
print(len(bin(reduce(gcd,list(map(int,input().split())))))-3)

### FIXED CODE ###

input()
a=list(map(int,input().split()))

c=0
while True:
    if not all([1-ai%2 for ai in a]):break
    a=[ai//2 for ai in a]
    c+=1    
print(c)
S,T = map(input().split())
A,B = map(int,input().split())
U = input()
if(S==U):
  print(A-1,B)
else:
  print(A,B-1)


### FIXED CODE ###

S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()
if(S==U):
  print(A-1,B)
else:
  print(A,B-1)
from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def f(A):
    bunsi = reduce(lambda x, y: x*y%mod, range(N, N-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod
  
ans = pow(2, n, mod) - f(a) -f(b) - 1
ans %= mod
print(ans)

### FIXED CODE ###

from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def f(A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = pow(2, n, mod) - f(a) -f(b) - 1
ans %= mod
print(ans)
n= int(input)
if n%2==0:
  print(int(n*0.5))
else:
  print(int(0.5*n)+1)

### FIXED CODE ###

n= int(input())
if n%2==0:
  print(int(n*0.5))
else:
  print(int(0.5*n)+1)
def nibun_right(a, x):
 lo, hi = 0, len(a)
 while lo < hi:
  mid = (lo+hi)//2
  if x < a[mid][0]: hi = mid
  else: lo = mid+1
 return lo
N,D,A=map(int,input().split())
lst=[0]*N
for i in range(N):
 lst[i]=list(map(int,input().split()))
 lst[i][1]=int((lst[i][1]-1)/A))+1
lst.sort()

### FIXED CODE ###

def nibun_right(a, x, lo=0, hi=None):
 if lo < 0:
  raise ValueError('lo must be non-negative')
 if hi is None:
  hi = len(a)
 while lo < hi:
  mid = (lo+hi)//2
  if x < a[mid][0]: hi = mid
  else: lo = mid+1
 return lo
N,D,A=map(int,input().split())
lst=[0]*N
for i in range(N):
 lst[i]=list(map(int,input().split()))
lst.sort()
DMG=[0]*N
ans=0
for i in range(N):
 if i!=0:
  DMG[i]+=DMG[i-1]
 renji=nibun_right(lst,lst[i][0]+2*D)
 Z=max(int((lst[i][1]-1)/A)+1-DMG[i],0)
 DMG[i]+=Z
 if renji!=N:
  DMG[renji]-=Z
 ans+=Z
print(ans)
import sys
import math
input = sys.stdin.readline


def main():
    A, B = map(int, input().split())
    for i in range(10000):
        if math.floor((i+1) * 0.08) == A and math.floor((i+1) * 0.1) == B:
            print(i+1)
            exit()
    print("-1")


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    print("No") if S == "AAA" or S == "BBB" else print("Yes")


if __name__ == '__main__':
    main()
def main():
  N,K= map(int,input().split())
  h = list(map(int,input().split()))
  dp = [-1]*N
  dp[0] = 0
  for i in range(1,N):
    tmp = i - K
    if tmp < 0: tmp = 0
    cost_min = 10**9
    for j in range(index,i):
      ans = dp[j] + abs(h[i] - h[j])
      if cost_min > ans: cost_min = ans
    dp[i] = cost_min
  print(dp[N-1])

if __name__ == '__main__':
  main()


### FIXED CODE ###

def main():
  N,K= map(int,input().split())
  h = list(map(int,input().split()))
  dp = [0]*N
  for i in range(1,N):
    dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(i-K,0),i))
  print(dp[N-1])

if __name__ == '__main__':
  main()
import bisect as bs
N = int(input())
A = [int(input()) for _ in range(N)]
def LDS(a):
    N = len(a)
    INF = float("inf")
    dp = [-INF]*N
    dp[N-1] = a[0]
    for i in range(1, N):
        j = bs.bisect_left(dp, a[i])-1
        print(j)
        dp[j] = a[i]
    for i in range(N-1, -1, -1):
        if dp[i] == -INF:
            return N-i-1
    return N
print(LDS(A))

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
b = [None for _ in range(N)]
for i in range(N):
    j = N-i
    if j > N//2:
        b[j-1] = a[j-1]
    else:
        s = 0
        for k in range(2*j-1, N, j):
            s = (s+b[k])%2
        b[j-1] = (a[j-1]-s) % 2
ans = []
for i in range(N):
    if b[i] == 1:
        ans.append(i+1)
if ans == []:
    print(0)
else:
    print(len(ans))
    print(" ".join(map(str, ans)))
INF = float("inf")
IINF = 10 ** 18
MOD = 998244353


def main():
    M = int(input())
    # d = [0] * M
    # c = [0] * M
    digits = []
    # d = sorted(d)

    for i in range(M):
        d, c = list(map(int, input().split()))

        if d == 0 and i == 0:
            continue

        for i in range(c):
            digits.append(d)

    if len(digits) == 1:
        print(0)
        return

    if len(digits) == 2:
        if digits[0] == 1 and digits[1] == 0:
            print(0)
        elif digits[0] == 0:
            print(0)
        else:
            print(1)
        return

    # print(digits)
    ith = 1
    nxt = digits[i] + digits[i+1]
    # print(nxt)
    for i in range(2, len(digits)):
        if nxt + digits[i] >= 10:
            nxt = nxt % 10
            ith += 2
        else:
            nxt = nxt + digits[i]
            ith += 1

    print(ith)


if __name__ == '__main__':
    main()


### FIXED CODE ###

INF = float("inf")
IINF = 10 ** 18
MOD = 998244353


def main():
    M = int(input())
    N = 0
    S = 0

    for i in range(M):
        d, c = list(map(int, input().split()))

        if d == 0 and i == 0:
            continue

        S += d * c
        N += c

    print((N - 1) + (S - 1) // 9)


if __name__ == '__main__':
    main()
a, b = map(int,input().split())
a = ("".join(a))*b

### FIXED CODE ###

a, b = map(int,input().split())
a1, b1 = str(a) * b, str(b) * a
ans = min(a1[0],b1[0])
if int(ans) == b:
  print(b1)
else:
  print(a1)
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(0,m+1):
    n-=a[i]
if n<=0:
    print(-1)
else:
    print(n)

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(0,m):
    n-=a[i]
if n<0:
    print(-1)
else:
    print(n)
a,b,c = input().split()
 
a = int(a)
b = int(b)
c = int(c)
 
import math
 
if ((math.sqrt(a) + math.sqrt(b)) / math.sqrt(c)) ** 1000000 < 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

if 4 * a * b < (c - a- b)**2 and c - a- b > 0:
    print("Yes")
else:
    print("No")
n=int(input())
a=list(map(int,input().split()))
plus=[a[i] for i in range(n) if a[i]>=0]
l_plus=len(plus)
minus=[a[i] for i in range(n) if a[i]<0]
l_minus=len(minus)
x_cal=[]
y_cal=[]
if n==2:
  a.sort()
  print(a[1]-a[0])
  print(a[0],a[1])
else:
  if plus!=[] and minus!=[]:
    x_cal.append(minus[0])
    for j in range(1,l_plus-1):
      x_cal.append(x_cal[-1]-plus[j])
    for k in range(1,l_plus):
      y_cal.append(plus[k])
    y_last=x_cal[-1]-y_cal[-1]
    x_cal.append(plus[0])
    for j in range(1,l_minus-1):
      x_cal.append(x_cal[-1]-minus[j])
    for k in range(1,l_minus):
      y_cal.append(minus[k])
    y_cal.append(y_last)
    print(x_cal[-1]-y_cal[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  elif minus==[]:
    a.sort()
    print(sum(a)-2*a[0])
    x_cal.append(a[0])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    y_cal.append(x_cal[-1]-y_cal[-1])
    x_cal.append(a[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  else:
    a.sort()
    print(a[-1]*2-sum(a))
    x_cal.append(a[-1])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    x_cal.append(x_cal[-1]-y_cal[-1])
    y_cal.append(a[0])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
plus=[a[i] for i in range(n) if a[i]>=0]
l_plus=len(plus)
minus=[a[i] for i in range(n) if a[i]<0]
l_minus=len(minus)
x_cal=[]
y_cal=[]
if n==2:
  a.sort()
  print(a[1]-a[0])
  print(a[0],a[1])
else:
  if plus!=[] and minus!=[]:
    if l_plus>1:
      x_cal.append(minus[0])
    for j in range(1,l_plus-1):
      x_cal.append(x_cal[-1]-plus[j])
    for k in range(1,l_plus):
      y_cal.append(plus[k])
    if l_plus>1:
      y_last=x_cal[-1]-y_cal[-1]
    else:
      y_last=minus[0]
    x_cal.append(plus[0])
    for j in range(1,l_minus):
      x_cal.append(x_cal[-1]-minus[j])
    for k in range(1,l_minus):
      y_cal.append(minus[k])
    y_cal.append(y_last)
    print(x_cal[-1]-y_cal[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  elif minus==[]:
    a.sort()
    print(sum(a)-2*a[0])
    x_cal.append(a[0])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    y_cal.append(x_cal[-1]-y_cal[-1])
    x_cal.append(a[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  else:
    a.sort()
    print(a[-1]*2-sum(a))
    x_cal.append(a[-1])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    x_cal.append(x_cal[-1]-y_cal[-1])
    y_cal.append(a[0])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
from collections import deque

H, W=map(int, input().split())
ch, cw=map(int, input().split())
dh, dw=map(int, input().split())
ch-=1
cw-=1
dh-=1
dw-=1

grid=["0"]*H
for i in range(H):
    s=input()
    grid[i]=s

Inf=10**12
cost=[[Inf] * W for i in range(H)]

walk=[(0, 1), (0, -1), (-1, 0), (1, 0)]
warp=[]
for i in range(-2, 3):
    for j in range(-2, 3):
        if i==0 and j==0:
            continue
        if (i, j) not in walk:
            warp.append((i, j))

q=deque()
cost=[ch][cw]=0
q.append((ch, cw, 0))

while q:
    x, y, c=q.popleft()
    for dx, dy in walk:
        nx = x+dx
        ny = y+dy
        if 0<= nx <= H and 0<= ny <= W and grid[nx][ny]=="." and cost[nx][ny]>c:
            cost[nx][ny]=c
            q.appendleft((nx, ny, c))
    
    for dx, dy in warp:
        nx = x+dx
        ny = y+dy
        if 0<= nx <= H and 0<= ny <= W and grid[nx][ny]=="." and cost[nx][ny]>c+1:
            cost[nx][ny]=c+1
            q.append((nx, ny, c+1))


if cost[dh][dw]==Inf:
    print(-1)
else:
    ans=cost[dh][dw]
    print(ans)

### 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())
maze = [input() for _ in range(H)]

INF = 10 ** 12
path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト

# walk:移動A, warp:移動B
walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:  # 移動A
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
    for dx, dy in warp:  # 移動B
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)
antenas = list(int, input() for in range(5))

k = int(input)

if (antenas[4] - antenas[0]) <= k:
  print("Yay!")
else :
  print(":(")
  
  

### FIXED CODE ###

antenas = [int(input()) for i in range(5)]

k = int(input())

if (antenas[4] - antenas[0]) <= k:
  print("Yay!")
else :
  print(":(")
import math
mod = 10e+9 + 7
n, m = map(int, input().split())
if abs(n-m) > 1:
    ans = 0
elif abs(n-m) == 1:
    ans = (math.factorial(n) % mod)*(math.factorial(m) % mod)
else:
    ans = (math.factorial(n) % mod)*(math.factorial(m) % mod)*2
print(int(ans % mod))


### FIXED CODE ###

import math
mod = 10**9 + 7
n, m = map(int, input().split())
ans = math.factorial(n)*math.factorial(m)
if abs(n-m) > 1:
    ans = 0
elif abs(n-m) == 0:
    ans *= 2
print(ans % mod)
n=int(input())
s=ord(input())

ans=s-65+n
if ans>=26:
  ans=ans%26
print(chr(ans+65))


### FIXED CODE ###

N = int(input())
S = input()

ans = ''
for c in S:
    i = ord(c) - ord('A')
    i = (i+N)%26
    ans += chr(i + ord('A'))
print(ans)
x,y=map(str,input().split())
x=int(x,16)
y=int(y,16)
if x<y:
    print(<)
elif x==y:
    print(=)
else:
    print(>)



### FIXED CODE ###

x,y=map(str,input().split())
x=int(x,16)
y=int(y,16)
if x<y:
    print("<")
elif x==y:
    print("=")
else:
    print(">")
num = int(input())
str_list = input.split(" ")

yes = True
 
for index, s in enumerate(str_list):
	if s in str_list[:index]:
		yes = False
		break
if yes:
	print("YES")
else:
	print("NO")

### FIXED CODE ###

num = input()
str_list = input().split(" ")
 
yes = True
num_dict = {}
for s in str_list:
	if s in num_dict:
		yes = False
		break
	else:
		num_dict[s] = 1
if yes:
	print("YES")
else:
	print("NO")
def calc(i, j):
    print(f'{i}, {j}')
    global m, scores, H, W
    if scores[i][j] is not None:
        return scores[i][j]
    if i == H - 1 and j == W - 1 and i != 0 and j != 0:
        score = 0
        scores[i][j] = score
        print(f'i: {i}, j: {j}, score: {score}')
        return score
    diff = []
    if j < W - 1:
        diff.append((0, 1))
    if i < H - 1:
        diff.append((1, 0))
#     print(f'diff: {diff}')
    score_cand = []
    for di, dj in diff:
        additional = 0
        if (m[i][j] == '.' and m[i+di][j+dj] == '#') or (i == 0 and j == 0 and m[0][0] == '#'):
            additional += 1 
        score = calc(i+di, j+dj) + additional
        score_cand.append(score)
    score = min(score_cand)
    scores[i][j] = score
    print(f'i: {i}, j: {j}, score: {score}')
    return score

### FIXED CODE ###

H, W = list(map(int, input().split()))
m = [list(input()) for _ in range(H)]
scores = [[None for _ in range(W)] for _ in range(H)]
def calc(i, j):
#     print(f'{i}, {j}')
    global m, scores, H, W
    if scores[i][j] is not None:
        return scores[i][j]
    if i == H - 1 and j == W - 1 and i != 0 and j != 0:
        score = 0
        scores[i][j] = score
#         print(f'i: {i}, j: {j}, score: {score}')
        return score
    diff = []
    if j < W - 1:
        diff.append((0, 1))
    if i < H - 1:
        diff.append((1, 0))
#     print(f'diff: {diff}')
    score_cand = []
    for di, dj in diff:
        additional = 0
        if (m[i][j] == '.' and m[i+di][j+dj] == '#') or (i == 0 and j == 0 and m[0][0] == '#'):
            additional += 1 
        score = calc(i+di, j+dj) + additional
        score_cand.append(score)
    score = min(score_cand)
    scores[i][j] = score
#     print(f'i: {i}, j: {j}, score: {score}')
    return score
print(calc(0, 0))
n,*a=map(int,open(0));n=n//2-1;a.sort();print(2*sum(a[n+2:])-2*sum(a[:n])+a[n+1]-a[n]-[0,min(a[n]+a[n+2],2*a[n+1])][n%2])

### FIXED CODE ###

#!/usr/bin/env python3
N, *a = map(int, open(0))
n = N//2 - 1
a.sort()
print(2*sum(a[n+2:]) - 2*sum(a[:n]) + a[n+1] - a[n] - (min(a[n]+a[n+2], 2*a[n+1]) if N%2 else 0))
import collections
h, w, m = map(int, input().split())
L_g = []
L_r = []
L = []
for i in range(m):
    a, b = map(int, input().split())
    L_g.append(a)
    L_r.append(b)
    L.append((a, b))
c1 = collections.Counter(L_g)
c2 = collections.Counter(L_r)

L1 = c1.most_common()
L2 = c2.most_common()

s = L1[0][1]
bL1 = []
d = 0
for i in range(len(L1)):
    if L1[i][1] == s:
        bL1.append(L1[i])
        d += 1
        if d == 3:
          break
    else:
        break
s = L2[0][1]
bL2 = []
d = 0
for i in range(len(L2)):
    if L2[i][1] == s:
        bL2.append(L2[i])
        d += 1
        if d == 3:
          break
    else:
        break
bL = []
for i in range(len(bL1)):
    for j in range(len(bL2)):
        bL.append((bL1[i][0], bL2[j][0]))
flag = 0
for e in bL:
    if e not in L:
        bom = e
        flag = 1
        break
if flag == 0:
    bom = bL[0]

t = L1[0][1]+L2[0][1]

if flag == 0:
        t -= 1
print(t)

### FIXED CODE ###

n,x,t = map(int, input().split())
if n%x == 0:
  print((n//x)*t)
else:
  print((n//x + 1)*t)