prithivMLmods/Coder-Stat huggingface dataset:
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for (ll i = ll(a); i <= ll(b); i++)
int main() {
  ll x, abc = 0, m, n, k, cnt = 0;
  cin >> n;
  ll a[n + 1];
  vector<ll> v;
  v.push_back(0);
  REP(i, 1, n) {
    cin >> x;
    a[x] = i;
  }
  REP(i, 1, n) {
    REP(j, 1, n) {
      if (a[j] == i) {
        v.push_back(j);
      }
    }
  }
  REP(i, 1, n) { cout << a[i] << " "; }
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for (ll i = ll(a); i <= ll(b); i++)
int main() {
  ll x, abc = 0, m, n, k, cnt = 0;
  cin >> n;
  ll a[n + 1];
  vector<ll> v;
  v.push_back(0);
  REP(i, 1, n) {
    cin >> x;
    a[x] = i;
  }
  REP(i, 1, n)
  cout << a[i] << " ";
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a;
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    a[i] = make_pair(b, i + 1);
  }
  sort(a.begin(), a.end());
  for (int j = 0; j < n; ++j) {
    cout << a[j].second;
    if (j == n - 1)
      cout << endl;
    else
      cout << " ";
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    a[i] = make_pair(b, i + 1);
  }
  sort(a.begin(), a.end());
  for (int j = 0; j < n; ++j) {
    cout << a[j].second;
    if (j == n - 1)
      cout << endl;
    else
      cout << " ";
  }
  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int p = 1;
  for (int j = 0; j < N; j++) {
    for (int i = 0; i < N; i++) {
      if (A[i] == p) {
        cout << i + 1 << ' ';
        p++;
      }
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> vec(N, 0);
  for (int i = 0; i < N; i++) {
    vec[A[i] - 1] = i + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << vec[i] << ' ';
  }
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  int i, n;
  cin >> n;

  std::vector<int> a(n);
  std::vector<int> b(n);

  for (i = 0; i < n; i++)
    cin >> a[i];
  for (i = 0; i < n; i++)
    b[a[i]] = i + 1;
  for (i = 1; i < n + 1; i++)
    cout << b[i] << " ";
  cout << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  int i, n;
  cin >> n;

  std::vector<int> a(n);
  std::vector<int> b(n);

  for (i = 0; i < n; i++)
    cin >> a[i];
  for (i = 0; i < n; i++)
    b[a[i] - 1] = i + 1;
  for (i = 0; i < n; i++)
    cout << b[i] << " ";
  cout << endl;

  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#pragma region Macros
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
#define int long long
#define all(x) (x).begin(), (x).end()
#define swap(a, b) (a += b, b = a - b, a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
  if (a < b)
    swap(a, b);
  if (b == 0)
    return a;
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
  return a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) B[A[i - 1]] = i + 1;
  rep(i, N) cout << B[i];
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#pragma region Macros
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
#define int long long
#define all(x) (x).begin(), (x).end()
#define swap(a, b) (a += b, b = a - b, a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
  if (a < b)
    swap(a, b);
  if (b == 0)
    return a;
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
  return a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) B[A[i] - 1] = i + 1;
  rep(i, N) cout << B[i] << " ";
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  int n;
  cin >> n;
  vector<int> a(10000), ans(10000, 0);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    ans.at(a.at(i) - 1) += i + 1;
  }
  for (int i = 0; i < n; i++) {
    cout << ans.at(i) << " ";
  }
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), ans(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    ans.at(a.at(i) - 1) += i + 1;
  }
  for (int i = 0; i < n; i++) {
    cout << ans.at(i) << " ";
  }
  cout << endl;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <math.h>
