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

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

int main() {
  using std::cin;
  int n, m;

  std::vector<std::string> blue, red;

  scanf("%d\n", &n);
  blue.resize(n);
  for (int i = 0; i < n; i++)
    cin >> blue[i];

  scanf("%d\n", &m);
  red.resize(n);
  for (int i = 0; i < m; i++)
    cin >> red[i];

  int r = 0;
  for (int i = 0; i < n - 1; i++) {
    int count = 1;
    for (int j = i + 1; j < n; j++) {
      if (blue[i] == blue[j])
        ++count;
    }
    for (int k = 0; k < m; k++) {
      if (blue[i] == red[k])
        --count;
    }
    r = std::max(r, count);
  }

  printf("%d\n", r);

  return 0;
}


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

int main() {
  using std::cin;
  int n, m;

  std::vector<std::string> blue, red;

  scanf("%d\n", &n);
  blue.resize(n);
  for (int i = 0; i < n; i++)
    cin >> blue[i];

  scanf("%d\n", &m);
  red.resize(m);
  for (int i = 0; i < m; i++)
    cin >> red[i];

  int r = 0;
  for (int i = 0; i < n - 1; i++) {
    int count = 1;
    for (int j = i + 1; j < n; j++) {
      if (blue[i] == blue[j])
        ++count;
    }
    for (int k = 0; k < m; k++) {
      if (blue[i] == red[k])
        --count;
    }
    r = std::max(r, count);
  }

  printf("%d\n", r);

  return 0;
}
Problem p03408 (C++)

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

int main() {
  int N, M;

  cin >> N;
  vector<string> ao(N);

  for (int i = 0; i < N; i++) {
    cin >> ao.at(i);
  }

  cin >> M;
  vector<string> aka(M);

  for (int i = 0; i < N; i++) {
    cin >> aka.at(i);
  }

  vector<int> kazu(N);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (ao.at(i) == ao.at(j)) {
        kazu.at(i)++;
      }
    }

    for (int j = 0; j < M; j++) {
      if (ao.at(i) == aka.at(j)) {
        kazu.at(i)--;
      }
    }
  }

  int answer = 0;
  for (int i = 0; i < N; i++) {
    answer = max(answer, kazu.at(i));
  }

  cout << answer << endl;
}


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

int main() {
  int N, M;

  cin >> N;
  vector<string> ao(N);

  for (int i = 0; i < N; i++) {
    cin >> ao.at(i);
  }

  cin >> M;
  vector<string> aka(M);

  for (int i = 0; i < M; i++) {
    cin >> aka.at(i);
  }

  vector<int> kazu(N);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (ao.at(i) == ao.at(j)) {
        kazu.at(i)++;
      }
    }

    for (int j = 0; j < M; j++) {
      if (ao.at(i) == aka.at(j)) {
        kazu.at(i)--;
      }
    }
  }

  int answer = 0;
  for (int i = 0; i < N; i++) {
    answer = max(answer, kazu.at(i));
  }

  cout << answer << endl;
}
Problem p03408 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++)
    cin >> s.at(i);
  cin >> M;
  vector<string> t(N);
  for (int j = 0; j < M; j++)
    cin >> t.at(j);
  map<string, int> U;
  for (int i = 0; i < N; i++) {
    if (U.count(s.at(i))) {
      U.at(s.at(i))++;
    } else
      U[s.at(i)] = 1;
  }
  for (int i = 0; i < M; i++) {
    if (U.count(t.at(i))) {
      U.at(t.at(i))--;
    }
  }
  int ans = 0;
  for (auto p : U) {
    auto k = p.first;
    auto v = p.second;
    if (ans <= v)
      ans = v;
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++)
    cin >> s.at(i);
  cin >> M;
  vector<string> t(M);
  for (int j = 0; j < M; j++)
    cin >> t.at(j);
  map<string, int> U;
  for (int i = 0; i < N; i++) {
    if (U.count(s.at(i))) {
      U.at(s.at(i))++;
    } else
      U[s.at(i)] = 1;
  }
  for (int i = 0; i < M; i++) {
    if (U.count(t.at(i))) {
      U.at(t.at(i))--;
    }
  }
  int ans = 0;
  for (auto p : U) {
    auto k = p.first;
    auto v = p.second;
    if (ans <= v)
      ans = v;
  }
  cout << ans << endl;

  return 0;
}
Problem p03408 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char buf[100];

map<string, int> load() {
  map<string, int> dp;
  int n;
  scanf("%d\n", &n);
  while (n--) {
    scanf("%s", buf);
    dp[string(buf)]++;
  }
}

