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

#include <iostream>
#include <math.h>
using namespace std;

int main() {
  double a;
  while (cin >> a) {
    double t = a / 9.8;
    double y = 4.9 * t * t;
    int y_c = ceil(y);
    int N = y_c / 5 + (y_c % 5 > 0);
    cout << N + 1 << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;

int main() {
  double a;
  while (cin >> a, a) {
    double t = a / 9.8;
    double y = 4.9 * t * t;
    int y_c = ceil(y);
    int N = y_c / 5 + (y_c % 5 > 0);
    cout << N + 1 << endl;
  }

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

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

int main() {
  double a;
  while (cin >> a) {
    double i = 1;
    while (1) {
      double h = ((a * a) / 19.6);
      double y = (5 * i - 5);
      if (y >= h)
        break;
      i++;
    }
    cout << i << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  while (1) {
    double a;
    cin >> a;
    double b = a / (9.8);
    double c = b * b * (4.9);
    double i = 1;
    while (1) {
      if ((5 * i - 5) >= i)
        break;
      i++;
    }
    cout << i << endl;
  }
  return 0;
}
Problem p00024 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>

using namespace std;

void solve() {
  double v;
  while (cin >> v) {
    int N = 2;
    while (true) {
      double velocity = 1.4 * sqrt(10.0 * (5 * N - 5));
      if (velocity >= v) {
        cout << N << endl;
        break;
      }
      ++N;
    }
  }
}

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

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>

using namespace std;

void solve() {
  double v;
  while (cin >> v, v) {
    int N = 2;
    while (true) {
      double velocity = 1.4 * sqrt(10.0 * (5 * N - 5));
      if (velocity >= v) {
        cout << N << endl;
        break;
      }
      ++N;
    }
  }
}

int main() {
  solve();
  return (0);
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

bool judgeZeroToNine(int n);
bool judgeCorr(int n[]);

int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    while (!(judgeZeroToNine(a[0]) && judgeZeroToNine(a[1]) &&
             judgeZeroToNine(a[2]) && judgeZeroToNine(a[3]))) {
      cout << "wrong value\\n";
      cin >> a[0] >> a[1] >> a[2] >> a[3];
    }
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    while (!(judgeZeroToNine(b[0]) && judgeZeroToNine(b[1]) &&
             judgeZeroToNine(b[2]) && judgeZeroToNine(b[3]))) {
      cout << "wrong value\\n";
      cin >> b[0] >> b[1] >> b[2] >> b[3];
    }

    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j])
          blow++;
      }
      if (a[i] == b[i]) {
        blow--;
        hit++;
      }
    }
    cout << hit << " " << blow << "\\n";
  }
  return 0;
}

bool judgeZeroToNine(int n) {
  if ((n >= 0) && (n <= 9))
    return true;
  else
    return false;
}

bool judgeCorr(int n[4]) {
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      if (n[i] == n[j])
        return true;
    }
    return false;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

bool judgeZeroToNine(int n);
// bool judgeCorr(int n[]);

int main() {
  int a[4], b[4];
  do {
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    while (!(judgeZeroToNine(a[0]) && judgeZeroToNine(a[1]) &&
             judgeZeroToNine(a[2]) && judgeZeroToNine(a[3]))) {
      cout << "wrong value\\n";
      cin >> a[0] >> a[1] >> a[2] >> a[3];
    }
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    while (!(judgeZeroToNine(b[0]) && judgeZeroToNine(b[1]) &&
             judgeZeroToNine(b[2]) && judgeZeroToNine(b[3]))) {
      cout << "wrong value\\n";
      cin >> b[0] >> b[1] >> b[2] >> b[3];
    }

    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j])
          blow++;
      }
      if (a[i] == b[i]) {
        blow--;
        hit++;
      }
    }
    cout << hit << " " << blow << "\\n";
  } while (true);
  return 0;
}

