Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42.
These divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764.
The sum of the squared divisors is 2500 which is 50 * 50, a square!

Given two integers m, n (1 <= m <= n) we want to find all integers 
between m and n whose sum of squared divisors is itself a square.
42 is such a number.

The result will be an array of arrays or of tuples (in C an array of Pair) or a string, each subarray having two elements,
first the number whose squared divisors is a square and then the sum
of the squared divisors.

#Examples:
```
list_squared(1, 250) --> [[1, 1], [42, 2500], [246, 84100]]
list_squared(42, 250) --> [[42, 2500], [246, 84100]]
```

The form of the examples may change according to the language, see `Example Tests:` for more details.

**Note**

In Fortran - as in any other language - the returned string is not permitted to contain any redundant trailing whitespace: you can use dynamically allocated character strings.

Difficulty: introductory

Starter code:

def list_squared(m, n):
	

Solutions:
CACHE = {}

def squared_cache(number):
    if number not in CACHE:
        divisors = [x for x in range(1, number + 1) if number % x == 0]
        CACHE[number] = sum([x * x for x in divisors])
        return CACHE[number] 
    
    return CACHE[number]

def list_squared(m, n):
    ret = []

    for number in range(m, n + 1):
        divisors_sum = squared_cache(number)
        if (divisors_sum ** 0.5).is_integer():
            ret.append([number, divisors_sum])

    return ret

WOAH = [1, 42, 246, 287, 728, 1434, 1673, 1880, 
        4264, 6237, 9799, 9855, 18330, 21352, 21385, 
        24856, 36531, 39990, 46655, 57270, 66815, 
        92664, 125255, 156570, 182665, 208182, 212949, 
        242879, 273265, 380511, 391345, 411558, 539560, 
        627215, 693160, 730145, 741096]

list_squared = lambda HUH, YEAH: [[YES, DUH(YES)] for YES in WOAH if YES >= HUH and YES <= YEAH]
DUH = lambda YEP: sum(WOW**2 for WOW in range(1, YEP + 1) if YEP % WOW == 0)

from math import floor, sqrt, pow

def sum_squared_factors(n):
    s, res, i = 0, [], 1
    while (i <= floor(sqrt(n))):
        if (n % i == 0):
            s += i * i
            nf = n // i
            if (nf != i):
                s += nf * nf
        i += 1
    if (pow(int(sqrt(s)), 2) == s):
        res.append(n)
        res.append(s)
        return res
    else:
        return None
        
def list_squared(m, n):
    res, i = [], m
    while (i <= n):
        r = sum_squared_factors(i)
        if (r != None):
            res.append(r);
        i += 1
    return res
    



def get_divisors_sum(n):
    """Get the divisors: iterate up to sqrt(n), check if the integer divides n with r == 0
        Return the sum of the divisors squared."""
    divs=[1]
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            divs.extend([i, int(n/i)])
    divs.extend([n])
    
    # Get sum, return the sum 
    sm = sum([d**2 for d in list(set(divs))])
    return sm
    
    
def list_squared(m, n):
    """Search for squares amongst the sum of squares of divisors of numbers from m to n """
    out = []
    for j in range(m,n+1):
        s = get_divisors_sum(j) # sum of divisors squared.
        if  (s ** 0.5).is_integer(): # check if a square.
            out.append([j, s])
    return out


from itertools import chain
from functools import reduce