int main() {
  map<string, int> a = load();
  map<string, int> b = load();
  int ret = 0;
  for (auto x : a) {
    ret = max(ret, x.second - b[x.first]);
  }
  printf("%d\n", ret);
}


Fixed submission:
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char buf[100];

map<string, int> load() {
  map<string, int> dp;
  int n;
  scanf("%d\n", &n);
  while (n--) {
    scanf("%s", buf);
    dp[string(buf)]++;
  }
  return dp;
}

int main() {
  map<string, int> a = load();
  map<string, int> b = load();
  int ret = 0;
  for (auto x : a) {
    ret = max(ret, x.second - b[x.first]);
  }
  printf("%d\n", ret);
}
Problem p03408 (C++)

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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  vector<string> t(m);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t.at(i);
  }
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    mp[s.at(i)]++;
  }
  for (int i = 0; i < m; i++) {
    mp[s.at(i)]--;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (ans < mp[s.at(i)]) {
      ans = mp[s.at(i)];
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  vector<string> t(m);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t.at(i);
  }
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    mp[s.at(i)]++;
  }
  for (int i = 0; i < m; i++) {
    mp[t.at(i)]--;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (ans < mp[s.at(i)]) {
      ans = mp[s.at(i)];
    }
  }
  cout << ans << endl;
}
Problem p03408 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<string> vecs(N);
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    vecs.at(i) = s;
  }

  int M;
  cin >> M;
  vector<string> vect(M);
  string t;
  for (int j = 0; j < M; j++) {
    cin >> t;
    vect.at(j) = t;
  }

  vector<int> vec = {0};
  int c = 0;
  int counts = 0;
  int countt = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (vecs.at(i) == vecs.at(j))
        counts++;
    }
    for (int k = 0; k < M; k++) {
      if (vecs.at(i) == vect.at(k))
        countt++;
    }
    if (counts > countt) {
      c = counts - countt;
      vec.push_back(c);
    } else if (counts <= countt) {
      vec.push_back(0);
    }
    counts = 0;
    countt = 0;
  }
  int Ans = 0;
  for (int i = 0; i < 100; i++) {
    if (vec.at(i + 1) > vec.at(i))
      Ans = vec.at(i + 1);
  }
  if (Ans > 0)
    cout << Ans << endl;
  else if (Ans <= 0)
    cout << 0 << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> vecs(N);
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    vecs.at(i) = s;
  }

  int M;
  cin >> M;
  vector<string> vect(M);
  string t;
  for (int j = 0; j < M; j++) {
    cin >> t;
    vect.at(j) = t;
  }

  vector<int> vec = {0};
  int c = 0;
  int counts = 0;
  int countt = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (vecs.at(i) == vecs.at(j))
        counts++;
    }
    for (int k = 0; k < M; k++) {
      if (vecs.at(i) == vect.at(k))
        countt++;
    }
    if (counts > countt) {
      c = counts - countt;
      vec.push_back(c);
    } else if (counts <= countt) {
      vec.push_back(0);
    }
    counts = 0;
    countt = 0;
  }
  int Ans = 0;
  for (int i = 0; i < N + 1; i++) {
    if (vec.at(i) > Ans)
      Ans = vec.at(i);
  }
  if (Ans > 0)
    cout << Ans << endl;
  else if (Ans <= 0)
    cout << 0 << endl;
}
Problem p03408 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  int m;
  cin >> m;
  vector<string> t(m);
  for (i = 0; i < m; i++) {
    cin >> t.at(i);
  }
  int j, ans = 0;
  for (i = 0; i < n; i++) {
    int maxi = 0;
    for (j = 0; j < n; j++) {
      if (s.at(i) == s.at(j)) {
        maxi++;
      }
    }
    for (int k = 0; k < m; k++) {
      if (s.at(i) == t.at(i)) {
        maxi--;
      }
    }
    ans = max(maxi, ans);
  }
  cout << ans;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  int m;
  cin >> m;
  vector<string> t(m);
  for (i = 0; i < m; i++) {
    cin >> t.at(i);
  }
  int j, ans = 0;
  for (i = 0; i < n; i++) {
    int maxi = 0;
    for (j = 0; j < n; j++) {
      if (s.at(i) == s.at(j)) {
        maxi++;
      }
    }
    for (int k = 0; k < m; k++) {
      if (s.at(i) == t.at(k)) {
        maxi--;
      }
    }
    ans = max(maxi, ans);
  }
  cout << ans;
}
Problem p03408 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3], n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int, int> P;

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

