title: Codechef problem Given integers N and M, find the number of ordered pairs (a,b) such that 1≤a<b≤N and ((M mod a) mod b) = ((M mod b) mod a) help plss
body: <p>this is so far all i have done
  i am trying to optimize the code for less time.but it is not working.</p>
  <pre><code>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 &lt; j &lt;= n and ((m%i)%j) == ((m%j)%i):
              count += 1
  print(count)
  </code></pre>
  <p>another approach I tried:</p>
  <pre class="lang-py prettyprint-override"><code>if i &lt; j &lt;= n and (m-(m%j))%i == 0:
  </code></pre>
  <p>both condition give correct result.but show time limit exceed</p>
  <p>what should i do.thanks</p>