def factors(n):
    return set(chain.from_iterable(
        [d, n // d] for d in range(1, int(n**0.5) + 1) if n % d == 0))


def square_factors(n):
    return reduce(lambda s, d: s + d**2, factors(n), 0)


def list_squared(m, n):
    l = []
    for x in range(m, n + 1):
        s = square_factors(x)
        if (s**0.5).is_integer():
            l.append([x, s])
    return l

def list_squared(m, n):
    list=[]
    for i in range(m,n+1):
        sum=0
        s_list=[]
        for j in range(1,int(i**.5)+1):
            if i%j==0:
                div=i//j
                sum+=j**2
                if j!=div:
                    sum+=div**2
        sqt=sum**.5
        if int(sqt)==sqt:
            s_list=[i,sum]
            list.append(s_list)
    return list

def list_squared(m, n):
    out = []
    for i in range(m,n+1):
        # Finding all divisors below the square root of i
        possibles = set([x for x in range (1,int(i**0.5)+1) if i%x == 0])
        # And adding their counterpart
        possibles.update([i/x for x in possibles])
        # Doubles in the possibles are solved due to the set
        val = sum(x**2 for x in possibles)
        # Checking for exact square
        if (int(val**0.5))**2 == val: out.append([i, val])
    return out

import math


def divisors(n):
    divs = [1, n]
    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            divs.extend([i, int(n/i)])
    return set(divs)


def list_squared(m, n):
    sq_list = []
    for num in range(m, n):
        _sum = sum(item**2 for item in divisors(num))
        if math.sqrt(_sum).is_integer():
            sq_list.append([num, _sum])
    return sq_list

def list_squared(m, n):
    list = [[1, 1], [42, 2500], [246, 84100], [287, 84100], [728, 722500], [1434, 2856100], [1673, 2856100], [1880, 4884100], [4264, 24304900], [6237, 45024100], [9799, 96079204], [9855, 113635600], [18330, 488410000], [21352, 607622500], [21385, 488410000], [24856, 825412900]]
    left = -1
    right = -1
    for i, r in enumerate(list):
        if left == -1 and r[0] >= m:
            left = i
        if right == -1 and r[0] >= n:
            right = i - 1
    print('left={0},right={1}'.format(m, n))
    return list[left: right + 1]

def list_squared(m, n):
    result, divisors = [], {k: k*k + 1 for k in range(m, n+1)}
    divisors[1] = 1
    for d in range(2, int(n ** .5) + 1):
        for k in range(max(d*d, m + -m%d), n + 1, d):
            divisors[k] += d*d
            if k/d != d:
                divisors[k] += (k/d) ** 2
    for k in range(m, n + 1):
        if not divisors[k] ** .5 % 1:
            result.append([k, divisors[k]])
    return result

def divi(n):
    fac = set()
    for i in range(1, int(n**.5)+1):
        if n % i == 0:
            fac.add(i**2)
            fac.add(int(n/i)**2)
    return fac

def list_squared(m, n):
    return [[i, sum(divi(i))] for i in range(m, n) if str(sum(divi(i))**.5)[-1] == '0']



from math import sqrt
from functools import reduce

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
                
def list_squared(m, n):
    l = []
    for i in range(m, n):
        s = sum([x**2 for x in factors(i)])
        if sqrt(s) == int(sqrt(s)):
            l.append( [i, s] )
    return l


import math

def store_diviors_squared_sum(func):
    store = {}
    def helper(integer):
        if integer not in store:
            store[integer] = func(integer)
        return store[integer]
    return helper

@store_diviors_squared_sum
def divisors_squared_sum(integer):
    squared_divisors_sum = 1
    for number in range(2, integer+1):
        if integer % number == 0: squared_divisors_sum += number**2
    return squared_divisors_sum


def list_squared(m, n):
    return_array = []
    for integer in range(m, n+1):
        squared_divisors_sum = divisors_squared_sum(integer)
        if math.sqrt(squared_divisors_sum) % 1 == 0:
            return_array.append([integer, squared_divisors_sum])
    return return_array


def list_squared(m, n):
    def f(number):
        divisor_list = []
        n = int(number ** 0.5) + 1
        for e in range(1,n):
            if number % e == 0:
                if int(number / e) == e:
                    divisor_list.append(e**2)
                else:
                    divisor_list.append(e**2)
                    divisor_list.append((int(number / e))**2)
    
        summation = sum(divisor_list)
    
        if int(summation ** 0.5) == float(summation ** 0.5):
            return [True,summation]
        else:
            return [False,summation]
    list = []
    for i in range(m, n):
        d_l = f(i)
        if d_l[0]:
            list.append([i,d_l[1]])
    return list



                       
                       


def list_squared(m, n):
    output = []
    for i in range(m,n):
        div = set() #using set to ignore duplicates (the square root of i)
        for d in range(1,int(i**0.5)+1): #going up to square root to save time. 
            if i%d == 0:
                div.add(d) #if d is a divisor, i/d is also a divisor
                div.add(i/d)
        sumsqdiv = sum([a * a for a in div]) #using map/lambda to multiply all divisors. 
        if (sumsqdiv**0.5).is_integer():
            output.append([i,sumsqdiv])
    return output


from math import floor, sqrt

def list_squared(m, n):
    result = []
    for number in range(m, n):
        divisors = set()
        for divisor in range(1, floor(sqrt(number))+1):
            if number%divisor == 0:
                divisors.add(divisor) 
                divisors.add(number//divisor)
        divisorsum = sum(x*x for x in divisors)
        if (sqrt(divisorsum))%1 == 0:
            result.append([number, divisorsum])
    return result

def list_squared(m, n):
    # time complexity O(w*sqrt(k)) where k are the nums between m and n and w is the number of ints between m and n
    # space complexity O(w)
    res = []
    for num in range(m, n):
        div_sum = sum(i*i + ((num//i)*(num//i) if num//i != i else 0) for i in range(1, int(num**0.5) + 1) if num % i == 0)
        root = div_sum ** 0.5
        if root.is_integer(): 
            res.append([num, div_sum])
    return res
        


def list_squared(m, n):
    result = []
    for number in range(m, n+1):
        s = 0
        
        factors = {1,number}
        for x in range(2, int(number**0.5)+1):
            if number % x == 0:
                factors.add(x)
                factors.add(number/x)
                
        for i in factors:
            s = s + i**2
        if s**0.5 == int(s**0.5):
            result.append([number, s])
    return result

from math import sqrt

def list_squared(m, n):
    result = []
    for a in range(m,n+1):
        total = 0
        for i in range(1,int(sqrt(a))+1):
            if a%i == 0:
                total += i**2
                if i < a/i:
                    total += (a/i)**2
        if sqrt(total)%1 == 0:
            result.append([a, total])
    return result


from math import ceil
from functools import lru_cache
            
def find_square_sums(m, n):
    for x in range(m, n+1):
        c = candidate(x)
        if c:
            yield c

def candidate(n):
    total = sum(x**2 for x in divisors(n))
    if (total**0.5).is_integer():
        return [n, total]
    return False

@lru_cache(maxsize=100000)
def divisors(n):
    divs = [1, n]
    for x in range(2, ceil((n+1)/2)):
        if x in divs: break
        if n % x == 0:
            divs.append(x)
            divs.append(int(n/x))
    return set(divs)

def list_squared(m, n):
    return list(find_square_sums(m, n))

div=lambda n:sum(set(sum([[i**2,(n//i)**2] for i in range(2,int(n**.5)+1) if not n%i],[]))) + n*n + int(n!=1)
d = {i: div(i) for i in range(10001)}   
list_squared=lambda a,b:[[i,d[i]] for i in range(a,b+1) if (d[i]**.5).is_integer()]

import math

def get_divisors(num):
    divisors = {1}
    
    if num == 1:
        return divisors
    
    for i in range(2, int(math.sqrt(num))+1):
        if num % i == 0:
            divisors.add(i)
            divisors.add(num/i)
    divisors.add(num)
    
    return list(divisors)

def list_squared(m, n):
    res = []
    
    for i in range(m,n+1):
        total = sum([x*x for x in get_divisors(i)])
        if int(math.sqrt(total))**2 == total:
            res.append([i,total])
    
    return res


A={}
for n in range(1,12000):
    A[n] = [j**2 for j in list(range(1,int(n/2)+1))+[n] if (n/j).is_integer()]
    
def list_squared(m, n):
    return [[i,sum(A[i])] for i in range(m,n+1) if (sum(A[i])**(1/2)).is_integer()]


def list_squared(m, n):
    return [[i, square_sum(i)] for i in range(m, n+1) if (square_sum(i)**0.5).is_integer()]

def square_sum(n):
    if n == 1: return 1
    div = []
    for i in range(1, int(n**0.5) + 1):
        if i in div: break
        if n%i == 0: div += [i, n//i] if i != n//i else [i]
    return sum(v**2 for v in div)

from math import sqrt

def list_squared(m, n):
    ret_list = []
    for i in range(m, n):
        sum_divisors_2 = sum(
            x ** 2 + (i / x) ** 2 
            if x != i / x 
            else x ** 2
            for x in range(1, int(sqrt(i)) + 1)
            if not i % x
        )
        if sqrt(sum_divisors_2).is_integer():
            ret_list.append([i, sum_divisors_2])
    return ret_list


def list_squared(m, n):
    result = []
    for i in range(m, n+1):
        divisor = {1, i}
        for j in range(2, int(i ** 0.5)+1):
            if i % j == 0:
                divisor.add(j)
                divisor.add(int(i/j))
        div_sq_sum = sum([k ** 2 for k in divisor])
        if div_sq_sum ** 0.5 == int(div_sq_sum ** 0.5):
            result.append([i, div_sq_sum])
    return result

def list_squared(m, n):
    a,b = {1:1,42:2500,246:84100,287:84100,728:722500,1434:2856100,1673:2856100,1880:4884100,4264:24304900,6237:45024100,9799:96079204,9855:113635600},[] 
    for i in a.keys():
        if m <= i <= n:
            b.append([i,a[i]])
    return sorted(b)

from math import sqrt
def list_squared(m, n):
    # your code
    def F(x): return sum(b**2 + ((x/b)**2 if b*b != x else 0) for b in [a for a in range(1,int(sqrt(x))+1) if x%a == 0])
    return [[d,F(d)] for d in range(m,n+1) if sqrt(F(d)).is_integer()]


import math

def is_square(n):
    s = math.sqrt(n)
    return (s - math.floor(s)) == 0

def sds(n):
    s = 1 + (n**2 if n>1 else 0)
    l , r = 2, n//2
    while l < r:
        if (l*r) == n:
            s += l**2 + r**2
        l , r = l+1, n//(l+1)
    return s

def list_squared(m, n):  
    res = []
    for i in range(m,n):
        s_sum = sds(i)
        if is_square(s_sum):
            res.append([i, s_sum])
    return res
        


from math import ceil, sqrt

def squared(l):
    return [x**2 for x in l]

def divisors(m):
    s = sqrt(m)
    k = ceil(s)
    aux = [d for d in range(1, k) if m % d == 0]
    aux += [m // d for d in aux]
    if k == s:
        aux.append(k)
    return aux

def is_square(m):
    return ceil(sqrt(m))==sqrt(m)

def list_squared(m, n):
    return [[k, s] for (k, s) in [(k, sum(squared(divisors(k)))) for k in range(m, n + 1)] if is_square(s)]


from math import sqrt

def divisors_squared(x):
    l2 = []
    y = int(sqrt(x))
    for a in range(1, y+1):
        if x % a == 0:
            divby = x//a
            if a != divby:
                l2.extend((a**2, divby**2))
            else:
                l2.append(a)
    return l2

def list_squared(x, y):
    arr = []
    for i in range(x, y+1):
        z = sum(divisors_squared(i))
        if (sqrt(z)).is_integer():
            arr.append([i, z])
    return arr 


def list_squared(m, n):
    lst = []
    for num in range(m, n):
        s = set()
        for div in range(1, int(num**0.5)+1):
            if not num%div: s.update({div**2, int(num/div)**2})
        summ = sum(s)
        if ((summ**0.5)//1)**2 == summ: lst.append([num, summ])
    return lst
    


from math import sqrt
from math import ceil
def list_squared(m, n):
    # your code
    final_list = []
    for x in range(m, n):
        divisors_sq = 0
        for y in range(1, ceil(sqrt(x))):
            if x % y == 0:
                divisors_sq += y**2
                if x !=1:
                    divisors_sq += (x//y)**2
        if x == 1:
            divisors_sq = 1
        if round(sqrt(divisors_sq)) == sqrt(divisors_sq):
            final_list.append([x, divisors_sq])
    return final_list

list_squared(1, 250)


from math import sqrt

def issquare(x):
    return sqrt(x)==int(sqrt(x))

def list_squared(m, n):
    out_list = []
    for x in range(m,n+1):
        sum_t=sum( (i**2 + (x//i)**2*(x/i!=i) ) for i in range(1,int(sqrt(x))+1) if x % i==0)
        if issquare(sum_t):
            out_list.append([x,sum_t])
    return out_list

def gen_primes():
    D = {}
    q = 2
    while True:
        if q not in D:
            yield q
            D[q * q] = [q]
        else:
            for p in D[q]:
                D.setdefault(p + q, []).append(p)
            del D[q]
        q += 1


def factorize(n, primes):
    factors = []
    for p in primes:
        if p*p > n: break
        i = 0
        while n % p == 0:
            n //= p
            i+=1
        if i > 0:
            factors.append((p, i));
    if n > 1: 
        factors.append((n, 1))
    return factors


def divisors(factors):
    div = [1]
    for (p, r) in factors:
        div = [d * p**e for d in div for e in range(r + 1)]
    return div


def list_squared(m, n):
    result = []
    for i in range(m, n + 1):
        sum_i = 0
        for d in divisors(factorize(i, gen_primes())):
            sum_i += d * d
        if is_sqrt(sum_i):
            result.append([i, sum_i])
    return result


def is_sqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x * x == n


def divisors_list(num):
  divisors = []
  for i in range(1,int(num**0.5)+1):
    if num % i == 0:
      divisors += [i,num/i]
  return set(divisors)

def sum_squares(nums):
  return sum(num**2 for num in nums)

def isSquarable(num):
  return (num**0.5).is_integer()

def list_squared(m, n):
  res = []
  for i in range(m,n+1):
    elems_sum = sum_squares(divisors_list(i))
    if isSquarable(elems_sum):
      res.append([i, elems_sum])
  return res

def list_squared(m, n):
    a = []
    b = []
    for i in range(m,n):
        sum = 0
        for j in range(1,int(i**(0.5))+1):
            if i%j==0:
              sum+=j**2
              if i/j!=j:
                  sum+=int(i/j)**2
              
        if (sum**(0.5)).is_integer():
            a.append(i)
            b.append(sum)

    return [list(i) for i in zip(a,b)]


from math import sqrt,pow
from functools import reduce

def list_squared(m, n):
    sqr_sum = lambda i: sum(set(reduce(list.__add__,
                                       ([pow(j,2), pow(i // j, 2)] for j in range(1, int(sqrt(i)) + 1) if i % j == 0))))
    return [[i, j] for i, j in zip(range(m, n + 1), map(sqr_sum, range(m, n + 1))) if sqrt(j) == int(sqrt(j))]

import math
sqrt = math.sqrt

def getDivisors(x):
  result = []
  i = 1
  while i*i <= x:
    if x % i == 0:
      result.append(i**2)
      if x/i != i:
        result.append((x/i)**2)
    i += 1
  return (result)

def isSquaredDivisor(n):
  squaredList = getDivisors(n)
  sumList = sum(squaredList)
  if sqrt(sumList) % 1 == 0:
    return [n,sumList]
  else:
    return 0

def list_squared(m, n):
  retList = []
  for i in range(m,n+1):
    res = isSquaredDivisor(i)
    if res != 0:
      retList.append(res)
  return retList

from math import sqrt


def list_squared(m, n):

    def sum_divisors_squared(n):
        def divisors(n):
            for i in range(1, int(sqrt(n) + 1)):
                if n % i == 0:
                    yield i
                    if i*i != n:
                        yield n / i

        return sum(i ** 2 for i in divisors(n))

    def is_square(n):
        return sqrt(n) % 1 == 0

    def gen_subarrays(m, n):
        for i in range(m, n):
            divisor_sum = sum_divisors_squared(i)
            if is_square(divisor_sum):
                yield [i, divisor_sum]
    return [subarray for subarray in gen_subarrays(m, n)]


def map_sum_of_squqres(n):
    if n == 1:
        return [1,1]
    sum = 1 + n ** 2
    for i in range(2, int(n ** 0.5) + 1):
         if n % i == 0:
             sum += i ** 2
             if i != n / i:
                  sum += (n/i) ** 2
    return [n, sum]
    
def is_square(n):
    return int(n ** 0.5) ** 2 == n

def list_squared(m, n):
    return [i for i in map(map_sum_of_squqres, range(m,n+1)) if is_square(i[1])]

def list_squared(m, n):
    result=[]
    divisors=set()
    for i in range(m,n+1):
        a=1
        b=i/a
        divisors.clear()
        while a<=b:
            if b.is_integer():
                divisors.update((a,int(b)))
            a+=1
            b=i/a
        sqsum=sum(d**2 for d in divisors)
        if (sqsum**0.5).is_integer():
            result.append([i,sqsum])
    return result
            


def list_squared(m, n):
    res = []
    pairs = [ [1, 1],
            [42, 2500],
            [246, 84100],
            [287, 84100],
            [728, 722500],
            [1434, 2856100],
            [1673, 2856100],
            [1880, 4884100],
            [4264, 24304900],
            [6237, 45024100],
            [9799, 96079204],
            [9855, 113635600]]
    for i in range(m, n + 1):
        for idx, x in enumerate(pairs):
            if i == x[0]:
                res.append(x)
    return res

def getDivisors(num):
    res = []
    sum = 0
    for i in range(1,num+1):
        if num % i == 0:
            res.append(i)
            sum += i**2
    return (res,sum)

def list_squared(m, n):
    result = []
    nums = [1,42,246,287,728,1434,1673,1880,4264,6237,9799,9855,18330,21352,21385,24856,36531,39990,46655,57270,66815,92664]
    s = [1,2500,84100,84100,722500,2856100,2856100,4884100,24304900,45024100,96079204,113635600,488410000,607622500,488410000,825412900,1514610724,2313610000,2313610000,4747210000,4747210000,13011964900]    
    for i in range(m,n+1):
        if i in nums:
            result.append([i, s[nums.index(i)]])
    return result

import math

def list_squared(m, n):
    final = []
    for i in range(m, n+1):
        results = []
        for j in range(1, int(math.sqrt(i))+1):
            if i % j == 0:
                    if int(i / j) != j:
                        results.append(int(i / j) ** 2)
                    results.append(j ** 2)
        summ = sum(results)
        if (math.sqrt(summ).is_integer()):
            final.append([i, summ])
    return final

import functools
def list_squared(m, n):
    lista_final = []
    lst = []
    for i in range(m,n):
        dic = factors(i)
        for el in dic:
            lst.append(el**2)   
        soma = sum(lst)
        numero = soma ** (0.5)
        if numero == int(numero):
            lista_final = lista_final + [[i, soma]]
        lst = []
    return lista_final

def factors(n):    
    return set(functools.reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
            


import numpy as np;
import math;

def list_squared(m, n):

    validValues = [];

    #cycle through the values
    for testValue in range(m, n):
        divisorList = divisors(testValue);
        totalOfSquareDivisors = sum(np.power(divisorList, 2))               # NumPy again to square all

        #Does result have an even square root? - if so, add to the list
        if ( totalOfSquareDivisors % math.sqrt(totalOfSquareDivisors) == 0):
            validValues.append([testValue, totalOfSquareDivisors]);

    return  validValues;

# Use NumPy to determine the valid divisors
def divisors(n):
    r = np.arange(1, int(n ** 0.5) + 1)
    x = r[np.mod(n, r) == 0]
    result = set(np.concatenate((x, n / x), axis=None))
    return [int(i) for i in result]                         # Casts back to integer


def list_squared(m, n):
    all = []
    for x in range(m, n):
        divisors = [i for i in range(1, int(x**0.5)+1) if x%i==0]
        divisors += [int(x/d) for d in divisors if x/d > x**0.5]
        sumExp = sum(d**2 for d in divisors)
        if sumExp**0.5%1==0:
            all.extend([[x,sumExp]])
    return all

def list_squared(m, n):
    pool, sums = range(m, n), []

    for number in pool:
        # This way of calculating the divisors saves a lot of time
        divisors = [x for x in range(1, int(number**0.5 + 1)) if not number%x] 
        divisors += [number/x for x in divisors if x != number/x]            
        sums.append([number, sum([x**2 for x in divisors])])

    return [x for x in sums if x[1]**0.5 == int(x[1]**0.5)]

import math
 
def list_squared(m, n):
    res = []
    for num in range(m, n):
        add = 0
        for i in range(1, math.ceil(math.sqrt(num))):
            if num % i == 0:
                add += i**2 + (num//i)**2
        if math.sqrt(num).is_integer():
            add += num        
        if math.sqrt(add).is_integer():
            res.append([num, add])    
    return res


import math

def divisors(n):
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            if i*i != n:
                yield n/i

def list_squared(m, n):
    ret = []
    for i in range(m, n+1):
        div_sum = sum([j**2 for j in divisors(i)])
        if math.sqrt(div_sum).is_integer():
            ret.append([i, div_sum])
    return ret


import math

def suma(i):
    return sum(x**2 + (i//x)**2 for x in range(1, math.ceil(i**0.5)) if not i%x) + (i if (i**0.5).is_integer() else 0)

def list_squared(m, n):
    return [[i, suma(i)] for i in range(m, n+1) if (suma(i)**0.5).is_integer()]

import math

def list_squared(m, n):
    divs = []
    answer = []
    for x in range(m,n):
        divs = [1]
        for y in range(2,int(math.sqrt(x))+1):
            if x % y == 0 and math.sqrt(x) != y:
                divs.extend([y**2, int((x/y)**2)])
        if x != 1: divs.append((x*x))
        z = sum(divs) 
        if math.sqrt(z) % 1 == 0: answer.append([x,z])
    return answer


CACHE = [[i,sum([x**2 for x in range(1,i+1) if not(i%x)])] for i in range(1,10000) if sum([x**2 for x in range(1,i+1) if not(i%x)])**0.5 % 1 == 0]

def list_squared(m, n):
    return [e for e in CACHE if m <= e[0] <= n]

def list_squared(m, n):
    squares = []
    for i in range(m, n):
        total = sum(get_divisors_sqrd(i))
        if (total ** (1/2)).is_integer():
            squares.append([i, total])
    return squares
            
def get_divisors_sqrd(n):
    divisors = []
    for i in  range(1, int(n ** (1/2)) + 1):
        if n % i == 0:
            if i ** 2 not in divisors:
                divisors.append(i ** 2)
            if int(n/i) ** 2 not in divisors:
                divisors.append(int(n / i) ** 2)
    return divisors


from math import sqrt

def sum_square_divisors(n):
  res = 0
  nn = n * n
  # odds have only odd divisors
  for i in range(1, int(sqrt(n)) + 1, n % 2 + 1):
    if n % i == 0:
      ii = i * i
      res += ii
      if ii != n:
        res += nn // ii
  return res

def list_squared(m, n):
  res = []
  for i in range(m, n + 1):
    sds = sum_square_divisors(i)
    r = int(sqrt(sds))
    if r * r == sds:
      res.append([i, sds])
  return res


def list_squared(m, n, cache={}):
    get = range(m,n+1)
    check = set(get) - set(cache.keys())
    for y in check:
        sqr = sum(x**2 for x in range(1, y+1) if not y%x)
        root = sqr**.5
        cache[y] = None
        if root == int(root):
            cache[y] = sqr
    result = list([k,cache[k]] for k in get if cache[k])
    return result

from collections import Counter
from functools import reduce
from operator import mul
from random import randrange,randint

def primesbelow(n):
    c=n%6>1
    n={0:n,1:n-1,2:n+4,3:n+3,4:n+2,5:n+1}[n%6]
    s=[True]*(n//3)
    s[0]=False
    for i in range(int(n**0.5)//3+1):
        if s[i]:
            k=(3*i+1)|1
            s[k*k//3::2*k]=[False]*((n//6-(k*k)//6-1)//k+1)
            s[(k*k+4*k-2*k*(i%2))//3::2*k]=[False]*((n//6-(k*k+4*k-2*k*(i%2))//6-1)//k+1)
    return [2,3]+[(3*i+1)|1 for i in range(1,n//3-c) if s[i]]

medsize=100000
medprimes=set(primesbelow(medsize))
smallprimes=sorted(p for p in medprimes if p<1000)

def isprime(n,precision=7):
    if n<1:
        return False
    elif n<=3:
        return n>=2
    elif n%2==0:
        return False
    elif n<medsize:
        return n in medprimes
    d=n-1
    s=0
    while d%2==0:
        d//=2
        s+=1
    for repeat in range(precision):
        a=randrange(2,n-2)
        x=pow(a,d,n)
        if x==1 or x==n-1: continue
        for r in range(s-1):
            x=pow(x,2,n)
            if x==1: return False
            if x==n-1: break
        else: return False
    return True

def pollard_brent(n):
    if n%2==0: return 2
    if n%3==0: return 3
    y,c,m=randint(1,n-1),randint(1,n-1),randint(1,n-1)
    g,r,q=1,1,1
    while g==1:
        x=y
        for i in range(r): y=(pow(y,2,n)+c)%n
        k=0
        while k<r and g==1:
            ys=y
            for i in range(min(m,r-k)):
                y=(pow(y,2,n)+c)%n
                q=q*abs(x-y)%n
            g=gcd(q,n)
            k+=m
        r*=2
    if g==n:
        while True:
            ys=(pow(ys,2,n)+c)%n
            g=gcd(abs(x-ys),n)
            if g>1: break
    return g

def primefactors(n):
    fs=[]
    for c in smallprimes:
        while n%c==0:
            fs.append(c)
            n//=c
        if c>n: break
    if n<2: return fs
    while n>1:
        if isprime(n):
            fs.append(n)
            break
        f=pollard_brent(n)
        fs.extend(primefactors(f))
        n//=f
    return fs

def factorization(n):
    return Counter(primefactors(n))

def ssd(n):
    return reduce(mul,((p**(2*e+2)-1)//(p*p-1) for p,e in factorization(n).items()),1)

def list_squared(m,n):
    return [a for a in ([x,ssd(x)] for x in range(m,n+1)) if (a[1]**0.5).is_integer()]

import numpy as np

            
def binary_check(x):
    if x == 1: return True
    start = 0
    stop = x//2
    sol = []
    while start <= stop:
        mid = (start+stop) // 2
        
        if mid*mid == x:
            return True
        if mid*mid < x:
            start = mid + 1
        if mid*mid > x:
            stop = mid - 1

import collections
import itertools


def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            n /= i
            yield i
        else:
            i += 1

    if n > 1:
        yield n


def prod(iterable):
    result = 1
    for i in iterable:
        result *= i
    return result


def get_divisors(n):
    pf = prime_factors(n)

    pf_with_multiplicity = collections.Counter(pf)

    powers = [
        [factor ** i for i in range(count + 1)]
        for factor, count in list(pf_with_multiplicity.items())
    ]

    for prime_power_combo in itertools.product(*powers):
        yield prod(prime_power_combo)
            
def list_squared(m, n):
    sol = []
    
    for number in range(m,n):
        candidate = [i**2 for i in range(1,number+2) if number % i == 0]
        n = sum(candidate)
        if binary_check(n):
            sol.append([number,n])
    return sol


def list_squared(m, n):
    sol = []
    for number in range(m,n):
        candidate = [i*i for i in get_divisors(number)]
        n=int(sum(candidate))
        if binary_check(n):
            sol.append([number,n])
    return sol


def list_squared(m, n):
    result = []
    for i in range(m, n + 1):
#         b = 0
        # 开根方次循环
        a = sum(let * let + (i / let) * (i / let) for let in range(1, int(i ** 0.5) + 1) if i % let == 0)
        
        # 如果本身能被开根方，则减去，因为循环求和时多算了一次
        if (i ** 0.5) % 1 == 0:
            a = a - (i ** 0.5) * (i ** 0.5)

        if (a ** 0.5) % 1 == 0:
            result.append([i, int(a)])
    return result  
#     r=[]
#     for i in range(m,n+1):
#         for x in range(1,int(i**0.5)+1):
#             if i%x==0:
#                 a=sum([x*x+(i/x)*(i/x)])
#         if (i ** 0.5) % 1 == 0:
#             a = a - (i ** 0.5) * (i ** 0.5)

#         if (a ** 0.5) % 1 == 0:
#             r.append([i, int(a)])
#     return r  


def list_squared(m, n):
    result = []
    for i in range(m, n + 1):
        b = 0
#         for x in range(1,int(i**0.5)+1):
#             if i%x==0:
#                 a=sum(x*x+(i/x)*(i/x))
                
        a = sum(let * let + (i / let) * (i / let) for let in range(1, int(i ** 0.5) + 1) if i % let == 0)

        if (i ** 0.5) % 1 == 0:
            a = a - (i ** 0.5) * (i ** 0.5)

        if (a ** 0.5) % 1 == 0:
            result.append([i, int(a)])
    return result  


import math

def divisorGenerator(n):
    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            if i*i != n:
                large_divisors.append(n / i)
    for divisor in reversed(large_divisors):
        yield divisor

def is_square(n):
    if n == 0:return True
    if n == 1:return True
    x = n // 2
    seen = set([x])
    while x * x != n:
        x = (x + (n // x)) // 2
        if x in seen: return False
        seen.add(x)
    return True

def list_squared(m, n):
    out = []
    for a in range(m, n+1):
        divisor_sum = sum(int(r*r) for r in list(divisorGenerator(a)))
        if is_square(divisor_sum):
            out.append([a, divisor_sum])
    return out


import math

def list_squared(m, n):
    print(f"m: {m}, n: {n}", flush=True)
    biglips = []
    for i in range(m,n):
        if i > 2000 and i < 4000:
            i = 4000
        max = i+1
        factors = []
        counter = 1
        while counter < max:
            if i % counter == 0:
                factors.append(counter)
                max = int(i/counter)
                if max != counter:
                    factors.append(max)
            else:
                max -= 1
            counter += 1
        #factors = [i ** 2 for i in factors]
        factors = list(map(lambda x: x ** 2, factors))
        sumOf = sum(factors)
        root = math.sqrt(sumOf)
        if sumOf == int(root + 0.5) ** 2:
            biglips.append([i,sumOf])
        
    print(biglips)
    return biglips
    

import math

def list_squared(m, n):
    result = []
    for i in range(m, n + 1):
        divisors = set()
        for j in range(1, int(math.sqrt(i)+1)):
            if i % j == 0:
                divisors.add(j**2)
                divisors.add(int(i/j)**2)
        summa = sum(divisors)
        if (summa ** 0.5).is_integer():
            result.append([i, summa])
    return result

import math
def list_squared(m, n):
    final = []
    for i in range(m,n):
        #find sum of squared divisiors
        divisors = find_divisors(i)
        sum_sqrd = sum([d*d for d in divisors])
        if math.sqrt(sum_sqrd).is_integer():
            final.append([i, sum_sqrd])
    
    return final


def find_divisors(x):
    i = 1
    divisors = []
    while i <= math.sqrt(x):
        if x % i == 0:
            if x / i == i:
                divisors.append(i)
            else:
                divisors.append(i)
                divisors.append(int(x/i))
        
        i += 1
    divisors.sort()
    return divisors

def list_squared(m, n):
    ans = []
    sum = 0
    for i in range(m,n+1):
        sq = int(i ** 0.5)
        if sq > 1 and sq == (i ** 0.5):
            sq -= 1
        for j in range(1,sq+1):
            if i % j == 0:
                if j != int(i/j):
                    sum += (j ** 2)+(int(i/j) **2)
                else:
                    sum += (j ** 2)
        if sum > 0 and (sum ** 0.5) % 1 == 0:
            ans.append([i, sum])
        sum = 0
    return ans


import math

def get_divisors(n):
    i = 1
    result = []
    while i <= math.sqrt(n):
        if (n % i == 0):
            if (n / i == i):
                result.append(i)
            else:
                result += [i, n/i]
        i += 1
    return result

def get_squared(n):
    return [x*x for x in n]

def list_squared(m, n):
    pairs = [[x, sum(get_squared(get_divisors(x)))] for x in range(m, n+1)]
    return list([x for x in pairs if math.sqrt(x[1]) % 1 == 0])


import math

def squareDivisors(n) : 
    list_divisors = []
    i = 1
    while i <= math.sqrt(n):           
        if (n % i == 0) :               
            # If divisors are equal, print only one 
            if (n / i == i) : 
                list_divisors.append(i**2) 
            else : 
                # Otherwise print both 
                list_divisors.extend([i**2,(n//i)**2])
        i = i + 1
    return list_divisors

def list_squared(m, n):
    return [[i,sum(squareDivisors(i))] for i in range(m,n+1) if math.sqrt(sum(squareDivisors(i))).is_integer()]


from math import sqrt

def sumsqrdivs(x):
    divs = []
    for i in range(1, int(sqrt(x)+1)):
        if x%i == 0 :
            divs.append(i)
            if i**2 != x :
                divs.append(int(x/i))
    return sum(div**2 for div in divs)

def list_squared(m, n):
    return [[i, sumsqrdivs(i)] for i in range(m, n+1) if sqrt(sumsqrdivs(i)).is_integer()]

def factors(n):
    return set([f for i in range(1, int(n**0.5)+1) if n % i == 0 for f in [i, n//i]])

def list_squared(m, n):
    ans = []
    for i in range(m, n):
        sum_of_squares = sum(map(lambda x: x**2, factors(i)))
        if (sum_of_squares ** 0.5) % 1 == 0:
            ans.append([i, sum_of_squares])
    return ans

import math
def list_squared(m, n):
    p = []
    for x in range(m, n+1):
        ds = sum(y**2 + (x/y)**2 for y in range(2,math.ceil(math.sqrt(x))) if x%y == 0) + x**2
        if x > 1:
            ds += 1
            if x%math.sqrt(x) == 0:
                ds += x
        if math.sqrt(ds).is_integer():
            p = p + [[x, ds]]
    return p

import numpy as np
def list_squared(m, n):
    res = []
    for i in range(m, n+1):
        factor = []
        for k in range(1, int(i ** (1/2)) +1):
            if i % k == 0:
                if k != i//k:
                    factor = factor + [k, i//k]
                else:
                    factor = factor + [k]
        arr = np.array(factor)
        total = sum(arr ** 2)
        if total ==  int(total ** (1/2)) ** 2:
            res.append([i, total])
    return res

def memoize(f):
    memo = {}
    def helper(*args):
        if args not in memo:
            memo[args] = f(*args)
        return memo[args]
    return helper

@memoize
def sum_of_squares(n):
    squares = [x**2 for x in range(1, n+1) if n % x == 0]
    return sum(squares)

def list_squared(m, n):
    result = []
    for i in range(m, n):
        sums = sum_of_squares(i)
        if sums > 0 and sums**0.5 % 1 == 0:
            result.append([i, sums])
    return result


def list_squared(m, n):
    result = []
    for i in range(m, n + 1):
        a = sum(x * x + (i / x) * (i / x) for x in range(1, int(i ** 0.5) + 1) if i % x == 0)
        
        if (i ** 0.5) % 1 == 0:
            a = a - (i ** 0.5) * (i ** 0.5)

        if (a ** 0.5) % 1 == 0:
            result.append([i, int(a)])
    return result  

import math
def div(n):
    i = 1
    l = []
    m = []
    while i <= math.sqrt(n):
        if (n % i == 0):
            if (n / i == i):
                l.append(i)
                m.append(i ** 2)
            else:
                l.append(i)
                l.append(n // i)
                m.append(i ** 2)
                m.append((n // i) ** 2)
        i = i + 1
    if math.sqrt(sum(m)).is_integer():
        return [n, sum(m)]
    pass
def list_squared(m, n):
    b = []
    for j in range(m, n):
        if div(j):
            b.append(div(j))
    return b

results = [[1, 1], [42, 2500], [246, 84100], [287, 84100], [728, 722500], [1434, 2856100], [1673, 2856100], [1880, 4884100], [4264, 24304900], [6237, 45024100], [9799, 96079204], [9855, 113635600]]
def list_squared(m, n):
    result = []
    i = 0;
    while i < len(results) and results[i][0] < n:
        if results[i][0] >= m and results[i][0] <= n:
            result.append(results[i])
        i += 1
    return result

import math

def list_squared(m, n):
    result = []
    for x in range(m, n):
        divisors = make_divisors(x)
        squared_list = list(map(square, divisors))
        total = sum(squared_list)
        if math.sqrt(total).is_integer():
            result.append([x, total])
    return result
        
        
def square(n):
    return n * n
        
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

from math import *
def list_squared(m, n):
    def factors(x):
        lst = []
        for i in range(1, int(sqrt(x) + 1)):
            if x % i == 0:
                lst.append(i)
                if x != i ** 2:
                    lst.append(x / i)
        return sum([k ** 2 for k in lst])
    return [[j, factors(j)] for j in range(m, n + 1) if sqrt(factors(j)) % 1 == 0]      

from math import sqrt, pow

def list_divisors(n):
    s = set()
    i = 1
    while i <= sqrt(n):
        if i in s:
            continue
        div, mod = divmod(n, i)
        if (mod == 0) : 
            s.add(i)
            if (div != i): 
                s.add(div)
        i = i + 1
    
    return sorted(list(s))


def list_squared(m, n):
    result = []
    for i in range(m, n + 1):
        divs_sum = sum(pow(d, 2) for d in list_divisors(i))
        if sqrt(divs_sum).is_integer():
            result.append([i, divs_sum])
    return result
        


def divisors(n):
    divs = []
    for x in range(1, int(n**0.5)+1): 
        if n % x == 0:
            divs.extend([x**2, (n//x)**2])
    return sum(set(divs)) 
    
def list_squared(start, stop):
    squares = []
    for x in range(start, stop+1):
        x_sum = divisors(x)
        if int(x_sum**0.5) **2 == x_sum: 
            squares.append([x, x_sum])

    return squares


from math import sqrt
from functools import reduce

CACHE = {}

def get_divisors_gen(number):
    if number in CACHE:
        return CACHE[number]
    
    divisors = []
    for i in range(1, int(number / 2) + 1):
        if number % i == 0:
            divisors.append(i)
    divisors.append(number)

    CACHE[number] = divisors
    
    return divisors
    

def list_squared(m, n):
    result = []
    for number in range(m, n+1):
        div_sq_sum = reduce(
            lambda acc, item: acc + item**2,
            get_divisors_gen(number)
        )
        if sqrt(div_sq_sum).is_integer():
            result.append([number, div_sq_sum])
    return result

from functools import reduce

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def list_squared(m, n):
    ans = []
    
    for i in range(m,n):
        factor_sum = 0
        factor_ans = []
        
        for j in factors(i):
            factor_sum += j**2
                
        if (factor_sum**0.5).is_integer():
            factor_ans.append(i)
            factor_ans.append(factor_sum)
            ans.append(factor_ans)
    return ans
        
        
            
            
        
    
        
                
            


def list_squared(m, n):
    # your code   
    import numpy as np
    # find the divisors all together with array operarions instead of for loop (TOO SLOW!)
    def find_divisor_square(n):
        arr = np.arange(1,n+1)
        arr = n/arr
        divs = arr[arr == arr.astype(int)]
        return divs**2
        
    res = []
    for num in range(m,n):
        divs = find_divisor_square(num)
        sum_squres = divs.sum()
        if (sum_squres**0.5).is_integer(): # checks whether a float obj is an integer
            res.append([num, sum_squres])
    return res


import math

def list_squared(m, n):
    result = []
    for number in range(m, n):
        divisors = []
        for div in range(1, int(math.sqrt(number) + 1)):
            if number % div == 0:
                divisors.append(div)
        upper_divisors = [int(number / i) for i in divisors if i*i != number]
        divisors.extend(upper_divisors[::-1])
        div_sum = sum([i**2 for i in divisors])
        if math.sqrt(div_sum).is_integer():
            result.append([number, div_sum])
    return result

CACHE = {}

def squared_cache(number):
    if number not in CACHE:
        divisors = [x for x in range(1, round(number/2) + 1) if number % x == 0]
        CACHE[number] = sum([x * x for x in divisors]) + number ** 2
        return CACHE[number] 
    
    return CACHE[number]

def list_squared(m, n):
    ret = []

    for number in range(m, n + 1):
        divisors_sum = squared_cache(number)
        if (divisors_sum ** 0.5).is_integer():
            ret.append([number, divisors_sum])

    return ret

def list_squared(m, n):
    squared_divisors = []
    for i in range(m, n + 1):
        if i == 1:
            div = [1]
        else:
            div = [j for j in range(1, int(i**0.5) + 1) if i % j == 0 for j in (j, i//j) if i/j != j]
        tot = sum(k*k for k in div)**0.5
        if tot == int(tot):
            squared_divisors.append([i, int(tot**2)])
    return squared_divisors


from math import sqrt

def list_squared(m, n):
    squares = []
    # Find all divisors
    for i in range(m,n):
        i_squares = 0
        for j in range(1,int(sqrt(i)//1)+1):
            if i%j == 0:
                i_squares += j**2
                if i//j != j:
                    i_squares += (i//j)**2
        if i_squares%sqrt(i_squares) == 0 and i_squares/sqrt(i_squares) == sqrt(i_squares):
            squares.append([i,i_squares])
    return squares

from functools import reduce

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def list_squared(m, n):
    result = []
    
    for i in range(m, n+1):
        factors_sq = [x**2 for x in factors(i)]
        sum_factors = sum(factors_sq)
        sum_factors_root = sum_factors ** 0.5
        if  sum_factors_root == int(sum_factors_root):
            result.append([i, sum_factors])
            
    return result
        


cache = {}

def sum_cache(n):
    if n not in cache:
        divs = [i for i in range(1, n+1) if n % i == 0]
        cache[n] = sum([x*x for x in divs])
        return cache[n]
    return cache[n]


def list_squared(m, n):
    # your code
    
    result = []
    for j in range(m, n+1):
        summ = sum_cache(j)
        if (summ ** 0.5).is_integer():
            result.append([j, summ])

    return result

import math

def get_factors(m, n):
    cache = dict()
    for i in range(m, n + 1):
        factors = (j for j in range(1, 1 + i) if i % j == 0)
        total_sum = sum(j * j for j in factors)
        if math.sqrt(total_sum) % 1 == 0.:
            cache[i] = total_sum
    return cache
    
    
FACTORS = get_factors(1, 10000)

def list_squared(m, n):
    return [[i, FACTORS[i]] for i in range(m, n + 1) if i in FACTORS]


def list_squared(m, n):
    answer = []
    for i in range(m, n+1):
        root = sumSquares(factors(i)) ** 0.5
        if root == round(root):
            answer.append([i, int(root ** 2)])
    return answer
 
# def factors(x):
#     factorsList = []
#     for i in range(1, x // 2 +1):
#         if  x % i == 0:
#             factorsList.append(i)
#     factorsList.append(x)
#     return factorsList
 
from functools import reduce
 
def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
 
def sumSquares(l):
    return sum(i ** 2 for i in l)

def list_squared(m, n):
    answer = []
    for i in range(m, n+1):
        root = sumSquares(factors(i)) ** 0.5
        if root == round(root):
            answer.append([i, int(root ** 2)])
    return answer

from functools import reduce

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def sumSquares(l):
    return sum(i ** 2 for i in l)