int main() {

  int n, m;
  map<string, int> cnt;
  cin >> n;
  string s[n + 1], t;

  rep(i, n) {
    cin >> s[i];
    cnt[s[i]]++;
  }

  cin >> m;
  rep(i, m) {
    cin >> t;
    cnt[t]--;
  }

  int ma = 0;

  rep(i, cnt.size()) { ma = max(ma, cnt[s[i]]); }
  cout << ma << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3], n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int, int> P;

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

int main() {

  int n, m;
  map<string, int> cnt;
  cin >> n;
  string s[n + 1], t;

  rep(i, n) {
    cin >> s[i];
    cnt[s[i]]++;
  }

  cin >> m;
  rep(i, m) {
    cin >> t;
    cnt[t]--;
  }

  int ma = 0;

  for (auto x : cnt) {
    ma = max(ma, x.second);
  }
  cout << ma << endl;
}
Problem p03408 (C++)

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

int main() {
  int n, m;

  cin >> n;
  vector<string> s(n);
  REP(i, n) { cin >> s[i]; }

  cin >> m;
  vector<string> t(n);
  REP(i, n) { cin >> t[i]; }

  int ans = 0;
  int res = 0;
  REP(i, n) {
    REP(j, n) {
      if (s[i] == s[j]) {
        res++;
      }
    }

    REP(j, m) {
      if (s[i] == t[j]) {
        res--;
      }
    }

    ans = max(ans, res);
    res = 0;
  }

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

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

int main() {
  int n, m;

  cin >> n;
  vector<string> s(n);
  REP(i, n) { cin >> s[i]; }

  cin >> m;
  vector<string> t(m);
  REP(i, m) { cin >> t[i]; }

  int ans = 0;
  int res = 0;
  REP(i, n) {
    REP(j, n) {
      if (s[i] == s[j]) {
        res++;
      }
    }

    REP(j, m) {
      if (s[i] == t[j]) {
        res--;
      }
    }

    ans = max(ans, res);
    res = 0;
  }

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, M;
  int sum = 0;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }

  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }

  for (int i = 0; i < N; i++) {
    int count = 0;
    string temp = s.at(i);
    for (int j = 0; j < N; j++) {
      if (temp == s.at(j)) {
        count++;
      }
    }
    for (int k = 0; k < M; k++) {
      if (temp == s.at(k)) {
        count++;
      }
    }
    sum = max(sum, count);
  }
  cout << sum << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, M;
  int sum = 0;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }

  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }

  for (int i = 0; i < N; i++) {
    int count = 0;
    string temp = s.at(i);
    for (int j = 0; j < N; j++) {
      if (temp == s.at(j)) {
        count++;
      }
    }
    for (int k = 0; k < M; k++) {
      if (temp == t.at(k)) {
        count--;
      }
    }
    sum = max(sum, count);
  }
  cout << sum << endl;
  return 0;
}
Problem p03408 (C++)

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

using namespace std;

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  int a = 0;
  for (int i = 0; i < N; i++) {
    int b = 0;
    for (int j = 0; j < N; j++) {
      if (s.at(j) == s.at(i)) {
        b++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (t.at(i) == s.at(i)) {
        b--;
      }
    }
    if (a < b) {
      a = b;
    }
  }
  cout << a;
  return 0;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  int a = 0;
  for (int i = 0; i < N; i++) {
    int b = 0;
    for (int j = 0; j < N; j++) {
      if (s.at(j) == s.at(i)) {
        b++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (t.at(j) == s.at(i)) {
        b--;
      }
    }
    if (a < b) {
      a = b;
    }
  }
  cout << a;
  return 0;
}
Problem p03408 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  int m;
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < n; i++) {
    cin >> t.at(i);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int temp = 0;
    for (int j = 0; j < n; j++)
      if (s.at(i) == s.at(j))
        temp++;
    for (int j = 0; j < m; j++)
      if (s.at(i) == t.at(j))
        temp--;
    ans = max(ans, temp);
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  int m;
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t.at(i);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int temp = 0;
    for (int j = 0; j < n; j++)
      if (s.at(i) == s.at(j))
        temp++;
    for (int j = 0; j < m; j++)
      if (s.at(i) == t.at(j))
        temp--;
    ans = max(ans, temp);
  }
  cout << ans << endl;
}
Problem p03408 (C++)

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

