Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

#define bip(a) __builtin_popcount(a)
#define ull unsigned long long
#define ll long long
#define u unsigned
#define pb push_back
#define pf push_front /// for list
#define mpr make_pair
#define is insert
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define si set<int>
#define sl set<ll>
#define li list<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mii map<int, int>
#define mll map<ll, ll>
#define ma INT_MAX
#define mi INT_MIN
#define mod 1000000007
#define pi 3.14159265359
#define e 2.71828182846
#define inf 1000000000000000LL
#define all(x) x.begin(), x.end()
#define lb(a, b, c) lower_bound(a, a + b, c) - a
#define ub(a, b, c) upper_bound(a, a + b, c) - a
#define lbv(a, c) lower_bound(all(a), c) - a.begin()
#define ubv(a, c) upper_bound(all(a), c) - a.begin()
#define srt1(a, b) sort(a, a + b)
#define srt2(a, b) sort(a, a + b, greater<int>())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * (b / gcd(a, b)))
#define harmonic(n) 0.57721566490153286l + log(n)
#define mem(a, b) memset(a, b, sizeof(a))

/// s.lower_bound(a),s.upper_bound(a), for set
/// nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
/// factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));

int main() {
  /*char ch;
  cin>>ch;
  if(ch>='a' && ch<='z')cout<<"a\\n";
  if(ch>='A' && ch<='Z')cout<<"A\\n";*/
  /*int n,k;
  cin>>n>>k;
  int p[n+5];
  for(int i=0;i<n;i++)cin>>p[i];
  srt1(p,n);
  ll sum=0;
  for(int i=0;i<k;i++)sum+=p[i];
  cout<<sum<<endl;*/
  ll n;
  cin >> n;
  vi v;
  while (n != 0) {
    n--;
    v.pb(n % 26);
    n /= 26;
  }
  for (int i = v.size() - 1; i >= 0; i--)
    cout << (char)(97 + v[i]);
  cout << endl;
}


Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
using namespace std;

#define bip(a) __builtin_popcount(a)
#define ull unsigned long long
#define ll long long
#define u unsigned
#define pb push_back
#define pf push_front /// for list
#define mpr make_pair
#define is insert
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define si set<int>
#define sl set<ll>
#define li list<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mii map<int, int>
#define mll map<ll, ll>
#define ma INT_MAX
#define mi INT_MIN
#define mod 1000000007
#define pi 3.14159265359
#define e 2.71828182846
#define inf 1000000000000000LL
#define all(x) x.begin(), x.end()
#define lb(a, b, c) lower_bound(a, a + b, c) - a
#define ub(a, b, c) upper_bound(a, a + b, c) - a
#define lbv(a, c) lower_bound(all(a), c) - a.begin()
#define ubv(a, c) upper_bound(all(a), c) - a.begin()
#define srt1(a, b) sort(a, a + b)
#define srt2(a, b) sort(a, a + b, greater<int>())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * (b / gcd(a, b)))
#define harmonic(n) 0.57721566490153286l + log(n)
#define mem(a, b) memset(a, b, sizeof(a))

/// s.lower_bound(a),s.upper_bound(a), for set
/// nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
/// factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));

int main() {
  /*char ch;
  cin>>ch;
  if(ch>='a' && ch<='z')cout<<"a\\n";
  if(ch>='A' && ch<='Z')cout<<"A\\n";*/
  /*int n,k;
  cin>>n>>k;
  int p[n+5];
  for(int i=0;i<n;i++)cin>>p[i];
  srt1(p,n);
  ll sum=0;
  for(int i=0;i<k;i++)sum+=p[i];
  cout<<sum<<endl;*/
  map<ll, string> mp;
  ll cnt = 1;
  for (char ch = 'a'; ch <= 'z'; ch++) {
    string str;
    str = ch;
    mp[cnt] = str;
    cnt++;
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    string str;
    str = ch;
    for (char ch1 = 'a'; ch1 <= 'z'; ch1++) {
      str += ch1;
      mp[cnt] = str;
      cnt++;
    }
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    string str;
    str = ch;
    for (char ch1 = 'a'; ch1 <= 'z'; ch1++) {
      str += ch1;
      for (char ch2 = 'a'; ch2 <= 'z'; ch2++) {
        str += ch2;
        mp[cnt] = str;
        cnt++;
      }
    }
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    string str;
    str = ch;
    for (char ch1 = 'a'; ch1 <= 'z'; ch1++) {
      str += ch1;
      for (char ch2 = 'a'; ch2 <= 'z'; ch2++) {
        str += ch2;
        for (char ch3 = 'a'; ch3 <= 'z'; ch3++) {
          str += ch3;
          mp[cnt] = str;
          cnt++;
        }
      }
    }
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    string str;
    str = ch;
    for (char ch1 = 'a'; ch1 <= 'z'; ch1++) {
      str += ch1;
      for (char ch2 = 'a'; ch2 <= 'z'; ch2++) {
        str += ch2;
        for (char ch3 = 'a'; ch3 <= 'z'; ch3++) {
          str += ch3;
          for (char ch4 = 'a'; ch4 <= 'z'; ch4++) {
            str += ch1;
            mp[cnt] = str;
            cnt++;
          }
        }
      }
    }
  }
  ll n;
  cin >> n;
  cout << mp[n] << endl;
}