Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(1500)

def f(x, y):
    if x == y:
        return x
    x, y = min(x, y), max(x, y)
    return 2 * (y // x) * x + f(x, y % x)

N, X = list(map(int, input().split()))
print(f(X, N-X) + N)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1500)

def f(x, y):
    if x == 0:
        return 0
    if y % x == 0:
        return 2 * (y // x) * x - x
    return 2 * (y // x) * x + f(y % x, x)

N, X = list(map(int, input().split()))
print(f(X, N-X) + N)
from itertools import product


def solve(n, a_list, b_list):
    res = 10 ** 9 + 7
    v_dict_from = dict()
    v_dict_to = dict()

    for p in product([0, 1], repeat=n):
        q = [0] * n
        position_now = list(range(n))
        r = 0

        c_list = a_list.copy()
        for i in range(n):
            if p[i] == 1:
                c_list[i] = b_list[i]
        c_list_s = list(sorted(c_list))
        for v in range(1, 51):
            v_dict_from[v] = []
            v_dict_to[v] = []
        for i in range(n):
            v_dict_from[c_list[i]].append(i)
            v_dict_to[c_list_s[i]].append(i)
        # print(v_dict_from)
        # print(v_dict_to)
        for v in range(1, 51):
            for j, k in zip(list(sorted(v_dict_from[v])), v_dict_to[v]):
                for i in range(n):
                    if k <= position_now[i] < position_now[j]:
                        q[i] += 1
                        q[j] += 1
                        position_now[i] += 1
                        r += 1
                position_now[j] = k

            d = 0
            for j in v_dict_from[v]:
                if q[j] % 2 != p[j]:
                    d += 1
            if d % 2 == 0:
                r += d // 2
            else:
                r += 10 ** 9 + 7

        res = min(res, r)
    if res < 10 ** 9 + 7:
        return res
    else:
        return -1


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    res = solve(n, a_list, b_list)
    print(res)


def test():
    assert solve(3, [3, 4, 3], [3, 2, 3]) == 1
    assert solve(2, [2, 1], [1, 2]) == -1
    assert solve(4, [1, 2, 3, 4], [5, 6, 7, 8]) == 0


if __name__ == "__main__":
    test()
    main()


### FIXED CODE ###

from itertools import product


def solve(n, a_list, b_list):

    res = 10 ** 9 + 7

    for p in product([0, 1], repeat=n):
        if sum(p) % 2 == 1:
            continue

        r = 0

        c_list = [a for a in a_list]
        for i in range(n):
            if p[i] == 1:
                c_list[i] = b_list[i]
        c_list_s = list(sorted(c_list))

        used = [0] * n
        d_list = [0] * n
        for k in range(n):
            j = -1
            for i in range(n):
                if c_list[i] == c_list_s[k] and not used[i] and (i - k + p[i]) % 2 == 0:
                    used[i] = 1
                    j = i
                    break
            if j >= 0:
                d_list[j] = k
            else:
                r += 10 ** 9 + 7

        # r
        for i in range(n - 1):
            for j in range(i + 1, n):
                if d_list[i] > d_list[j]:
                    r += 1

        res = min(res, r)
    # print(res)
    if res < 10 ** 9 + 7:
        return res
    else:
        return -1


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    res = solve(n, a_list, b_list)
    print(res)


def test():
    assert solve(3, [3, 4, 3], [3, 2, 3]) == 1
    assert solve(2, [2, 1], [1, 2]) == -1
    assert solve(4, [1, 2, 3, 4], [5, 6, 7, 8]) == 0


if __name__ == "__main__":
    test()
    main()
N=int(input())
while for i in range(1,N+1):
  if i**2>N:
    break
  answer=i**2
print(answer)

### FIXED CODE ###

N=int(input())
for i in range(1,N+1):
  if i**2>N:
    break
  answer=i**2
print(answer)
N=int(input())
if N[-1]==3:
    print("bon")
elif N[-1] in [0,1,6,8]:
    print("pon")
else:
    print("hon")

### FIXED CODE ###

N=int(input())
if N%10==3:
    print("bon")
elif N%10 in [0,1,6,8]:
    print("pon")
else:
    print("hon")
n, k = list(map(int, input().split()))

proba = 0.0

for i in range(1, N+1):
  x = i
  p = 1.0
  while x < K:
    p *= 0.5
    x += 1
  proba += p/N
  
print(proba)

### FIXED CODE ###

N, K = list(map(int, input().split()))
 
ans = 0
for i in range(1, N+1):
    p = 1
    x = i
    while x < K:
        p *= 0.5
        x *= 2
    
    ans += p/N
 
print(ans)
for case in range (int(input())):
    triple = input().split()
    for i in range (3):
        triple[i] = int(triple[i])
    triple.sort()
    if (triple [0] == triple [2]) :
        print('No')
    elif (triple[0] == triple [1] or triple[1] == triple [2]) :
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

from sys import stdin
import math

if __name__ == '__main__':
	n = stdin.readline()
	n = n.rstrip('\n')
	n = n.split(' ')
	n = [int(i) for i in n]
	n.sort()
	if (n[0] == n[1] and n[1] != n[2]) or (n[0] != n[1] and n[1] == n[2]):
		print('Yes')
	else:
		print('No')
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
a,b,c=[a,b,c].sort()
print(a*b)

### FIXED CODE ###

a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
abc=sorted([a,b,c])
if abc[2]%2==0:
    print(0)
else:
    print(abc[0]*abc[1])
A, B, K = input().split()

A = int(A)
B = int(B)
K = int(K)

while K >= 1:
	if A % 2 == 0:
		B += A / 2
		A = A / 2
	else:
		A -= 1
		B += A / 2
		A = A / 2
	if B % 2 == 0:
		A += B / 2
		B = B /2
	else:
		B -= 1
		A += B / 2
		B = B /2		
	K -= 1
print(A + " " + B)

### FIXED CODE ###

A, B, K = input().split()

A = int(A)
B = int(B)
K = int(K)

for i in range(K):
	if i % 2 == 0:
		A //= 2
		B += A 
	else:
		B //= 2
		A += B 
print(str(A) + " " + str(B))
a,b,c,d = map(int, input())
print(a*b if c*d<a*b else c*d)

### FIXED CODE ###

a,b,c,d = map(int, input().split())
print(a*b if c*d<a*b else c*d)
n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
INF=10**9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

### FIXED CODE ###

N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 100000000
def rec(i,a,b,c):
    if(i==N):
        return(abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF)
    ret0 = rec(i+1,a,b,c)
    ret1 = rec(i+1,a+l[i],b,c)+10
    ret2 = rec(i+1,a,b+l[i],c)+10
    ret3 = rec(i+1,a,b,c+l[i])+10
    return min(ret0,ret1,ret2,ret3)
print(rec(0,0,0,0))
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main2():
	#a = int(input())
	#b , c = IN()
	s =  input()
	#s='1'*3000
	s=[int(c) for c in s]
	ll=len(s)
	ret_count=0
	for i in range(1):#ll-2):
		v = s[i]
		vs=[v]
		for c in s[i+1:]:
			v = (v * 10 + c) % 2019
			vs.append(v)
			if v == 0:
				ret_count += 1
		else:
			pa(vs)	
	print(ret_count)
				
def main():
	#a = int(input())
	#b , c = IN()
	s =  input()
	#s='1'*3000
	s=[int(c) for c in s]
	s=s[::-1]
	ll=len(s)
	cc=[0]*2018
	p=0
	tt=1
	cc[0]=1
	for i, v in enumerate(s):
		tt *= 10
		tt %= 2019
		p += tt*v
		p %= 2019
		cc[p] += 1
	
	ret = 0
	for v in cc:
		ret += v *(v-1)//2
	print(ret)	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main2():
	#a = int(input())
	#b , c = IN()
	s =  input()
	#s='1'*3000
	s=[int(c) for c in s]
	ll=len(s)
	ret_count=0
	for i in range(1):#ll-2):
		v = s[i]
		vs=[v]
		for c in s[i+1:]:
			v = (v * 10 + c) % 2019
			vs.append(v)
			if v == 0:
				ret_count += 1
		else:
			pa(vs)	
	print(ret_count)
				
def main():
	#a = int(input())
	#b , c = IN()
	s =  input()
	#s='1'*3000
	s=[int(c) for c in s]
	s=s[::-1]
	ll=len(s)
	cc=[0]*2019
	p=0
	tt=1
	cc[0]=1
	for i, v in enumerate(s):
		tt *= 10
		tt %= 2019
		p += tt*v
		p %= 2019
		cc[p] += 1
	
	ret = 0
	for v in cc:
		ret += v *(v-1)//2
	print(ret)	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

MOD = 10 ** 9 + 7

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

blue, red = K, N - K

p = 1 
d = 0

for i in range(1, blue + 1):
    print(int((comb(red + 1, p) % MOD) * (comb(blue - 1, d) % MOD) % MOD))
    p += 1
    d += 1


### FIXED CODE ###

def comb(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**4
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 )


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

blue, red = K, N - K

p = 1 
d = 0

for i in range(1, blue + 1):
    print(int((comb(red + 1, p, mod) * comb(blue - 1, d, mod) % mod)))
    p += 1
    d += 1
N, Q = [int(item) for item in input().split()]

tree_list = [input() for _ in range(1,N)]
tree_list_int = [[int(k) for k in i.split()] for i in tree_list]
query_list = [input() for _ in range(Q)]
query_list_int = [[int(k) for k in i.split()]  for i in query_list]

val_list = [0 for _ in range(N)]
node_index = [[] for _ in range(N)]
cumulated_sum_list = [0] * N


for a, b in tree_list_int:
    node_index[a -1].append(b - 1)
    node_index[b -1].append(a - 1)

for index, val in query_list_int:
    val_list[index-1] += val

def dfs(child_index, pairent_index):
    for child in node_index[child_index]:

        if child == pairent_index:
            continue

        val_list[child] += val_list[child_index]
        dfs(child, child_index)

    return val_list

res = dfs(0, -1)

for i in res:
    print(i)

### FIXED CODE ###

N, Q = [int(item) for item in input().split()]

tree_list = [input().split() for j in range(1, N)]

query_list = [input().split() for k in range(Q)]
query_list_int = [[int(k) for k in i] for i in query_list]

val_list = [0 for _ in range(N)]

linked_node_list = [[] for _ in range(N)]

for a, b in tree_list:
    a, b = int(a)-1, int(b) -1
    linked_node_list[a].append(b)
    linked_node_list[b].append(a)


for index, val in query_list_int:
    val_list[index-1] += val

stack = [0]
parent = [0] * (N+1)

while True:
    v=stack.pop()
    for child in linked_node_list[v]:
        if child != parent[v]:
            parent[child] = v
            stack.append(child)
            val_list[child] += val_list[v]
    if not stack:
        break

print(*val_list)
N, M = map(int, raw_input().split())
a={}
b={}
for i in range(M):
    k,l=a.append(map(int, raw_input().split()))
    if k==1:
        a.add(k)
    if l==1: 
        b.add(l)
if a&b: 
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

N, M = map(int, input().split())
a=set()
b=set()
for i in range(M):
    k,l=map(int, input().split())
    if k==1:
        a.add(l)
    if l==N:
        b.add(k)
if a&b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
N, A, B = map(int,input().split())

s = ''

while N>len(s):
    s += 'b' * A
    s += 'r' * B

print(s[:N].count('b'))

### FIXED CODE ###

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

a = N // (A+B)
b = N % (A+B)

ans = a * A + min(b,A)
print(ans)
from collections import Counter
s = input()
s_list = list(s)
counter = Counter(s_list)
values = list(counter.values())
if values[0]==values[1]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input()
a = [i for i in s]
a.sort()
if a[0]==a[1] and a[2]==a[3] and a[0]!=a[2]:
    print("Yes")
else:
    print("No")
def tax(p,x):
    return p*(100+x) // 100
def solve(X,Y,S):
    for a in range(1,S):
        for b in range(1,S-a+1):
            sum = tax(a,X)+tax(b,X)
            if sum == S:
                NS = tax(a,Y)+tax(b,Y)
                if NS > A:
                    A = NS
            if sum > S:
                break
    return A 
while True:
    X,Y,S = map(int, input().split()) 
    if X == 0:
        break
    print(solve(X,Y,S))


### FIXED CODE ###

def tax(p,x):
    return p*(100+x) // 100

def solve(X,Y,S):
    A=0
    sum=0
    NS=0
    for a in range(1,S):
        for b in range(1,S-a+1):
            sum = tax(a,X)+tax(b,X)
            if sum == S:
                NS = tax(a,Y)+tax(b,Y)
                if NS > A:
                    A = NS
            if sum > S:
                break
    return A 

while True:
    X,Y,S = map(int, input().split()) 
    if X == 0:
        break
    print(solve(X,Y,S))
A, B, C = map(int, input().split())
K = input()

M = max(A, B, C)

SUM = M*(2**K)

print(M)

if M == A:
	SUM+=(B+C)

if M == B:
	SUM+=(A+C)

if M == C:
	SUM+=(A+B)

print(SUM)


### FIXED CODE ###

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

if b < a:
	print(a-1)
else:
	print(a)
n = int(input())
action = []
for i in range(n):
    action.append(list(map(int,input().split())))

memo = []
for i in range(n):
    memo.append([-1]*3)

def dp(i, a):
    if i == 0:
        return action[0][a]
    elif memo[i][a] != -1:
        return memo[i][a]
    else:
        memo[i][a] = max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]
        return memo[i][a]

print(max([dp(n-1,a) for a in range(3)]))


### FIXED CODE ###

n = int(input())
action = []
for i in range(n):
    action.append(list(map(int,input().split())))

memo = []
for i in range(n):
    memo.append([-1]*3)

def dp(i, a):
    if i == 0:
        return action[0][a]
    elif memo[i][a] != -1:
        return memo[i][a]
    else:
        memo[i][a] = max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]
        return memo[i][a]

