User ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below.  At first, the score is 0.  For each block of contiguous "o"s with length x the score increases by x^2.  For each block of contiguous "x"s with length y the score decreases by y^2.   

For example, if a = 6, b = 3 and ainta have arranged the cards in the order, that is described by string "ooxoooxxo", the score of the deck equals 2^2 - 1^2 + 3^2 - 2^2 + 1^2 = 9. That is because the deck has 5 blocks in total: "oo", "x", "ooo", "xx", "o".

User ainta likes big numbers, so he wants to maximize the score with the given cards. Help ainta make the score as big as possible. Note, that he has to arrange all his cards.


-----Input-----

The first line contains two space-separated integers a and b (0 ≤ a, b ≤ 10^5; a + b ≥ 1) — the number of "o" cards and the number of "x" cards.


-----Output-----

In the first line print a single integer v — the maximum score that ainta can obtain.

In the second line print a + b characters describing the deck. If the k-th card of the deck contains "o", the k-th character must be "o". If the k-th card of the deck contains "x", the k-th character must be "x". The number of "o" characters must be equal to a, and the number of "x " characters must be equal to b. If there are many ways to maximize v, print any.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Examples-----
Input
2 3

Output
-1
xoxox

Input
4 0

Output
16
oooo
Input
0 4

Output
-16
xxxx

Difficulty: HARD
Tags: Implementation

Constructive algorithms

Starter code:

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

def sqr(x):
	return x * x

def work(num, flag=0):
	ans = sqr(a - num + 1) + num - 1
	could = min(b, num + 1)
	cc = b // could
	res = b % could
	ans -= res * sqr(cc + 1) + (could - res) * sqr(cc)
	if flag:
		print(ans)
		list = ''
		res2 = could - res
		if could == num + 1:
			list += 'x' * cc
			res2 -= 1
		ta = a
		list += 'o' * (a - num + 1)
		ta -= a - num + 1
		while ta > 0:
			u = cc + int(res > 0)
			if res > 0:
				res -= 1
			else:
				res2 -= 1
			list += 'x' * u
			list += 'o'
			ta -= 1
		if res > 0 or res2 > 0:
			list += 'x' * (cc + int(res > 0))
		print(str(list))
	return ans
if a == 0:
	print(-sqr(b))
	print('x' * b)
elif b == 0:
	print(sqr(a))
	print('o' * a)
else:
	now = 1
	for i in range(1, a + 1):
		if i - 1 <= b and work(i) > work(now):
			now = i
	work(now, 1)


(a, b) = [int(i) for i in input().split()]
if a == 0:
	print(-b ** 2)
	print('x' * b)
elif b == 0:
	print(a ** 2)
	print('o' * a)
elif b == 1:
	print(a ** 2 - 1)
	print('x' + 'o' * a)
else:
	ans = -float('inf')
	gr_no = None
	for i in range(2, min(a + 2, b + 1)):
		v1 = (a + 2 - i) ** 2 + i - 2
		quo = b // i
		rem = b % i
		v2 = rem * (quo + 1) ** 2 + (i - rem) * quo ** 2
		if v1 - v2 > ans:
			gr_no = i
			ans = v1 - v2
	quo = b // gr_no
	rem = b % gr_no
	if rem > 0:
		s = 'x' * (quo + 1) + 'o' * (a + 2 - gr_no)
		rem -= 1
	else:
		s = 'x' * quo + 'o' * (a + 2 - gr_no)
	gr_no -= 1
	s1 = 'x' * (quo + 1) + 'o'
	s2 = 'x' * quo + 'o'
	for i in range(rem):
		s += s1
	for i in range(gr_no - rem - 1):
		s += s2
	s += 'x' * quo
	print(ans)
	print(s)


def main():
	(a, b) = map(int, input().split(' '))
	answer = -b ** 2
	a_cluster = a
	if a:
		for i in range(a):
			answer_candicate = (a - i) ** 2 + i
			quotient = b // (i + 2)
			remainder = b % (i + 2)
			answer_candicate -= (i + 2 - remainder) * quotient ** 2 + remainder * (quotient + 1) ** 2
			if answer_candicate > answer:
				answer = answer_candicate
				a_cluster = a - i
	print(answer)
	if a:
		quotient = b // (a - a_cluster + 2)
		remainder = b % (a - a_cluster + 2)
		print('x' * quotient, end='')
		print('o' * a_cluster, end='')
		print('x' * (quotient + (1 if remainder else 0)), end='')
		remainder = max(remainder - 1, 0)
		for i in range(a - a_cluster):
			print('o', end='')
			print('x' * (quotient + (1 if remainder else 0)), end='')
			remainder = max(remainder - 1, 0)
		print()
	else:
		print('x' * b)
main()


import math
import sys
inp = input().split()
a = int(inp[0])
b = int(inp[1])
if a == 0:
	print(str(-b ** 2))
	out = 'x' * b
	print(out)
elif b == 0:
	print(str(a ** 2))
	out = 'o' * a
	print(out)
else:
	ind = -1
	buk = -1
	quo = -1
	rem = -1
	sco = -sys.maxsize - 1
	for i in range(a):
		buk_i = i + 2
		quo_i = int(b / buk_i)
		rem_i = b % buk_i
		sco_i = (a - i) ** 2 + i - rem_i * (quo_i + 1) ** 2 - (buk_i - rem_i) * quo_i ** 2
		if sco_i > sco:
			buk = buk_i
			quo = quo_i
			rem = rem_i
			sco = sco_i
			ind = i
	print(sco)
	out = 'x' * quo + 'o' * (a - ind - 1)
	for i in range(rem):
		out += 'o' + 'x' * (quo + 1)
	for i in range(buk - rem - 1):
		out += 'o' + 'x' * quo
	print(out)