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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9 + 7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f ? "Yes" : "No")
#define YN(f) (f ? "YES" : "NO")
#define pro                                                                                                                   \
  "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○" \
  "○するために生まれてきた男"

signed main() {
  cout << fixed << setprecision(7);
  int n = 0, m = 0;
  int a = 0, b = 0, c = 0, d = 0, e = 0;
  bool f = true, flag = true;
  string S[0];
  cin >> S[0] >> S[1];
  rep(i, S[0].size()) {
    if (S[0][i] != S[1][S[1].size() - i - 1])
      f = false;
  }
  // cin>>n;

  // for(int i = 0; i < n; i++){
  // }

  // cout<<yn(f)<<endl;
  cout << YN(f) << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9 + 7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f ? "Yes" : "No")
#define YN(f) (f ? "YES" : "NO")
#define pro                                                                                                                   \
  "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○" \
  "○するために生まれてきた男"

signed main() {
  cout << fixed << setprecision(7);
  int n = 0, m = 0;
  int a = 0, b = 0, c = 0, d = 0, e = 0;
  bool f = true, flag = true;
  string S[2];
  cin >> S[0] >> S[1];
  rep(i, S[0].size()) {
    if (S[0][i] != S[1][S[1].size() - i - 1])
      f = false;
  }
  // cin>>n;

  // for(int i = 0; i < n; i++){
  // }

  // cout<<yn(f)<<endl;
  cout << YN(f) << endl;

  return 0;
}
Problem p03555 (C++)

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1000 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

string s1, s2;

int main() {

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

  cin >> s1 >> s2;
  reverse(s1.begin(), s2.end());
  cout << (s1 == s2 ? "YES" : "NO") << '\n';

  return 0;
}

Fixed submission:
// #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1000 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

string s1, s2;