import sys
sys.setrecursionlimit(1000000)
print(max([dp(n-1,a) for a in range(3)]))
import sys

n,m = map(int,input().split())
sc = []

for _ in range(m):
  sc.append(list(map(int,input().split())))

sc.sort()

if m == 1:
  print(sc[0][1])
  sys.exit()
if sc[0][0] == 1 and sc[0][1] == 0:
  print('-1')
  sys.exit()

num = 0
while len(sc) > num+1:
  if sc[num][0] == sc[num+1][0]:
    if sc[num][1] == sc[num+1][1]:
      del sc[num]
      num = 0
      continue
    else:
      print('-1')
      sys.exit()
  num += 1

ans = [0 for _ in range(n)]
for i in range(len(sc)):
  ans[sc[i][0]-1] = sc[i][1]
if ans[0] == 0:
  ans[0] = 1

res = ''
for i in range(len(ans)):
  res = res + str(ans[i])

print(res)


### FIXED CODE ###

import sys

n,m = map(int,input().split())
sc = []

if m == 0 and n == 1:
  print(0)
  sys.exit()
elif m == 0 and n != 1:
  print(10**n // 10)
  sys.exit()


for _ in range(m):
  sc.append(list(map(int,input().split())))

sc.sort()

if n == 1:
  tmp = 0
  for i in range(m):
    if sc[i][0] == 1 and sc[i][1] == 0:
      tmp += 1
    if tmp == m:
      print(0)
      sys.exit()

if sc[0][0] == 1 and sc[0][1] == 0:
  print('-1')
  sys.exit()

ans = [-1 for _ in range(n)]
for i in range(m):
  if ans[sc[i][0]-1] == -1:
    ans[sc[i][0]-1] = sc[i][1]
  else:
    if ans[sc[i][0]-1] != sc[i][1]:
      print('-1')
      sys.exit()

res = ''
if ans[0] == -1:
  ans[0] = 1
for i in range(n):
  if ans[i] == -1:
    ans[i] = 0
  res = res + str(ans[i])

print(res)
def main():
    n, m = list(map(int, input().split()))
    dcon = [set() for _ in range(n)]
    for _ in range(m):
        s, c = tuple(map(int, input().split()))
        dcon[s-1].add(c)

    if any(len(d) > 1 for d in dcon):
        print(-1)
        return
    
    # populate the digits with the constrained digit, if it exists,
    # or the minimum possible digit.  the min possible digit is
    # 1 if it's the leading digit, or zero otherwise
    digits = [d.pop() if d else 0 + int(i == 0) for i, d in enumerate(dcon)]

    if digit[0] == 0:
        print(-1)
    else:
        print(''.join(map(str, digits)))

main()


### FIXED CODE ###

def main():
    n, m = list(map(int, input().split()))
    dcon = [set() for _ in range(n)]
    for _ in range(m):
        s, c = tuple(map(int, input().split()))
        dcon[s-1].add(c)

    if any(len(d) > 1 for d in dcon):
        print(-1)
        return
    
    digits = [0] if n == 1 else [1] + [0] * (n-1)
    for i in range(n):
        if dcon[i]:
            digits[i] = dcon[i].pop()

    if digits[0] == 0 and n != 1:
        print(-1)

    else:
        print(''.join(map(str, digits)))

main()
a,b = map(str,input().split())
cnt = 0
for i in range(1,400):
    if int(a+b) == i*i:
        print("Yes")
        cnt = 1
        break
if cnt == 0:
    prnt("No")

### FIXED CODE ###

a,b = map(str,input().split())
cnt = 0
for i in range(1,400):
    if int(a+b) == i*i:
        print("Yes")
        cnt = 1
        break
if cnt == 0:
    print("No")
# -*- coding: utf-8 -*-
# abc139/abc139_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    n = N - 1
    print((n * (1+n))　>>　1)
    return

main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
# abc139/abc139_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    n = N - 1
    print((n * (1 + n)) >> 1)
    return

main()
S = list(input ())
T = list(input ())
a = len(S)
change_time = 0
 
for i in range(a):
  if S[i] ==T[i]:
  	continue
  
  else:
  	S[i] =T[i]
  	change_time += 1
  
  
print(change_time)

### FIXED CODE ###

s = int(input())
 
N=s+s*s+s*s*s
 
print (N)
n,m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]

