Help me in solving MANYSUMS problem

My issue

What is the issue in the code

My code

``````#include<stdio.h>

int main() {
int T, L, R;
scanf("%d", &T);

while (T > 0) {
scanf("%d %d", &L, &R);

// Initialize count for each test case
int count = 1;

// Check all combinations of pairs (i, j) in the range [L, R]
for (int i = L; i <= R; i++) {
for (int j = L; j <= R; j++) {
// Check if the sum i + j is a new reachable integer
if (i + j != i + i && i + j != j + j) {
count++;
}
}
}

// Print the count for the current test case
printf("%d\n", count);

// Decrement the number of test cases
T--;
}

return 0;
}

``````

Learning course: Level up from 1* to 2*
Problem Link: Practice Problem in - CodeChef

@shrutinandanwa
due to high constraints looping will give u tle
so u have to do some maths over here .
plzz refer the following code for better understanding

``````#include <stdio.h>
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int l, r;
scanf("%d%d", &l, &r);
if (l == r)
{
printf("1\n");
}
else
{
printf("%d\n", (2 * r) - (2 * l) + 1);
}
}
return 0;
}``````