bool judgeZeroToNine(int n) {
  if ((n >= 0) && (n <= 9))
    return true;
  else
    return false;
}
/*
bool judgeCorr(int n[4]){
        for(int i = 0;i < 3;i++){
                for(int j = i + 1;j < 4;j++){
                        if(n[i] == n[j])
                                return true;
                }
        return false;
        }
}*/
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[i]) {
          hit++;
          break;
        } else if (a[i] == b[j] && i != j) {
          blow++;
          break;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a[4], b[4];
  while (1) {
    int hit = 0, blow = 0;
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[i]) {
          hit++;
          break;
        } else if (a[i] == b[j] && i != j) {
          blow++;
          break;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  int a[4];
  int b[4];
  int h, br;

  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {

    h = 0;
    br = 0;

    for (int k = 0; k < 4; k++) {
      for (int l = 0; l < 4; l++) {
        if (a[k] == b[l]) {
          if (k == l)
            h++;
          else
            br++;
        }
      }
    }

    cout << h << ' ' << br << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int a[4];
  int b[4];
  int h, br;

  while (1) {

    h = 0;
    br = 0;

    for (int i = 0; i < 4; i++)
      cin >> a[i];
    for (int j = 0; j < 4; j++)
      cin >> b[j];

    for (int k = 0; k < 4; k++) {
      for (int l = 0; l < 4; l++) {
        if (a[k] == b[l]) {
          if (k == l)
            h++;
          else
            br++;
        }
      }
    }
    cout << h << ' ' << br << endl;
  }
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int a[4], c[4];
  while (1) {
    int e = 0, b = 0, k;
    for (int i = 0; i < 4; i++)
      k = scanf("%d", &a[i]);
    if (k == -1)
      break;
    for (int i = 0; i < 4; i++) {
      cin >> c[i];
      for (int j = 0; j < 4; j++)
        if (c[i] == a[j]) {
          if (i == j)
            e++;
          else
            b++;
        }
    }
    cout << e << ' ' << b << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[4], c[4];
  while (1) {
    int e = 0, b = 0;
    for (int i = 0; i < 4; i++)
      cin >> a[i];
    for (int i = 0; i < 4; i++) {
      cin >> c[i];
      for (int j = 0; j < 4; j++)
        if (c[i] == a[j]) {
          if (i == j)
            e++;
          else
            b++;
        }
    }
    cout << e << ' ' << b << endl;
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int a[4], b[4];

  while (~scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0],
                &b[1], &b[2], &b[3])) {
    int hit = 0, blow = 0;

    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        if (a[i] == b[j]) {
          if (i == j)
            ++hit;
          else
            ++blow;
        }
      }
    }

    cout << hit << " " << blow << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  while (true) {
    int a[4], b[4];
    int hit = 0, blow = 0;
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    cin >> b[0] >> b[1] >> b[2] >> b[3];

    for (int i = 0; i < 4; ++i) {
      for (int j = i; j < 4; ++j) {
        if (a[i] == b[j])
          ++blow;
      }
    }

    for (int i = 0; i < 4; ++i) {
      if (a[i] == b[i])
        ++hit;
    }

    blow -= hit;
    cout << hit << " " << blow << endl;
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <array>
#include <iostream>

/*This function is a counter for "hit" and "blow".*/
void counter(int *n_a, int *n_b, int *hit, int *blow) {

  *hit = 0;
  *blow = 0;

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      // the case of factor and place are same
      if (n_a[i] == n_b[j] && i == j) {
        *hit = *hit + 1;
      }
      // the case of only factor is same
      else if (n_a[i] == n_b[j]) {
        *blow = *blow + 1;
      }
    }
  }
}

int main() {

  std::array<int, 4> n_a; // selection of "A"
  std::array<int, 4> n_b; // selection of "B"

  while (std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3] &&
         std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3]) {
    // std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3];
    // std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3];

    int hit = 0;  // factor and place are same
    int blow = 0; // only factor is same

    counter(n_a.data(), n_b.data(), &hit, &blow);

    std::cout << hit << " " << blow << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <array>
#include <iostream>

/*This function is a counter for "hit" and "blow".*/
void counter(int *n_a, int *n_b, int *hit, int *blow) {

  *hit = 0;
  *blow = 0;

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      // the case of factor and place are same
      if (n_a[i] == n_b[j] && i == j) {
        *hit = *hit + 1;
      }
      // the case of only factor is same
      else if (n_a[i] == n_b[j]) {
        *blow = *blow + 1;
      }
    }
  }
}

