title: Memory Limit Exceed in Vector C++
body: <p>I'm getting memory limit exceeded error for this code. I can't find the way to resolve it. If I'm taking  a <code>long long int</code> it gives the same error.<br>
  Why this error happening?  </p>
  
  <pre><code>#include&lt;bits/stdc++.h&gt;
  #define ll long long int
  using namespace std;
  int main()
  {
      ///1000000000000 500000000001 getting memory limit exceed for this test case.
  
      ll n,k;
      cin&gt;&gt;n&gt;&gt;k;
      vector&lt;ll&gt; v;
      vector&lt;ll&gt; arrange;
  
  
      for(ll i=0;i&lt;n;i++)
      {
          v.push_back(i+1);
      }
  
      //Arranging vector like 1,3,5,...2,4,6,....
      for(ll i=0;i&lt;v.size();i++)
      {
          if(v[i]%2!=0)
          {
              arrange.push_back(v[i]);
          }
      }
      for(ll i=0;i&lt;v.size();i++)
      {
          if(v[i]%2==0)
          {
              arrange.push_back(v[i]);
          }
      }
      cout&lt;&lt;arrange[k-1]&lt;&lt;endl; // Found the kth number.
  
      return 0;
  }
  </code></pre>