def find_largest_anysize_at_xy(grid, x, y):
    """
    Finds the largest sizexsize grid with top-left location (x,y).
    """
    maxsize = min(300 - x, 300 - y)
    record = grid[(x,y)]
    record_tuple = (x, y, 1)
    prevsize = record
    for size in range(2, maxsize + 1):
        cand = prevsize
        for i in range(size):
            cand += grid[(x+i, y+size-1)]
            cand += grid[(x+size-1, y+i)]
        cand -= grid[(x+size-1, y+size-1)]
        prevsize = cand
        if cand > record:
            record = cand
            record_tuple = (x, y, size)
    return record, record_tuple