(LOOP) TLE ERROR HOW TO FIX THIS ?

This is my code :-

`#include<stdio.h>

int main() {

int t;
scanf("%d" , &t);

for(int i = 0 ; i < t ; i++) {
    int a , b , m , count1 = 0 , count2 = 0;
    scanf("%d%d%d" , &a , &b , &m);
    if(a > b) {
        int temp = a;
        a = b;
        b = temp;
    }
    for(int j = 0 ; j < a ; j++) {
        count1++;
    }
    for(int j = b ; j < m ; j++) {
        count1++;
    }
    for(int j = a ; j < b ; j++) {
        count2++;
    }
    (count1 > count2) ? printf("%d\n",count2) : printf("%d\n",count1);
}

return 0;

}`
I don’t understand how do I fix the TLE error here?? , suggest me some tips so that I don’t commit these errors again.

Try to avoid executing loop whose number of iterations can be as large as 10^9.

This problem has an O(1) time-complexity solution using simple mathematics.

Check the following update to your code.

Accepted