Six friends go on a trip and are looking for accommodation. After looking for hours, they find a hotel which offers two types of rooms — double rooms and triple rooms. A double room costs Rs. X, while a triple room costs Rs. Y.

The friends can either get three double rooms or get two triple rooms. Find the minimum amount they will have to pay to accommodate all six of them.

------ Input Format ------ 

- The first line contains a single integer T - the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two integers X and Y - the cost of a double room and the cost of a triple room.

------ Output Format ------ 

For each testcase, output the minimum amount required to accommodate all the six friends.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ X < Y ≤ 100$

----- Sample Input 1 ------ 
3
10 15
6 8
4 8

----- Sample Output 1 ------ 
30
16
12

----- explanation 1 ------ 
Test case 1: The friends can take three double rooms and thus pay a total of Rs. $30$.

Test case 2: The friends can take two triple rooms and thus pay a total of Rs. $16$.

Test case 3: The friends can take three double rooms and thus pay a total of Rs. $12$.

Difficulty: EASY
Tags: Constructive algorithms

Mathematics

Ad-hoc

Starter code:

Solutions:
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a * 3 <= b * 2:
		print(a * 3)
	else:
		print(b * 2)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	print(min(x * 3, y * 2))


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	a1 = a * 3
	b1 = b * 2
	print(min(a1, b1))


import random
T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	a = 3 * X
	b = 2 * Y
	if a > b:
		print(b)
	elif a == b:
		print(random.randint(a, b))
	else:
		print(a)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	a = x * 3
	b = y * 2
	if a <= b:
		print(a)
	else:
		print(b)


test = int(input())
for i in range(test):
	(a, b) = map(int, input().split())
	r = 3 * a
	s = 2 * b
	if r > s:
		print(s)
	else:
		print(r)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if 3 * x < 2 * y:
		print(3 * x)
	else:
		print(2 * y)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	k = 3 * x
	l = 2 * y
	print(min(k, l))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	print(min(2 * y, 3 * x))


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	a = x * 3
	b = y * 2
	if a < b:
		print(a)
	else:
		print(b)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if 3 * x > 2 * y:
		print(2 * y)
	elif 3 * x < 2 * y:
		print(3 * x)
	else:
		print(3 * x)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(min(a * 3, b * 2))


T = int(input())
for t in range(T):
	(X, Y) = map(int, input().split())
	do = X * 3
	tr = Y * 2
	print(min(do, tr))


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	double_rooms = x * 3
	tripple_rooms = y * 2
	if double_rooms <= tripple_rooms:
		print(double_rooms)
	else:
		print(tripple_rooms)


n = int(input())
for i in range(n):
	m = input().split()
	if int(m[0]) * 3 < int(m[1]) * 2:
		print(int(m[0]) * 3)
	else:
		print(int(m[1]) * 2)


for T in range(int(input())):
	(X, Y) = map(int, input().split())
	if X * 3 > Y * 2:
		print(Y * 2)
	else:
		print(X * 3)


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	double = 6 // 2 * X
	triple = 6 // 3 * Y
	print(min(double, triple))


t = int(input())
while t:
	(x, y) = map(int, input().split())
	print(3 * x if 3 * x < 2 * y else 2 * y)
	t -= 1


T = int(input())
for i in range(0, T):
	(X, Y) = input().split()
	x = int(X)
	y = int(Y)
	minimum = min(3 * x, 2 * y)
	print(minimum)


n = int(input())
for i in range(n):
	a = 6
	(x, y) = list(map(int, input().split()))
	p = x * 3
	q = y * 2
	if p <= q:
		print(p)
	else:
		print(q)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = a * 3
	d = b * 2
	print(min(c, d))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	z = x * 3
	w = y * 2
	if z > w:
		print(w)
	else:
		print(z)


a = int(input())
while a != 0:
	(x, y) = map(int, input().split())
	doubleroom = 3 * x
	tripleroom = 2 * y
	if doubleroom > tripleroom:
		print(tripleroom)
	else:
		print(doubleroom)
	a -= 1


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	product_1 = X * 3
	product_2 = Y * 2
	if product_1 > product_2:
		print(product_2)
	else:
		print(product_1)


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if a * 3 > b * 2:
		print(b * 2)
	else:
		print(a * 3)


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	print(min(3 * X, 2 * Y))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = a * 6 // 2
	y = b * 6 // 3
	print(min(x, y))


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	x = 3 * X
	y = 2 * Y
	if x > y:
		print(y)
	else:
		print(x)


for _ in range(int(input())):
	(d, t) = map(int, input().split())
	print(min(3 * d, 2 * t))


for i in range(int(input())):
	(X, Y) = map(int, input().split())
	double_cost = 3 * X
	triple_cost = 2 * Y
	print(min(double_cost, triple_cost))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	s = 3 * x
	u = 2 * y
	if s > u:
		print(u)
	else:
		print(s)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	double = x * 3
	triple = y * 2
	h = min(double, triple)
	print(h)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	c = x * 3
	d = y * 2
	if c > d:
		print(d)
	else:
		print(c)


t = int(input())
i = 1
while i <= t:
	(X, Y) = list(map(int, input().split()))
	s = X * 3
	v = Y * 2
	if s > v:
		print(v)
	else:
		print(s)
	i = i + 1


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	mini1 = 3 * x
	mini2 = 2 * y
	if mini1 > mini2:
		print(mini2)
	else:
		print(mini1)


T = int(input())
for i in range(T):
	(a, b) = map(int, input().split())
	n1 = 3 * a
	n2 = 2 * b
	print(min(n1, n2))


t = int(input())
for i in range(t):
	(X, Y) = map(int, input().split())
	if X * 3 <= Y * 2:
		print(X * 3)
	elif X * 3 > Y * 2:
		print(Y * 2)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	m = 3 * x
	j = 2 * y
	if m <= j:
		print(m)
	else:
		print(j)


def ask_numbers():
	text1 = list()
	text2 = list()
	h = -1
	text = input('')
	for i in range(len(text)):
		if text[i] == ' ':
			h = i
	text1 = text[:h]
	text2 = text[h + 1:]
	return [int(text1), int(text2)]

def min_price(a):
	if 3 * a[0] > 2 * a[1]:
		return 2 * a[1]
	else:
		return 3 * a[0]

def main():
	T = int(input(''))
	for _ in range(T):
		a = ask_numbers()
		h = min_price(a)
		print(h)
	return 0
main()


len = int(input())
for i in range(len):
	c = input()
	v = c.split(' ')
	x = int(v[0])
	y = int(v[1])
	a = 3 * x
	b = 2 * y
	if a < b:
		print(a)
	else:
		print(b)


x = []
y = []
T = int(input())
for i in range(T):
	(tx, ty) = input().split(' ')
	x.append(int(tx))
	y.append(int(ty))
for i in range(T):
	print(min(3 * x[i], 2 * y[i]))


t = int(input())
for i in range(t):
	inp = input().split(' ')
	x = int(inp[0])
	y = int(inp[1])
	print(min(x * 3, y * 2))


n = int(input())
for x in range(n):
	(a, b) = map(int, input().split())
	s = a * 3
	r = b * 2
	if s > r:
		print(r)
	else:
		print(s)


t = int(input())
for i in range(t):
	(X, Y) = map(int, input().split())
	double = 3 * X
	triple = 2 * Y
	cost = min(double, triple)
	print(cost)


i = int(input(''))
j = 0
while j < i:
	(x, y) = map(int, input('').split())
	op = min(3 * x, 2 * y)
	j += 1
	print(op)