How does this code for Delicious Dishes take too long to compile ???

#include <stdio.h>

  int main()
{   int T,R,L,flag=1,num[10],temp,cnt=0,i,j,k;   
    scanf("%d",&T);
    while(T>0)
{   T--; 
  	cnt = 0;       
    scanf("%d %d",&R,&L);
    for(j=L; j <= R; j++)
  { flag = 1;                     
    for (k=0; k < 10; k++)       
         num[k]=0; 
  	temp = j;
  	while(temp>0)
  	{   num[(temp%10)]++;         
  		temp/=10;
  	}
    for(k=0; k < 10; k++)
        if(num[k]>=2) 
    	{   flag = 0;
    		break;
    	}
    if (flag == 1) cnt++;         
 } 	
    printf("Dishes: %d\n",cnt);
    {
    	
    };
 }  
    return 0;
}

Please read these two articles to understand it better in the future

The code has the following glitches:

  1. scanf("%d %d",&R,&L) should be replaced by scanf("%lld %lld",&L,&R)
  2. Your approach is brute force. This shall not work given the time limit of the question and the size of the numbers involved. Try to think of a smarter way to find out the result. Mathematics often comes in handy for these kind of questions.