alexjercan/bugnet huggingface dataset:
Problem p02628 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> lol(n);
  for (int i = 0; i < n; i++) {
    cin >> lol[i];
  }
  sort(lol.begin(), lol.end());
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += lol[i];
  }
  cout << sum;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> lol;
  for (int i = 0; i < n; i++) {
    cin >> lol[i];
  }
  sort(lol.begin(), lol.end());
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += lol[i];
  }
  cout << sum;
}
Problem p02628 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, K;
  const int p_size = 1010;
  int p[p_size];
  int sum = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  sort(p, p + N);

  for (int i = 0; i < K; i++) {
    sum += p[i];
  }

  cout << sum << endl;
}

Error: -11

Fixed submission:

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

int main() {
  int N, K;
  vector<int> p;
  int sum = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());

  for (int i = 0; i < K; i++) {
    sum += p[i];
  }

  cout << sum << endl;
  return 0;
}
Problem p02628 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, k, n, sum = 0;
  cin >> t >> k;
  int ar[t];
  for (int i = 0; i < t; i++) {
    cin >> ar[i];
  }
  n = sizeof(ar) / sizeof(ar[0]);
  sort(ar, ar + n);
  for (int j = 0; j < k; j++) {
    sum = sum + ar[j];
  }
  cout << sum << endl;
}

Error: 0

Fixed submission:

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

void bubble_sort(int list[], int n);
int main() {
  int array[100], n, c, sum = 0;
  int k;
  scanf("%d", &n);
  scanf("%d", &k);
  for (c = 0; c < n; c++) {
    scanf("%d", &array[c]);
  }
  bubble_sort(array, n);

  for (c = 0; c < k; c++) {
    sum = sum + array[c];
  }
  printf("%d\\n", sum);
  return 0;
}
void bubble_sort(int list[], int n) {
  int i, j, temp;
  int count = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n - i - 1; j++) {
      if (list[j] > list[j + 1]) // use < to sort in descending order//;
      {
        temp = list[j];
        list[j] = list[j + 1];
        list[j + 1] = temp;
      }
    }
  }
}
Problem p02629 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define lol long long
#define SUM(n) ((n) + 1) * (n) / 2 // 1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed << setprecision(x + 1) // 小数点桁数を指定する
#define abs(x, y) max(x, y) - min(x, y)
#define all(v) v.begin(), v.end()
#define UPDigit(a, b) (a + b - 1) / b // 小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = int(1e9) + 7;
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