int main() {

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

  cin >> s1 >> s2;
  reverse(s1.begin(), s1.end());
  cout << (s1 == s2 ? "YES" : "NO") << '\n';

  return 0;
}
Problem p03555 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
char a[2][3];
int main() {
  for (int i = 0; i <= 1; i++) {
    for (int j = 0; i <= 2; j++) {
      cin >> a[i][j];
    }
  }
  if (a[0][1] == a[1][1] && a[0][2] == a[1][0] && a[0][0] == a[1][2])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
char a[2][3];
int main() {
  for (int i = 0; i <= 1; i++) {
    for (int j = 0; j <= 2; j++) {
      cin >> a[i][j];
    }
  }
  if (a[0][1] == a[1][1] && a[0][2] == a[1][0] && a[0][0] == a[1][2])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
Problem p03555 (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++)
using ll = long long;
using P = pair<int, string>;

int main() {
  vector<vector<char>> a(2, vector<char>(3));

  rep(i, 2) rep(j, 3) cin >> a.at(i).at(j);

  bool ans = true;
  rep(i, 3) {
    if (a.at(1).at(i) != a.at(2).at(2 - i))
      ans = false;
  }
  puts(ans ? "YES" : "NO");
}

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;
using P = pair<int, string>;

int main() {
  vector<vector<char>> a(2, vector<char>(3));

  rep(i, 2) rep(j, 3) cin >> a.at(i).at(j);

  bool ans = true;
  rep(i, 3) {
    if (a.at(0).at(i) != a.at(1).at(2 - i))
      ans = false;
  }
  puts(ans ? "YES" : "NO");
}
Problem p03555 (C++)

Buggy submission (status: Runtime Error):
// #define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
typedef long long ll;

int main() {
  vector<char> c;
  for (int i = 0; i < 6; i++)
    cin >> c[i];
  if (c[0] == c[5] && c[1] == c[4] && c[2] == c[3])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Fixed submission:
// #define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
typedef long long ll;

int main() {
  vector<char> c(6);
  for (int i = 0; i < 6; i++)
    cin >> c[i];
  if (c[0] == c[5] && c[1] == c[4] && c[2] == c[3])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
Problem p03555 (C++)

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

using namespace std;

int main() {
  char a[3];
  char b[3];
  cin >> a >> b;
  for (int i = 0; i < 3; i++) {
    if (a[i] != b[2 - i]) {
      cout << "NO";
      return 1;
    }
  }
  cout << "YES";
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  char a[3];
  char b[3];
  cin >> a >> b;
  for (int i = 0; i < 3; i++) {
    if (a[i] != b[2 - i]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
Problem p03555 (C++)

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

int main() {
  vector<char> up(2);
  vector<char> down(2);

  for (char &i : up)
    cin >> i;
  for (char &i : down)
    cin >> i;

  if (up.at(0) == down.at(2) && up.at(1) == down.at(1) &&
      up.at(2) == down.at(0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


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

int main() {
  string up, down;
  cin >> up >> down;

  if (up.at(0) == down.at(2) && up.at(1) == down.at(1) &&
      up.at(2) == down.at(0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
Problem p03555 (Python)

Buggy submission (status: Runtime Error):
a = list(map(str, input().split()))
b = list(map(str, input().split()))
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
    print("YES")
else:
    print("NO")


Fixed submission:
a = input()
b = input()
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
    print("YES")
else:
    print("NO")
Problem p03555 (Python)

Buggy submission (status: Runtime Error):
a, b = input().split()
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
    print("YES")
else:
    print("NO")


Fixed submission:
word1, word2 = [input() for i in range(2)]
if word1[0] == word2[2] and word1[1] == word2[1] and word1[2] == word2[0]:
    print("YES")
else:
    print("NO")
Problem p03555 (Python)

Buggy submission (status: Runtime Error):
C1 = list(input().split())
C2 = list(input().split())

if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
    print("YES")
else:
    print("NO")


Fixed submission:
C1 = list(input())
C2 = list(input())

if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
    print("YES")
else:
    print("NO")
Problem p03555 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  string a, b;
  bool c = 1;
  cin >> a >> b;
  for (int i = 0; i < 2; i++) {
    if (a.at(i) != b.at(-1 * i + 3)) {
      c = 0;
    }
  }
  if (c == 0)
    cout << "NO" << endl;
  else if (c == 1)
    cout << "YES" << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  string a, b;
  bool c = 1;
  cin >> a >> b;
  if (a.at(0) != b.at(2)) {
    c = 0;
  } else if (a.at(1) != b.at(1)) {
    c = 0;
  } else if (a.at(2) != b.at(0)) {
    c = 0;
  }
  if (c == 0)
    cout << "NO" << endl;
  else if (c == 1)
    cout << "YES" << endl;
  return 0;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int N;
  cin >> N;
  for (int i = 0; i <= N; i++) {
    if (i * i <= N && (i + 1) * (i + 1) > N) {
      cout << i * i << endl;
    }
  }
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int N;
  cin >> N;
  for (int i = 0; i <= N; i++) {
    if (i * i <= N && (i + 1) * (i + 1) > N) {
      cout << i * i << endl;
      return 0;
    }
  }
}
Problem p03556 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const long long MOD = 1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void) {
  int N;
  cin >> N;
  int ans;
  for (int i = 1; i < 100000; i++) {
    if (i * i > N) {
      ans = (i - 1) * (i - 1);

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

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const long long MOD = 1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void) {
  int N;
  cin >> N;
  int ans;
  for (int i = 1; i < 100000; i++) {
    if (i * i > N) {
      ans = (i - 1) * (i - 1);

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

  return 0;
}
Problem p03556 (C++)

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

int main() {
  double n;
  cin >> n;
  for (int i = n; i > 0; i--) {
    for (int j = sqrt(n); j > 0; j--) {
      if (i == pow(j, 2)) {
        cout << i << endl;
        return 0;
      }
    }
  }
}

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

int main() {
  double n;
  cin >> n;
  for (int i = n; i > 0; i--) {
    int j = sqrt(n);
    if (i == pow(j, 2)) {
      cout << i << endl;
      return 0;
    }
  }
}
Problem p03556 (Python)

Buggy submission (status: Runtime Error):
n = int(input())

for i in range(1, n):
    if i**2 <= n:
        ans = min(n, i**2)
    else:
        break

print(ans)


Fixed submission:
n = int(input())

for i in range(1, n + 1):
    if i**2 <= n:
        ans = min(n, i**2)
    else:
        break

print(ans)
Problem p03556 (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 FOR(i, a, b) for (int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

int bitCount(long bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> v(n + 1);
  FOR(i, 1, sqrt(n + 1) + 1) {
    if ((ll)i * i <= n) {
      v[i * i] = 1;
    }
  }
  for (int i = n; i > 0; --i) {
    if (v[i] == 1) {
      cout << i << '\n';
      return 0;
    }
  }

  return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

int bitCount(long bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1;; i++) {
    if (i * i > n) {
      cout << (i - 1) * (i - 1) << '\n';
      return 0;
    }
  }

  return 0;
}
Problem p03556 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
for i in range(N):
    if i * i > N:
        ans = (i - 1) ** 2
        break
print(ans)


Fixed submission:
N = int(input())
ans = 1
for i in range(N):
    if i * i > N:
        ans = (i - 1) ** 2
        break
print(ans)
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main() {
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  double D = 0;
  for (int i = N; i > 0; i--) {
    for (int j = 0; j < pow(N, 0.5) + 1; j++) {
      if (i == j * j) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main() {
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  for (ll i = N; i > 0; i--) {
    double D = sqrt(i);
    int d = D;
    if (i == d * d) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(), (v).end()
#define REP(i, p, n) for (int i = p; i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

bool isSquare(Int a) {
  bool flag = false;
  double z = double(sqrt(a));
  if (ceil(z) == floor(z))
    flag = true;
  return flag;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (isSquare(i))
      ans = max(ans, i);
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(), (v).end()
#define REP(i, p, n) for (int i = p; i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

bool isSquare(Int a) {
  bool flag = false;
  double z = double(sqrt(a));
  if (ceil(z) == floor(z))
    flag = true;
  return flag;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (i * i <= n)
      ans = max(ans, i * i);
  }
  cout << ans << endl;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ll n;
  cin >> n;
  ll ans = 1;
  FOR(i, 1, n) {
    if (i <= sqrt(n))
      ans = i * i;
  }
  print(ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ll n;
  cin >> n;
  ll ans = 1;
  FOR(i, 1, sqrt(n) + 1) {
    if (i <= sqrt(n))
      ans = i * i;
  }
  print(ans);
  return 0;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(), A.end()
#define RALL(A) A.rbegin(), A.rend()
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (floor(sqrt(i)) == i / floor(sqrt(i))) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(), A.end()
#define RALL(A) A.rbegin(), A.rend()
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;

int main() {
  int n;
  cin >> n;
  int x = floor(sqrt(n));
  cout << x * x << endl;
  return 0;
}
Problem p03556 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9 + 7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

signed main() {
  int N;
  vector<int> As, Bs, Cs;
  cin >> N;
  As.reserve(N);
  Bs.reserve(N);
  Cs.reserve(N);

  int n = (int)sqrt(N);
  cout << n * n << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9 + 7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

signed main() {
  int N;
  vector<int> As, Bs, Cs;
  cin >> N;

  int n = (int)sqrt(N);
  cout << n * n << endl;
  return 0;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
  long long n;
  scanf("%I64d", &n);
  for (long long i = n; i > 0; i--) {
    for (long long j = 1; j <= i; j++) {
      if (j * j == i) {
        printf("%I64d\n", i);
        return 0;
      }
    }
  }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = n; i > 0; i--) {
    double b;
    b = sqrt(i);
    if (int(b) == b) {
      printf("%d\n", i);
      return 0;
    }
  }
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  for (int i = N; i >= 0; i--) {
    for (int j = 1; j <= sqrt(i); j++)
      if (j * j == i) {
        cout << i << endl;
        return 0;
      }
  }
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;

  for (int i = 1;; i++)
    if (i * i > n) {
      cout << (i - 1) * (i - 1) << endl;
      return 0;
    }
}
Problem p03556 (C++)

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

int heihou(int n) {
  int count = 0;
  for (int i = 1; i < 40000; i++) {
    if (i * i == n) {
      count++;
    }
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  for (int i = n;; i--) {
    if (heihou(i) == 1) {
      cout << i << endl;
      break;
    }
  }
}


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

int heihou(int n) {
  int count = 0;
  for (int i = 1; i < 32000; i++) {
    if (i * i == n) {
      count++;
    }
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  for (int i = n;; i--) {
    if (heihou(i) == 1) {
      cout << i << endl;
      break;
    }
  }
}
Problem p03556 (C++)

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

int main() {
  long long n;
  cin >> n;
  long long res = 1;
  while (1) {
    if ((res * res) > n) {
      cout << (res - 1) * (res - 1) << endl;
      return 0;
    }
  }
}

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

int main() {
  long long n;
  cin >> n;
  long long res = 1;
  while (1) {
    if ((res * res) > n) {
      cout << (res - 1) * (res - 1) << endl;
      return 0;
    }
    ++res;
  }
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>
using namespace std;
int main(void) {
  long N;
  cin >> N;
  long max = 0;
  for (long i = 1; i <= N; i++) {
    long x;
    x = sqrt(i);
    if (x * x == i && max < i)
      max = i;
  }
  cout << max;
  return 0;
}


Fixed submission:
#include <cmath>
#include <iostream>
using namespace std;
int main(void) {
  long N;
  cin >> N;
  long max = 0;
  for (long i = 1; i * i <= N; i++) {
    max = i * i;
  }
  cout << max;
  return 0;
}
Problem p03556 (C++)

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << (x - z) / (y + z) << endl;
}

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

int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  long long i = 1;
  while (ans + i <= n) {
    ans += i;
    i += 2;
  }
  cout << ans << endl;
}
Problem p03556 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <cstdio>
using namespace std;
int n, m;
int main() {
  scanf("%d", n);
  m = (int)(sqrt(n));
  printf("%d\n", m * m);
}

Fixed submission:
#include <cmath>
#include <cstdio>
using namespace std;
int n, m;
int main() {
  scanf("%d", &n);
  m = (int)(sqrt(n));
  printf("%d\n", m * m);
}
Problem p03556 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.141592653289793;
using namespace std;
#define FOR(i, r, n) for (int i = (ll)(r); i < (ll)(n); i++)
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define lld long double
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
// vector<vector<ll>> vv(n, vector<ll>(n));

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  x -= y;
  cout << x / (y + z) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.141592653289793;
using namespace std;
#define FOR(i, r, n) for (int i = (ll)(r); i < (ll)(n); i++)
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define lld long double
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
// vector<vector<ll>> vv(n, vector<ll>(n));

int main() {
  int n;
  cin >> n;
  int d = sqrt(n);
  cout << d * d << endl;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>
typedef long long ll;
int main() {
  ll N;
  std::cin >> N;
  ll ans;
  for (ll i = 1; i <= N; i++) {
    ll x = int(sqrt(i));
    if (x * x == i)
      ans = i;
  }

  std::cout << ans << std::endl;
}

Fixed submission:
#include <cmath>
#include <iostream>
typedef long long ll;
int main() {
  ll N;
  std::cin >> N;
  ll ans;
  for (ll x = 1; x * x <= N; x++)
    ans = x * x;

  std::cout << ans << std::endl;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans;
  cin >> N;
  int i = 1;
  while (1) {
    if (i * i > N)
      break;
    ans = i;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans;
  cin >> N;
  int i = 1;
  while (1) {
    if (i * i > N)
      break;
    ans = i * i;
    i++;
  }
  cout << ans << endl;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N;
  cin >> N;
  long long ans = 1;
  for (int i = 1; i <= N; i++) {
    long long I = sqrt(i);
    double D = sqrt(i);
    if (I == D)
      ans = i;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N;
  cin >> N;
  long long ans = 1;
  long long i = 1;
  while (i * i <= N) {
    ans = i * i;
    i++;
  }
  cout << ans << endl;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  for (ll i = 1;; i++) {
    if (i * i == n) {
      cout << i * i << endl;
    } else if (i * i > n) {
      cout << (i - 1) * (i - 1) << endl;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  for (ll i = n; i >= 0; i--) {
    int k = sqrt(i);
    if (k * k == i) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
Problem p03556 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <math.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int cnt = 0;
  while (true) {
    int m = static_cast<int>(static_cast<double>(sqrt(n - cnt)));
    if (m * m == n - cnt) {
      cout << n - cnt << endl;
    }
    ++cnt;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <math.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int cnt = 0;
  while (true) {
    int m = static_cast<int>(static_cast<double>(sqrt(n - cnt)));
    if (m * m == n - cnt) {
      cout << n - cnt << endl;
      break;
    }
    ++cnt;
  }
  return 0;
}
Problem p03556 (C++)

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

int main() {

  ll n;
  cin >> n;
  ll a = 1;
  ll b = 40000;
  ll c;
  ll ans;
  while (1) {
    c = (a + b) / 2;
    if (c * c < n) {
      a = c;
      if ((c + 1) * (c + 1) > n) {
        ans = c * c;
        break;
      }
    } else {
      b = c;
    }
  }
  cout << ans << endl;
}

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

int main() {

  ll n;
  cin >> n;
  cout << (int)sqrt(n) * (int)sqrt(n) << endl;
}
Problem p03557 (C++)

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

typedef long long ll;
typedef pair<int, int> P;

#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)

const long double PI = acos(-1);

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for (ll i = 0; i < n; i++)
    cin >> a[i];
  for (ll i = 0; i < n; i++)
    cin >> b[i];
  for (ll i = 0; i < n; i++)
    cin >> c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ll itr1 = upper_bound(all(b), a[i]) - b.begin();
    for (ll j = itr1; j < n; j++) {
      ll itr2 = upper_bound(all(c), b[j]) - c.begin();
      ans += n - itr2;
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)

const long double PI = acos(-1);

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for (ll i = 0; i < n; i++)
    cin >> a[i];
  for (ll i = 0; i < n; i++)
    cin >> b[i];
  for (ll i = 0; i < n; i++)
    cin >> c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ll itr1 = upper_bound(all(c), b[i]) - c.begin();
    ll itr2 = lower_bound(all(a), b[i]) - a.begin();
    ans += (n - itr1) * itr2;
  }
  cout << ans << endl;
  return 0;
}
Problem p03557 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x) cout << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cout << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<P>> Graph;

int main() {

  int n;
  cin >> n;

  vector<int> a, b, c;
  int x;

  REP(i, n) {
    cin >> x;
    a.push_back(x);
  }
  REP(i, n) {
    cin >> x;
    b.push_back(x);
  }
  REP(i, n) {
    cin >> x;
    c.push_back(x);
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  vector<ll> set(n + 1, 0);

  REP(i, n) {
    set[i + 1] += lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    set[i + 2] = set[i + 1];
  }

  // REP(i,n+1)
  // debug(set[i]);

  ll ans = 0;
  REP(i, n) {
    int x = lower_bound(b.begin(), b.end(), c[i]) - b.begin();
    ans += set[x];
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x) cout << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cout << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<P>> Graph;

int main() {

  int n;
  cin >> n;

  vector<int> a, b, c;
  int x;

  REP(i, n) {
    cin >> x;
    a.push_back(x);
  }
  REP(i, n) {
    cin >> x;
    b.push_back(x);
  }
  REP(i, n) {
    cin >> x;
    c.push_back(x);
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  vector<ll> set(n + 2, 0);

  REP(i, n) {
    set[i + 1] += lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    set[i + 2] = set[i + 1];
  }

  // REP(i,n+1)
  // debug(set[i]);

  ll ans = 0;
  REP(i, n) {
    int x = lower_bound(b.begin(), b.end(), c[i]) - b.begin();
    ans += set[x];
  }

  cout << ans << endl;

  return 0;
}
Problem p03557 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int INF = 1e9 + 7;
int mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++)
    cin >> B[i];
  for (int i = 0; i < N; i++)
    cin >> C[i];
  sort(A.begin(), A.end());
  sort(C.begin(), B.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int cnt = 1;
    int it = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    cnt *= it;
    it = C.end() - upper_bound(C.begin(), C.end(), B[i]);
    cnt *= it;
    ans += cnt;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int INF = 1e9 + 7;
int mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++)
    cin >> B[i];
  for (int i = 0; i < N; i++)
    cin >> C[i];
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int cnt = 1;
    int it = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    cnt *= it;
    it = C.end() - upper_bound(C.begin(), C.end(), B[i]);
    cnt *= it;
    ans += cnt;
  }
  cout << ans << endl;
}
Problem p03557 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9 + 7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f ? "Yes" : "No")
#define YN(f) (f ? "YES" : "NO")
#define pro                                                                                                                   \
  "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○" \
  "○するために生まれてきた男"

int a[MAX_N] = {}, b[MAX_N] = {}, c[MAX_N] = {}, n, t[MAX_N] = {},
    tt[MAX_N] = {}, sum, ans;
signed main() {

  cin >> n;

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

  for (int i = 0; i < n; i++) {
    t[i] = c + n - upper_bound(c, c + n, b[i]);
    // cout<<"b "<<t[i]<<" "<<b[i]<<endl;
  }

  for (int i = 0; i < n; i++) {
    // tt[0]++;
    // tt[b+n-upper_bound(b,b+n,a[i])]--;
    tt[n - (b + n - upper_bound(b, b + n, a[i]))]++;
    tt[n]--;
    // cout<<"a "<<tt[i]<<" "<<b+n-upper_bound(b,b+n,a[i])<<" "<<a[i]<<endl;
    // cout<<"a "<<tt[i]<<" "<<b+n-upper_bound(b,b+n,a[i])<<" "<<a[i]<<endl;
  }

  for (int i = 0; i < n; i++) {
    tt[i + 1] += tt[i];
    sum += t[i] * tt[i];
    // cout<<t[i]<<" "<<tt[i]<<endl;
  }
  cout << sum << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9 + 7)
#define MAX_N 200000
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f ? "Yes" : "No")
#define YN(f) (f ? "YES" : "NO")
#define pro                                                                                                                   \
  "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○" \
  "○するために生まれてきた男"

int a[MAX_N] = {}, b[MAX_N] = {}, c[MAX_N] = {}, n, t[MAX_N] = {},
    tt[MAX_N] = {}, sum, ans;
signed main() {

  cin >> n;

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

  for (int i = 0; i < n; i++) {
    t[i] = c + n - upper_bound(c, c + n, b[i]);
    // cout<<"b "<<t[i]<<" "<<b[i]<<endl;
  }

  for (int i = 0; i < n; i++) {
    // tt[0]++;
    // tt[b+n-upper_bound(b,b+n,a[i])]--;
    tt[n - (b + n - upper_bound(b, b + n, a[i]))]++;
    tt[n]--;
    // cout<<"a "<<tt[i]<<" "<<b+n-upper_bound(b,b+n,a[i])<<" "<<a[i]<<endl;
    // cout<<"a "<<tt[i]<<" "<<b+n-upper_bound(b,b+n,a[i])<<" "<<a[i]<<endl;
  }

  for (int i = 0; i < n; i++) {
    tt[i + 1] += tt[i];
    sum += t[i] * tt[i];
    // cout<<t[i]<<" "<<tt[i]<<endl;
  }
  cout << sum << endl;
  return 0;
}
Problem p03557 (C++)

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

int main(void) {
  int n;

  cin >> n;

  int a[10000], b[10000], c[10000];

  long long ans = 0;

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

  for (int i = 0; i < n; i++)
    cin >> b[i];

  for (int i = 0; i < n; i++)
    cin >> c[i];
  sort(c, c + n);

  for (int i = 0; i < n; i++) {
    long long s = lower_bound(a, a + n, b[i]) - a;
    long long t = n - (upper_bound(c, c + n, b[i]) - c);
    ans += s * t;
  }

  cout << ans << endl;

  return 0;
}


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

int main(void) {
  int n;

  cin >> n;

  int a[100000], b[100000], c[100000];

  long long ans = 0;

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

  for (int i = 0; i < n; i++)
    cin >> b[i];

  for (int i = 0; i < n; i++)
    cin >> c[i];
  sort(c, c + n);

  for (int i = 0; i < n; i++) {
    long long s = lower_bound(a, a + n, b[i]) - a;
    long long t = n - (upper_bound(c, c + n, b[i]) - c);
    ans += s * t;
  }

  cout << ans << endl;

  return 0;
}
Problem p03557 (C++)

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

int main() {

  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
    cin >> b[i];
  for (int i = 0; i < n; i++)
    cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  int b_left = 0;
  for (int a_index = 0; a_index < n; a_index++) {

    for (int i = b_left; i < n; i++) {

      while (i < n) {
        if (a[a_index] < b[i]) {
          break;
        } else { // b[b_index] <= a[a_index]
          i++;
          b_left++;
        }
      }
      if (b_left != n)
        ans += c.end() - upper_bound(c.begin(), c.end(), b[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {

  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
    cin >> b[i];
  for (int i = 0; i < n; i++)
    cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  for (int j = 0; j < n; j++) {
    ll na = lower_bound(a.begin(), a.end(), b[j]) - a.begin();
    ll nc = c.end() - upper_bound(c.begin(), c.end(), b[j]);
    ans += na * nc;
  }
  cout << ans << endl;
  return 0;
}
Problem p03557 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(j, n) cin >> b[j];
  rep(k, n) cin >> c[k];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  rep(i, n) {
    auto itb = upper_bound(b.begin(), b.end(), a[i]);
    for (auto x = itb; x != b.end(); x++)
      ans += c.end() - upper_bound(c.begin(), c.end(), *x);
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(j, n) cin >> b[j];
  rep(k, n) cin >> c[k];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  rep(j, n) {
    auto itra = lower_bound(a.begin(), a.end(), b[j]);
    auto itrc = upper_bound(c.begin(), c.end(), b[j]);
    ans += (itra - a.begin()) * (c.end() - itrc);
  }
  cout << ans << endl;
}
Problem p03557 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define vec vector
#define ALL(v) v.begin(), v.end()
#define ll long long
using namespace std;
int main() {
  int n;
  cin >> n;
  vec<int> a, b, c;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a.push_back(t);
  }

  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    b.push_back(t);
  }
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    c.push_back(t);
  }
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  ll ans = 0;
  for (auto i : a) {

    auto j = upper_bound(ALL(b), i);
    if (j == b.end())
      break;
    for (; j != b.end(); j++) {

      auto k = upper_bound(ALL(c), *j);

      // cout << *j << "," << c.end() - k << endl;
      ans += c.end() - k;
      if (c.end() - k == 0)
        break;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define vec vector
#define ALL(v) v.begin(), v.end()
#define ll long long
using namespace std;
int main() {
  int n;
  cin >> n;
  vec<int> a, b, c;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a.push_back(t);
  }

  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    b.push_back(t);
  }
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    c.push_back(t);
  }
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  ll ans = 0;
  for (auto j : b) {
    auto i = lower_bound(ALL(a), j) - a.begin();
    auto k = c.end() - upper_bound(ALL(c), j);
    ans += i * k;
  }
  cout << ans << endl;
  return 0;
}
Problem p03557 (C++)

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

int main() {

  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<ll> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<ll> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(c.begin(), c.end());
  ll ans = 0;
  for (int j = 0; j < n; j++) {
    ll a_cnt = 0;
    ll c_cnt = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] < b[j])
        a_cnt++;
    }
    for (int i = 0; i < n; i++) {
      if (b[j] < c[i])
        c_cnt++;
    }
    ans += a_cnt * c_cnt;
  }

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

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

int main() {

  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<ll> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<ll> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(c.begin(), c.end());
  ll ans = 0;
  for (int j = 0; j < n; j++) {
    auto itr_a = lower_bound(a.begin(), a.end(), b[j]);
    ll a_cnt = itr_a - a.begin();
    auto itr_c = upper_bound(c.begin(), c.end(), b[j]);
    ll c_cnt = c.end() - itr_c;
    ans += a_cnt * c_cnt;
  }

  cout << ans << endl;
  return 0;
}
Problem p03557 (C++)

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

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

  int n;
  cin >> n;
  vector<int> A(n), B(n), C(n);
  REP(i, n) cin >> A[i];
  REP(i, n) cin >> B[i];
  REP(i, n) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int b = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
    for (int j = b; j < n; j++) {
      int c = upper_bound(C.begin(), C.end(), B[j]) - C.begin();
      ans += (n - c);
    }
  }

  cout << ans << endl;

  return 0;
}

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

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

  int n;
  cin >> n;
  vector<int> A(n), B(n), C(n);
  REP(i, n) cin >> A[i];
  REP(i, n) cin >> B[i];
  REP(i, n) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  long long ans = 0;
  for (int b = 0; b < n; b++) {
    long long a = lower_bound(A.begin(), A.end(), B[b]) - A.begin();
    long long c = upper_bound(C.begin(), C.end(), B[b]) - C.begin();
    ans += a * (n - c);
  }

  cout << ans << endl;

  return 0;
}