int main() {
  // 入力値取得
  int N;
  cin >> N;
  vector<string> str_blue(N);
  for (int i = 0; i < N; i++) {
    cin >> str_blue.at(i);
  }

  int M;
  cin >> M;
  vector<string> str_red(M);
  for (int i = 0; i < M; i++) {
    cin >> str_red.at(i);
  }

  // 勘定
  int max = 0;
  // 青カード
  for (int i = 0; i < N; i++) {
    int counter = 0;
    // 青カード比較
    for (int j = 0; j < N; j++) {
      if (str_blue.at(i) == str_blue.at(j)) {
        counter++;
      }
    }
    // 赤カード比較
    for (int j = 0; j < M; j++) {
      if (str_blue.at(i) == str_red.at(j)) {
        counter--;
      }
    }

    if (counter > max)
      max = counter;
  }

  // 赤カード
  for (int i = 0; i < N; i++) {
    int counter = 0;
    // 青カード比較
    for (int j = 0; j < N; j++) {
      if (str_red.at(i) == str_blue.at(j)) {
        counter++;
      }
    }
    // 赤カード比較
    for (int j = 0; j < M; j++) {
      if (str_red.at(i) == str_red.at(j)) {
        counter--;
      }
    }

    if (counter > max)
      max = counter;
  }

  cout << max << endl;

  // 確認
  /*
  cout << N << ' ' << M << endl;
  for(int i=0; i<N; i++){
    cout << str_blue.at(i) << ' ';
  }
  cout << endl;
  for(int i=0; i<M; i++){
    cout << str_red.at(i) << ' ';
  }
  cout << endl;
  */
}


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

int main() {
  // 入力値取得
  int N;
  cin >> N;
  vector<string> str_blue(N);
  for (int i = 0; i < N; i++) {
    cin >> str_blue.at(i);
  }

  int M;
  cin >> M;
  vector<string> str_red(M);
  for (int i = 0; i < M; i++) {
    cin >> str_red.at(i);
  }

  // 勘定
  int max = 0;
  // 青カード
  for (int i = 0; i < N; i++) {
    int counter = 0;
    // 青カード比較
    for (int j = 0; j < N; j++) {
      if (str_blue.at(i) == str_blue.at(j)) {
        counter++;
      }
    }
    // 赤カード比較
    for (int j = 0; j < M; j++) {
      if (str_blue.at(i) == str_red.at(j)) {
        counter--;
      }
    }

    if (counter > max)
      max = counter;
  }

  // 赤カード
  for (int i = 0; i < M; i++) {
    int counter = 0;
    // 青カード比較
    for (int j = 0; j < N; j++) {
      if (str_red.at(i) == str_blue.at(j)) {
        counter++;
      }
    }
    // 赤カード比較
    for (int j = 0; j < M; j++) {
      if (str_red.at(i) == str_red.at(j)) {
        counter--;
      }
    }

    if (counter > max)
      max = counter;
  }

  cout << max << endl;

  // 確認
  /*
  cout << N << ' ' << M << endl;
  for(int i=0; i<N; i++){
    cout << str_blue.at(i) << ' ';
  }
  cout << endl;
  for(int i=0; i<M; i++){
    cout << str_red.at(i) << ' ';
  }
  cout << endl;
  */
}
Problem p03408 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <tuple>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  map<string, int> mp1, mp2;
  rep(i, n) cin >> s[i], mp1[s[i]]++;
  int m;
  cin >> m;
  vector<string> t(n);
  rep(i, m) cin >> t[i], mp2[t[i]]++;
  vector<int> v;
  v.push_back(0);
  for (auto &i : mp1) {
    if (i.second > mp2[i.first]) {
      v.push_back(i.second - mp2[i.first]);
    }
  }
  cout << *max_element(all(v)) << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <tuple>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  map<string, int> mp1, mp2;
  rep(i, n) cin >> s[i], mp1[s[i]]++;
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i], mp2[t[i]]++;
  vector<int> v;
  v.push_back(0);
  for (auto &i : mp1) {
    if (i.second > mp2[i.first]) {
      v.push_back(i.second - mp2[i.first]);
    }
  }
  cout << *max_element(all(v)) << endl;
}
Problem p03408 (C++)

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

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

  vector<string> s(N);
  vector<string> c(N);
  vector<int> sum(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    bool flg = false;
    cin >> s.at(i);
    for (int j = 0; j < N; j++) {
      if (c.at(j) == s.at(i)) {
        sum.at(j)++;
        flg = true;
        break;
      }
    }
    if (flg == false) {
      c.at(i) = s.at(i);
      sum.at(i) += 1;
    }
  }

  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
    for (int j = 0; j < M; j++) {
      if (c.at(j) == t.at(i)) {
        sum.at(j)--;
        break;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (ans < sum.at(i)) {
      ans = sum.at(i);
    }
  }

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

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

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

  vector<string> s(N);
  vector<string> c(N);
  vector<int> sum(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    bool flg = false;
    cin >> s.at(i);
    for (int j = 0; j < N; j++) {
      if (c.at(j) == s.at(i)) {
        sum.at(j)++;
        flg = true;
        break;
      }
    }
    if (flg == false) {
      c.at(i) = s.at(i);
      sum.at(i) += 1;
    }
  }

  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
    for (int j = 0; j < N; j++) {
      if (c.at(j) == t.at(i)) {
        sum.at(j)--;
        break;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (ans < sum.at(i)) {
      ans = sum.at(i);
    }
  }

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

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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i];

  int ans = 0;
  rep(i, n) {
    int score = 0;
    rep(j, n) {
      if (s[i] == s[j])
        score++;
    }
    rep(j, n) {
      if (s[i] == t[j])
        score--;
    }
    ans = max(score, ans);
  }
  cout << ans << 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, m;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i];

  int ans = 0;
  rep(i, n) {
    int score = 0;
    rep(j, n) {
      if (s[i] == s[j])
        score++;
    }
    rep(j, m) {
      if (s[i] == t[j])
        score--;
    }
    ans = max(score, ans);
  }
  cout << ans << endl;
  return 0;
}
Problem p03408 (C++)

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