// 最大公約数
lol gcd(lol x, lol y) {
  if (x < y)
    swap(x, y);
  lol r = x % y;
  while (r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// 最小公倍数
lol lcm(lol x, lol y) {
  lol a = x * y;
  return (a / gcd(x, y));
}

void ans(lol n) {
  if (n == 0) {
    return;
  }
  ans((n - 1) / 26);
  cout << (char)((n - 1) % 26 + 'a');
  return;
}

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol n;
  cin >> n;
  ans(n);
  cout << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define lol long long
#define SUM(n) ((n) + 1) * (n) / 2 // 1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed << setprecision(x + 1) // 小数点桁数を指定する
#define abs(x, y) max(x, y) - min(x, y)
#define all(v) v.begin(), v.end()
#define UPDigit(a, b) (a + b - 1) / b // 小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = int(1e9) + 7;
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

// 最大公約数
lol gcd(lol x, lol y) {
  if (x < y)
    swap(x, y);
  lol r = x % y;
  while (r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// 最小公倍数
lol lcm(lol x, lol y) {
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol n;
  cin >> n;
  stack<char> ans;
  while (n >= 0) {
    ans.push('a' + (n % 26 - 1));
    n /= 26;
  }
  while (!ans.empty()) {
    cout << ans.top();
    ans.pop();
  }
  cout << '\\n';
  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
using namespace std;
// mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for (int i = 1; i <= n; ++i)
#define ji for (int j = 1; j <= n; ++j)
#define jj for (int j = 1; j <= m; ++j)
#define ij for (int i = 1; i <= m; ++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(), x.end()
#define al(x) x + 1, x + 1 + n
#define asd cout << "ok" << endl;
#define asdd cout << "okok" << endl;
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int, int>>
#define pr(v)                                                                  \\
  for (auto i : v)                                                             \\
    cout << i << " ";                                                          \\
  cout << endl
#define prt(a, l, r)                                                           \\
  for (auto i = l; i <= r; ++i)                                                \\
    cout << a[i] << " ";                                                       \\
  cout << endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int main() {
  ll n;
  cin >> n;
  string ans;
  while (n) {
    ans += ('a' + (n - 1) % 26);
    n = (n - 1) / 26;
  }
  reverse(all(ans));
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  while (1) {
    ll n;
    cin >> n;
    string ans;
    while (n > 0) {
      n--;
      ans += (char)('a' + n % 26);
      n /= 26;
    }
    cout << ans << endl;
  }
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string l = "abcdefghijklmnopqrstuvwxyz";
  long a;
  cin >> a;
  vector<int> v;
  while (a != 0) {
    long b = a % 26;
    if (b == 0)
      b = 26;
    v.push_back(b);
    a = (a - b) / 26;
  }
  // for(auto x:v)cout << x << " ";
  for (int i = v.size() - 1; i > -1; i--)
    cout << l[v[i] - 1];
  cout << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string l = "abcdefghijklmnopqrstuvwxyz";
  long a;
  cin >> a;
  int b = 0;
  long c = 0;
  vector<int> v(10);
  while (a >= c) {
    c += pow(26, b);
    b++;
  }
  b--;
  long d = pow(26, b - 1);

  for (int i = 0; i < b; i++) {
    v[i] = int(a / d);
    a %= d;
    d /= 26;
  }
  for (int i = 0; i < b; i++) {
    if (v[b - i - 1] == 0) {
      v[b - i - 1] = 26;
      v[b - i - 2]--;
    }
  }
  // for(auto x:v)cout << x << " ";
  for (int i = 0; i < b; i++)
    cout << l[v[i] - 1];
  cout << endl;
}
Problem p02629 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long int n;
  cin >> n;

  int k = 0;
  long int max = 0, pow = 1;
  while (max < n) {
    k++;
    pow *= 26;
    max += pow;
  }

  for (; k > 0; k--) {
    char alf = 'z';
    pow /= 26;
    while (n + pow - 1 < max) {
      max -= pow;
      alf--;
    }
    cout << alf;
  }
  cout << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;

  int k = 0, max = 0, pow = 1;
  while (max < n) {
    k++;
    pow *= 26;
    max += pow;
  }

  for (; k > 0; k--) {
    char alf = 'z';
    pow /= 26;
    while (n + pow - 1 < max) {
      max -= pow;
      alf--;
    }
    cout << alf;
  }

  cout << endl;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define pb push_back
#define ALL(v) v.begin(), v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<int>>;

#if 0
string f(ll n)
{
    if(n == 0) return "";
    n--;
    //char t = 'a'+n%26;
    return f(n/26) + string(1, 'a'+n%26);
}
int main()
{
    ll N;
    cin >> N;
    cout << f(N) << endl;
    return 0;
}
#else
int main() {
  ll N;
  cin >> N;
  string ans;
  while (N) {
    N--;
    ans += 'a' + N % 26;
    N /= 26;
  }
  reverse(ALL(ans));
  cout << ans << endl;
  return 0;
}
#endif

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define pb push_back
#define ALL(v) v.begin(), v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<int>>;

// ABC171C
int main() {
  ll N;
  cin >> N;
  ll MAX = 26;
  vector<string> X(N);
  rep(i, MAX) {
    char t = 'a' + i;
    X[i] = t;
  }
  // rep(i, 2) cout << X[i] << endl;
  ll l = MAX;
  ll r = l + MAX * MAX;
  ll k = l;
  ll time = MAX;
  ll prev = 0;
  while (k < N) {
    char t = 'a';
    ll p = 0;
    rep2(i, l, r) {
      X[k++] = t + X[prev++];
      if (k == N)
        goto EXIT_;
      // cout << X[k-1] << endl;;
      if (++p >= time) {
        p = 0;
        t++;
        prev -= time;
        // cout << "DD"<< t<< endl;
      }
    }
    prev = l;
    l = r;
    time *= MAX;
    r = r + time * MAX;
    // cout << l << "+"<<r << endl;
  }
EXIT_:
  cout << X[N - 1] << endl;
  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

int main() {
  ll n;
  cin >> n;

  ll t = 1;
  string ans = "";
  for (int i = 1; i < 100; i++) {
    t *= 26;
    if (n <= t) {
      n--;
      for (int j = 0; j < i; j++) {
        ans += 'a' + n % 26;
        n /= 26;
      }
      break;
    } else {
      n -= t;
    }
  }

  reverse(all(ans));
  cout << ans << endl;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<ll> ans(n, 0);
  for (int i = 0; i < 60; i++) {
    ll cnt = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] & (1LL << i)) {
        cnt++;
      }
    }
    for (int j = 0; j < n; j++) {

      if (cnt % 2 == 0) {
        if (a[j] & (1LL << i)) {
          ans[j] += 1LL << i;
        }

      } else {
        if (a[j] & (1LL << i)) {
          ;
        } else {
          ans[j] += 1LL << i;
        }
      }
    }
  }

  reverse(all(ans));
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

void solve() {
  long long n, x = 26, pre = 1;
  cin >> n;
  string s;
  while (n > 0) {
    long long c = n % x;
    if (!c)
      c = x;
    n -= c;
    s += ((c / pre - 1) + 'a');
    x *= 26;
    pre *= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}

int main() {
  int tt = 1;
  // cin >> tt;
  while (tt--)
    solve();
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

void solve() {
  long long n, x = 26, pre = 1;
  cin >> n;
  string s;
  while (n > 0) {
    int c = n % x;
    if (!c)
      c = x;
    n -= c;
    s += ((c / pre - 1) + 'a');
    x *= 26;
    pre *= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}

int main() {
  int tt = 1;
  // cin >> tt;
  while (tt--)
    solve();
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

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

const int N = 5000;
typedef long long LL;

LL n, cnt;
char ch[N];

int main() {
  cin >> n;
  while (n > 0) {
    if (n % 26 == 0)
      ch[++cnt] = 'z', n -= 1;
    else
      ch[++cnt] = (char)(n % 26 + 'a' - 1);
    n /= 26;
  }
  for (int i = cnt; i; i--)
    cout << ch[i];
  return 0;
}

Error: -11

Fixed submission:

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

const int N = 5000;
typedef long long LL;

LL n, cnt;
char ch[N];

int main() {
  cin >> n;
  while (n) {
    if (n % 26 == 0)
      ch[++cnt] = 'z';
    else
      ch[++cnt] = (char)(n % 26 + 'a' - 1);
    n /= 26;
    n--;
  }
  for (int i = cnt; i; i--)
    cout << ch[i];
  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int64_t n;
  cin >> n;
  vector<string> judge = {
      "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
      "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
  };
  string ans;
  while (n > 0) {
    n--;
    ans = judge.at(n % 26) + ans;
    n /= 26;
  }

  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int64_t n;
  cin >> n;
  vector<int> keta(20, -1);
  vector<string> judge = {
      "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
      "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y",
  };

  int count = 0;
  while (n > 0) {
    keta.at(count) = n % 26;
    n /= 26;
    // cout << count << "," << keta.at(count) <<endl;
    count++;
  }

  string ans;
  for (int i = 0; i < 19; i++) {
    if (keta.at(i) <= 0 && keta.at(i + 1) < 0) {
      break;
    }
    ans = judge.at(keta.at(i)) + ans;
    if (keta.at(i) == 0) {
      keta.at(i + 1) += 25;
      keta.at(i + 1) % 26;
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, x, n) for (int i = x; i < n; i++)
#define repr(i, x, n) for (int i = x; i > n; i--)
#define pii pair<int, int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6 + 3);
int dir4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int knight[8][2] = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},
                    {1, 2}, {-1, 2}, {1, -2}, {-1, -2}};

using namespace std;

void solve() {
  long long n;
  cin >> n;
  string s = "zabcdefghijklmnopqrstuvwxy";
  string ans = "";
  while (n) {
    int rem = n % 26;
    ans += s[rem];
    if (rem == 0)
      n--;
    n /= 26LL;
  }
  reverse(ans.begin(), ans.end());
  cout << ans;
}
// new line is printed in the main

int main() {
  int t = 1;
  // cin >> t; // comment out if no test case is required
  // int i = 1;
  while (t--) {
    // cout << "Case " << i++ << ": ";
    solve();
    // printf("\\n");
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, x, n) for (int i = x; i < n; i++)
#define repr(i, x, n) for (int i = x; i > n; i--)
#define pii pair<int, int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6 + 3);
int dir4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int knight[8][2] = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},
                    {1, 2}, {-1, 2}, {1, -2}, {-1, -2}};

using namespace std;

void solve() {
  long long n;
  cin >> n;
  string s = "zabcdefghijklmnopqrstuvwxy";
  string ans = "";
  long long x = 26;
  while (x <= n) {
    ans += s[n % x];
    x = x + x * 26;
    // n -= 26;
    // n /= 26LL;
  }
  reverse(ans.begin(), ans.end());
  cout << ans;
}
// new line is printed in the main

int main() {
  int t = 1;
  // cin >> t; // comment out if no test case is required
  // int i = 1;
  while (t--) {
    // cout << "Case " << i++ << ": ";
    solve();
    // printf("\\n");
  }
  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int mod = 1e9 + 7;
const int nax = 1e7;
const ll inf = 1e10 + 17;
vector<int> prime(nax, -1);
ll pow1(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b % 2)
      res = (res * 1LL * a);
    a = (a * 1LL * a);
    b /= 2;
  }
  return res;
}
ll mul(ll a, ll b) { return (a * 1LL * b) % mod; }
ll eval(int i) {
  ll ans = (26 * 1LL * (pow1(26, i) - 1)) / (25 * 1LL);
  return ans;
}
int main() {
  int n = 12;
  ll N, i;
  cin >> N;
  for (i = 1; i <= 11; i++) {
    if (eval(i) >= N) {
      break;
    }
  }
  // cout<<i<<endl;
  int y = i - 1;
  N -= eval(y);

  int len = i;
  vector<char> ans(len + 1);
  set<char> unused;
  // cout<<N<<endl;
  for (int k = 0; k < 26; k++) {
    unused.insert((char)(k + 'a'));
  }
  for (int j = 1; j <= len; j++) {
    ll ev = pow1(26, len - j);

    ll x = (N + ev - 1) / ev;
    N -= (x - 1) * ev;
    // cout<<N<<endl;

    ans[j] = (char)(x - 1 + 'a');
    // unused.erase(ans[j]);
  }
  for (int i = 1; i <= len; i++) {
    cout << ans[i];
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int mod = 1e9 + 7;
const int nax = 1e7;
const ll inf = 1e10 + 17;
vector<int> prime(nax, -1);
ll pow1(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b % 2)
      res = (res * 1LL * a);
    a = (a * 1LL * a);
    b /= 2;
  }
  return res;
}
ll mul(ll a, ll b) { return (a * 1LL * b) % mod; }
ll eval(int i) { ll ans = (26 * 1LL * (pow1(26, i) - 1)) / (25 * 1LL); }
int main() {
  int n = 12;
  ll N, i;
  cin >> N;
  for (i = 1; i <= 11; i++) {
    if (eval(i) >= N) {
      break;
    }
  }
  // cout<<i<<endl;
  int y = i - 1;
  N -= eval(y);

  int len = i;
  vector<char> ans(len + 1);
  set<char> unused;
  // cout<<N<<endl;
  for (int k = 0; k < 26; k++) {
    unused.insert((char)(k + 'a'));
  }
  for (int j = 1; j <= len; j++) {
    ll ev = pow1(26, len - j);

    ll x = (N + ev - 1) / ev;
    N -= (x - 1) * ev;
    // cout<<N<<endl;

    ans[j] = (char)(x - 1 + 'a');
    // unused.erase(ans[j]);
  }
  for (int i = 1; i <= len; i++) {
    cout << ans[i];
  }
}
Problem p02629 (C++) — buggy submission, verdict: Time Limit Exceeded

/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH
*RANJAN******************************************************
***********************************************************************************************/
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);

    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i, n) for (int i = 0; i < n; i++)
#define frs(i, a, b) for (int i = a; i < b; i++)
#define meme(a, b) memset(a, b, sizeof(a)); // works only for 0 and -1
int main() {
  fast();
  ll n;
  cin >> n;
  string ans = "";
  while (n) {
    ll k = n / 26;
    ll z = n % 26;
    if (z == 0) {
      k--;
      ans = (char)'z' + ans;
    } else {
      ans = (char)(('a' + z - 1)) + ans;
    }
    n = k;
  }
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH
*RANJAN******************************************************
***********************************************************************************************/
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);

    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i, n) for (int i = 0; i < n; i++)
#define frs(i, a, b) for (int i = a; i < b; i++)
#define meme(a, b) memset(a, b, sizeof(a)); // works only for 0 and -1
int main() {
  fast();
  ll n;
  cin >> n;
  string ans = "";
  while (n) {
    ll k = n / 26;
    ll z = n % 26;
    if (z == 0) {
      k--;
      ans = (char)'z' + ans;
    } else {
      ans = (char)(('a' + z - 1)) + ans;
      n = k;
    }
  }
  cout << ans;
  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define PRINT(x) cout << (x) << endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007    // 10^9+7
#define PB push_back
#define MP make_pair

ll N;

int main() {
  cin >> N;
  N -= 1;
  ll a = 26;
  char ans[100];
  while (N - a >= 0) {
    N -= a;
    a *= 26;
  }
  int j = 0;
  while (a > 1) {
    a /= 26;
    char c = N / a + 'a';
    ans[j] = c;
    N %= a;
    j++;
  }
  ans[j] = '\\0';
  PRINT(ans);
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define PRINT(x) cout << (x) << endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007    // 10^9+7
#define PB push_back
#define MP make_pair

ll N;

int main() {
  cin >> N;
  N -= 1;
  int a = 26;
  string ans = "";
  while (N - a >= 0) {
    N -= a;
    a *= 26;
  }
  while (a > 1) {
    a /= 26;
    char c = N / a + 'a';
    ans = ans + c;
    N %= a;
  }
  PRINT(ans);
  return 0;
}