title: Time Limit Exceed Error in java
body: <p>When I am submitting this program on codechef. I am getting TLF error...
  So, please help.....what should I do?
  And I want to know when TLF occurs and What is the normal cause of them.
  time limit for this program is 1sec.</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  
  class Query {
  
      public static void main(String[] args) throws IOException {
          int M = 1000000007;
          BufferedReader scan = new BufferedReader (new InputStreamReader(System.in));
          String[] buff = scan.readLine().split(" ");
          int n = Integer.parseInt(buff[0]);
          int q = Integer.parseInt(buff[1]);
          int s[] = new int[n];
          buff = scan.readLine().split(" ");
          for(int i=0;i&lt;n;i++){
              s[i] = Integer.parseInt(buff[i]);
          }
          for(int p=0;p&lt;q;p++){
              buff = scan.readLine().split(" ");
              int type = Integer.parseInt(buff[0]);
              int x = Integer.parseInt(buff[1])-1;
              int y = Integer.parseInt(buff[2])-1;
              if(type == 4){
                  int sum = 0;
                      for (int i = x; i &lt;= y; i++){
                          sum += s[i];
                      }
                      sum %= M;
                      System.out.println(sum);
              }
              else{
                  int v = Integer.parseInt(buff[3]) ;
                  switch(type){
                      case 1:{
                          for (int i = x; i &lt;= y; i++){   
                              s[i]  += v;
                              s[i] %= M;
                          }
                          break;
                      }
                      case 2:{
                          for (int i = x; i &lt;= y; i++){
                              s[i] *= v;
                              s[i] %= M;
                          }
                          break;
                      }
                      case 3:{
                          for (int i = x; i &lt;= y; i++)    
                              s[i] = v ;
                          break;
                      }
                  }
              }
          }
      }
  }
  </code></pre>