count = float('inf')
if n == 3:
    for i in range(100, 1000):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                 count = i
elif n == 2:
    for i in range(10, 100):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                count = i
elif n == 1:
    for i in range(0, 10):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                count = i

if count == float('inf'):
    print(-1)
else:
    print(

### FIXED CODE ###

n,m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]

count = float('inf')
if n == 3:
    for i in range(100, 1000):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                 count = i
elif n == 2:
    for i in range(10, 100):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                count = i
elif n == 1:
    for i in range(0, 10):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                count = i

if count == float('inf'):
    print(-1)
else:
    print(count)
while(true)
if W==0 && H==0 :
	break 
H,W = map(int,raw_input().split())
print "#"*W + "\n"
print ("#"+ "."*(W-2)+ "#"+"\n")*(H-2)
print "#"*W + "\n"

### FIXED CODE ###

while 1:
    H, W = map(int,raw_input().split())
    if H + W == 0: break
    print ('#' * W)
    for h in range(H-2):
        print ('#' + '.' * (W - 2) + '#')
    print ('#' * W + '\n')
from sys import stdin
from statistics import median


def main():
    i = 0
    n = 10**10
    a = []
    b = []
    for line in stdin:
        if i == 0:
            n = int(line)
            i += 1
            continue
        (ai, bi) = line.split()
        a.append(int(ai))
        b.append(int(bi))
        i += 1
        if i > n:
            break

    a_mid = median(a)
    b_mid = median(b)
    if a_mid == b_mid:
        print(1)
        return
    if b_mid - a_mid < 1:
        print(3)
        return
    if n % 2 == 0:
        print(int(b_mid - a_mid) * 2 + 1)
    else:
        print(int(b_mid - a_mid) + 1)