int main() {

  std::array<int, 4> n_a; // selection of "A"
  std::array<int, 4> n_b; // selection of "B"

  while (true) {
    std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3];
    std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3];

    int hit = 0;  // factor and place are same
    int blow = 0; // only factor is same

    counter(n_a.data(), n_b.data(), &hit, &blow);

    std::cout << hit << " " << blow << std::endl;
  }

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

#include <iostream>
using namespace std;
bool Init(int *a, int *b);

int main() {
  int a[4], b[4];
  int cntHits, cntBlow;
  while (Init(a, b)) {
    cntHits = cntBlow = 0;
    for (int i = 0; i < 4; ++i) {
      if (a[i] == b[i])
        ++cntHits;
    }
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        if (i != j && a[i] == b[j])
          ++cntBlow;
      }
    }
    cout << cntHits << " " << cntBlow << endl;
  }
  return 0;
}
bool Init(int *a, int *b) {
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    return true;
  }
  return false;
}

Error: TLE

Fixed submission:

#include <iostream>
#define N 4
using namespace std;
int main() {
  int a[N][N];
  while (1) {
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        cin >> a[j][k];
    for (int i = 0; i < N; i++) {
      if (a[0][i] == a[1][i])
        cout << a[1][i] << " "
             << "1" << endl;
      if (a[2][i] != a[3][i])
        cout << a[3][i] << " "
             << "0" << endl;
    }
  }
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a[4], b[4];
  int hit, blow;

  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    hit = 0;
    blow = 0;

    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i])
        hit++;
    }

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j])
          blow++;
      }
    }
    blow -= hit;

    cout << hit << " " << blow << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[4], b[4];
  int hit, blow;

  while (1) {
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    cin >> b[0] >> b[1] >> b[2] >> b[3];

    hit = 0;
    blow = 0;

    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i])
        hit++;
    }

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j])
          blow++;
      }
    }
    blow -= hit;

    cout << hit << " " << blow << endl;
  }

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

#include <array>
#include <iostream>

