title: "runtime error: addition of unsigned offset to 0x129000a0 overflowed to 0x12900088"
body: <p>Here is my code.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;bits/stdc++.h&gt;
  
  using namespace std;
  
  int main()
  {
      int n;
      cin &gt;&gt; n;
      vector&lt;string&gt; v;
  
      for(int i=0; i&lt;n; i++)
      {
          string temp;
          cin&gt;&gt;temp;
          v.push_back(temp);
  
          //if(v.size() == 1)
          //{
          //    continue;
          //}
  
          //cout &lt;&lt; i &lt;&lt; endl;
          //cout &lt;&lt; endl;
  
          //cout &lt;&lt; v.size();
  
          int k = i;
          while(v[k-1].length() &gt; v[k].length() &amp;&amp; k&gt;-1)
          {
              swap(v[k], v[k-1]);
  
              k--;
          }
          //cout &lt;&lt; endl;
      }
  
      bool check = true;
      for(int i=0; i&lt;v.size()-1; i++)
      {
          //cout &lt;&lt; v[i] &lt;&lt; endl;
          //cout &lt;&lt; v[i+1] &lt;&lt; endl;
  
          if (v[i+1].find(v[i]) != std::string::npos)
          {
              //std::cout &lt;&lt; &quot;found!&quot; &lt;&lt; '\n';
              continue;
          }
  
          //cout &lt;&lt; &quot;false&quot; &lt;&lt; endl;
          check = false;
      }
  
      if(check == true)
      {
          cout &lt;&lt; &quot;YES&quot; &lt;&lt; endl;
          for(int i=0; i&lt;n; i++)
          {
              cout &lt;&lt; v[i] &lt;&lt; endl;
          }
      }
      else
      {
          cout &lt;&lt; &quot;NO&quot; &lt;&lt; endl;
      }
  }
  </code></pre>
  <p>What’s the reason for this error?</p>
  <p>The <strong>input</strong> was:</p>
  <pre class="lang-none prettyprint-override"><code>100
  npugmvzdgfnzyxuyfwbzwktiylhvhwgeqauolidpnbemhgbunpefzsltewkxdcrzxgvmkb
  bezfumiguzafxghvcfqmwpopxvazctlftelveayycypjckooxeehyk
  ingenqhogs
  elhnhxjwrytbmmqdwwrivvljybhnwfgwhvdgjqgqgvunuemdtrgpyvaanovheqbupamzrjxh
  rpvktlmyxfshahfgunrhuqtosysymfjruqlzdooauuihtchzqgyrhcoxbtoorkxkwakvdkiakitlqfbgz
  tnrnpghjmqumbzfnztiijgwkiygyfevfebuammkwnoinqvhhlsuoqtfkazqhlnuqtthudhhovjqiuykwqtck
  mloehzniuwyakgwmopfgknpoiuiyewijmoefjjjsdimkisugehwqefcx
  tthmaxtahimxxts
  fspoetalxgcgowhjtanerjpqnen
  hefsyokneekdgpbicss
  </code></pre>
  <p>It works for other cases.</p>
  <blockquote>
  <p>Diagnostics detected issues [cpp.clang++-diagnose]: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\vector:1802:11: runtime error: addition of unsigned offset to 0x129000a0 overflowed to 0x12900088</p>
  </blockquote>
  <blockquote>
  <p>SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\vector:1802:11 in</p>
  </blockquote>