main()

### FIXED CODE ###

from sys import stdin

def main():
    for line in stdin:
        factors = line.split()
        break

    print(int(factors[0]) * int(factors[1]))

main()
N, A, B = map(int, raw_input().split())

print(min(A*N, B))

### FIXED CODE ###

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

print(min(A*N, B))
N,M=map(int,inputt().split())
print(N*(N-1)+N*M)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)
a,b,c = input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

from operator import itemgetter
import bisect
from itertools import accumulate
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]
WV.sort(key=itemgetter(0, 1))
w, v = zip(*WV)
w0 = w[0]
w1 = w0 + 1
w2 = w1 + 1
w3 = w2 + 1
i0 = bisect.bisect_left(w, w0)
i1 = bisect.bisect_left(w, w1)
i2 = bisect.bisect_left(w, w2)
i3 = bisect.bisect_left(w, w3)
v0 = sorted(v[i0:i1], reverse=True)
v1 = sorted(v[i1:i2], reverse=True)
v2 = sorted(v[i2:i3], reverse=True)
v3 = sorted(v[i3:], reverse=True)
a0 = list(accumulate(v0)) + [0]
a1 = list(accumulate(v1)) + [0]
a2 = list(accumulate(v2)) + [0]
a3 = list(accumulate(v3)) + [0]
n0 = 1 + len(v0)
n1 = 1 + len(v1)
n2 = 1 + len(v2)
n3 = 1 + len(v3)

ans = 0
for i0 in range(n0):
    for i1 in range(n1):
        for i2 in range(n2):
            for i3 in range(n3):
                if i0*w0 + i1*w1 + i2*w2 + i3*w3 <= W:
                    ans = max(ans, a0[i0-1]+a1[i1-1]+a2[i2-1]+a3[i3-1])
print(ans)