using namespace std;

int main() {
  map<string, int> msi;
  int m, n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    msi[s]++;
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    string s;
    cin >> s;
    msi[s]--;
  }
  int r = 0;
  for (auto it = msi.begin(); it != msi.end(); ++it)
    r = max(r, it->second);
  return r;
}

Fixed submission:
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  map<string, int> msi;
  int m, n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    msi[s]++;
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    string s;
    cin >> s;
    msi[s]--;
  }
  int r = 0;
  for (auto it = msi.begin(); it != msi.end(); ++it)
    r = max(r, it->second);
  cout << r;
  return 0;
}
Problem p03408 (C++)

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

int main() {
  int N, M, f, g;
  cin >> N;
  vector<string> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  g = 0;
  f = 0;
  cin >> M;
  vector<string> b(M);
  for (int i = 0; i < M; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (a[i] == a[j]) {
        f++;
      }
    }
    for (int j = 0; j < N; j++) {
      if (a[i] == b[j]) {
        f--;
      }
    }
    g = max(g, f);
    f = 0;
  }
  cout << g << endl;
}


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

int main() {
  int N, M, f, g;
  cin >> N;
  vector<string> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  g = 0;
  f = 0;
  cin >> M;
  vector<string> b(M);
  for (int i = 0; i < M; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (a[i] == a[j]) {
        f++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (a[i] == b[j]) {
        f--;
      }
    }
    g = max(g, f);
    f = 0;
  }
  cout << g << endl;
}
Problem p03408 (C++)

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

using namespace std;

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

  int m;
  cin >> m;
  string t[n];

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (int j = i; j < n; j++) {
      if (s[i] == s[j])
        count++;
    }
    for (int k = 0; k < m; k++) {
      if (s[i] == t[k])
        count--;
    }
    if (ans < count)
      ans = count;
  }
  cout << ans << endl;
}


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

using namespace std;

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

  int m;
  cin >> m;
  string t[m];

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (int j = i; j < n; j++) {
      if (s[i] == s[j])
        count++;
    }
    for (int k = 0; k < m; k++) {
      if (s[i] == t[k])
        count--;
    }
    if (ans < count)
      ans = count;
  }
  cout << ans << endl;
}
Problem p03408 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, m;
  int count = 1;
  int ans = 0;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      for (int j = 0; j < m; j++) {
        if (t[j] == s[i]) {
          count--;
        }
      }
      if (ans < count) {
        ans = count;
      }
    }
    if (s[i] == s[i + 1]) {
      count++;
    } else {
      for (int j = 0; j < m; j++) {
        if (t[j] == s[i]) {
          count--;
        }
      }
      if (count > ans) {
        ans = count;
      }
      count = 1;
    }
  }
  if (ans < 0) {
    ans = 0;
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, m;
  int count = 1;
  int ans = 0;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      for (int j = 0; j < m; j++) {
        if (t[j] == s[i]) {
          count--;
        }
      }
      if (ans < count) {
        ans = count;
      }
    } else if (s[i] == s[i + 1]) {
      count++;
    } else {
      for (int j = 0; j < m; j++) {
        if (t[j] == s[i]) {
          count--;
        }
      }
      if (count > ans) {
        ans = count;
      }
      count = 1;
    }
  }
  if (ans < 0) {
    ans = 0;
  }
  cout << ans << endl;
}
Problem p03408 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <map>
#include <string>
#include <vector>
int main() {
  int N, M;
  std::cin >> N;
  std::vector<std::string> s(N);
  std::map<std::string, int> st;
  for (int i = 0; i < N; i++) {
    std::cin >> s[i];
    if (st.find(s[i]) == std::end(st)) {
      st.insert(std::make_pair(s[i], 1));
    } else {
      st[s[i]]++;
    }
  }

  std::cin >> M;
  std::vector<std::string> t(M);
  for (int i = 0; i < M; i++) {
    std::cin >> t[i];
    if (st.find(t[i]) == std::end(st)) {
      st.insert(std::make_pair(t[i], -1));
    } else {
      st[s[i]]--;
    }
  }

  int ans = -10000000;
  for (auto &a : st) {
    if (a.second > ans) {
      ans = a.second;
    }
  }

  if (ans < 0)
    ans = 0;

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

  return 0;
}

