prithivMLmods/Coder-Stat huggingface dataset:
Problem p02836 (Python)

Buggy submission (status: Runtime Error):
S = list(input())

firstS = S[: len(S) // 2]
secondS = list(reversed(S[len(S) // 2 + 1 :]))

count = 0

for x in range(len(firstS)):
    if firstS[x] != secondS[x]:
        count += 1
print(count)


Fixed submission:
S = list(input())

firstS = S[: len(S) // 2]
if len(S) % 2 == 0:
    secondS = list(reversed(S[len(S) // 2 :]))
else:
    secondS = list(reversed(S[len(S) // 2 + 1 :]))

count = 0

for x in range(len(firstS)):
    if firstS[x] != secondS[x]:
        count += 1
print(count)
Problem p02836 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); i++)
int main() {
  string S;
  cin >> S;
  int ans = 0;
  int a = S.size();
  for (int i = 0; i < a / 2;) {
    if (S.at(i) != S.at(a - 1 - i)) {
      ans++;
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); i++)
int main() {
  string S;
  cin >> S;
  int ans = 0;
  int a = S.size();
  for (int i = 0; i < a / 2; i++) {
    if (S.at(i) != S.at(a - 1 - i)) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02836 (C++)

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

#include <math.h>
#include <numeric>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
string s;
int main() {
  cin >> s;
  int ans = 0;
  for (int i = 0; i <= s.length() / 2 - 1; i++) {
    if (s[i] != s[s.length() - i - 1])
      ans++;
  }
  // cout << s.length() << endl;
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#include <math.h>
#include <numeric>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
string s;
int main() {
  cin >> s;
  int ans = 0;
  if (s.length() == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i <= s.length() / 2 - 1; i++) {
    if (s[i] != s[s.length() - i - 1])
      ans++;
  }
  // cout << s.length() << endl;
  cout << ans << endl;
  return 0;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(int argc, const char *argv[]) {

  string S;
  cin >> S;

  int a = 0;
  int b = (int)S.length() - 1;
  int count = 0;

  while (a >= b) {
    if (S[a] != S[b]) {
      S[a] = S[b];
      count++;
    }
    a++;
    b--;
  }

  cout << count << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(int argc, const char *argv[]) {

  string S;
  cin >> S;

  int a = 0;
  int b = (int)S.length() - 1;
  int count = 0;

  while (a < b) {
    if (S[a] != S[b]) {
      S[a] = S[b];
      count++;
    }
    a++;
    b--;
  }

  cout << count << endl;

  return 0;
}
Problem p02836 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int count = 0;
  int i = 0;
  int j = str.size() - 1;
  while (i < j) {
    if (str[i] == str[j])
      continue;
    else
      count++;
    i++;
    j--;
  }
  printf("%d\n", count);

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int count = 0;
  int i = 0;
  int j = str.size() - 1;
  while (i < j) {
    if (str[i] == str[j])
      ;
    else
      count++;
    i++;
    j--;
  }
  printf("%d\n", count);

  return 0;
}
Problem p02836 (C++)

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

#define roop(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9 + 7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
  float x = 1;
  while (n > 0) { // 全てのbitが捨てられるまで
    if (n & 1) {  // 一番右のbitが１のとき
      x *= a;
    }
    a *= a;
    n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
  }
  return x;
}

int main() {
  string s;
  cin >> s;
  int i = 0, j = s.size() - 1, ans = 0;
  if (s.size() % 2 == 0) {
    while (true) {
      if (s[i] != s[j]) {
        ans++;
      }
      i++;
      j--;
      if (j < (s.size() / 2)) {
        break;
      }
    }
  } else {
    while (true) {
      if (s[i] != s[j]) {
        ans++;
      }
      i++;
      j--;
      if ((j < (s.size() / 2) + 1)) {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define roop(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9 + 7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
  float x = 1;
  while (n > 0) { // 全てのbitが捨てられるまで
    if (n & 1) {  // 一番右のbitが１のとき
      x *= a;
    }
    a *= a;
    n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
  }
  return x;
}

int main() {
  string s;
  cin >> s;
  int i = 0, j = s.size() - 1, ans = 0;
  if (s.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (s.size() % 2 == 0) {
    while (true) {
      if (s[i] != s[j]) {
        ans++;
      }
      i++;
      j--;
      if (j < (s.size() / 2)) {
        break;
      }
    }
  } else {
    while (true) {
      if (s[i] != s[j]) {
        ans++;
      }
      i++;
      j--;
      if ((j < (s.size() / 2) + 1)) {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

int main() {
  std::string s;

  std::cin >> s;

  int end = s.length() - 1;
  int ans = 0;

  for (size_t i = 0; i <= end; i++) {
    if (s[i] != s[end]) {
      ans++;
    }
    end--;
  }

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

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

int main() {
  std::string s;

  std::cin >> s;

  int end = s.length() - 1;
  int ans = 0;

  for (int i = 0; i <= end; i++) {
    if (s[i] != s[end]) {
      ans++;
    }
    end--;
  }

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

  return 0;
}
Problem p02836 (C++)

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

int main(void) {

  string S;

  cin >> S;

  int ans = 0;

  rep(i, S.length() / 2 - 1) if (S[i] != S[S.length() - i - 1]) ans++;

  cout << ans;

  return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

int main(void) {

  string S;

  cin >> S;

  int ans = 0;

  rep(i, S.length() / 2) if (S[i] != S[S.length() - i - 1]) ans++;

  cout << ans;

  return 0;
}
Problem p02836 (C++)

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

int main() {
  string S;
  cin >> S;
  int A = S.size() - 1;
  int count = 0;

  if (S.size() == 1) {
    cout << 0 << endl;
  }
  for (int i = 0; A >= S.size() / 2; i++) {
    if (S.at(i) != S.at(A)) {
      count++;
    }
    A--;
  }

  cout << count << endl;
}

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

int main() {
  string S;
  cin >> S;
  int A = S.size() - 1;
  int count = 0;

  if (S.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; A >= S.size() / 2; i++) {
    if (S.at(i) != S.at(A)) {
      count++;
    }
    A--;
  }

  cout << count << endl;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  char s[150];
  int sleng = 0, dif = 0;
  scanf("%s", s);
  for (size_t i = 0; s[i] != '\0'; i++) {
    sleng++;
  }

  for (size_t i = 0; sleng - i - 1 >= i; i++) {
    if (s[i] != s[sleng - i - 1])
      dif++;
  }

  printf("%d", dif);
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  char s[150];
  int sleng = 0, dif = 0;
  scanf("%s", s);
  for (size_t i = 0; s[i] != '\0'; i++) {
    sleng++;
  }

  for (size_t i = 0; sleng - i - 1 >= i; i++) {
    if (sleng - i - 1 <= 0)
      break;
    if (s[i] != s[sleng - i - 1])
      dif++;
  }

  printf("%d", dif);
  return 0;
}
Problem p02836 (C++)

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define FORall(it, a)                                                          \
  for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
const int N = (int)1e5;
void TimeExecution() {
  cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  /*
  #ifndef ONLINE_JUDGE
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
  #endif
  */
  string s;
  cin >> s;
  int res = 0;
  FOR(i, 0, s.size() / 2 - 1) {
    if (s[i] != s[s.size() - i - 1])
      res++;
  }
  cout << res;
  return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define FORall(it, a)                                                          \
  for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
const int N = (int)1e5;
void TimeExecution() {
  cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  /*
  #ifndef ONLINE_JUDGE
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
  #endif
  */
  string s;
  cin >> s;
  int res = 0;
  if (s.size() == 1) {
    cout << 0;
    return 0;
  }
  FOR(i, 0, s.size() / 2 - 1) {
    if (s[i] != s[s.size() - i - 1])
      res++;
  }
  cout << res;
  return 0;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define rgi register int
#define pii pair<int, int>
#define mkp make_pair
#define fi first
#define se second
#define pb push_back
#define filein(x) freopen(x, "r", stdin)
#define fileout(x) freopen(x, "w", stdout)
using namespace std;
int n, ans;
string s;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> s;
  n = s.size();
  rgi i = 0, j = n - 1;
  while (i != j) {
    if (s[i] != s[j])
      ++ans;
    ++i, --j;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define rgi register int
#define pii pair<int, int>
#define mkp make_pair
#define fi first
#define se second
#define pb push_back
#define filein(x) freopen(x, "r", stdin)
#define fileout(x) freopen(x, "w", stdout)
using namespace std;
int n, ans;
string s;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> s;
  n = s.size();
  rgi i = 0, j = n - 1;
  while (i < j) {
    if (s[i] != s[j])
      ++ans;
    ++i, --j;
  }
  cout << ans << endl;
  return 0;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
/*
    author: Salam_35
    problem name:
*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d", &n)
#define Max 100005
#define scan(n) scanf("%lld", &n)
#define pi acos(-1.0)
#define _fastio                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define ALL(x) x.begin(), x.end()
#define sci(n) scanf("%d", &n);
#define scl(n) scanf("%lld", &n);
#define load(array, size)                                                      \
  for (ll i = 0; i < size; i++)                                                \
    cin >> array[i];
#define load1(array, size)                                                     \
  for (ll i = 1; i <= size; i++)                                               \
    cin >> array[i];
#define INF 1LL << 19
#define pll pair<ll, ll>
#define mst(arr, value) memset(arr, value, sizeof(arr));

const ll MOD = 1e9 + 7;

typedef vector<ll> vec;
typedef pair<ll, ll> pii;
typedef map<ll, ll> mpll;
typedef set<ll> seet;
vec primes;
//

int main() {
  string a;
  cin >> a;
  int ans = 0;
  for (int i = 0, j = a.size() - 1; i < a.size() / 2, j >= a.size() / 2;
       i++, j--) {
    if (a[i] != a[j])
      ans++;
  }

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


Fixed submission:
/*
    author: Salam_35
    problem name:
*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d", &n)
#define Max 100005
#define scan(n) scanf("%lld", &n)
#define pi acos(-1.0)
#define _fastio                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define ALL(x) x.begin(), x.end()
#define sci(n) scanf("%d", &n);
#define scl(n) scanf("%lld", &n);
#define load(array, size)                                                      \
  for (ll i = 0; i < size; i++)                                                \
    cin >> array[i];
#define load1(array, size)                                                     \
  for (ll i = 1; i <= size; i++)                                               \
    cin >> array[i];
#define INF 1LL << 19
#define pll pair<ll, ll>
#define mst(arr, value) memset(arr, value, sizeof(arr));

const ll MOD = 1e9 + 7;

typedef vector<ll> vec;
typedef pair<ll, ll> pii;
typedef map<ll, ll> mpll;
typedef set<ll> seet;
vec primes;
//

int main() {
  string a;
  cin >> a;
  int ans = 0;
  if (a.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0, j = a.size() - 1; i < a.size() / 2, j >= a.size() / 2;
       i++, j--) {
    if (a[i] != a[j])
      ans++;
  }

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int cnt = 0;
  for (int i = 0; i < s.length() - 1 - i; i++)
    if (s[i] != s[s.length() - 1 - i])
      cnt++;
  cout << cnt << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int cnt = 0;
  getline(cin, s);
  for (int i = 0; i < s.length() - 1 - i; i++)
    if (s[i] != s[s.length() - 1 - i])
      cnt++;
  cout << cnt << "\n";
  return 0;
}
Problem p02836 (C++)

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

int main() {
  string s;
  cin >> s;

  int k = s.size();

  int ans = 0;

  for (int i = 0; i < k / 2; k++) {
    if (s[i] != s[k - i - 1]) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main() {
  string s;
  cin >> s;

  int k = s.size();

  int ans = 0;

  for (int i = 0; i < k / 2; i++) {
    if (s[i] != s[k - i - 1]) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  string S = 0;
  cin >> S;
  for (int i = 0, j = S.length() - 1; i < j; i++, j--) {
    if (S[i] != S[j]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  string S;
  cin >> S;
  for (int i = 0, j = S.length() - 1; i < j; i++, j--) {
    if (S[i] != S[j]) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02836 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  getline(cin, a);
  int l = 0;
  for (int i = 0; i < a.length(); i++) {
    for (int j = a.length() - 1; j >= 0; j++) {
      if (a[i] != a[j]) {
        l++;
      }
    }
  }
  cout << l;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  getline(cin, a);
  int l = 0, k = a.length();
  for (int i = 0; i < k / 2; i++) {
    if (a[i] != a[k - i - 1]) {
      l++;
    }
  }
  cout << l;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int a = 0;
  for (int i = 0; i < S.size() / 2 - 1; i++) {
    if (S.at(i) != S.at(S.size() - i - 1))
      a++;
  }
  cout << a << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int a = 0;
  for (int i = 0; i < S.size() / 2; i++) {
    if (S.at(i) != S.at(S.size() - i - 1))
      a++;
  }
  cout << a << endl;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(), (x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main() {
  string s;
  cin >> s;

  int ans = 0;
  for (int i = 0; i <= s.length() / 2 - 1; i++) {
    char a, b;
    a = s[i];
    b = s[s.length() - i - 1];

    if (a - b)
      ans++;
  }

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


Fixed submission:
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(), (x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main() {
  string s;
  cin >> s;

  if (s.length() == 1) {
    cout << "0" << endl;
    return 0;
  }

  int ans = 0;
  for (int i = 0; i <= s.length() / 2 - 1; i++) {
    char a, b;
    a = s[i];
    b = s[s.length() - i - 1];

    if (a - b)
      ans++;
  }

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define rep2(i, n) for (int i = 0; i <= n; i++)
#define repr(i, a, n) for (int i = a; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<long long, long long>
#define double long double
#define INF 1e10
#define MOD 1e9 + 7
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<int>>;
signed main() {
  string a;
  cin >> a;
  int b = 0;
  if (a.size() % 2 == 0) {
    rep(i, a.size() / 2) {
      if (a[i] != a[a.size() - 1 - i])
        b++;
    }
    cout << b;
  } else {
    rep(i, a.size() / 2 - 1) {
      if (a[i] != a[a.size() - 1 - i])
        b++;
    }
    cout << b;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define rep2(i, n) for (int i = 0; i <= n; i++)
#define repr(i, a, n) for (int i = a; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<long long, long long>
#define double long double
#define INF 1e10
#define MOD 1e9 + 7
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<int>>;
signed main() {
  string a;
  cin >> a;
  int b = 0;
  if (a.size() % 2 == 0) {
    rep(i, a.size() / 2) {
      if (a[i] != a[a.size() - 1 - i])
        b++;
    }
    cout << b;
  } else {
    rep(i, (a.size() - 1) / 2) {
      if (a[i] != a[a.size() - 1 - i])
        b++;
    }
    cout << b;
  }
}
Problem p02836 (C++)

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i <= s.size() - 1 - i; i++) {
    if (s[i] != s[s.size() - 1 - i])
      ans++;
  }
  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;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    int j = s.size() - 1 - i;
    if (s[i] != s[j] && i < j)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02836 (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() {
  string s;
  cin >> s;
  int count = 0;
  rep(i, s.size() / 2) {
    if (s.at(i) != s.at(s.size() - i)) {
      count++;
    }
  }
  cout << count;
}

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  rep(i, s.size() / 2) {
    if (s.at(i) != s.at(s.size() - 1 - i)) {
      count++;
    }
  }
  cout << count;
}
Problem p02836 (C++)

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

int main() {
  string s;
  int a;
  cin >> s;
  a = s.size();

  int count = 0;
  for (int i = 0; i < a; i++) {
    if (s.at(i) != s.at(a - i)) {
      count++;
    }
  }

  cout << count / 2 << endl;
}


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

int main() {
  string s;
  int a;
  cin >> s;
  a = s.size();

  int count = 0;
  for (int i = 0; i < a; i++) {
    if (s.at(i) != s.at(a - i - 1)) {
      count++;
    }
  }

  cout << count / 2 << endl;
}
Problem p02836 (C++)

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

int main() {
  string s;
  cin >> s;

  int cnt = 0;
  int i = 0;
  int j = s.size() - 1;
  while (i <= j) {
    if (s[i] != s[j]) {
      cnt++;
    }
  }

  cout << cnt;
}

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

int main() {
  string s;
  cin >> s;

  int cnt = 0;
  int i = 0;
  int j = s.size() - 1;
  while (i <= j) {
    if (s[i] != s[j]) {
      cnt++;
    }
    i++;
    j--;
  }

  cout << cnt;
}
Problem p02836 (C++)

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

int lenght(char *str) {
  int a = strlen(str);
  return a;
}

int main() {
  char str[10];
  cin >> str;
  int l = lenght(str);
  int m = (l + 1) / 2;
  int counter = 0;
  for (int i = 0; i < m; ++i) {
    if (str[i] == str[l - i - 1])
      ++counter;
  }
  int x = m - counter;
  cout << x << endl;
}

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

int lenght(char *str) {
  int a = strlen(str);
  return a;
}

int main() {
  char str[100];
  cin >> str;
  int l = lenght(str);
  int m = (l + 1) / 2;
  int counter = 0;
  for (int i = 0; i < m; ++i) {
    if (str[i] == str[l - i - 1])
      ++counter;
  }
  int x = m - counter;
  cout << x << endl;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

typedef long long ll;
#define mop 1000000007
using namespace std;

int main() {

  string s;
  cin >> s;
  ll lenS = s.length();
  ll ans = 0;
  //    if(lenS%2 == 0){
  ll tmp = 0;
  while (true) {
    if (s[tmp] != s[s.length() - 1 - tmp]) {
      ans++;
    }
    tmp++;
    if (tmp == lenS / 2)
      break;
  }
  cout << ans << endl;
  //
  //    }else{
  //        ll tmp = 0;
  //        while(true) {
  //            if (s[tmp] != s[s.length() - 1 - tmp]) {
  //                ans++;
  //            }
  //            tmp++;
  //            if(tmp == lenS/2) break;
  //        }
  //    }
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

typedef long long ll;
#define mop 1000000007
using namespace std;

int main() {

  string s;
  cin >> s;
  ll lenS = s.length();
  ll ans = 0;
  //    if(lenS%2 == 0){
  ll tmp = 0;
  while (true) {
    if (s.length() == 1)
      break;
    if (s[tmp] != s[s.length() - 1 - tmp]) {
      ans++;
    }
    tmp++;
    if (tmp == lenS / 2)
      break;
  }
  cout << ans << endl;
  //
  //    }else{
  //        ll tmp = 0;
  //        while(true) {
  //            if (s[tmp] != s[s.length() - 1 - tmp]) {
  //                ans++;
  //            }
  //            tmp++;
  //            if(tmp == lenS/2) break;
  //        }
  //    }
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0;; i++) {
    if (S.size() - 1 - i < i)
      break;
    if (S[i] != S[S.size() - 1 - i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  if (S.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0;; i++) {
    if (S.size() - 1 - i < i)
      break;
    if (S[i] != S[S.size() - 1 - i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

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

  for (int i = 0; i <= s.size(); i++) {
    if (s.at(i) != s.at(s.size() - 1 - i)) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

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

  for (int i = 0; i < s.size() / 2; i++) {
    if (s.at(i) != s.at(s.size() - 1 - i)) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define MAXN 1000100
#define pii pair<int, int>
#define pb push_back
#define inf 1e18
#define fi first
#define se second
#define mt make_tuple
typedef long long ll;

using namespace std;

string s;
int ans;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1])
      ans++;
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
#define MAXN 1000100
#define pii pair<int, int>
#define pb push_back
#define inf 1e18
#define fi first
#define se second
#define mt make_tuple
typedef long long ll;

using namespace std;

string s;
int ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1])
      ans++;
  }
  cout << ans;
}
Problem p02836 (C++)

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

int main() {

  int count = 0;
  string S;
  cin >> S;
  for (int i = 0; 2 * i < S.length(); i++) {
    if (S.at(i) != S.at(S.length() - i)) {
      count++;
    }
  }

  cout << count << endl;
}


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

int main() {

  int count = 0;
  string S;
  cin >> S;
  for (int i = 0; i < S.length() / 2; i++) {
    if (S.at(i) != S.at(S.length() - 1 - i)) {
      count++;
    }
  }

  cout << count << endl;
}
Problem p02836 (C++)

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

int main() {
  string s;
  cin >> s;
  int l = 0, r = s.size() - 1;
  int ans = 0;
  while (l < r) {
    ans += s[l] != s[r];
  }
  cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int l = 0, r = s.size() - 1;
  int ans = 0;
  while (l < r) {
    ans += s[l] != s[r];
    l++;
    r--;
  }
  cout << ans << endl;
}
Problem p02836 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int c = 0;
  string s;
  cin >> s;
  int i = 0, j = s.length() - 1;
  while (i <= j) {
    if (s[i] != s[j])
      c++;
  }
  cout << c << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int c = 0;
  string s;
  cin >> s;
  int i = 0, j = s.length() - 1;
  while (i <= j) {
    if (s[i] != s[j])
      c++;
    i++;
    j--;
  }
  cout << c << endl;
  return 0;
}
Problem p02836 (C++)

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

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

  for (int i = 0; i <= s.size() / 2 - 1; i++) {
    if (s.at(i) != s.at(s.size() - 1 - i))
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}

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

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

  if (s.size() == 1) {
  } else {
    for (int i = 0; i <= s.size() / 2 - 1; i++) {
      if (s.at(i) != s.at(s.size() - 1 - i))
        cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p02836 (C++)

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size() / 2; i++) {
    for (int j = S.size() - 1; j > S.size() / 2; j++) {
      if (S[i] != S[j]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size() / 2; i++) {
    if (S[i] != S[S.size() - i - 1]) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02836 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
string s;
int ans;
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    if (s[i] >= 'A' && s[i] <= 'Z')
      s[i] = 'a' + s[i] - 'A';
  for (int i = 0; i <= s.size() / 2 - 1; i++)
    ans += (s[i] != s[s.size() - i - 1]);
  cout << ans;
  return 0;
}

Fixed submission:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
string s;
int ans;
int main() {
  cin >> s;
  if (s.size() == 1) {
    cout << "0";
    return 0;
  }
  for (int i = 0; i < s.size(); i++)
    if (s[i] >= 'A' && s[i] <= 'Z')
      s[i] = 'a' + s[i] - 'A';
  for (int i = 0; i <= s.size() / 2 - 1; i++)
    ans += (s[i] != s[s.size() - i - 1]);
  cout << ans;
  return 0;
}
Problem p02837 (C++)

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

typedef long long ll;
#define rep1(i, n) for (int i = 1; i <= (ll)(n); i++)
#define rep0(i, n) for (int i = 0; i <= (ll)(n); i++)

int main() {
  int n;
  cin >> n;
  int x[n][n];
  int y[n][n];
  int a[n + 1];
  bool all_not_told = true;
  rep1(i, n) {
    cin >> a[i];
    if (a[i] > 0)
      all_not_told = false;
    rep1(j, a[i]) cin >> x[i][j] >> y[i][j];
  }

  if (all_not_told) {
    cout << n << endl;
    return 0;
  }

  if (n == 1)
    cout << 1 << endl;

  int max_honest_count = 0;
  // {0, 1, ..., n-1} の部分集合の全探索
  for (int bit = 1; bit < (1 << n); ++bit) {
    int honest_count = 0;
    bool contradiction = false;
    rep1(i, n) {
      if (bit & (1 << (i - 1))) { // i が bit に入るかどうか
        honest_count++;
        rep1(j, a[i]) {
          if (((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) {
            contradiction = true;
            break;
          }
        }
      }
    }
    if (!contradiction)
      max_honest_count = max(honest_count, max_honest_count);
  }
  cout << max_honest_count << endl;
  return 0;
}

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

typedef long long ll;
#define rep1(i, n) for (int i = 1; i <= (ll)(n); i++)
#define rep0(i, n) for (int i = 0; i <= (ll)(n); i++)

int main() {
  int n;
  cin >> n;
  int x[20][20];
  int y[20][20];
  int a[20];
  bool all_not_told = true;
  rep1(i, n) {
    cin >> a[i];
    if (a[i] > 0)
      all_not_told = false;
    rep1(j, a[i]) cin >> x[i][j] >> y[i][j];
  }

  if (all_not_told) {
    cout << n << endl;
    return 0;
  }

  if (n == 1)
    cout << 1 << endl;

  int max_honest_count = 0;
  // {0, 1, ..., n-1} の部分集合の全探索
  for (int bit = 1; bit < (1 << n); ++bit) {
    int honest_count = 0;
    bool contradiction = false;
    rep1(i, n) {
      if (bit & (1 << (i - 1))) { // i が bit に入るかどうか
        honest_count++;
        rep1(j, a[i]) {
          if (((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) {
            contradiction = true;
            break;
          }
        }
      }
    }
    if (!contradiction)
      max_honest_count = max(honest_count, max_honest_count);
  }
  cout << max_honest_count << endl;
  return 0;
}
Problem p02837 (C++)

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
  if (x == 0)
    return 0;
  return counter(1 << x) + (x & 1);
}

void solve() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    for (int j = 1; j <= A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  for (int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for (int i = 1; i <= N; i++) {
      if (!(bits & (1 << (i - 1))))
        continue;
      for (int j = 1; j <= A[i]; j++) {
        if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j])
          ok = false;
      }
    }
    if (ok)
      ans = max(ans, counter(bits));
  }
  cout << ans << endl;
  return;
}

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


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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
  if (x == 0)
    return 0;
  return counter(x >> 1) + (x & 1);
}

void solve() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    for (int j = 1; j <= A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  for (int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for (int i = 1; i <= N; i++) {
      if (!(bits & (1 << (i - 1))))
        continue;
      for (int j = 1; j <= A[i]; j++) {
        if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j])
          ok = false;
      }
    }
    if (ok)
      ans = max(ans, counter(bits));
  }
  cout << ans << endl;
  return;
}

int main() {
  solve();
  return 0;
}
Problem p02837 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 22;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
template <typename T> inline void read(T &x) {
  x = 0;
  char ch = getchar();
  bool f = false;
  while (ch < '0' || ch > '9')
    f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = x * 10 + ch - '0', ch = getchar();
  if (f)
    x = -x;
}
int n, a[maxn], x[maxn][maxn], y[maxn][maxn], sz[maxn], ans;
int main() {
  read(n);
  FOR(i, 1, n) {
    read(a[i]);
    FOR(j, 1, a[i]) read(x[i][j]), read(y[i][j]);
  }
  FOR(i, 1, (1 << n) - 1) sz[i] = sz[i >> 1] + (i & 1);
  FOR(i, 0, (1 << n) - 1) {
    bool flag = true;
    FOR(j, 1, n) if ((i >> (j - 1)) & 1) {
      FOR(k, 1, a[j]) if (((i >> (x[j][k] - 1)) & 1) != y[j][k]) flag = false;
    }
    if (flag)
      ans = max(ans, sz[i]);
  }
  printf("%d\n", ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 22;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
template <typename T> inline void read(T &x) {
  x = 0;
  char ch = getchar();
  bool f = false;
  while (ch < '0' || ch > '9')
    f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = x * 10 + ch - '0', ch = getchar();
  if (f)
    x = -x;
}
int n, a[maxn], x[maxn][maxn], y[maxn][maxn], sz[66666], ans;
int main() {
  read(n);
  FOR(i, 1, n) {
    read(a[i]);
    FOR(j, 1, a[i]) read(x[i][j]), read(y[i][j]);
  }
  FOR(i, 1, (1 << n) - 1) sz[i] = sz[i >> 1] + (i & 1);
  FOR(i, 0, (1 << n) - 1) {
    bool flag = true;
    FOR(j, 1, n) if ((i >> (j - 1)) & 1) {
      FOR(k, 1, a[j]) if (((i >> (x[j][k] - 1)) & 1) != y[j][k]) flag = false;
    }
    if (flag)
      ans = max(ans, sz[i]);
  }
  printf("%d\n", ans);
  return 0;
}
Problem p02837 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <vector>
#define ll long long int
#define ld long double
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n; i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(), x.end()
#define p pair<ll, ll>
#define pb push_back
#define mp make_pair
#define PI 3.14159265359

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<p>> vec(n);
  int a;
  int x, y;
  rep(i, n) {
    cin >> a;
    rep(j, a) {
      cin >> x >> y;
      x--;
      vec[i].pb(mp(x, y));
    }
  }
  vector<bool> h(n);
  ll ans = 0;
  ll tmp = 0;
  ll m = 0;

  for (ll i = 0; i < (1ll << n); i++) {
    m = 0;
    tmp = 0;
    rep(j, n) h[i] = false;

    rep(j, n) {
      if (i & (1ll << j)) {
        h[j] = true;
        m++;
      } else {
        h[j] = false;
      }
    }

    rep(j, n) {
      if (i & (1ll << j)) {
        rep(k, vec[j].size()) {
          if ((h[vec[j][k].first] == true && vec[j][k].second == 0) ||
              (h[vec[j][k].first] == false && vec[j][k].second == 1)) {
            m = -1;
            break;
          }
        }
      }
      if (m < 0) {
        break;
      }
    }
    ans = max(ans, m);
  }

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

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <vector>
#define ll long long int
#define ld long double
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n; i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(), x.end()
#define p pair<ll, ll>
#define pb push_back
#define mp make_pair
#define PI 3.14159265359

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<p>> vec(n);
  int a;
  int x, y;
  rep(i, n) {
    cin >> a;
    rep(j, a) {
      cin >> x >> y;
      x--;
      vec[i].pb(mp(x, y));
    }
  }
  vector<bool> h(n);
  ll ans = 0;
  ll tmp = 0;
  ll m = 0;

  for (ll i = 0; i < (1ll << n); i++) {
    m = 0;
    tmp = 0;
    rep(j, n) h[j] = false;

    rep(j, n) {
      if (i & (1ll << j)) {
        h[j] = true;
        m++;
      } else {
        h[j] = false;
      }
    }

    rep(j, n) {
      if (i & (1ll << j)) {
        rep(k, vec[j].size()) {
          if ((h[vec[j][k].first] == true && vec[j][k].second == 0) ||
              (h[vec[j][k].first] == false && vec[j][k].second == 1)) {
            m = -1;
            break;
          }
        }
      }
      if (m < 0) {
        break;
      }
    }
    ans = max(ans, m);
  }

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

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

int main() {
  int n;
  scanf("%d", &n);

  vector<vector<P>> xy(n, vector<P>(0));
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    for (int j = 0; j < a; j++) {
      int x, y;
      scanf("%d %d", &x, &y);
      xy[i].push_back(make_pair(x - 1, y));
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    vector<bool> hone(n), evil(n);
    for (int j = 0; j < n; j++)
      hone[i] = 0, evil[i] = 0;

    int tmp = 0;
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        tmp++;
        if (evil[j])
          tmp = -1e9;
        else
          hone[j] = 1;
        for (P pr : xy[j]) {
          if (pr.second) {
            if (!evil[pr.first])
              hone[pr.first] = 1;
            else
              tmp = -1e9;
          } else {
            if (!hone[pr.first])
              evil[pr.first] = 1;
            else
              tmp = -1e9;
          }
        }
      } else {
        if (hone[j])
          tmp = -1e9;
        else
          evil[j] = 1;
      }
    }
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main() {
  int n;
  scanf("%d", &n);

  vector<vector<P>> xy(n, vector<P>(0));
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    for (int j = 0; j < a; j++) {
      int x, y;
      scanf("%d %d", &x, &y);
      xy[i].push_back(make_pair(x - 1, y));
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    vector<bool> hone(n), evil(n);
    for (int j = 0; j < n; j++)
      hone[j] = 0, evil[j] = 0;

    int tmp = 0;
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        tmp++;
        if (evil[j])
          tmp = -1e9;
        else
          hone[j] = 1;
        for (P pr : xy[j]) {
          if (pr.second) {
            if (!evil[pr.first])
              hone[pr.first] = 1;
            else
              tmp = -1e9;
          } else {
            if (!hone[pr.first])
              evil[pr.first] = 1;
            else
              tmp = -1e9;
          }
        }
      } else {
        if (hone[j])
          tmp = -1e9;
        else
          evil[j] = 1;
      }
    }
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}
Problem p02837 (C++)

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

// const long long int MOD = 1000000007;
const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<vector<int>> x(N, vector<int>(0)), y(N, vector<int>(0));
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    vector<int> empty(A[i]);
    x[i] = empty;
    y[i] = empty;
    for (int j = 0; j < A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> b(tmp);
    int ok_tmp = 1;
    for (int i = 0; i < N; i++) {
      if (b.test(i)) {
        for (int j = 0; j < A[j]; j++) {
          if (y[i][j] == 1 && !(b.test(x[i][j]))) {
            ok_tmp *= 0;
            break;
          } else if (y[i][j] == 0 && b.test(x[i][j])) {
            ok_tmp *= 0;
            break;
          }
        }
      }
      if (ok_tmp == 0) {
        break;
      }
    }
    if (ok_tmp) {
      int alt = b.count();
      ans = max(ans, alt);
    }
  }
  cout << ans << endl;
}


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

// const long long int MOD = 1000000007;
const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<vector<int>> x(N, vector<int>(0)), y(N, vector<int>(0));
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    vector<int> empty(A[i]);
    x[i] = empty;
    y[i] = empty;
    for (int j = 0; j < A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> b(tmp);
    int ok_tmp = 1;
    for (int i = 0; i < N; i++) {
      if (b.test(i)) {
        for (int j = 0; j < A[i]; j++) {
          if (y[i][j] == 1 && !(b.test(x[i][j]))) {
            ok_tmp *= 0;
            break;
          } else if (y[i][j] == 0 && b.test(x[i][j])) {
            ok_tmp *= 0;
            break;
          }
        }
      }
      if (ok_tmp == 0) {
        break;
      }
    }
    if (ok_tmp) {
      int alt = b.count();
      ans = max(ans, alt);
    }
  }
  cout << ans << endl;
}