int main() {

  std::array<int, 4> num_a, num;

  while (std::cin >> num_a[0] >> num_a[1] >> num_a[2] >> num_a[3]) {
    std::cin >> num[0] >> num[1] >> num[2] >> num[3];
    int hit = 0, blow = 0;
    for (std::size_t i = 0; i < 4; ++i) {
      if (num_a[i] == num[i]) {
        ++hit;
      } else {
        for (std::size_t j = 0; j < 4; ++j) {
          if (num_a[j] == num[i]) {
            ++blow;
          }
        }
      }
    }
    std::cout << hit << " " << blow << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <array>
#include <iostream>

int main() {

  std::array<int, 4> num_a, num;

  while (true) {
    std::cin >> num_a[0] >> num_a[1] >> num_a[2] >> num_a[3];
    std::cin >> num[0] >> num[1] >> num[2] >> num[3];
    int hit = 0, blow = 0;
    for (std::size_t i = 0; i < 4; ++i) {
      if (num_a[i] == num[i]) {
        ++hit;
      } else {
        for (size_t j = 0; j < 4; ++j) {
          if (num_a[j] == num[i]) {
            ++blow;
          }
        }
      }
    }
    std::cout << hit << " " << blow << std::endl;
  }

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

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

int main() {
  vector<int> a(4), b(4);

  while (cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> b.at(0) >>
         b.at(1) >> b.at(2) >> b.at(3)) {
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a.at(i) == b.at(j)) {
          if (i == j) {
            hit++;
          } else {
            blow++;
          }
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  for (;;) {
    vector<int> a(4), b(4);
    for (int i = 0; i < 4; i++) {
      cin >> a.at(i);
    }
    for (int i = 0; i < 4; i++) {
      cin >> b.at(i);
    }
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a.at(i) == b.at(j)) {
          if (i == j) {
            hit++;
          } else {
            blow++;
          }
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b, c, d, e, f, g, h, x = 0, y = 0;
  while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
    x = 0;
    y = 0;
    if (a == e) {
      x = x + 1;
      e = e + 10;
    }
    if (b == f) {
      x = x + 1;
      f = f + 10;
    }
    if (c == g) {
      x = x + 1;
      g = g + 10;
    }
    if (d == h) {
      x = x + 1;
      h = h + 10;
    }
    if (e == a || e == b || e == c || e == d) {
      y = y + 1;
    }
    if (f == a || f == b || f == c || f == d) {
      y = y + 1;
    }
    if (g == a || g == b || g == c || g == d) {
      y = y + 1;
    }
    if (h == a || h == b || h == c || h == d) {
      y = y + 1;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b, c, d, e, f, g, h, x, y;
  cin >> a >> b >> c >> d;
  cin >> e >> f >> g >> h;
  while (1) {
    if (a == e) {
      x++;
      e = e + 10;
    }
    if (b == f) {
      x++;
      f = f + 10;
    }
    if (c == g) {
      x++;
      g = g + 10;
    }
    if (d == h) {
      x++;
      h = h + 10;
    }
    if (e == a || e == b || e == c || e == d) {
      y++;
    }
    if (f == a || f == b || f == c || f == d) {
      y++;
    }
    if (g == a || g == b || g == c || g == d) {
      y++;
    }
    if (h == a || h == b || h == c || h == d) {
      y++;
    }
    cout << x << y << endl;
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  int a[4], b[4];
  while (1) {
    rep(i, 4) cin >> a[i];
    rep(i, 4) cin >> b[i];
    if (cin.eof())
      break;

    int blow = 0, hit = 0;

    rep(i, 4) {
      if (a[i] == b[i])
        hit++;
    }
    rep(i, 4) for (int j = 0; j < 4; j++) {
      if (a[i] == b[j] && i != j)
        blow++;
    }
    cout << hit << " " << blow << endl;
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  int a[4], b[4];
  while (1) {
    rep(i, 4) cin >> a[i];
    rep(i, 4) cin >> b[i];

    int blow = 0, hit = 0;

    rep(i, 4) {
      if (a[i] == b[i])
        hit++;
    }
    rep(i, 4) for (int j = 0; j < 4; j++) {
      if (a[i] == b[j] && i != j)
        blow++;
    }
    cout << hit << " " << blow << endl;
  }
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a[4], b[4];
  while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0],
               &b[1], &b[2], &b[3]) != EOF) {
    int hit = 0;
    int blow = 0;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (a[i] == b[j])
          if (i == j)
            hit++;
          else
            blow++;
    printf("%d %d\\n", hit, blow);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a[4], b[4];
  while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0],
               &b[1], &b[2], &b[3])) {
    int hit = 0;
    int blow = 0;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (a[i] == b[j])
          if (i == j)
            hit++;
          else
            blow++;
    printf("%d %d\\n", hit, blow);
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main() {
  int a1, a2, a3, a4, b1, b2, b3, b4, k, l, m, hit, blow;
  vector<int> s, t, u;
  while (cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4) {
    hit = 0;
    blow = 0;
    s.clear();
    t.clear();
    s.push_back(a1);
    s.push_back(a2);
    s.push_back(a3);
    s.push_back(a4);
    t.push_back(b1);
    t.push_back(b2);
    t.push_back(b3);
    t.push_back(b4);
    for (k = 0; k < 4; k++) {
      if (s[k] == t[k] && s[k] >= 0) {
        hit += 1;
        s[k] = -1;
        t[k] = -1;
      }
    }
    for (l = 0; l < 4; l++) {
      for (m = 0; m < 4; m++) {
        if (s[l] == t[m] && s[l] > 0) {
          blow += 1;
          s[l] = -1;
          t[m] = -1;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main() {
  int a, i, j, k, l, m, hit, blow;
  vector<int> s, t, u;
  while (true) {
    hit = 0;
    blow = 0;
    s.clear();
    t.clear();
    for (i = 0; i < 4; i++) {
      cin >> a;
      s.push_back(a);
    }
    for (j = 0; j < 4; j++) {
      cin >> a;
      t.push_back(a);
    }
    for (k = 0; k < 4; k++) {
      if (s[k] == t[k] && s[k] >= 0) {
        hit += 1;
        s[k] = -1;
        t[k] = -1;
      }
    }
    for (l = 0; l < 4; l++) {
      for (m = 0; m < 4; m++) {
        if (s[l] == t[m] && s[l] > 0) {
          blow += 1;
          s[l] = -1;
          t[m] = -1;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}
Problem p00025 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
using namespace std;
#include <iostream>

int main(void) {
  int a[50][4];
  int b[50][4];
  int i = 0, j, k;
  int h, br;
  int num = 0;

  /*
  for ( i=0; i<2; i++) {
    scanf("%d %d %d %d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]);
    scanf("%d %d %d %d", &b[i][0], &b[i][1], &b[i][2], &b[i][3]);
  }*/

  while (cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3]) {
    scanf("%d %d %d %d", &b[i][0], &b[i][1], &b[i][2], &b[i][3]);
    num++;
    i++;
  }

  for (i = 0; i < num; i++) {
    for (j = 0; j < 4; j++) {
      for (k = 0; k < 4; k++) {
        if (a[i][j] == b[i][k]) {
          if (j == k) {
            h++;
          } else {
            br++;
          }
        }
      }
    }
    printf("%d %d\\n", h, br);
    br = h = 0;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int a[50][4];
  int b[50][4];
  int i, j, k;
  int h, br;
  int num = 0;

  /*
  for ( i=0; i<2; i++) {
    scanf("%d %d %d %d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]);
    scanf("%d %d %d %d", &b[i][0], &b[i][1], &b[i][2], &b[i][3]);
  }*/

  while (scanf("%d %d %d %d", &a[i][0], &a[i][1], &a[i][2], &a[i][3])) {
    scanf("%d %d %d %d", &b[i][0], &b[i][1], &b[i][2], &b[i][3]);
    num++;
  }

  for (i = 0; i < num; i++) {
    for (j = 0; j < 4; j++) {
      for (k = 0; k < 4; k++) {
        if (a[i][j] == b[i][k]) {
          if (j == k) {
            h++;
          } else {
            br++;
          }
        }
      }
    }
    printf("%d %d\\n", h, br);
    br = h = 0;
  }

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

#define rep(x, to) for (int x = 0; x < to; x++)
#define rep2(x, from, to) for (x = from; x < to; x++)

using namespace std;

int main(void) {
  int aa[4], bb[4];
  int ht, bl, j;

  while (cin >> aa[0]) {
    rep2(j, 1, 4) cin >> aa[j];
    rep(i, 4) cin >> bb[i];
    ht = 0;
    bl = 0;
    rep(i, 4) rep(j, 4) {
      if (aa[i] == bb[j]) {
        if (i == j)
          ht++;
        else
          bl++;
      }
    }
    cout << ht << " " << bl << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

#define rep(x, to) for (int x = 0; x < to; x++)
#define rep2(x, from, to) for (x = from; x < to; x++)

using namespace std;

int main(void) {
  int aa[4], bb[4];
  int ht, bl;

  while (1) {
    rep(i, 4) cin >> aa[i];
    rep(i, 4) cin >> bb[i];
    ht = 0;
    bl = 0;
    rep(i, 4) rep(j, 4) {
      if (aa[i] == bb[j]) {
        if (i == j)
          ht++;
        else
          bl++;
      }
    }
    cout << ht << " " << bl << endl;
  }

  return 0;
}