alexjercan/bugnet huggingface dataset:
Problem p00064 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int main(void) {
  string s;

  int total = 0;

  while (cin >> s) {
    replace_if(
        s.begin(), s.end(),
        [](char c) { return isalpha(c) || c == '.' || c == '_' || c == '\\''; },
        ' ');

    istringstream iss(s);
    int num;
    while (iss >> num) {
      total += num;
    }
  }

  cout << total << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

// string HOGE(".!\\"#&%&'()*+,-/:;<=>?@[\\\\]^_`{|}~"); // ok
// string HOGE(".!\\"#&%&'()*+,-/:"); // bad
// string HOGE(";<=>?@[\\\\]^_`{|}~"); // bad

// string HOGE(".!\\"#&%&'"); // bad
// string HOGE("()*+,-/:;<=>?@[\\\\"); // bad
// string HOGE("]^_`{|}~"); // bad

// string HOGE(".!\\"#&%&'()*+,-/:;<=>?@[\\\\"); // bad
// string HOGE("()*+,-/:;<=>?@[\\\\]^_`{|}~"); // bad

// string HOGE(".!\\"#&%&'()*,-/:;<=>?@[\\\\]^_`{|}~"); // ok (no +)

// string HOGE(".!\\"#&%&'()*+,-/:;<=>?@[\\\\]^_"); // ok -5

// included '_'

// string HOGE("_.!\\"#&%&'()*+,-/:;<=>?"); // ok more -5
// string HOGE("_.!\\"#&%&'()*+,-/:"); // ok more -5
// string HOGE("_.!\\"#&%"); // ok more -5
// string HOGE("_.!"); // bad
// string HOGE("_.!\\"#&%"); // bad
// string HOGE("_.!\\"#&%&'()"); // ok
// string HOGE("_.!\\"#&%&'("); // ok
// string HOGE("_.!\\"#&%&'"); // ok

// string HOGE("_'"); // ok!!!

// included '_' and '''

int main(void) {
  string s;

  int total = 0;

  int hoge = 0;

  while (cin >> s) {
    for (auto c : s) {
      if (c == '_') {
        hoge |= 1;
      }
      if (c == '\\'') {
        hoge |= 2;
      }
    }

    replace_if(
        s.begin(), s.end(),
        [](char c) { return isalpha(c) || c == '.' || c == '_' || c == '\\''; },
        ' ');

    istringstream iss(s);
    int num;
    while (iss >> num) {
      total += num;
    }
  }

  if (hoge == 3) {
    return 1;
  }

  cout << total << endl;

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

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

string sentence;
typedef string::const_iterator State;

int parse(State &it) {
  int ret = 0;
  while (isdigit(*it)) {
    ret = ret * 10;
    ret = ret + *it - '0';
    it++;
  }
  return ret;
}

int main(void) {
  int sum = 0;
  while (cin >> sentence) {
    for (State it = sentence.begin(); it != sentence.end(); it++) {
      if (isdigit(*it)) {
        sum += parse(it);
        it--;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Error: 0

Fixed submission:

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

string sentence;
typedef string::const_iterator State;

int parse(State &it) {
  int ret = 0;
  while (isdigit(*it)) {
    ret = ret * 10;
    ret = ret + *it - '0';
    it++;
  }
  return ret;
}

int main(void) {
  int sum = 0;
  while (cin >> sentence) {
    for (State it = sentence.begin(); it != sentence.end(); it++) {
      if (isdigit(*it)) {
        sum += parse(it);
      }
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p00064 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
#include <string>

int main() {
  std::string s;
  int sum = 0, d = 0;
  while (std::cin >> s) {
    if (!s.compare("abc"))
      break;
    if (std::cin.eof())
      break;
    for (int i = s.length() - 1; i >= 0; i--) {
      d = 0;
      // ツづつアツづ慊づ堕アツつッツづァツづェツづゥツつゥツづーツ板サツ津ィツつオツづつ「ツづ慊つキツ。
      int k = i;
      for (int j = i; j >= 0; j--) {
        if (s[j] >= '0' && s[j] <= '9')
          d += (static_cast<int>(s[j] - '0') * pow(10, k - j)), i--;
        else {
          break;
        }
      }
      sum += d;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <math.h>
#include <string>
int main() {
  std::string s;
  int sum = 0, d = 0;
  while (std::cin >> s) {
    if (std::cin.eof())
      break;
    for (int i = s.length() - 1; i != -1; i--) {
      d = 0;
      // ツづつアツづ慊づ堕アツつッツづァツづェツづゥツつゥツづーツ板サツ津ィツつオツづつ「ツづ慊つキツ。
      int k = i;
      for (int j = i; j != -1; j--) {
        if (s[j] >= '0' && s[j] <= '9')
          d += (static_cast<int>(s[j] - '0') * pow(10, k - j)), i--;
        else {
          break;
        }
      }
      sum += d;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}
Problem p00064 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;

int main() {
  int n;
  int ans = 0;

  while (~scanf("%*[^0-9]%d", &n)) {
    ans += n;
  }

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

  return (0);
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  int n;
  int ans = 0;

  while (scanf("%[0-9]", &n) != EOF) {
    ans += n;
  }

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

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

#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main(int argc, char **argv) {
  int secretNum = 0;
  string str;
  while (getline(cin, str)) {
    for (unsigned int i = 0; i < str.size(); ++i) {
      if (str[i] < '0' || '9' < str[i]) {
        str[i] = ' ';
      }
    }
    stringstream ss(str);
    int j;
    while (ss >> j) {
      secretNum += j;
    }
  }
  cout << secretNum << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <ctype.h>
#include <iostream>
#include <sstream>
using namespace std;

int main() {
  string str;
  int d, sum = 0, len;

  while (1) {
    getline(cin, str);
    if (cin.eof())
      break;
    len = str.length();

    for (int i = 0; i < len; i++) {
      if (isalpha((int)str[i]) || str[i] == '.')
        str.replace(i, 1, " ");
    }

    istringstream ss(str);

    while (!ss.eof()) {
      ss >> d;
      sum += d;
      d = 0;
    }
  }
  cout << sum << endl;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, sum = 0;
  char c;
  while ((c = getchar()) != EOF) {
    if (c >= '0' && c <= '9') {
      n *= 10;
      n += (c - ('0'));
    } else {
      sum += n;
      n = 0;
    }
  }
  cout << sum << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, sum = 0;
  char c;
  while ((c = getchar())) {
    if (c >= '0' && c <= '9') {
      n *= 10;
      n += (c - ('0'));
    } else {
      sum += n;
      n = 0;
    }
  }
  cout << sum << endl;
}
Problem p00064 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1e9;

int main() {
  string s;
  int cnt = 0;
  while (cin >> s) {

    string tmp = "";
    for (int i = 0; i < s.size(); i++) {
      if ('0' <= s[i] && s[i] <= '9')
        tmp += s[i];
      else {
        if (tmp.size() != 0) {
          int a = stoi(tmp);
          cnt += a;
        }
        tmp = "";
      }
    }
    if (tmp.size() != 0) {
      int a = stoi(tmp);
      cnt += a;
    }
  }
  cout << cnt << endl;

  return 0;
}

// EOF

Error: 0
100
17
6


Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1e9;

int main() {
  string s;
  int cnt = 0;
  while (cin >> s) {

    string tmp = "";
    for (int i = 0; i < s.size(); i++) {
      if ('0' <= s[i] && s[i] <= '9')
        tmp += s[i];
      else {
        if (tmp.size() != 0) {
          cerr << tmp << endl;
          int a = stoi(tmp);
          cnt += a;
        }
        tmp = "";
      }
    }
    if (tmp.size() != 0) {
      cerr << tmp << endl;
      int a = stoi(tmp);
      cnt += a;
    }
  }
  cout << cnt << endl;

  return 0;
}

// EOF
Problem p00065 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  int a, b;
  string str;
  map<int, int> pre_m, post_m;
  map<int, int>::iterator mp;
  while (1) {
    getline(cin, str);
    if (str == "")
      break;
    string tmp = "";
    int i = 0;
    for (; i < str.size(); i++)
      if (str[i] == ',')
        break;
      else
        tmp += str[i];
    int TMP = atoi(tmp.c_str());
    if (pre_m.find(TMP) == pre_m.end())
      pre_m.insert(pair<int, int>(TMP, 1));
    else
      pre_m[TMP]++;
  }
  while (scanf("%d,%d", &a, &b) != EOF) {
    if (pre_m.find(a) == pre_m.end())
      continue;
    if (post_m.find(a) != post_m.end())
      post_m[a]++;
    else
      post_m[a] = pre_m[a] + 1;
  }
  for (mp = post_m.begin(); mp != post_m.end(); mp++)
    cout << mp->first << ' ' << mp->second << '\\n';
}

Error: TLE

Fixed submission:

#include <iostream>
#include <iterator>
#include <map>
using namespace std;
int main() {
  multimap<int, int> m;
  multimap<int, int>::iterator mp;
  int a, b;
  char ch;
  while (cin >> a >> ch >> b)
    m.insert(pair<int, int>(a, b));
  for (mp = m.begin(); mp != m.end(); mp++) {
    int tmp = mp->first;
    int sum = distance(m.lower_bound(tmp), m.upper_bound(tmp));
    if (sum >= 2)
      cout << tmp << ' ' << sum << endl;
    mp = m.upper_bound(tmp);
  }
}
Problem p00065 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
bool end;
map<int, int> one, two;
int getline() {
  char res[1050];
  int p = 0;
  while (true) {
    char c = getchar();
    if (c == EOF)
      end = true;
    if (c == '\\n' || c == EOF) {
      if (p == 0)
        return -1;
      sscanf(res, "%d,%*d", &p);
      return p;
    }
    res[p++] = c;
  }
}
int main() {
  while (!end) {
    int p = getline();
    if (p == -1)
      swap(one, two);
    else {
      two[p]++;
    }
  }
  map<int, int>::iterator it = one.begin();
  while (it != one.end()) {
    if (two[it->first]) {
      cout << it->first << " " << (it->second) + two[it->first] << endl;
    }
    it++;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

vector<int> inputs;
map<int, int> one, two;
int main() {
  int x, n;
  while (~scanf("%d,%*d", &x)) {
    inputs.push_back(x);
  }
  for (int i = 0; i < inputs.size(); i++) {
    if (i < inputs.size() / 2)
      one[inputs[i]]++;
    else
      two[inputs[i]]++;
  }
  map<int, int>::iterator it = one.begin();
  while (it != one.end()) {
    if (two[it->first]) {
      cout << (it->first) << " " << (it->second) + two[it->first] << endl;
    }
    it++;
  }
  return inputs.size() % 2;
}
Problem p00065 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(void) {

  priority_queue<int, vector<int>, greater<int>> data, data2;
  int sum, cnt = 0;
  int min = -1, max = -1;
  int sta, w;
  string inp, num("");
  bool f = true;

  while (1) {
    inp = getchar();
    if (inp == "\\n") {
      f = true;
      inp = getchar();
      if (inp == "\\n")
        break;
    }
    if (inp == ",") {
      sta = num.length() - 1;
      w = 1;
      sum = 0;
      for (int j = sta; j >= 0; j--) {
        sum += w * (num[j] - '0');
        w *= 10;
      }
      data.push(sum);
      if (min == -1)
        min = sum, max = sum;
      else {
        if (min > sum)
          min = sum;
        if (max < sum)
          max = sum;
      }
      num = ("");
      f = false;
    }
    if (f) {
      num += inp;
    }
  }

  while (cin >> inp) {
    num = ("");
    for (int j = 0;; j++) {
      if (inp[j] == ',') {
        break;
      }
      num += inp[j];
    }
    sta = num.length() - 1;
    w = 1;
    sum = 0;
    for (int j = sta; j >= 0; j--) {
      sum += w * (num[j] - '0');
      w *= 10;
    }
    data2.push(sum);
  }

  while (!data.empty() && !data2.empty()) {
    if (data.top() == data2.top()) {
      sum = data.top();
      cnt = 0;
      while (!data.empty()) {
        if (data.top() != sum)
          break;
        cnt++;
        data.pop();
      }
      while (!data2.empty()) {
        if (data2.top() != sum)
          break;
        cnt++;
        data2.pop();
      }
      cout << sum << " " << cnt << endl;
    } else if (data.top() < data2.top())
      data.pop();
    else
      data2.pop();
  }

  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void) {

  int data[2][1619000] = {0};
  int sum;
  int min = -1, max = -1;
  int sta, w;
  string inp, num("");
  bool f;

  while (1) {
    inp = getchar();
    if (inp == "\\n") {
      f = true;
      inp = getchar();
      if (inp == "\\n")
        break;
    }
    if (inp == ",") {
      sta = num.length() - 1;
      w = 1;
      sum = 0;
      for (int j = sta; j >= 0; j--) {
        sum += w * (num[j] - '0');
        w *= 10;
      }
      data[0][sum]++;
      if (min == -1)
        min = sum, max = sum;
      else {
        if (min > sum)
          min = sum;
        if (max < sum)
          max = sum;
      }
      num = ("");
      f = false;
    }
    if (f) {
      num += inp;
    }
  }

  while (cin >> inp) {
    num = ("");
    for (int j = 0;; j++) {
      if (inp[j] == ',') {
        break;
      }
      num += inp[j];
    }
    sta = num.length() - 1;
    w = 1;
    sum = 0;
    for (int j = sta; j >= 0; j--) {
      sum += w * (num[j] - '0');
      w *= 10;
    }
    data[1][sum]++;
  }

  for (int j = min; j <= max; j++) {
    if (data[0][j] > 0 && data[1][j] > 0) {
      cout << j << " " << data[0][j] + data[1][j] << endl;
    }
  }

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

#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int count[1001][2], c, n;
  string a, b;
  for (int i = 0; i < 1001; ++i) {
    for (int j = 0; j < 2; ++j) {
      count[i][j] = 0;
    }
  }
  while (getline(cin, a)) {
    if (a == "\\0")
      break;
    c = 0;
    b = a[c];
    ++c;
    n = a.find(',');
    for (; c < n; ++c) {
      b += a[c];
    }
    ++count[atoi(b.c_str())][0];
  }
  while (getline(cin, a)) {
    c = 0;
    b = a[c];
    ++c;
    n = a.find(',');
    for (; c < n; ++c) {
      b += a[c];
    }
    ++count[atoi(b.c_str())][1];
  }
  for (int i = 1; i < 1001; ++i) {
    if (count[i][0] > 0 && count[i][1] > 0) {
      cout << i << " " << count[i][0] + count[i][1] << endl;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int count[1001][2], c, n;
  string a, b;
  for (int i = 0; i < 1001; ++i) {
    for (int j = 0; j < 2; ++j) {
      count[i][j] = 0;
    }
  }
  while (getline(cin, a)) {
    if (a == "\\n")
      break;
    c = 0;
    b[c] = a[c];
    n = a.find(',');
    for (; c < n; ++c) {
      b += a[c];
    }
    ++count[atoi(b.c_str())][0];
  }
  while (getline(cin, a)) {
    if (a == "\\n")
      break;
    c = 0;
    b[c] = a[c];
    n = a.find(',');
    for (; c < n; ++c) {
      b += a[c];
    }
    ++count[atoi(b.c_str())][1];
  }
  for (int i = 1; i < 1001; ++i) {
    if (count[i][0] > 0 && count[i][1] > 0) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p00065 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int kawa = 0, company[2][10001] = {};
  char str[1000];
  while (fgets(str, 1000, stdin)) {
    if (strcmp(str, "\\n") == 0)
      kawa++;
    else
      company[kawa][atoi(strtok(str, ","))]++;
  }
  for (int i = 0; i < 10001; i++)
    if (company[0][i] != 0 && company[1][i] != 0)
      cout << i << " " << company[0][i] + company[1][i] << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int nu[3] = {}, kawa = 0, company[2][10001] = {};
  char str;
  while (cin >> nu[0] >> str >> nu[1]) {
    if (nu[1] < nu[2])
      kawa++;
    nu[2] = nu[1];
    company[kawa][nu[0]]++;
  }
  for (int i = 0; i < 10001; i++)
    if (company[0][i] != 0 && company[1][i] != 0)
      cout << i << " " << company[0][i] + company[1][i] << endl;
}
Problem p00065 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
string S;
int x[100000][2];
int c = 0;
int main() {
  while (getline(cin, S)) {
    if (S.size() == 0) {
      c++;
      continue;
    }
    string T[2];
    int ok = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == ',') {
        ok++;
      } else {
        T[ok] += S[i];
      }
    }
    x[stoi(T[0])][c]++;
  }
  for (int i = 0; i < 99999; i++) {
    if (x[i][0] >= 1 && x[i][1] >= 1) {
      cout << i << ' ' << x[i][0] + x[i][1] << endl;
    }
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
string S;
int x[100000][2];
int c = 0;
int main() {
  while (getline(cin, S)) {
    if (S.size() == 0) {
      c++;
    }
    string T[2];
    int ok = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == ',') {
        ok++;
      } else {
        T[ok] += S[i];
      }
    }
    x[stoi(T[0])][c]++;
  }
  for (int i = 0; i < 99999; i++) {
    if (x[i][0] >= 1 && x[i][1] >= 1) {
      cout << i << ' ' << x[i][0] + x[i][1] << endl;
    }
  }
  return 0;
}
Problem p00065 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int num, day;
  string str;
  char input[256];
  vector<int> mon;
  map<int, int> res;
  while (getline(cin, str) && str.length() != 0) {
    string nstr = "";
    for (int i = 0; i < str.length(); i++) {
      if (str[i] == ',')
        break;
      else
        nstr += str[i];
    }
    stringstream ss;
    ss << nstr;
    ss >> num;
    mon.push_back(num);
  }
  while (scanf("%s", input) != EOF) {
    sscanf(input, "%d%*c%d", &num, &day);
    int cnt = count(mon.begin(), mon.end(), num);
    if (cnt != 0) {
      if (res.find(num) == res.end()) {
        res.insert(make_pair(num, cnt + 1));
      } else {
        res[num]++;
      }
    }
  }
  map<int, int>::iterator itr;
  for (itr = res.begin(); itr != res.end(); itr++) {
    printf("%d %d\\n", (*itr).first, (*itr).second);
  }
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>
using namespace std;
int main() {
  int num, day;
  char input[80];
  vector<int> mon;
  map<int, int> res;
  while (scanf("%s", input) && input != "\\n") {
    sscanf(input, "%d%*c%d", &num, &day);
    mon.push_back(num);
  }
  while (scanf("%s", input) && input != "\\n") {
    sscanf(input, "%d%*c%d", &num, &day);
    int cnt = count(mon.begin(), mon.end(), num);
    if (cnt != 0) {
      if (res.find(num) == res.end()) {
        res.insert(make_pair(num, cnt + 1));
      } else {
        res[num]++;
      }
    }
  }
  map<int, int>::iterator itr;
  for (itr = res.begin(); itr != res.end(); itr++) {
    printf("%d %d\\n", (*itr).first, (*itr).second);
  }
}
Problem p00065 (C++) — buggy submission, verdict: Runtime Error

// #include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int main() {

  int ky[1000] = {};
  int ny[1000] = {};
  string s;
  while (getline(cin, s)) {
    if (s.empty())
      break;

    int it = 1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == ',') {
        it = i;
        break;
      }
    }

    string a;
    a = s.substr(0, it);
    int c = stoi(a);
    ky[c - 1]++;
  }

  string sa;
  while (getline(cin, sa)) {
    int it;
    for (int i = 0; i < sa.size(); i++) {
      if (sa[i] == ',') {
        it = i;
        break;
      }
    }

    string a;
    a = sa.substr(0, it);
    int c = stoi(a);

    ny[c - 1]++;
  }

  for (int i = 0; i < 1000; i++) {
    if (ky[i] != 0 && ny[i] != 0)
      cout << i + 1 << ' ' << ky[i] + ny[i] << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

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

int main() {

  int ky[1000] = {};
  int ny[1000] = {};
  string s;
  while (cin >> s && s.empty()) {
    int it = 1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == ',') {
        it = i;
        break;
      }
    }

    string a, b;
    a = s.substr(0, it - 1);
    b = s.substr(it + 1, s.size() - 1);
    int c = stoi(a);
    int d = stoi(b);
    ky[c - 1]++;
  }

  while (cin >> s) {
    int it;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == ',') {
        it = i;
        break;
      }
    }

    string a, b;
    a = s.substr(0, it - 1);
    b = s.substr(it + 1, s.size() - 1);
    int c = stoi(a);
    int d = stoi(b);

    ny[c - 1]++;
  }

  for (int i = 0; i < 1000; i++) {
    if (ky[i] != 0 && ny[i] != 0)
      cout << i + 1 << ' ' << ky[i] + ny[i] << endl;
  }
  return 0;
}
Problem p00065 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) range(i, 0, b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main() {
  int i = 0, number;
  int a[1010] = {0}, b[1010] = {0};
  string input;

  while (getline(cin, input), !input.empty())
    a[atoi(input.c_str())]++;
  while (getline(cin, input))
    b[atoi(input.c_str())]++;
  rep(i, 1010) if (a[i] && b[i]) cout << i << ' ' << a[i] + b[i] << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) range(i, 0, b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main() {
  int i = 0, number;
  int a[1000] = {0}, b[1000] = {0};
  string input;

  while (getline(cin, input), !input.empty())
    a[atoi(input.c_str())]++;
  while (getline(cin, input))
    b[atoi(input.c_str())]++;
  rep(i, 1000) if (a[i] && b[i]) cout << i << ' ' << a[i] + b[i] << endl;
}