#include <stdlib.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a;
  cin >> a;
  vector<int> vec(a);
  vector<int> mvec(a);
  rep(i, a) { cin >> vec.at(i); }
  rep(i, a) { mvec.at(vec.at(i)) = i + 1; }
  rep(i, a) { cout << vec.at(i) << endl; }
}


Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
#include <stdlib.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a;
  cin >> a;
  vector<int> vec(a);
  vector<int> mvec(a);
  rep(i, a) { cin >> vec.at(i); }
  rep(i, a) { mvec.at(vec.at(i) - 1) = i + 1; }
  rep(i, a) { cout << mvec.at(i) << endl; }
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  vector<int> ans(N);
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < N; j++) {
      if (vec.at(j) != i) {
        continue;
      }
      if (vec.at(j) == i) {
        ans.at(i - 1) = j + 1;
        break;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    if (i != N - 1)
      cout << ans.at(i) << " ";
    if (i == N - 1)
      cout << ans.at(i) << endl;
  }
}

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

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

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    ans.at(vec.at(i) - 1) = i + 1;
  }

  for (int i = 0; i < N; i++) {
    if (i != N - 1)
      cout << ans.at(i) << " ";
    if (i == N - 1)
      cout << ans.at(i) << endl;
  }
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(10001);
  vector<int> b(10001);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  for (int i = 0; i < n; i++)
    b.at(a.at(i) - 1) = i + 1;
  for (int i = 0; i < n; i++)
    cout << b.at(i) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(100001);
  vector<int> b(100001);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  for (int i = 0; i < n; i++)
    b.at(a.at(i) - 1) = i + 1;
  for (int i = 0; i < n; i++)
    cout << b.at(i) << endl;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), ans(N);
  for (int i = 1; i <= N; ++i) {
    int n;
    cin >> n;
    A[n] = i;
  }
  for (int i = 0; i < N; ++i) {
    cout << A[i] << " ";
  }
  return 0;
}


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), ans(N);
  for (int i = 1; i <= N; ++i) {
    int n;
    cin >> n;
    A[n - 1] = i;
  }
  for (int i = 0; i < N; ++i) {
    cout << A[i] << " ";
  }
  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N], num[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[j] == i + 1) {
        cout << j + 1 << ' ';
      }
    }
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N], num[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    num[A[i] - 1] = i + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << num[i] << ' ';
  }
  cout << endl;
  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

  vector<int> seito(n);
  for (int i = 0; i < n; i++) {
    cin >> seito.at(i);
  }

  for (int i = 1; i < n + 1; i++) {
    for (int j = 0; j < n; j++) {
      if (i == seito.at(j)) {
        if (i == n) {
          cout << j + 1 << endl;
          break;
        } else {
          cout << j + 1 << " ";
          break;
        }
      }
    }
  }
  cout << endl;
}


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

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

  vector<int> seito(n);
  for (int i = 0; i < n; i++) {
    cin >> seito.at(i);
  }

  vector<int> ans(n);

  for (int i = 0; i < n; i++) {
    ans.at(seito.at(i) - 1) = i;
  }
  for (int i = 0; i < n; i++) {
    cout << ans.at(i) + 1 << " ";
  }
  cout << endl;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < N; j++) {
      if (A.at(j) == i) {
        cout << j + 1 << " ";
        break;
      }
    }
  }
  cout << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    B.at(A.at(i) - 1) = i + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << B.at(i) << " ";
  }
  cout << endl;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end() // 使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main() {
  int n;
  cin >> n;
  vector<int> num(n), ans(n + 1, 0);
  rep(i, n) {
    cin >> num[i + 1];
    ans[num[i + 1]] = i + 1;
  }
  rep(i, n - 1) { cout << ans[i + 1] << ' '; }
  cout << ans[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end() // 使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main() {
  int n;
  cin >> n;
  vector<int> num(n + 1, 0), ans(n + 1, 0);
  rep(i, n) {
    cin >> num[i + 1];
    ans[num[i + 1]] = i + 1;
  }
  rep(i, n - 1) { cout << ans[i + 1] << ' '; }
  cout << ans[n] << endl;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, order;

  // input
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  // calc
  for (int i = 0; i < N; i++) {
    order = i + 1;
    for (int j = 0; j < N; j++) {
      if (A.at(j) == order) {
        B.at(i) = j + 1;
        break;
      } else
        ;
    }
  }

  // output
  for (int i = 0; i < N; i++) {
    cout << B.at(i) << " ";
  }
  cout << endl;
}


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