Fixed submission:
#include <iostream>
#include <map>
#include <string>
#include <vector>
int main() {
  int N, M;
  std::cin >> N;
  std::vector<std::string> s(N);
  std::map<std::string, int> st;
  for (int i = 0; i < N; i++) {
    std::cin >> s[i];
    if (st.find(s[i]) == std::end(st)) {
      st.insert(std::make_pair(s[i], 1));
    } else {
      st[s[i]]++;
    }
  }

  std::cin >> M;
  std::vector<std::string> t(M);
  for (int i = 0; i < M; i++) {
    std::cin >> t[i];
    if (st.find(t[i]) == std::end(st)) {
      st.insert(std::make_pair(t[i], -1));
    } else {
      st[t[i]]--;
    }
  }

  int ans = -10000000;
  for (auto &a : st) {
    if (a.second > ans) {
      ans = a.second;
    }
  }

  if (ans < 0)
    ans = 0;

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

  return 0;
}
Problem p03408 (C++)

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

int main() {
  int n, m, i, j;
  cin >> n;
  string s[n];
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> m;
  string t[m];
  for (i = 0; i < m; i++) {
    cin >> t[i];
  }
  string p[n + 1];
  int cnt = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < cnt; j++) {
      if (s[i] == p[j]) {
        j++;
        break;
      }
    }
    if (s[i] != p[j - 1]) {
      p[cnt] = s[i];
      cnt++;
    }
  }
  int score[cnt];
  for (i = 0; i < cnt; i++) {
    score[i] = 0;
    for (j = 0; j < n; j++) {
      if (p[i] == s[j])
        score[i]++;
    }
    for (j = 0; j < m; j++) {
      if (p[i] == t[j])
        score[i]--;
    }
  }
  int ma = 0;
  for (i = 0; i < cnt; i++) {
    ma = max(ma, score[i]);
  }
  cout << ma;
}

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

int main() {
  int n, m, i, j;
  cin >> n;
  string s[n];
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> m;
  string t[m];
  for (i = 0; i < m; i++) {
    cin >> t[i];
  }
  string p[n + 1];
  int cnt = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < cnt; j++) {
      if (s[i] == p[j]) {
        j++;
        break;
      }
    }
    if (j == 0)
      j++;
    if (s[i] != p[j - 1]) {
      p[cnt] = s[i];
      cnt++;
    }
  }
  int score[cnt];
  for (i = 0; i < cnt; i++) {
    score[i] = 0;
    for (j = 0; j < n; j++) {
      if (p[i] == s[j])
        score[i]++;
    }
    for (j = 0; j < m; j++) {
      if (p[i] == t[j])
        score[i]--;
    }
  }
  int ma = 0;
  for (i = 0; i < cnt; i++) {
    ma = max(ma, score[i]);
  }
  cout << ma;
}
Problem p03408 (C++)

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

int main() {
  int N, M;
  string s[55], t[55];
  set<string> kinds;
  cin >> N;
  REP(i, N) cin >> s[i], kinds.insert(s[i]);
  cin >> M;
  REP(i, M) cin >> t[i], kinds.insert(t[i]);

  int now_max = 0;
  for (string c : kinds) {
    int now_get = count(&s[0], &s[N], c) - count(&t[0], &t[M], c);
    now_max = max(now_max, now_get);
  }

  cout << now_max << endl;

  return 0;
}


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

