|Teddy loves roses and Tracy loves lilies. They wish to plant these flowers in a large garden.
However, the only florist in town sells these flowers in packets which are represented by ints roses and lilies. The i-th packet contains roses[i] roses and lilies[i] lilies. Each packet can be bought only once.
Teddy and Tracy wish to buy some flowers and arrange them into a rectangular grid. This grid must be arranged such that each cell contains exactly one flower, and any two cells which share an edge must contain different kinds of flowers. Additionally, Teddy and Tracy must use all the flowers they buy.
Teddy and Tracy love square-shaped grids, so they wish to buy a set of packets such that they can arrange the flowers into the most square-like grid possible. More precisely, they wish to arrange the flowers into an R x C grid, where R and C are positive integers, such that |R-C| (|R-C| denotes the absolute value of R-C) is minimized. Return this minimum absolute value, or -1 if no valid arrangement exists.
|-||roses and lilies will contain the same number of elements, between 1 and 16, inclusive.|
|-||Each element of roses and lilies will be between 0 and 10000, inclusive.|
|-||The total number of flowers in each packet represented by roses and lilies will be greater than 0.|