alexjercan/bugnet huggingface dataset:
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265
#define pb push_back
#define pr pair<int, int>
using namespace std;
using ll = long long;
// using mod = 1000000000 + 7;
void self_max(int &a, int b) { a = max(a, b); }

void self_min(int &a, int b) { a = min(a, b); }
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  // vector<int> B(n);
  ll total = 0;
  rep(i, n) {
    cin >> A[i];
    total = total xor A[i];
  }

  rep(i, n) {
    int k = total xor A[i];
    cout << k << " " << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265
#define pb push_back
#define pr pair<int, int>
using namespace std;
using ll = long long;
// using mod = 1000000000 + 7;
void self_max(int &a, int b) { a = max(a, b); }

void self_min(int &a, int b) { a = min(a, b); }
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> B(n);
  rep(i, n) { cin >> A[i]; }

  rep(i, n) {
    int k = 0;
    rep(j, n) {
      if (i == j)
        continue;
      k = k xor A[j];
    }
    cout << k << " " << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\\n"
#define all(v) v.begin(), v.end()
#define mp make_pair
#define mm(a) memset(a, 0, sizeof(a))
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repn(i, a, b) for (ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k, m) for (auto k : m)
#define in_edges(m)                                                            \\
  repp(i, 1, m) {                                                              \\
    ll a, b;                                                                   \\
    cin >> a >> b;                                                             \\
    adj[a].pb(b), adj[b].pb(a);                                                \\
  }
#define debug(this) cerr << "> " << #this << " : " << this << "\\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
// stoll(s);
int main() {
  quick ll t;
  t = 1;
  // cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) { cin >> a[i]; }
    ll k = 0;
    vector<ll> ans;
    rep(i, 0, n) { k ^= a[i]; }
    rep(i, 0, n) { ans.pb(k ^ a[i]); }
    fto(k, ans) cout << k << " ";
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\\n"
#define all(v) v.begin(), v.end()
#define mp make_pair
#define mm(a) memset(a, 0, sizeof(a))
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repn(i, a, b) for (ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k, m) for (auto k : m)
#define in_edges(m)                                                            \\
  repp(i, 1, m) {                                                              \\
    ll a, b;                                                                   \\
    cin >> a >> b;                                                             \\
    adj[a].pb(b), adj[b].pb(a);                                                \\
  }
#define debug(this) cerr << "> " << #this << " : " << this << "\\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
// stoll(s);
int main() {
  quick ll t;
  t = 1;
  // cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) { cin >> a[i]; }
    ll k = 0;
    vector<ll> ans;
    rep(i, 0, n) {
      k = 0;
      rep(j, 0, n) {
        if (j == i)
          continue;
        k ^= a[j];
      }
      ans.pb(k);
    }
    fto(j, ans) cout << j << " ";
  }
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ((ll)(n)); i++)
#define reg(i, a, b) for (ll i = ((ll)(a)); i <= ((ll)(b)); i++)
#define irep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (ll i = ((ll)(b)); i >= ((ll)(a)); i--)
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
template <class T = int> void print(vector<T> v) {
  for (auto a : v)
    cout << a << " ";
  cout << endl;
}

/*
nは偶数なので、全てのaのxorをとると、すべてのスカーフの数のxorになる事がわかる。これをsumとする
あとは、sum xor a[i]とすると各スカーフの値がわかる
*/

ll n, a[200010], sum = 0;

int main(void) {
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) sum ^= a[i];
  rep(i, n) cout << (sum ^ a[i]) << " ";
  cout << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ((ll)(n)); i++)
#define reg(i, a, b) for (ll i = ((ll)(a)); i <= ((ll)(b)); i++)
#define irep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (ll i = ((ll)(b)); i >= ((ll)(a)); i--)
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
template <class T = int> void print(vector<T> v) {
  for (auto a : v)
    cout << a << " ";
  cout << endl;
}

/*
 */

ll n, a[100010], sum = 0;

int main(void) {
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) sum ^= a[i];
  rep(i, n) cout << (sum ^ a[i]) << " ";
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
  int n;
  int a[200000];
  int s = 0;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    s ^= a[i];
  }
  rep(i, n) {
    cout << (s ^ a[i]);
    if (i != n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}

Error: 0

Fixed submission:

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
  int n;
  int a[100000];
  int s = 0;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    s ^= a[i];
  }
  rep(i, n) {
    cout << (s ^ a[i]);
    if (i != n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  long long XOR = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    XOR ^= A.at(i);
  }

  for (int i = 0; i < N; i++) {
    long long ans = A.at(i) ^ XOR;
    cout << ans << " ";
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  for (int i = 0; i < N; i++) {
    long long XOR = 0;
    for (int j = 0; j < N; j++) {
      if (j == i)
        continue;
      XOR ^= A.at(j);
    }
    cout << XOR << " ";
  }
  cout << endl;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);                                                                 \\
  cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main() {
  IOS;
  int n, s = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s ^= a[i];
  }
  for (int i = 0; i < n; i++)
    cout << (s ^ a[i]) << ' ';
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);                                                                 \\
  cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main() {
  IOS;
  int n, s;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++) {
    s = 0;
    for (int j = 0; j < n; j++) {
      if (j != i)
        s ^= a[j];
    }
    cout << s << ' ';
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>

using namespace std;

void solve(const vector<int> &val) {
  int tot_xor = 0;
  int res = 0;
  for (int i = 0; i < (int)val.size(); i++)
    tot_xor ^= val[i];
  for (int i = 0; i < (int)val.size(); i++) {
    res = 0;
    res = tot_xor ^ val[i];
    if (i != (int)val.size() - 1)
      cout << res << " ";
    else
      cout << res;
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> val(N);
  for (int i = 0; i < N; i++) {
    cin >> val[i];
  }
  solve(val);
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

void solve(const vector<int> &val) {

  for (int i = 0; i < (int)val.size(); i++) {
    int res = 0;
    for (int j = 0; j < (int)val.size(); j++) {
      if (i == j)
        continue;
      res ^= val[j];
    }
    if (i != (int)val.size() - 1)
      cout << res << " ";
    else
      cout << res;
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> val(N);
  for (int i = 0; i < N; i++) {
    cin >> val[i];
  }
  solve(val);
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

// https://atcoder.jp/contests/abc170/tasks/abc171_e
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> forward_sum(n + 1);
  vector<int> reverse_sum(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    forward_sum[i + 1] = forward_sum[i] ^ a[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    reverse_sum[i] = reverse_sum[i + 1] ^ a[i];
  }
  for (int i = 0; i < n; i++) {
    int ans = forward_sum[i] ^ reverse_sum[i + 1];
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

// https://atcoder.jp/contests/abc170/tasks/abc170_e
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x : a) {
    cin >> x;
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      if (i != j) {
        ans = ans ^ a[j];
      }
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<long> so;
  long x, z = 0;
  cin >> x;
  for (int i = 0; i < x; i++) {
    long y;
    cin >> y;
    z ^= y;
    so.push_back(y);
  }
  for (int i = 0; i < x; i++) {
    int a = z ^ so[i];
    cout << a << " ";
  }
}


Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<long> so;
  long x;
  cin >> x;
  for (int i = 0; i < x; i++) {
    long y;
    cin >> y;
    so.push_back(y);
  }
  for (int i = 0; i < x; i++) {
    int z = 0;
    for (int j = 0; j < x; j++) {
      if (i != j) {
        z ^= so[j];
      }
    }
    cout << z << " ";
  }
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
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;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> a(n), ans(n, 0);
  rep(i, n) cin >> a[i];

  int sum = 0;

  rep(i, n) { sum = sum ^ a[i]; }

  rep(i, n) {
    int ans = sum ^ a[i];
    cout << ans << " ";
  }

  cout << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
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;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<ll> a(n), ans(n, 0);
  rep(i, n) cin >> a[i];

  rep(i, n) {
    rep(j, n) {
      if (i != j)
        ans[i] = ans[i] ^ a[j];
    }
    cout << ans[i] << " ";
  }

  cout << endl;

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

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll n;
vll a;

void input() {
  cin >> n;
  rep(i, n) {
    ll A;
    cin >> A;
    a.push_back(A);
  }
}

void solve() {
  ll M = 0;
  rep(i, n) { M = max(M, a[i]); }
  ll m;
  if (M != 0) {
    m = (ll)floor(log2((ld)M)) + 1;
  } else {
    m = 0;
  }
  // cout << "m:" << m << endl;
  vvll b(n, vll(m));
  rep(i, n) {
    for (ll j = m - 1; j >= 0; j--) {
      b[i][j] = a[i] % 2;
      a[i] /= 2;
    }
  }
  /*
  rep(i,n){
    rep(j,m){
      cout << b[i][j] << " ";
    }
    cout << endl;
  }
  */
  vll c(m, 0);
  rep(j, m) {
    rep(i, n) { c[j] += b[i][j]; }
    // cout << c[j] << " ";
  }
  rep(j, m) {
    if (c[j] % 2 == 1) {
      rep(i, n) { b[i][j] = (b[i][j] + 1) % 2; }
    }
  }
  rep(i, n) {
    ll s = 0;
    rep(j, m) { s += (ll)pow(2, m - j - 1) * b[i][j]; }
    cout << s;
    if (i != n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}

int main() {
  input();
  solve();
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll n;
vll a;

void input() {
  cin >> n;
  rep(i, n) {
    ll A;
    cin >> A;
    a.push_back(A);
  }
}

void solve() {
  ll M = 0;
  rep(i, n) { M = max(M, a[i]); }
  ll m = (ll)floor(log2((ld)M)) + 1;
  vvll b(n, vll(m));
  rep(i, n) {
    for (ll j = m - 1; j >= 0; j--) {
      b[i][j] = a[i] % 2;
      a[i] /= 2;
    }
  }
  /*
  rep(i,n){
    rep(j,m){
      cout << b[i][j] << " ";
    }
    cout << endl;
  }
  */
  vll c(m, 0);
  rep(j, m) {
    rep(i, n) { c[j] += b[i][j]; }
    // cout << c[j] << " ";
  }
  rep(j, m) {
    if (c[j] % 2 == 1) {
      rep(i, n) { b[i][j] = (b[i][j] + 1) % 2; }
    }
  }
  rep(i, n) {
    ll s = 0;
    rep(j, m) { s += (ll)pow(2, m - j - 1) * b[i][j]; }
    cout << s;
    if (i != n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}

int main() {
  input();
  solve();
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define limit (int)(2e5 + 5)
// #define mod (int)(1e9 + 7)
#define pb push_back
#define fi first
#define se second

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

lli a[limit];
int main() {

  int n;
  cin >> n;

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

  lli sum = 0;

  for (int i = 0; i < n / 2; ++i) {
    sum = sum ^ (a[2 * i] ^ a[2 * i + 1]);
  }

  lli t;

  for (int i = 0; i < n; ++i) {
    t = sum ^ a[i];
    cout << t << " ";
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define limit (int)(1e5 + 5)
// #define mod (int)(1e9 + 7)
#define pb push_back
#define fi first
#define se second

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

lli a[limit], cou[limit] = {0};
int main() {

  int n;
  cin >> n;

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

  lli sum = 0;

  for (int i = 0; i < n / 2; ++i) {
    sum = sum ^ (a[2 * i] ^ a[2 * i + 1]);
  }

  lli t;

  for (int i = 0; i < n; ++i) {
    t = sum ^ a[i];
    cout << t << " ";
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h> //toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\\n"
using namespace std;
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  forn(i, n) cin >> a[i];
  vector<ll> ans(n);
  int i, j;
  ans[0] = 0;
  for (i = 1; i < n; i++) {
    ans[0] = ans[0] ^ a[i];
  }
  ll temp = ans[0];
  for (i = 1; i < n; i++) {
    temp = temp ^ a[i];
    temp = temp ^ a[i - 1];
    ans[i] = temp;
  }
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//     freopen("output.txt","w",stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h> //toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\\n"
using namespace std;
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  forn(i, n) cin >> a[i];
  vector<ll> ans(n);
  int i, j;
  for (i = 0; i < n; i++) {
    ans[i] = 0;
    for (j = 0; j < n; j++) {
      if (i == j)
        continue;
      ans[i] = ans[i] ^ a[j];
    }
  }
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//     freopen("output.txt","w",stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;
ll factorial[2000010];

ll power(ll n, ll m) {
  ll ans = 1;
  for (ll r = 0; m >> r > 0; r++) {
    if ((m >> r) & 1)
      ans = ans * n % mod;
    n = n * n % mod;
  }
  return ans;
}

ll inv(ll n) { return power(n, mod - 2); }

void fact() {
  factorial[0] = 1;
  for (ll i = 1; i < 2000010; i++)
    factorial[i] = i * factorial[i - 1] % mod;
  return;
}

ll cmb(ll n, ll r) {
  if (r > n)
    return 0;
  else
    return factorial[n] * inv(factorial[n - r]) % mod * inv(factorial[r]) % mod;
}

int main() {
  fact();
  ll k;
  cin >> k;
  string S;
  cin >> S;
  ll si = S.size();
  ll ans = 0;
  for (ll i = si; i < si + k + 1; i++) {
    ans = (ans + power(25, i - si) * cmb(i - 1, si - 1) % mod *
                     power(26, si + k - i) % mod) %
          mod;
  }
  cout << ans % mod << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;
ll factorial[1000000];

ll power(ll n, ll m) {
  ll ans = 1;
  for (int r = 0; m >> r > 0; r++) {
    if ((m >> r) & 1)
      ans = ans * n % mod;
    n = n * n % mod;
  }
  return ans;
}

ll inv(ll n) { return power(n, mod - 2); }

void fact() {
  factorial[0] = 1;
  for (int i = 1; i < 1000000; i++)
    factorial[i] = i * factorial[i - 1] % mod;
  return;
}

ll cmb(ll n, ll r) {
  if (r > n)
    return 0;
  else
    return factorial[n] * inv(factorial[n - r]) % mod * inv(factorial[r]) % mod;
}

int main() {
  fact();
  int k;
  cin >> k;
  string S;
  cin >> S;
  int si = S.size();
  ll ans = 0;
  for (int i = si; i < si + k + 1; i++) {
    ans = (ans + power(25, i - si) * cmb(i - 1, si - 1) % mod *
                     power(26, si + k - i)) %
          mod;
  }
  cout << ans % mod << endl;
  return 0;
}