int main() {
  int N, order;

  // input
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(A.at(i) - 1) = i + 1;
  }

  // output
  for (int i = 0; i < N; i++) {
    cout << B.at(i) << " ";
  }
  cout << endl;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 1; i < N + 1; i++) {
    std::vector<int>::iterator itr = std::find(A.begin(), A.end(), i);
    cout << std::distance(A.begin(), itr) + 1 << " ";
  }
  cout << endl;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    B[A[i] - 1] = i + 1;
  }

  for (int i = 0; i < N; i++) {
    cout << B[i] << " ";
  }
  cout << endl;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> A;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  vector<int> Ranking;
  for (int rank = 1; rank <= n; rank++) {
    for (int i = 0; i < n; i++) {
      if (rank == A[i]) {
        Ranking.push_back(i + 1);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << Ranking[i] << " ";
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> A;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  vector<int> Ranking(n, 0);
  for (int i = 0; i < n; i++) {
    Ranking[A[i] - 1] = i + 1;
  }

  for (int i = 0; i < n; i++) {
    cout << Ranking[i] << " ";
  }

  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define sz size
#define len length
#define se second
const ll p = 31;
const ll mod = 67280421310721;
const ll N = 1000000 + 6;
#define M_PI 3.14159265358979323846

struct stu {
  ll num_b4, stu;
};

bool comp(stu a, stu b) { return a.num_b4 < b.num_b4; }

int main()

{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
  int n;
  cin >> n;
  stu a[n];
  int s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    a[i].num_b4 = s;
    a[i].stu = i;
  }
  sort(a, a + n, comp);
  for (int i = 0; i < n; i++) {
    cout << a[i].stu + 1 << " ";
  }
  cout << '\n';
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define sz size
#define len length
#define se second
const ll p = 31;
const ll mod = 67280421310721;
const ll N = 1000000 + 6;
#define M_PI 3.14159265358979323846

struct stu {
  ll num_b4, stu;
};

bool comp(stu a, stu b) { return a.num_b4 < b.num_b4; }

int main()

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

  int n;
  cin >> n;
  stu a[n];
  int s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    a[i].num_b4 = s;
    a[i].stu = i;
  }
  sort(a, a + n, comp);
  for (int i = 0; i < n; i++) {
    cout << a[i].stu + 1 << " ";
  }
  cout << '\n';
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int a[N], b[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (int i = 1; i < N + 1; i++) {
    for (int j = 0; j < N; j++) {
      if (a[j] == i) {
        b[i - 1] = j + 1;
        break;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << b[i] << endl;
  }

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a[N], b[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < N; i++) {
    b[a[i] - 1] = i + 1;
  }

  for (int i = 0; i < N; i++) {
    cout << b[i] << endl;
  }

  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
int main() {
  using namespace std; // swap
  int n, value;
  cin >> n;
  vector<int> vec(n + 1), ivec(n + 1);
  for (int i = 1; i <= n; i++)
    cin >> vec[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i == vec[j]) {
        ivec[i] = j;
        j = n + 1;
      }
  for (int i = 1; i <= n; i++)
    cout << ivec[i] << " ";
  cout << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
int main() {
  using namespace std; // swap
  int n, value;
  cin >> n;
  vector<int> vec(n + 1), ivec(n + 1);
  for (int i = 1; i <= n; i++)
    cin >> vec[i];
  for (int i = 1; i <= n; i++)
    ivec[vec[i]] = i;
  for (int i = 1; i <= n; i++)
    cout << ivec[i] << " ";
  cout << endl;
  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
#define M 1005
#define N 15
#define ll long long
int arr[N];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    arr[x] = i;
  }
  for (int i = 1; i <= n; i++)
    cout << arr[i] << " ";
  return 0;
}
/*
2 3
10 1
1
15 1
2
30 2
1 2
*/


Fixed submission:
#include <bits/stdc++.h>

using namespace std;
#define N 100005
#define ll long long
int arr[N];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    arr[x] = i;
  }
  for (int i = 1; i <= n; i++)
    cout << arr[i] << " ";
  return 0;
}
/*
2 3
10 1
1
15 1
2
30 2
1 2
*/
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int N;
int main() {
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  vector<int> rev(N);

  rep(i, N) rev[A[i] - 1] = i++;
  rep(i, N) cout << rev[i] << " ";

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int N;
int main() {
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  vector<int> rev(N);

  rep(i, N) rev[A[i] - 1] = i + 1;
  rep(i, N) cout << rev[i] << " ";

  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
struct Node {
  int num;
  int v;
} a[10010];
bool cmp(Node a, Node b) { return a.num < b.num; }
int n;
using namespace std;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].num;
    a[i].v = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    printf("%d ", a[i].v);
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
struct Node {
  int num;
  int v;
} a[100100];
bool cmp(Node a, Node b) { return a.num < b.num; }
int n;
using namespace std;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].num;
    a[i].v = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    printf("%d ", a[i].v);
  }
  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> ans(n);
  rep(i, n) {
    rep(j, n) {
      if (a[j] == (i + 1)) {
        ans[i] = (j + 1);
      }
    }
  }

  rep(i, n) cout << ans[i] << ' ';
  cout << endl;

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> ans(n);
  rep(i, n) ans[a[i] - 1] = i + 1;

  rep(i, n) cout << ans[i] << ' ';
  cout << endl;

  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;
int main() {
  int n, i, temp;
  cin >> n;
  int *brr = new int(n);
  for (i = 0; i < n; i++) {
    cin >> temp;
    brr[temp - 1] = i + 1;
  }
  for (i = 0; i < n; i++) {
    cout << brr[i] << ' ';
  }
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;
int main() {
  int n, i, temp;
  cin >> n;
  int brr[100000];
  for (i = 0; i < n; i++) {
    cin >> temp;
    brr[temp - 1] = i + 1;
  }
  for (i = 0; i < n; i++) {
    cout << brr[i] << ' ';
  }
  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

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

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

  for (int i = 0; i < n; i++) {
    cout << b[i] << " " << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

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

  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    b[a[i] - 1] = i + 1;
  }

  for (int i = 0; i < n; i++) {
    cout << b[i] << " " << endl;
  }
}
Problem p02899 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  rep(i, N) {
    auto iter = find(A.begin(), A.end(), i + 1);
    auto index = distance(A.begin(), iter);
    cout << index + 1 << " ";
  }
  cout << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  map<int, int> order;
  rep(i, N) { order[--A[i]] = i + 1; }
  rep(i, N) { cout << order[i] << " "; }
  cout << endl;
  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define maxim (ll)1000000000000
#define PB push_back
#define MP make_pair
using namespace std;
bool sortbysecond(const pair<ll, ll> &a, const pair<ll, ll> &b) {
  if (a.second < b.second)
    return true;
  else
    return false;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    ll n, a;
    cin >> n;
    vector<pair<ll, ll>> vp;
    for (ll i = 1; i <= n; i++) {
      cin >> a;
      vp.PB(MP(i, a));
    }
    sort(vp.begin(), vp.end(), sortbysecond);
    for (ll i = 0; i < n; i++)
      cout << vp[i].first << " ";
    cout << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define maxim (ll)1000000000000
#define PB push_back
#define MP make_pair
using namespace std;
bool sortbysecond(const pair<ll, ll> &a, const pair<ll, ll> &b) {
  if (a.second < b.second)
    return true;
  else
    return false;
}
int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    ll n, a;
    cin >> n;
    vector<pair<ll, ll>> vp;
    for (ll i = 1; i <= n; i++) {
      cin >> a;
      vp.PB(MP(i, a));
    }
    sort(vp.begin(), vp.end(), sortbysecond);
    for (ll i = 0; i < n; i++)
      cout << vp[i].first << " ";
    cout << endl;
  }
  return 0;
}
Problem p02899 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  int a[10010] = {};
  int b[10010] = {};
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= n; i++) {
    b[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    cout << b[i] << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  int a[100100] = {};
  int b[100100] = {};
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= n; i++) {
    b[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    cout << b[i] << endl;
  }
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be(), (a).en()

using LL = long long;

template <typename T> using V = vector<T>;
using Vi = V<int>;
using Vll = V<LL>;

template <typename T1, typename T2> using P = pair<T1, T2>;
using Pii = P<int, int>;

LL GCD(LL a, LL b) {
  LL t;
  LL r;
  if (a < b) {
    t = a;
    a = b;
    b = t;
  }
  if (b == 0) {
    return a;
  }
  while (a % b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return b;
}

P<Vll, Vll> primeFactor(LL n) {
  Vll p, e;
  LL m = n;
  int c;
  for (LL i = 2; i * i <= n; i++) {
    if (m % i != 0) {
      continue;
    }
    c = 0;
    while (m % i == 0) {
      c++;
      m /= i;
    }
    p.pb(i);
    e.pb(c);
  }
  if (m > 1) {
    p.pb(m);
    e.pb(1);
  }
  return mp(p, e);
}

int main() {
  LL a, b;
  cin >> a >> b;

  LL gcd_ab = GCD(a, b);

  Vll cds;
  for (int i = 1; i <= gcd_ab; i++) {
    if (gcd_ab % i == 0) {
      cds.pb(i);
    }
  }

  auto pf_gcd = primeFactor(gcd_ab);

  cout << pf_gcd.fi.size() + 1 << endl;

  return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be(), (a).en()

using LL = long long;

template <typename T> using V = vector<T>;
using Vi = V<int>;
using Vll = V<LL>;

template <typename T1, typename T2> using P = pair<T1, T2>;
using Pii = P<int, int>;

LL GCD(LL a, LL b) {
  LL t;
  LL r;
  if (a < b) {
    t = a;
    a = b;
    b = t;
  }
  if (b == 0) {
    return a;
  }
  while (a % b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return b;
}

P<Vll, Vll> primeFactor(LL n) {
  Vll p, e;
  LL m = n;
  int c;
  for (LL i = 2; i * i <= n; i++) {
    if (m % i != 0) {
      continue;
    }
    c = 0;
    while (m % i == 0) {
      c++;
      m /= i;
    }
    p.pb(i);
    e.pb(c);
  }
  if (m > 1) {
    p.pb(m);
    e.pb(1);
  }
  return mp(p, e);
}

int main() {
  LL a, b;
  cin >> a >> b;

  LL gcd_ab = GCD(a, b);

  auto pf_gcd = primeFactor(gcd_ab);

  cout << pf_gcd.fi.size() + 1 << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))

#define INF 2e9
#define ll long long
#define MOD 1e9 + 7
#define MAX_V

ll euclid(ll a, ll b) {
  ll temp;

  if (a < b) {
    temp = a;
    a = b;
    b = temp;
  }
  if (b < 1)
    return -1;

  if (a % b == 0)
    return b;
  return euclid(b, a % b);
}

int main() {
  ll a, b;
  cin >> a >> b;

  ll max_koyakusu = euclid(a, b);
  vector<ll> yakusu;

  // cout<<max_koyakusu<<endl;

  for (ll i = 1; (ll)sqrt(max_koyakusu); i++) {
    if (max_koyakusu % i == 0) {
      yakusu.push_back(max_koyakusu / i);
      yakusu.push_back(i);
    }
  }

  sort(yakusu.begin(), yakusu.end());

  ll ans = 1;
  ll gcd = 1;

  if (yakusu[0] == 1 && yakusu[1] == 1) {
    cout << "1" << endl;
    return 0;
  }

  for (ll i = 1; i < yakusu.size(); i++) {
    if (euclid(gcd, yakusu[i]) == 1) {
      ans++;
      gcd *= yakusu[i];
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))

#define INF 2e9
#define ll long long
#define MOD 1e9 + 7
#define MAX_V

ll euclid(ll a, ll b) {
  ll temp;

  if (a < b) {
    temp = a;
    a = b;
    b = temp;
  }
  if (b < 1)
    return -1;

  if (a % b == 0)
    return b;
  return euclid(b, a % b);
}

int main() {
  ll a, b;
  cin >> a >> b;

  ll max_koyakusu = euclid(a, b);
  vector<ll> yakusu;

  // cout<<max_koyakusu<<endl;

  for (ll i = 1; i <= (ll)sqrt(max_koyakusu); i++) {
    if (max_koyakusu % i == 0) {
      yakusu.push_back(max_koyakusu / i);
      yakusu.push_back(i);
    }
  }

  sort(yakusu.begin(), yakusu.end());

  ll ans = 1;
  ll gcd = 1;

  if (yakusu[0] == 1 && yakusu[1] == 1) {
    cout << "1" << endl;
    return 0;
  }

  for (ll i = 1; i < yakusu.size(); i++) {
    if (euclid(gcd, yakusu[i]) == 1) {
      ans++;
      gcd *= yakusu[i];
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;

int main() {
#ifndef ONLINE_JUDGE
  freopen(".in.txt", "r", stdin);
  freopen(".out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  int ans = 0;
  for (ll i = 1; i <= sqrtl(g); i++)
    if (!(g % i)) {
      bool p = 1;
      for (ll j = 2; j <= sqrtl(i); j++)
        if (!(i % j)) {
          p = 0;
          break;
        }
      if (p)
        ans++;
      if (g / i == i)
        break;
      p = 1;
      for (ll j = 2; j <= sqrtl(g / i); j++)
        if (!(g / i % j)) {
          p = 0;
          break;
        }
      if (p)
        ans++;
    }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;

int main() {
  // #ifndef ONLINE_JUDGE
  // freopen(".in.txt", "r", stdin);
  // freopen(".out.txt", "w", stdout);
  // #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  int ans = 0;
  for (ll i = 1; i <= sqrtl(g); i++)
    if (!(g % i)) {
      bool p = 1;
      for (ll j = 2; j <= sqrtl(i); j++)
        if (!(i % j)) {
          p = 0;
          break;
        }
      if (p)
        ans++;
      if (g / i == i)
        break;
      p = 1;
      for (ll j = 2; j <= sqrtl(g / i); j++)
        if (!(g / i % j)) {
          p = 0;
          break;
        }
      if (p)
        ans++;
    }
  cout << ans << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
/*
https://t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC push_options
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC pop_options
// #pragma GCC target("popcnt")
// #pragma GCC target("sse4")
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

signed main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  map<int, int> fl;
  for (int j = 2; j * j <= g; j++) {
    if (g % j == 0) {
      g /= j;
      fl[j]++;
      j--;
    }
  }
  fl[g]++;
  fl[1]++;
  cout << fl.size();
}


Fixed submission:
/*
https://t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC push_options
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC pop_options
// #pragma GCC target("popcnt")
// #pragma GCC target("sse4")
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

signed main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  map<ll, int> fl;
  for (ll j = 2; j * j <= g; j++) {
    if (g % j == 0) {
      g /= j;
      fl[j]++;
      j--;
    }
  }
  fl[g]++;
  fl[1]++;
  cout << fl.size();
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

long long int gcd(long long int x, long long int y) {
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}

int main(void) {
  long long int A, B, ans = 1;
  cin >> A >> B;
  long long int hcf = gcd(A, B);

  for (long long int i = 2; i <= hcf; i++) {
    if (hcf % i == 0) {
      ans++;
      while (hcf % i == 0) {
        hcf /= i;
      }
    }
  }
  if (hcf > 2) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

long long int gcd(long long int x, long long int y) {
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}

int main(void) {
  long long int A, B, ans = 1;
  cin >> A >> B;
  long long int hcf = gcd(A, B);

  for (long long int i = 2; i <= hcf / i; i++) {
    if (hcf % i == 0) {
      ans++;
      while (hcf % i == 0) {
        hcf /= i;
      }
    }
  }
  if (hcf > 2) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>

using namespace std;
vector<int> primes;

long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

void prime_list() {
  primes.push_back(2);
  for (int i = 3; i <= 1000009; i += 2) {
    int tmp = primes.size();
    for (int j = 0; primes[j] * primes[j] <= i; j++) {
      if (i % primes[j] == 0)
        break;
      if (j == tmp - 1)
        primes.push_back(i);
    }
  }
}

int main() {
  long long a, b, lgcd, cnt = 0;
  cin >> a >> b;
  lgcd = gcd(a, b);
  for (int i = 2; i * i <= lgcd; i++) {
    if (lgcd % i == 0)
      cnt++;
    while (lgcd % i == 0)
      lgcd /= i;
  }
  if (lgcd != 1)
    cnt++;
  cout << cnt + 1 << endl;
}

Fixed submission:
#include <iostream>
#include <vector>

using namespace std;
vector<int> primes;

long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

void prime_list() {
  primes.push_back(2);
  for (int i = 3; i <= 1000009; i += 2) {
    int tmp = primes.size();
    for (int j = 0; primes[j] * primes[j] <= i; j++) {
      if (i % primes[j] == 0)
        break;
      if (j == tmp - 1)
        primes.push_back(i);
    }
  }
}

int main() {
  long long a, b, lgcd, cnt = 0;
  cin >> a >> b;
  lgcd = gcd(a, b);
  for (long long i = 2; i * i <= lgcd; i++) {
    if (lgcd % i == 0)
      cnt++;
    while (lgcd % i == 0)
      lgcd /= i;
  }
  if (lgcd != 1)
    cnt++;
  cout << cnt + 1 << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
long long n, m;
int ans = 1;
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      while (n % i == 0)
        n /= i;
      if (m % i == 0)
        ans++;
      while (m % i == 0)
        m /= i;
    }
  if (n != 1)
    if (m % n == 0)
      ans++;
  printf("%d", ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long n, m;
int ans = 1;
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 2; 1ll * i * i <= n; i++)
    if (n % i == 0) {
      while (n % i == 0)
        n /= i;
      if (m % i == 0)
        ans++;
      while (m % i == 0)
        m /= i;
    }
  if (n != 1)
    if (m % n == 0)
      ans++;
  printf("%d", ans);
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
#define rep(i, N) for (ll(i) = 0; (i) < (N); (i)++)
const int mod = 1000000007;
const int INF = 1001001001;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
vector<P> factorize(ll x) {
  vector<P> res;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i)
      continue;
    res.emplace_back(i, 0);
    while (!(x % i)) {
      res.back().second++;
      x /= i;
    }
  }
  if (x != 1)
    res.emplace_back(x, 1);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto primes = factorize(g);
  cout << primes.size() + 1 << endl;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
#define rep(i, N) for (ll(i) = 0; (i) < (N); (i)++)
const int mod = 1000000007;
const int INF = 1001001001;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
vector<P> factorize(ll x) {
  vector<P> res;
  for (ll i = 2; i * i <= x; ++i) {
    if (x % i)
      continue;
    res.emplace_back(i, 0);
    while (!(x % i)) {
      res.back().second++;
      x /= i;
    }
  }
  if (x != 1)
    res.emplace_back(x, 1);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto primes = factorize(g);
  cout << primes.size() + 1 << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (long int i = 0; i < n; i++)
#define P pair<long int, long int>

vector<P> prime;

long int gcd(long int x, long int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

void factorize(long int x) {
  long int num = x;
  for (int i = 2; i * i <= x; i++) {
    if (num % i == 0) {
      P p;
      p.first = i;
      p.second = 0;
      while (num % i == 0) {
        p.second++;
        num /= i;
      }
      prime.push_back(p);
    }
  }
  if (num > 1) {
    P p;
    p.first = num;
    p.second = 1;
    prime.push_back(p);
  }
}

int main() {
  long int a, b;
  cin >> a >> b;
  long int n = gcd(a, b);
  factorize(n);
  cout << prime.size() + 1 << endl;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (long int i = 0; i < n; i++)
#define P pair<long int, long int>

vector<P> prime;

long int gcd(long int x, long int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

void factorize(long int x) {
  long int num = x;
  for (long int i = 2; i * i <= x; i++) {
    if (num % i == 0) {
      P p;
      p.first = i;
      p.second = 0;
      while (num % i == 0) {
        p.second++;
        num /= i;
      }
      prime.push_back(p);
    }
  }
  if (num > 1) {
    P p;
    p.first = num;
    p.second = 1;
    prime.push_back(p);
  }
}

int main() {
  long int a, b;
  cin >> a >> b;
  long int n = gcd(a, b);
  factorize(n);
  cout << prime.size() + 1 << endl;
}
Problem p02900 (C++)

Buggy submission (status: 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 rep1(i, n) for (int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll A, B;
  cin >> A >> B;

  int Asq = sqrt(A);
  int Bsq = sqrt(B);
  int AL[1000001] = {};
  AL[1] = 1;
  int BL[1000001] = {};
  BL[1] = 1;
  for (int i = 2; i <= Asq; i++) {
    while (A % i == 0) {
      A /= i;
      AL[i] = 1;
    }
  }
  if (A <= 1000000)
    AL[A] = 1;
  for (int i = 2; i <= Bsq; i++) {
    while (B % i == 0) {
      B /= i;
      BL[i] = 1;
    }
  }
  if (B <= 1000000)
    BL[A] = 1;

  int kotae = 0;
  rep1(i, 1000000) {
    if (AL[i] && BL[i]) {
      kotae++;
    }
  }
  if (A > 1000000 && B > 1000000 && A == B)
    kotae++;

  cout << kotae << endl;

  Would you please return 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 rep1(i, n) for (int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll A, B;
  cin >> A >> B;

  int Asq = sqrt(A);
  int Bsq = sqrt(B);
  int AL[1000001] = {};
  AL[1] = 1;
  int BL[1000001] = {};
  BL[1] = 1;
  for (int i = 2; i <= Asq; i++) {
    while (A % i == 0) {
      A /= i;
      AL[i] = 1;
    }
  }
  if (A <= 1000000)
    AL[A] = 1;
  for (int i = 2; i <= Bsq; i++) {
    while (B % i == 0) {
      B /= i;
      BL[i] = 1;
    }
  }
  if (B <= 1000000)
    BL[B] = 1;

  int kotae = 0;
  rep1(i, 1000000) {
    if (AL[i] && BL[i]) {
      kotae++;
    }
  }
  if (A > 1000000 && B > 1000000 && A == B)
    kotae++;

  cout << kotae << endl;

  Would you please return 0;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <iomanip>
#include <iostream>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

ll gcd(ll a, ll b) {
  int x, y;
  x = max(a, b);
  y = min(a, b);
  if (x % y == 0) {
    return y;
  } else {
    gcd(y, x % y);
  }
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  map<ll, ll> pf;
  { // 素因数分解
    for (ll i = 2; i * i <= g; i++) {
      while (g % i == 0) {
        pf[i]++;
        g /= i;
      }
    }
    if (g != 1)
      pf[g] = 1; // 最後の素因数を回収
  }

  cout << pf.size() + 1 << endl;
  return 0;
}

Fixed submission:
#include <iomanip>
#include <iostream>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

ll gcd(ll a, ll b) {
  ll x, y;
  x = max(a, b);
  y = min(a, b);
  if (x % y == 0) {
    return y;
  } else {
    gcd(y, x % y);
  }
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  map<ll, ll> pf;
  { // 素因数分解
    for (ll i = 2; i * i <= g; i++) {
      while (g % i == 0) {
        pf[i]++;
        g /= i;
      }
    }
    if (g != 1)
      pf[g] = 1; // 最後の素因数を回収
  }

  cout << pf.size() + 1 << endl;
  return 0;
}