title: Why is the output of these 2 programs different on codeforces while they are the same on ideone?
body: <p>First program:</p>
  
  <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  
  int main() {
  int n,taken,i,j,ans=0,t,num,k;
  cin&gt;&gt;n&gt;&gt;t;
  vector&lt;int&gt;a(n);
  
  for(i=0;i&lt;n;++i)
      cin&gt;&gt;a[i];
  
  i=0;j=0;    
  for(;i&lt;n;++i)
  {
      if(i&gt;j)
      {
          j=i;
          k=0;
          taken=0;
      }
  
      for(;j&lt;n;++j)
      {
          if(taken+a[j]&lt;=t)
          {
              taken+=a[j];
              k++;
          }
          else
              break;
      }
      ans=max(ans,k);
      taken-=a[i];
      k--;
  }
  
  cout&lt;&lt;ans;
  return 0;
  }
  </code></pre>
  
  <p>Second program:</p>
  
  <pre><code>  #include &lt;bits/stdc++.h&gt;
    using namespace std;
  
  int main() {
  int n,taken,i,j,ans=0,t,num,k;
  cin&gt;&gt;n&gt;&gt;t;
  vector&lt;int&gt;a(n);
  
  for(i=0;i&lt;n;++i)
      cin&gt;&gt;a[i];
  
  
  for(i=0;i&lt;n;++i)
  {
      if(i&gt;j)
      {
          j=i;
          k=0;
          taken=0;
      }
  
      for(j=0;j&lt;n;++j)
      {
          if(taken+a[j]&lt;=t)
          {
              taken+=a[j];
              k++;
          }
          else
              break;
      }
      ans=max(ans,k);
      taken-=a[i];
      k--;
  }
  
  cout&lt;&lt;ans;
  return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>it seems these 2 programs give 2 diffrent outputs,here is a testcase to check it out yourself:
  4 5
  3 1 2 1</p>
  
  <p>the first one outputs "3" while the second outputs "1991243264
  " on codeforces tests while the 2 programs give the same output on ideone..any help?</p>