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

#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int charToInt(char c) {
  char zero_num = '0';
  return (int)c - (int)zero_num;
}

signed main() {

  string alphabets = "abcdefghijklmnopqrstuvwxyz";

  int N;
  cin >> N;

  int index = 1;
  int tot = 0;
  while (true) {
    tot += pow(26, index);
    if (N <= tot) {
      break;
    }
    index++;
  }

  string out_str = "";

  int aaaa = 26;
  int aaa = 0;
  for (int i = 1; i < index + 1; i++) {
    int temp = (N - 1 - aaa) % aaaa;
    int temp2 = (temp) / (aaaa / 26);
    out_str = alphabets.at(temp2) + out_str;
    aaa += aaaa;
    aaaa = aaaa * 26;
  }

  cout << out_str << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int charToInt(char c) {
  char zero_num = '0';
  return (int)c - (int)zero_num;
}

signed main() {

  string alphabets = "abcdefghijklmnopqrstuvwxyz";

  int N;
  cin >> N;

  int index = 1;
  int tot = 0;
  while (true) {
    tot += pow(26, index);
    if (N <= tot) {
      break;
    }
    index++;
  }

  string out_str = "";

  int aaaa = 26;
  for (int i = 1; i < index + 1; i++) {

    int temp = N % aaaa;
    int temp2 = temp / (aaaa / 26);
    out_str = alphabets.at(temp2 - 1) + out_str;
    aaaa = aaaa * 26;
  }

  cout << out_str << endl;

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

#include <iostream>
using namespace std;
int main() {
  long n;
  cin >> n;
  int digit[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int idx = 0;
  while (n > 0) {
    digit[idx] = n % 26;
    if (digit[idx] == 0) {
      digit[idx] = 26;
      n -= 26;
    }
    n /= 26;
    idx++;
  }

  for (; digit[idx] == 0; idx--)
    ;
  for (; idx >= 0; idx--) {
    cout << (char)('a' + digit[idx] - 1);
  }

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  long n;
  cin >> n;
  int digit[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int idx = 0;
  while (n > 0) {
    digit[idx] = n % 26;
    if (digit[idx] == 0) {
      digit[idx] = 26;
      n -= 26;
    }
    n /= 26;
    idx++;
  }

  for (; digit[idx] == 0; idx--)
    ;
  for (; idx >= 0; idx--) {
    cout << (char)('a' + digit[idx] - 1);
  }

  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm = 2e5 + 100;
ll d[mm];
int main() {
  ll n, m, i, j, t, a, b, c, p, kk;
  cin >> n;
  char k;
  string s;
  s = "";
  while (n) {

    if (n % 26 == 0) {
      k = 'z';
      n--;
    } else {
      k = n % 26 + 'a' - 1;
    }
    s += k;
    n = n / 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm = 2e5 + 100;
ll d[mm];
int main() {
  ll n, m, i, j, t, a, b, c, p, kk;
  while (1) {
    cin >> n;
    char k;
    string s;
    s = "";
    while (n) {

      if (n % 26 == 0) {
        k = 'z';
        n--;
      } else {
        k = n % 26 + 'a' - 1;
      }
      s += k;
      n = n / 26;
    }
    reverse(s.begin(), s.end());
    cout << s << 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 < (int)(n); i++)
using ll = long long;

string f(ll n) {
  if (n == 0)
    return "";
  n--;
  return f(n / 26) + string(1, 'a' + n % 26);
}

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

  cout << f(n) << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  string s;
  while (n > 0) {
    n--;
    s += (char)'a' + n % 26;
    n /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

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

#define ll long long

int main() {
  ll n;
  string s = "";
  cin >> n;
  while (n > 0) {
    n -= 1;
    s += char('a' + (n) % 26);
    n /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s;
}

Error: WA

Fixed submission:

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

#define ll long long

char letter(int n) {
  assert(n >= 1 && n <= 26);
  return "abcdefghijklmnopqrstuvwxyz"[n - 1];
}
int main() {
  int n;
  string s = "";
  cin >> n;
  int temp = n;
  while (n) {
    temp = n % 26;
    char c = letter(temp);
    s.push_back(c);
    n /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

char nth_letter(int n) {
  assert(n >= 0 && n <= 25);
  return "abcdefghijklmnopqrstuvwxyz"[n];
}

int main() {
  ll n;
  cin >> n;
  int len = 1;
  ll kurai = 26;
  while (n > kurai) {
    n -= kurai;
    len++;
    kurai *= 26;
  }
  //   cout << "For debug -- n : " << n << ", kurai : " << kurai << endl;

  kurai /= 26;
  n--;
  rep(i, len) {
    char ans = nth_letter(n / kurai);
    cout << ans;
    n %= kurai;
    kurai /= 26;
  }
  cout << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

char nth_letter(int n) {
  assert(n >= 1 && n <= 26);
  return "abcdefghijklmnopqrstuvwxyz"[n - 1];
}

int main() {
  ll n;
  cin >> n;
  int len = 1;
  ll kurai = 26;
  vector<ll> memo;
  while (n / kurai > 0) {
    memo.push_back(n % kurai);
    n -= kurai;
    len++;
    kurai *= 26;
  }
  //   cout << "For debug -- n : " << n << ", kurai : " << kurai << endl;

  kurai /= 26;
  n--;
  rep(i, len) {
    char ans = nth_letter(1 + n / kurai);
    cout << ans;
    n %= kurai;
    kurai /= 26;
  }
  cout << endl;
}
Problem p02629 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double pi = 3.14159265358979323846;
#define x first
#define y second

bool isP(ll x) {
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  // freopen("op.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  ll t = 1;
  // cin>>t;
  while (t--) {
    ll C;
    cin >> C;
    string ab = "zabcdefghijklmnopqrstuvwxy";
    ll bbb = 1, y = 1, p = 1, x = 0, z = 0;
    string bb = "";
    while (bbb != 0) {
      bbb = C / 26;
      y = C % 26;

      if (bbb == 0 && y == 1 && z == 1)
        break;
      if (y - z == -1)
        bb += ab[25];
      else
        bb += ab[y - z];

      if (y == 0 || y == z) {
        if (C == 26)
          break;
        z = 1;
      } else {
        z = 0;
      }
      C = bbb;
    }
    reverse(bb.begin(), bb.end());
    cout << bb;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double pi = 3.14159265358979323846;
#define x first
#define y second

bool isP(ll x) {
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  // freopen("op.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  ll t = 1;
  // cin>>t;
  while (t--) {
    ll C;
    cin >> C;
    string ab = "zabcdefghijklmnopqrstuvwxy";
    ll bbb = 1, y = 1, p = 1, x = 0, z = 0;
    vector<char> bb;
    while (bbb != 0) {
      bbb = C / 26;
      y = C % 26;

      if (bbb == 0 && y == 1 && z == 1)
        break;

      bb.push_back(ab[y - z]);

      if (y == 0 || (y - z == 0)) {
        if (C == 26)
          break;
        z = 1;
      } else {
        z = 0;
        C = bbb;
      }
    }
    for (ll i = bb.size() - 1; i >= 0; i--)
      cout << bb[i];
  }
  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  int i = 0;
  long long N;
  vector<char> result(15);
  cin >> N;
  while (N) {
    N--;
    char alp = N % 26 + 97;
    result.at(i) = alp;
    i++;
    N /= 26;
  }

  for (int j = i; j > 0; j--)
    cout << result.at(j - 1);
  cout << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int i = 0;
  long long N;
  vector<char> result(10);
  cin >> N;
  while (N > 0) {
    char alp = N % 26 + 96;
    result.at(i) = alp;
    i++;
    N /= 26;
  }

  for (int j = i; j > 0; j--)
    cout << result.at(j - 1);
  cout << endl;

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
string alpha = "abcdefghijklmnopqrstuvwxyz";
int main() {
  ll N, T;
  cin >> N;
  T = N;
  ll count = 0;
  vector<long long> digits;
  string s;
  while (T > 0) {
    T--;
    s += T % 26 + 'a';
    T = T / 26;
  }
  // string name="";
  reverse(s.begin(), s.end());
  // reverse(digits.begin(),digits.end());
  // cout<<alpha[10]<<endl;
  cout << s << endl;
  // for(int i=0;i<5;i++)//
  //{
  // cout<<n_digits[i]-1;
  // cout<<alpha[digits[i]-1];
  //}
  // for(int i=5;i<10;i++)//
  //{
  // cout<<n_digits[i]-1;
  // cout<<alpha[digits[i]-1];
  // }
  // cout<<name<<endl;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
string alpha = "abcdefghijklmnopqrstuvwxyz";
vector<long long> digits(5000);
int main() {
  ll N, T;
  cin >> N;
  T = N;
  ll count = 0;
  for (int i = 0; i < 5000; i++) {
    if (T >= 26) {
      T = T / 26;
      digits[count] = T;
      count++;
    } else {
      digits[count] = T;
      count++;
      break;
    }
  }
  string name = "";
  vector<int> n_digits(count);
  for (int i = 0; i < count; ++i) {
    n_digits[i] = digits[i];
  }
  reverse(n_digits.begin(), n_digits.end());
  for (int i = 0; i < 6; ++i) {
    // cout<<n_digits[i]-1;
    cout << alpha[n_digits[i] - 1];
  }
  if (count > 6) {
    for (int i = 6; i < count; ++i) {
      // cout<<n_digits[i]-1;
      cout << alpha[n_digits[i] - 1];
    }
  }
  // cout<<name<<endl;
  return 0;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

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

signed main() {
  unsigned long long int N;
  cin >> N;
  vector<char> B(100);
  vector<char> A(26);
  int count = 0;
  A[1] = 'a';
  A[2] = 'b';
  A[3] = 'c';
  A[4] = 'd';
  A[5] = 'e';
  A[6] = 'f';
  A[7] = 'g';
  A[8] = 'h';
  A[9] = 'i';
  A[10] = 'j';
  A[11] = 'k';
  A[12] = 'l';
  A[13] = 'm';
  A[14] = 'n';
  A[15] = 'o';
  A[16] = 'p';
  A[17] = 'q';
  A[18] = 'r';
  A[19] = 's';
  A[20] = 't';
  A[21] = 'u';
  A[22] = 'v';
  A[23] = 'w';
  A[24] = 'x';
  A[25] = 'y';
  A[0] = 'z';
  for (int i = 0; i < 100; i++) {
    if (N % 26 != 0) {
      B[i] = A[N % 26];
      N /= 26;
    } else {
      B[i] = 'z';
      N /= 26;
      N--;
    }
    if (N == 0) {
      count = i;
      break;
    }
  }
  for (int i = count; i >= 0; i--) {
    cout << B[i];
  }
  cout << endl;
}


Error: -11

Fixed submission:

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

signed main() {
  unsigned long long int N;
  cin >> N;
  vector<char> B(100);
  vector<char> A(26);
  int count;
  A[1] = 'a';
  A[2] = 'b';
  A[3] = 'c';
  A[4] = 'd';
  A[5] = 'e';
  A[6] = 'f';
  A[7] = 'g';
  A[8] = 'h';
  A[9] = 'i';
  A[10] = 'j';
  A[11] = 'k';
  A[12] = 'l';
  A[13] = 'm';
  A[14] = 'n';
  A[15] = 'o';
  A[16] = 'p';
  A[17] = 'q';
  A[18] = 'r';
  A[19] = 's';
  A[20] = 't';
  A[21] = 'u';
  A[22] = 'v';
  A[23] = 'w';
  A[24] = 'x';
  A[25] = 'y';
  A[0] = 'z';
  for (int i = 0; i < 100; i++) {
    B[i] = A[N % 26];
    N /= 26;
    if (N == 0) {
      count = i;
      break;
    }
  }
  for (int i = count; i >= 0; i++) {
    cout << B[i];
  }
  cout << endl;
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = int(a); i < (int)b; ++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll, ll>>
#define pb push_back

using namespace std;
using ll = long long;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(void) {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll k = 26;
  ll subn = n;
  while (k < subn) {
    subn -= k;
    k *= 26;
  }
  k /= 26;
  string ans = "";
  while (k != 1) {
    ll x = subn / k;
    if (subn % k == 0) {
      x--;
    }
    char end = 'a' + x;

    subn -= k * x;
    k /= 26;
    ans += end;
  }
  char end = 'a' + subn - 1;
  ans += end;

  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = int(a); i < (int)b; ++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll, ll>>
#define pb push_back

using namespace std;
using ll = long long;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(void) {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll k = 1;
  ll keta = 0;
  while (k < n) {
    k *= 26;
  }

  k /= 26;
  string ans = "";
  while (n != 0) {
    ll x = n / k;
    char end = 'a' + x - 1;
    n %= k;
    k /= 26;
    ans += end;
  }

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  string ans;
  while (n) {
    n--;
    ans += 'a' + n % 26;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Error: -6
free(): invalid size


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(12);

  for (int i = 11; i >= 0; i--) {
    ll y = pow(26, i);
    ll x = n / y;
    n -= x * y;
    a[i] = x;
  }
  reverse(a.begin(), a.end());

  ll count = 0;
  ll count2 = 0;
  for (int i = 0; i <= 11; i++) {
    if (a[i] == 1)
      count++;
    if (a[i] != 1) {
      if (a[i] == 0) {
        ll k = i;
        while (a[k] == 0) {
          count2++;
          k++;
        }
        if (count2 == 1) {

          for (int j = 1; j <= count; j++) {
            a[i - j] = 26;
          }
        } else {
          for (int j = 2; j <= count; j++) {
            a[i - j] = 26;
          }
          for (int j = i; j <= k; j++) {
            a[i - j] = 26;
          }
          a[i - 1] = 25;
        }

        count2 = 0;
        i = k;
      }

      count = 0;
    }
  }

  string ans;
  for (int i = 0; i <= 11; i++) {
    if (a[i] == 0)
      continue;
    ans += a[i] + 'a' - 1;
  }

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

#include <bits/stdc++.h>

using namespace std;

#define MAX 50

// Function to print Excel column name for a given column number
void printString(long long int n) {
  char str[MAX];       // To store result (Excel column name)
  long long int i = 0; // To store current index in str which is result

  while (n > 0) {
    // Find remainder
    long long int rem = n % 26;

    // If remainder is 0, then a 'Z' must be there in output
    if (rem == 0) {
      str[i++] = 'z';
      n = (n / 26) - 1;
    } else // If remainder is non-zero
    {
      str[i++] = (rem - 1) + 'a';
      n = n / 26;
    }
  }
  str[i] = '\\0';

  // Reverse the string and print result
  reverse(str, str + strlen(str));
  cout << str;

  return;
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  long long int n, num = 0, num1 = 0;
  cin >> n;
  printString(n);

  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define MAX 500000000

// Function to print Excel column name for a given column number
void printString(long long int n) {
  char str[MAX];       // To store result (Excel column name)
  long long int i = 0; // To store current index in str which is result

  while (n > 0) {
    // Find remainder
    long long int rem = n % 26;

    // If remainder is 0, then a 'Z' must be there in output
    if (rem == 0) {
      str[i++] = 'z';
      n = (n / 26) - 1;
    } else // If remainder is non-zero
    {
      str[i++] = (rem - 1) + 'a';
      n = n / 26;
    }
  }
  str[i] = '\\0';

  // Reverse the string and print result
  reverse(str, str + strlen(str));
  cout << str;

  return;
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  long long int n, num = 0, num1 = 0;
  cin >> n;
  printString(n);

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

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
void printString(long long int n) {
  char str[100000];    // To store result (Excel column name)
  long long int i = 0; // To store current index in str which is result

  while (n > 0) {
    // Find remainder
    long long int rem = n % 26;

    // If remainder is 0, then a 'Z' must be there in output
    if (rem == 0) {
      str[i++] = 'z';
      n = (n / 26) - 1;
    } else // If remainder is non-zero
    {
      str[i++] = (rem - 1) + 'a';
      n = n / 26;
    }
  }
  str[i] = '\\0';

  // Reverse the string and print result
  reverse(str, str + strlen(str));
  cout << str << endl;

  return;
}
int main() {
  long long int n;
  cin >> n;
  printString(n);
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
void printString(long long int n) {
  char str[INT_MAX];   // To store result (Excel column name)
  long long int i = 0; // To store current index in str which is result

  while (n > 0) {
    // Find remainder
    long long int rem = n % 26;

    // If remainder is 0, then a 'Z' must be there in output
    if (rem == 0) {
      str[i++] = 'z';
      n = (n / 26) - 1;
    } else // If remainder is non-zero
    {
      str[i++] = (rem - 1) + 'a';
      n = n / 26;
    }
  }
  str[i] = '\\0';

  // Reverse the string and print result
  reverse(str, str + strlen(str));
  cout << str << endl;

  return;
}
int main() {
  long long int n, k;
  cin >> n;
  printString(n);
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
#define ll long long
using namespace std;

ll pow(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else if (b == 1) {
    return a;
  } else if (b % 2 == 0) {
    return pow(a, b / 2) * pow(a, b / 2);
  } else {
    return a * pow(a, b - 1);
  }
}

int main() {
  ll a;
  cin >> a;
  vector<char> v;
  for (int i = 1; i < 12; i++) {
    if (a > pow(26, i)) {
      ll temp = (a % pow(26, i)) / pow(26, i - 1);
      v.push_back(temp == 0 ? 'z' : (char)('a' - 1 + temp));
      a -= (temp == 0 ? 26 : temp) * pow(26, i - 1);
    } else {
      ll temp = a / pow(26, i - 1);
      if (temp != 0) {
        v.push_back((char)('a' - 1 + temp));
      }
      break;
    }
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    cout << v[i];
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
#define ll long long

ll pow(ll a, ll b) {
  if (b == 1) {
    return a;
  } else if (b % 2 == 0) {
    return pow(a, b / 2) * pow(a, b / 2);
  } else {
    return a * pow(a, b - 1);
  }
}

int main() {
  ll n;
  cin >> n;
  ll i = 10;
  while (n > 0) {
    ll w = n / pow(26, i);
    if (w != 0) {
      cout << 'a' + w;
    }
    n -= pow(26, i) * w;
    i--;
  }
}
Problem p02629 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
  ll n, k, a[20], b[20];
  b[0] = 0;
  char c[26] = {'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'};
  for (int i = 1; i < 12; i++)
    b[i] = pow(26, i) + b[i - 1];
  cin >> n;
  for (ll i = 1; i > 0; i++) {
    if (b[i] >= n) {
      k = i;
      break;
    }
  }
  if (k > 1)
    n -= b[k - 1];
  n--;
  for (int i = 0; i < k; i++) {
    a[i] = n % 26;
    n /= 26;
  }
  for (int i = k - 1; i >= 0; i--)
    cout << c[a[i]];

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
  ll n, k, a[20], b[20];
  b[0] = 0;
  char c[26] = {'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'};
  for (int i = 1; i < 12; i++)
    b[i] = pow(26, i) + b[i - 1];
  cin >> n;
  for (ll i = 1; i > 0; i++) {
    if (b[i] >= n) {
      k = i;
      break;
    }
  }
  if (k > 1)
    n -= b[k - 1];

  for (int i = 0; i < k; i++) {
    int res = n;
    while (res > 26) {
      res -= 26;
    }
    if (i == 0) {
      a[0] = res - 1;

    } else
      a[i] = res;

    n -= n % 26;
    n /= 26;
  }
  for (int i = k - 1; i >= 0; i--)
    cout << c[a[i]];

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<char> str;
  while (n) {
    long long p = n % 26;
    if (p == 0) {
      str.push_back('z');
      n = (n / 26) - 1;
    } else {
      n = n / 26;
      str.push_back('a' + p - 1);
    }
  }
  for (long long i = str.size() - 1; i >= 0; i--)
    printf("%c", str[i]);
}


Error: WA

Fixed submission:

#pragma GCC optimize("Ofast", 3, "inline")
#include <bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int>> min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mon[20] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ll gcd(ll x, ll y) { return ((y == 0) ? x : gcd(y, x % y)); }
ll x = 1000000000000001;
ll n;
char c[100000];
ll a[100000];
int pos;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //	freopen(".in","r",stdin);
  //	freopen(".out","w",stdout);
  cin >> n;
  a[0] = 1;
  while (n <= a[pos]) {
    a[++pos] = a[pos] * 26;
  }
  for (int i = pos - 1; i >= 0; i++) {
    if (a[i] <= n)
      cout << ((n / a[i]) + 'a'), n -= (a[i] * (n / a[i]));
  }
  return 0;
}