int main() {
  int N, M;
  string s[110], t[110];
  set<string> kinds;
  cin >> N;
  REP(i, N) cin >> s[i], kinds.insert(s[i]);
  cin >> M;
  REP(i, M) cin >> t[i], kinds.insert(t[i]);

  int now_max = 0;
  for (string c : kinds) {
    int now_get = count(&s[0], &s[N], c) - count(&t[0], &t[M], c);
    now_max = max(now_max, now_get);
  }

  cout << now_max << endl;

  return 0;
}
Problem p03408 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  int m;
  cin >> m;
  vector<string> t(n);
  rep(i, m) cin >> t[i];
  int ans_score = 0;
  map<string, int> count;

  for (auto s_ : s) {
    if (count.find(s_) != count.end())
      count[s_]++;
    else
      count[s_] = 1;
  }

  for (auto t_ : t) {
    if (count.find(t_) != count.end())
      count[t_]--;
    else
      count[t_] = -1;
  }

  int ans = 0;
  for (pair<string, int> p : count) {
    ans = max(ans, p.second);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i];
  int ans_score = 0;
  map<string, int> count;

  for (auto s_ : s) {
    if (count.find(s_) != count.end())
      count[s_]++;
    else
      count[s_] = 1;
  }

  for (auto t_ : t) {
    if (count.find(t_) != count.end())
      count[t_]--;
    else
      count[t_] = -1;
  }

  int ans = 0;
  for (pair<string, int> p : count) {
    ans = max(ans, p.second);
  }
  cout << ans << endl;
  return 0;
}
Problem p03408 (Python)

Buggy submission (status: Runtime Error):
ans = 0
n = int(input())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
for i in range(m):
    if red[m] in blue:
        blue.remove(red[m])
for j in list(set(blue)):
    if blue.count(j) > ans:
        ans = blue.count(j)
print(ans)


Fixed submission:
ans = 0
n = int(input())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
for i in range(m):
    if red[i] in blue:
        blue.remove(red[i])
for j in list(set(blue)):
    if blue.count(j) > ans:
        ans = blue.count(j)
print(ans)
Problem p03408 (Python)

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

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(counter.values(), 0))


Fixed submission:
n = int(input())
s = list()

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(max(counter.values()), 0))
Problem p03408 (Python)

Buggy submission (status: Runtime Error):
import collections

bluecard = []
redcard = []

n = int(input())
for i in range(n):
    bluecard.append(input())

m = int(input())
for i in range(m):
    redcard.append(input())

blue_count = collections.Counter(bluecard)
red_count = collections.Counter(redcard)
diff = blue_count - red_count
if len(diff.keys) > 0:
    print(diff.most_common(1)[0][1])
else:
    print(0)


Fixed submission:
import collections

bluecard = []
redcard = []

n = int(input())
for i in range(n):
    bluecard.append(input())

m = int(input())
for i in range(m):
    redcard.append(input())

blue_count = collections.Counter(bluecard)
red_count = collections.Counter(redcard)
diff = blue_count - red_count
if len(diff.keys()) > 0:
    print(diff.most_common(1)[0][1])
else:
    print(0)
Problem p03408 (Python)

Buggy submission (status: Runtime Error):
from collections import defaultdict

n = int(input())
d = defaultdict()
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)


Fixed submission:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)
Problem p03408 (Python)

Buggy submission (status: Runtime Error):
from collections import defaultdict

d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
for _ in range(int(input())):
    d[input()] -= 1
print(max(0, d.values()))


Fixed submission:
from collections import defaultdict

d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
for _ in range(int(input())):
    d[input()] -= 1
print(max(0, max(d.values())))
Problem p03408 (Python)

Buggy submission (status: Runtime Error):
def main(n, s: list, m, t: list):
    choices = set(s + t)

    ans = [0]

    for choice in choices:
        ans_t = 0
        for _s in s:
            if choice == _s:
                ans_t += 1
        for _t in t:
            if choice == _t:
                ans_t -= 1

        ans.append(ans_t)

    print(max(ans))


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(n)]

    main(n, s, m, t)


Fixed submission:
def main(n, s: list, m, t: list):
    choices = set(s + t)

    ans = [0]

    for choice in choices:
        ans_t = 0
        for _s in s:
            if choice == _s:
                ans_t += 1
        for _t in t:
            if choice == _t:
                ans_t -= 1

        ans.append(ans_t)

    print(max(ans))


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(m)]

    main(n, s, m, t)
Problem p03408 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(n)]

res = 0
for u in ss:
    tmp = ss.count(u) - tt.count(u)
    res = max(res, tmp)
print(res)


Fixed submission:
n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(m)]

res = 0
for u in ss:
    tmp = ss.count(u) - tt.count(u)
    res = max(res, tmp)
print(res)
Problem p03408 (C++)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)

#define All(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i];

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    for (int j = 0; j < n; j++)
      if (s[i] == s[j])
        tmp++;
    for (int j = 0; j < n; j++)
      if (s[i] == t[j])
        tmp--;
    ans = max(ans, tmp);
  }
  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++)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)

