from itertools import count
from math import sqrt


def counting_rectangles(target):
    """
    Returns the area of the rectangular grid with the nearest to target
    number of rectangles.
    """
    mindiff = target
    bestarea = 0

    def rectangles(n, m):
        return int((n**2 + n) * (m**2 + m) / 4)
    
    for i in count(1):
        for j in count(int(sqrt(4*target/(i**2 + i)))):
            r = rectangles(i, j)
            if abs(target - r) < mindiff:
                mindiff = abs(target - r)
                bestarea = i * j
            if r > target:
                break
        if i**2 + i > target / 2:
            break
    return bestarea


def solve(vol=0):
    return counting_rectangles(2000000)

from itertools import count
from math import sqrt


def counting_rectangles(target):
    """
    Returns the area of the rectangular grid with the nearest to target
    number of rectangles.
    """
    mindiff = target
    bestarea = 0

    def rectangles(n, m):
        return int((n**2 + n) * (m**2 + m) / 4)
    
    for i in count(1):
        for j in count(int(sqrt(4*target/(i**2 + i)))):
            r = rectangles(i, j)
            if abs(target - r) < mindiff:
                mindiff = abs(target - r)
                bestarea = i * j
            if r > target:
                break
        if i**2 + i > target / 2:
            break
    return bestarea


def solve(vol=0):
    return counting_rectangles(2000000)

Returns the area of the rectangular grid with the nearest to target     number of rectangles.