this is so far all i have done i am trying to optimize the code for less time.but it is not working.
for _ in range(int(input())):
n, m = map(int, input().split())
count = 0
for i in range(1, n+1):
for j in range(1, n+1):
if i < j <= n and ((m%i)%j) == ((m%j)%i):
count += 1
print(count)
another approach I tried:
if i < j <= n and (m-(m%j))%i == 0:
both condition give correct result.but show time limit exceed
what should i do.thanks