#define All(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i];

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    for (int j = 0; j < n; j++)
      if (s[i] == s[j])
        tmp++;
    for (int j = 0; j < m; j++)
      if (s[i] == t[j])
        tmp--;
    ans = max(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}
Problem p03408 (Python)

Buggy submission (status: Runtime Error):
dict_ = dict()
[
    exec("dict_['{0}'] = dict_.get('{0}', 0) + 1".format(input()))
    for _ in range(int(input()))
]
[
    exec("dict_['{0}'] = dict_.get('{0}', 0) - 1".format(input()))
    for _ in range(int(input()))
]
print(max(*dict_.values(), 0))


Fixed submission:
dict_ = dict()
[
    exec("dict_['{0}'] = dict_.get('{0}', 0) + 1".format(input()))
    for _ in range(int(input()))
]
[
    exec("dict_['{0}'] = dict_.get('{0}', 0) - 1".format(input()))
    for _ in range(int(input()))
]
print(max(max(dict_.values()), 0))
Problem p03408 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  int m;
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; ++i) {
    cin >> t[i];
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  int cnt = 0;
  int i, j, bi, bj;
  i = j = bi = bj = 0;

  int sum = 0;
  while (bi < s.size()) {
    if (s[i] == s[bi]) {
      i++;
      continue;
    }
    int cnt = 0;
    for (int k = 0; k < t.size(); ++k) {
      if (s[bi] == t[k])
        cnt++;
    }
    if (i - bi > cnt)
      sum = max(sum, i - bi - cnt);
    bi = i;
  }
  cout << sum << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  int m;
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; ++i) {
    cin >> t[i];
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  int cnt = 0;
  int i, j, bi, bj;
  i = j = bi = bj = 0;

  int sum = 0;
  while (bi < s.size()) {
    if (i < s.size() && s[i] == s[bi]) {
      i++;
      continue;
    }
    int cnt = 0;
    for (int k = 0; k < t.size(); ++k) {
      if (s[bi] == t[k])
        cnt++;
    }
    if (i - bi > cnt)
      sum = max(sum, i - bi - cnt);
    bi = i;
  }
  cout << sum << endl;

  return 0;
}
Problem p03408 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i); i < (n); i++)

int main() {
  int n, m, ans = 0, c;
  string s[100], t[100];
  cin >> n;
  rep(i, n) cin >> s[i];
  cin >> m;
  rep(i, m) cin >> t[i];
  rep(i, n) {
    c = 0;
    rep(j, n) if (s[i] == s[j]) c++;
    rep(j, m) if (s[i] == t[j]) c--;
    ans = max(ans, c);
  }
  cout << ans << endl;
}

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

int main() {
  int n, m, ans = 0, c;
  string s[100], t[100];
  cin >> n;
  rep(i, n) cin >> s[i];
  cin >> m;
  rep(i, m) cin >> t[i];
  rep(i, n) {
    c = 0;
    rep(j, n) if (s[i] == s[j]) c++;
    rep(j, m) if (s[i] == t[j]) c--;
    ans = max(ans, c);
  }
  cout << ans << endl;
}
Problem p03408 (C++)

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

int main() {
  int N, M;
  vector<string> blue(N), red(100);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int count = 0;
    for (int j = 0; j < N; j++) {
      if (blue.at(j) == blue.at(i)) {
        count++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (red.at(j) == blue.at(i)) {
        count--;
      }
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
}

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

int main() {
  int N, M;
  vector<string> blue(100), red(100);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int count = 0;
    for (int j = 0; j < N; j++) {
      if (blue.at(j) == blue.at(i)) {
        count++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (red.at(j) == blue.at(i)) {
        count--;
      }
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
}
Problem p03408 (C++)

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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  cin >> m;
  vector<string> t(n);
  for (int i = 0; i < m; i++) {
    cin >> t.at(i);
  }
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (s.at(i) == s.at(j)) {
        ans.at(i)++;
      }
    }
    for (int j = 0; j < m; j++) {
      if (s.at(i) == t.at(j)) {
        ans.at(i)--;
      }
    }
  }
  sort(ans.begin(), ans.end());
  if (ans.at(n - 1) > 0) {
    cout << ans.at(n - 1) << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t.at(i);
  }
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (s.at(i) == s.at(j)) {
        ans.at(i)++;
      }
    }
    for (int j = 0; j < m; j++) {
      if (s.at(i) == t.at(j)) {
        ans.at(i)--;
      }
    }
  }
  sort(ans.begin(), ans.end());
  if (ans.at(n - 1) > 0) {
    cout << ans.at(n - 1) << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}