title: scanner - nextInt issue in codeChef
body: <p>this the code which i wrote on Jcreator &amp; worked perfectly. But when i tried running on CodeChef's ide <code>[JAVA (javac 8)]</code>. It gave runtime error as follows:</p>
  
  <pre><code>Exception in thread "main" java.util.NoSuchElementException
  at java.util.Scanner.throwFor(Scanner.java:862)
  at java.util.Scanner.next(Scanner.java:1485)
  at java.util.Scanner.nextInt(Scanner.java:2117)
  at java.util.Scanner.nextInt(Scanner.java:2076)
  at Codechef.main(Main.java:14)
  </code></pre>
  
  <p>Code is as follows:-</p>
  
  <pre><code>import java.util.*;
  import java.lang.*;
  import java.io.*;
  
  class Codechef {
      public static void main (String[] args) throws java.lang.Exception {
          Scanner s =new Scanner(System.in);
          int n=s.nextInt(); //error points to this line
          int k=s.nextInt();
          int a[]=new int[n+1];
          int sum=1,x=1,y=n;
          for(int i=1; i&lt;=n; i++) {
              a[i]=s.nextInt();
          }
          while(x!=n) {
              int temp=a[y]-a[x];
              if(temp&gt;=1 &amp;&amp; temp&lt;=k) {
                  sum=sum+y;
                  x=y;
                  y=n;
              } else {
                  y--;
              }
          }
          System.out.println(sum);
      }
  }
  </code></pre>
  
  <p>What is wrong and how do i rectify it? Please help.</p>