title: std::bad_array_new_length for large numbers
body: <p>I try to run following code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int find_next(int act, unsigned long long survivors[], int n)
  {
      int i = act;
      while (survivors[i] == 0)
      {
          i++;
          i = i % n;
      }
      i = (i + 1) % n; // found first one, but need to skip 
      while (survivors[i] == 0)
      {
          i++;
          i = i % n;
  
      }// thats the guy 
      return i;
  }
  int main()
  {
      long long int lines;
      long long int* results;
  
      scanf_s(&quot;%llu&quot;, &amp;lines);
      results = new long long int[lines];
  
      for (long long int i = 0; i &lt; lines; i++) {
          unsigned long long n, k;
  
          scanf_s(&quot;%llu&quot;, &amp;n);
          scanf_s(&quot;%llu&quot;, &amp;k);
          unsigned long long* survivors;
          survivors = new unsigned long long[n];
          for (int m = 0; m &lt; n; m++) {
              survivors[m] = 1;
          }
          int* order;
          order = new int[n];
          int p = 0;
          int act = 0;
          while (p &lt; n - 1)
          {
              act = find_next(act, survivors, n);
              order[p] = act;
              survivors[act] = 0; // dies; 
              p++;
          }
          order[p] = find_next(act, survivors, n);
  
          if (k &gt; 0)
          {
              results[i] = order[k - 1] + 1;
          }
          else
          {
              results[i] = order[n + k] + 1;
          }
          delete[] survivors;
          delete[] order;
      }
      for (long long int i = 0; i &lt; lines; i++) {
          printf(&quot;%llu\n&quot;, results[i]);
      }
      delete[] results;
      return 0;
  }
  </code></pre>
  <p>My inputs are: <br>
  1 <br>
  1111111111 <br>
  -1 <br></p>
  <p>I am getting an exeption:</p>
  <pre><code>std::bad_array_new_length for large numbers
  </code></pre>
  <p>At line:</p>
  <pre><code>survivors = new unsigned long long[n];
  </code></pre>
  <p>How should I fix it that it wont show for such large numbers?</p>
  <p>So far I tried all numeric types of n -&gt; long long int, unsigned long and so on but everytime I was failing. Or maybe there is no way around that?</p>