title: SIGABRT:out of range when using stoi/stol
body: <p>//I'm trying to solve this problem from <code>HackerEarth</code>: Binary Queries.</p>
  
  <p>Though initially, the problem sounds easy to me but when actually submitted my code to run on all the test cases, my code is throwing <code>SIGABRT error</code>.</p>
  
  <p>Upon checking the error, I found the error to be of type <code>out of range</code>. I'm unable to figure out how to resolve this:
  problem: <a href="https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/range-query-2/" rel="nofollow noreferrer">https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/range-query-2/</a> </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;algorithm&gt;
  #include&lt;cctype&gt;
  using namespace std;
  
  int main()
  { 
      long N,Q,L,R,X;
      int ch=0,buf;
      unsigned long long intrim;
      string str,cstr;
  
      scanf("%ld %ld",&amp;N,&amp;Q);
      cin.ignore();
      getline(cin,str);
      str.erase((remove_if(str.begin(),str.end(),(int(*)(int))isspace)),str.end()); // here its a key point
      //cout&lt;&lt;str;
  
      for(int i=0;i&lt;Q;i++)
      { 
          scanf("%d",&amp;ch);
  
          if(ch==1) // alter the X bit
          { 
              scanf("%ld",&amp;X);
  
              if(str[X-1]==0){ 
                  str[X-1]=1;
              }
              else {
                       str[X-1]=0;
                   }
          }
          else if(ch==0)
               { 
                   scanf("%ld %ld",&amp;L,&amp;R); 
                   cstr.append((str.begin()+L-1),str.begin()+R);
                   intrim=std::stoull(cstr,nullptr,2);
                   if(intrim%2==0){ 
                       cout&lt;&lt;"EVEN"&lt;&lt;endl;
                   }
                   else{ 
                           cout&lt;&lt;"ODD"&lt;&lt;endl;
                       }
                   cstr.clear();
               }
       }
  }
  </code></pre>