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

Buggy submission (status: Runtime Error):
li = list(input())
li.sort()
while True:
    if len(li) == 0:
        print("Yes")
        break
    elif li[0] == li[1]:
        li.pop(0)
        li.pop(0)
    else:
        print("No")
        break


Fixed submission:
li = list(input())
li.sort()
while True:
    if len(li) == 0:
        print("Yes")
        break
    elif not len(li) % 2 == 0:
        print("No")
        break
    elif li[0] == li[1]:
        li.pop(0)
        li.pop(0)
    else:
        print("No")
        break
Problem p04012 (C++)

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

int main() {
  string w;
  cin >> w;
  int k = w.size();
  vector<char> MY(k);
  for (int i = 0; i < k; i++) {
    MY.at(i) = w.at(i);
  }
  sort(MY.begin(), MY.end());
  int count = 1;
  for (int i = 1; i < k; i++) {
    if (MY.at(i) == MY.at(i - 1)) {
      count++;
    }
    if (MY.at(i) != MY.at(i - 1)) {
      if (count % 2 != 0) {
        cout << "No" << endl;
        return 0;
      }
      count = 1;
    }
  }
  if (MY.at(k - 2) != MY.at(k - 1)) {
    cout << "No" << endl;
  } else
    cout << "Yes" << endl;
}


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

int main() {
  string w;
  cin >> w;
  int k = w.size();
  if (k == 1) {
    cout << "No" << endl;
    return 0;
  }
  vector<char> MY(k);
  for (int i = 0; i < k; i++) {
    MY.at(i) = w.at(i);
  }
  sort(MY.begin(), MY.end());
  int count = 1;
  for (int i = 1; i < k; i++) {
    if (MY.at(i) == MY.at(i - 1)) {
      count++;
    }
    if (MY.at(i) != MY.at(i - 1)) {
      if (count % 2 != 0) {
        cout << "No" << endl;
        return 0;
      }
      count = 1;
    }
  }
  if (MY.at(k - 2) != MY.at(k - 1)) {
    cout << "No" << endl;
  } else
    cout << "Yes" << endl;
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string ans = "Yes";
  vector<int> alpha(26, 0);
  for (int i = 0; i < 26; i++) {
    alpha[(int)(s.at(i) - '0') % 26]++;
  }
  for (int i = 0; i < 26; i++) {
    if (alpha[i] % 2 == 1) {
      ans = "No";
      break;
    }
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string ans = "Yes";
  vector<int> alpha(26, 0);
  for (int i = 0; i < s.size(); i++) {
    alpha[(int)(s.at(i) - '0') % 26]++;
  }
  for (int i = 0; i < 26; i++) {
    if (alpha[i] % 2 == 1) {
      ans = "No";
      break;
    }
  }
  cout << ans;
}
Problem p04012 (C++)

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for (auto x = a.begin(); x != a.end(); ++x)

using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double &a, const double &b) {
  return fabs(a - b) < 1e-10;
}

using namespace std;

int n, k, x, y;

int main() {
  //    int n, l;
  //    cin >> n >> k;
  //    vector<bool> dislike(10, false);
  //
  //    FOR(i, 0, k) {
  //        int t;
  //        cin >> t;
  //        dislike[t] = true;
  //    }

  string str;
  //  cin >> n >> k >> x >> y;
  cin >> str;
  vector<int> cnt(26, 0);

  FOR(i, 0, str.size()) { cnt.at(str.at(i) - 'a')++; }
  string rs = "Yes";
  FOR(i, 0, str.size()) {
    if (1 == cnt.at(i) % 2) {
      rs = "No";
      break;
    }
  }
  cout << rs << endl;
  return 0;
}


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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for (auto x = a.begin(); x != a.end(); ++x)

using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double &a, const double &b) {
  return fabs(a - b) < 1e-10;
}

using namespace std;

int n, k, x, y;

int main() {
  //    int n, l;
  //    cin >> n >> k;
  //    vector<bool> dislike(10, false);
  //
  //    FOR(i, 0, k) {
  //        int t;
  //        cin >> t;
  //        dislike[t] = true;
  //    }

  string str;
  //  cin >> n >> k >> x >> y;
  cin >> str;
  vector<int> cnt(26, 0);

  FOR(i, 0, str.size()) { cnt.at(str.at(i) - 'a')++; }
  string rs = "Yes";
  FOR(i, 0, cnt.size()) {
    if (1 == cnt.at(i) % 2) {
      rs = "No";
      break;
    }
  }
  cout << rs << endl;
  return 0;
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  string s;

  // cout<<"a"<<endl;

  cin >> s;
  //  cout<<"b "<<s<<endl;

  int l = s.length();
  vector<char> t(l);
  //  cout<<l<<" "<<s[0]<<endl;

  for (int i = 0; i < l; i++)
    t.at(i) = s[i];
  //  cout<<"f "<<t.at(0)<<endl;
  sort(t.begin(), t.end());
  // for(int i=0;i<l;i++)cout<<t.at(i);
  bool flag = true;
  for (int i = 0; i < l / 2 + 1; i += 2)
    if (t.at(i) != t.at(i + 1))
      flag = false;
  if (flag && l % 2 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  string s;

  // cout<<"a"<<endl;

  cin >> s;
  //  cout<<"b "<<s<<endl;

  int l = s.length();
  vector<char> t(l);
  //  cout<<l<<" "<<s[0]<<endl;

  for (int i = 0; i < l; i++)
    t.at(i) = s[i];
  //  cout<<"f "<<t.at(0)<<endl;
  sort(t.begin(), t.end());
  // for(int i=0;i<l;i++)cout<<t.at(i);
  bool flag = true;
  for (int i = 0; i < l / 2; i += 2)
    if (t.at(i) != t.at(i + 1))
      flag = false;
  if (flag && l % 2 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void yn(bool ok) {
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int main() {
  string s;
  cin >> s;
  vector<int> a(26, 0);
  for (int i = 0; i < s.size(); i++)
    a[i - 'a']++;
  bool ok = 1;
  for (int i = 0; i < 26; i++)
    if (a[i] % 2 == 1)
      ok = 0;
  yn(ok);
}


Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void yn(bool ok) {
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int main() {
  string s;
  cin >> s;
  vector<int> a(26, 0);
  for (int i = 0; i < s.size(); i++)
    a[s[i] - 'a']++;
  bool ok = 1;
  for (int i = 0; i < 26; i++)
    if (a[i] % 2 == 1)
      ok = 0;
  yn(ok);
}
Problem p04012 (C++)

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

int main(void) {
  string w;

  cin >> w;

  sort(w.begin(), w.end());

  for (int i = 0; i < w.size(); i += 2) {
    if (w.at(i) != w.at(i + 1)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

int main(void) {
  string w;

  cin >> w;

  sort(w.begin(), w.end());

  for (int i = 0; i < w.size(); i += 2) {
    if (w.size() == 1) {
      cout << "No" << endl;
      return 0;
    }
    if (w.at(i) != w.at(i + 1)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}
Problem p04012 (C++)

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long, long long>>
#define forll(s, a, b) for (long long s = a; s < b; s++)
#define forllde(s, a) for (long long s = a; s > 0; s--)

int main() {
  string w;
  bool contin = true;
  cin >> w;
  vecll a((unsigned char)'z' - (unsigned char)'a');
  forll(i, 0, w.size()) a[(unsigned char)w[i] - (unsigned char)'a'] += 1;
  forll(i, 0, a.size()) if ((a[i] % 2) != 0) {
    cout << "No" << endl;
    contin = false;
    break;
  }
  if (contin)
    cout << "Yes" << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long, long long>>
#define forll(s, a, b) for (long long s = a; s < b; s++)
#define forllde(s, a) for (long long s = a; s > 0; s--)

int main() {
  string w;
  bool contin = true;
  cin >> w;
  vecll a((unsigned char)'z' - (unsigned char)'a' + 1);
  forll(i, 0, w.size()) a[(unsigned char)w[i] - (unsigned char)'a'] += 1;
  forll(i, 0, a.size()) if ((a[i] % 2) != 0) {
    cout << "No" << endl;
    contin = false;
    break;
  }
  if (contin)
    cout << "Yes" << endl;
}
Problem p04012 (C++)

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

int main() {
  string w;
  cin >> w;
  string nomal = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < nomal.size(); i++) {
    int ans = 0;
    for (int j = 0; j < nomal.size(); j++) {
      if (nomal.at(i) == w.at(j)) {
        ans++;
      }
    }
    if (ans % 2 != 0) {
      cout << "No" << endl;
      break;
    }
    if (i == nomal.size() - 1) {
      cout << "Yes" << endl;
    }
  }
}

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

int main() {
  string w;
  cin >> w;
  string nomal = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < nomal.size(); i++) {
    int ans = 0;
    for (int j = 0; j < w.size(); j++) {
      if (nomal.at(i) == w.at(j)) {
        ans++;
      }
    }
    if (ans % 2 != 0) {
      cout << "No" << endl;
      break;
    }
    if (i == nomal.size() - 1) {
      cout << "Yes" << endl;
    }
  }
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  cin >> n;
  string X = "abcdefghijklmnopqrstuvwxyz";
  vector<int> Y(26);
  for (int i = 0; i < n.size(); i++) {
    for (int j = 0; j < n.size(); j++) {
      if (X[i] == n[j]) {
        Y[i]++;
      }
    }
  }
  int Z = 0;
  for (int i = 0; i < 26; i++) {
    if (Y[i] % 2 == 1) {
      Z = 1;
    }
  }
  if (Z == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  cin >> n;
  string X = "abcdefghijklmnopqrstuvwxyz";
  vector<int> Y(26);
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < n.size(); j++) {
      if (X[i] == n[j]) {
        Y[i]++;
      }
    }
  }
  int Z = 0;
  for (int i = 0; i < 26; i++) {
    if (Y[i] % 2 == 1) {
      Z = 1;
    }
  }
  if (Z == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ALPHABET 26
using namespace std;
int main() {
  string w;
  vector<int> W(ALPHABET);
  cin >> w;
  for (char c : w) {
    W[c - '0']++;
    W[c - '0'] %= 2;
  }
  if (count(W.begin(), W.end(), 0) == ALPHABET) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define ALPHABET 26
using namespace std;
int main() {
  string w;
  vector<int> W(ALPHABET);
  cin >> w;
  for (char c : w) {
    W[c - 'a']++;
    W[c - 'a'] %= 2;
  }
  if (count(W.begin(), W.end(), 0) == ALPHABET) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
Problem p04012 (C++)

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

int main() {
  int num;
  bool ans = true;
  string w;
  vector<int> moji(23);
  cin >> w;

  for (int i = 0; i < w.size(); i++) {
    num = w.at(i) - 'a';
    moji.at(num)++;
  }

  for (int i = 0; i < 23; i++) {
    if ((moji.at(i) % 2) == 1) {
      ans = false;
      break;
    }
  }

  if (ans)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

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

int main() {
  int num;
  bool ans = true;
  string w;
  vector<int> moji(26);
  cin >> w;

  for (int i = 0; i < w.size(); i++) {
    num = w.at(i) - 'a';
    moji.at(num)++;
  }

  for (int i = 0; i < 23; i++) {
    if ((moji.at(i) % 2) == 1) {
      ans = false;
      break;
    }
  }

  if (ans)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  string W;
  bool flg = true;
  cin >> W;
  int array[26] = {0};
  if (W.length() % 2 == 0) {
    for (int i = 0; i < W.length(); i++) {
      array[W[i] - 'A']++;
    }
    for (int i = 0; i < 26; i++) {
      if (array[i] % 2 != 0) {
        flg = false;
        break;
      }
    }
  } else {
    flg = false;
  }

  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  string W;
  bool flg = true;
  cin >> W;
  int array[26] = {0};
  if (W.length() % 2 == 0) {
    for (int i = 0; i < W.length(); i++) {
      array[W[i] - 'a'] += 1;
    }
    for (int i = 0; i < 26; i++) {
      if (array[i] % 2 != 0) {
        flg = false;
        break;
      }
    }
  } else {
    flg = false;
  }

  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
int main() {
  char s[100];
  scanf("%s", s);
  int a = 0, aa = 0, b;
  b = strlen(s);
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < b; j++) {
      if (s[i] == s[j]) {
        aa++;
      }
    }
    if (aa % 2 != 0) {
      a++;
      printf("No\n");
      break;
    }
    aa = 0;
  }
  if (a == 0)
    printf("Yes\n");
  return 1;
}

Fixed submission:
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
int main() {
  char s[100];
  scanf("%s", s);
  int a = 0, aa = 0, b;
  b = strlen(s);
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < b; j++) {
      if (s[i] == s[j]) {
        aa++;
      }
    }
    if (aa % 2 != 0) {
      a++;
      printf("No\n");
      break;
    }
    aa = 0;
  }
  if (a == 0)
    printf("Yes\n");
  return 0;
}
Problem p04012 (C++)

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

int main() {
  string w;
  cin >> w;
  vector<bool> cnt('z' - 'a', true);
  for (auto e : w) {
    int idx = e - 'a';
    cnt.at(idx) = not cnt.at(idx);
  }
  bool ans = true;
  for (auto e : cnt)
    ans &= e;
  cout << (ans ? "Yes" : "No") << endl;
}

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

int main() {
  string w;
  cin >> w;
  vector<bool> cnt('z' - 'a' + 1, true);
  for (auto e : w) {
    int idx = e - 'a';
    cnt.at(idx) = not cnt.at(idx);
  }
  bool ans = true;
  for (auto e : cnt)
    ans &= e;
  cout << (ans ? "Yes" : "No") << endl;
}
Problem p04012 (C++)

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

int main() {
  string s;
  cin >> s;
  vector<int> alpa(26);
  int n = s.size();
  rep(i, n) {
    int x = s[i] - 'a' + 1;
    alpa[x]++;
  }
  bool beauty = true;
  rep(i, 26) {
    // cout << alpa[i] << endl;
    if (alpa[i] % 2 == 1)
      beauty = false;
  }
  if (beauty)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)                                                              \
  ;                                                                            \
  for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main() {
  string s;
  cin >> s;
  vector<int> alpa(26);
  int n = s.size();
  rep(i, n) {
    int x = s[i] - 'a';
    alpa[x]++;
  }
  bool beauty = true;
  rep(i, 26) {
    // cout << alpa[i] << endl;
    if (alpa[i] % 2 == 1)
      beauty = false;
  }
  if (beauty)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<char> moji(26);
  vector<int> count(26, 0);
  for (int i = 0; i < s.size(); i++) {
    for (int j = 97; j < 122; j++) {
      if (s[i] == j)
        count.at(j - 97)++;
    }
  }
  bool answer = true;
  for (int i = 0; i < s.size(); i++) {
    if (count.at(i) % 2 == 1) {
      answer = false;
    }
  }
  if (answer == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<char> moji(26);
  vector<int> count(26, 0);
  for (int i = 0; i < s.size(); i++) {
    for (int j = 97; j < 122; j++) {
      if (s[i] == j)
        count.at(j - 97)++;
    }
  }
  bool answer = true;
  for (int i = 0; i < 26; i++) {
    if (count.at(i) % 2 == 1) {
      answer = false;
    }
  }
  if (answer == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main() {
  string w;
  vector<int> e('z' - 'a', 0);
  cin >> w;
  rep(i, w.size()) { e.at(w.at(i) - 'a')++; }

  rep(i, e.size()) {
    if (e.at(i) % 2 != 0) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Fixed submission:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main() {
  string w;
  vector<int> e('z' - 'a' + 1, 0);
  cin >> w;
  rep(i, w.size()) { e.at(w.at(i) - 'a')++; }

  rep(i, e.size()) {
    if (e.at(i) % 2 != 0) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}
Problem p04012 (C++)

Buggy submission (status: Runtime Error):
#include "stdio.h"

char letter[101];
int num[26] = {};

int main() {
  scanf("%s", letter);
  for (int i = 0; i < 100; i++) {
    num[letter[i] - 'a']++;
    //	printf("%c", letter[i]);
  }
  for (int i = 0; i < 26; i++) {
    //	printf("%d", i + 'a');
    if (num[i] % 2 != 0) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Fixed submission:
#include "stdio.h"

char letter[101];
int num[26] = {};

int main() {
  scanf("%s", letter);
  for (int i = 0; i < 100; i++) {
    if (letter[i] < 'a' || letter[i] > 'z')
      break;
    num[letter[i] - 'a']++;
    //	printf("%c", letter[i]);
  }
  for (int i = 0; i < 26; i++) {
    //	printf("%d", i + 'a');
    if (num[i] % 2 != 0) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
Problem p04012 (C++)

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<char> v;
  for (int i = 0; i < n; i++)
    v[s[i] - 'a']++;
  string ans = "Yes";
  for (int i = 0; i < 26; i++) {
    if (v[i] % 2 != 0) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int v[26] = {};
  for (int i = 0; i < n; i++)
    v[s[i] - 'a']++;
  string ans = "Yes";
  for (int i = 0; i < 26; i++) {
    if (v[i] % 2 != 0) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}
Problem p04013 (C++)

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

using namespace std;

long long dp[50][50][2500];
long long n, a, x[50];
int main() {
  cin >> n >> a;
  for (int i = 0; i < n; i++)
    cin >> x[i];
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 2500; k++) {
        if (dp[i][j][k] == 0)
          continue;
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        dp[i + 1][j][k] += dp[i][j][k];
      }
    }
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++)
    sum += dp[n][i][a * i];
  cout << sum << endl;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

long long dp[51][51][2500];
long long n, a, x[50];
int main() {
  cin >> n >> a;
  for (int i = 0; i < n; i++)
    cin >> x[i];
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 2500; k++) {
        if (dp[i][j][k] == 0)
          continue;
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        dp[i + 1][j][k] += dp[i][j][k];
      }
    }
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++)
    sum += dp[n][i][a * i];
  cout << sum << endl;
}
Problem p04013 (C++)

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, x, ...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__, REP1, REP2, REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)

template <typename T, typename U> bool maxup(T &a, U &&b) {
  if (a < b) {
    a = b;
    return true;
  };
}
template <typename T, typename U> bool minup(T &a, U &&b) {
  if (a > b) {
    a = b;
    return true;
  };
}

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template <typename T> inline void input(vector<T> &v) {
  for (auto &x : v)
    cin >> x;
}

int dp[51][2501];

signed main() {
  int n, a;
  cin >> n >> a;
  V xs(n);
  input(xs);
  dp[0][0] = 1;
  rep(i, n) for (int k = n; k >= 0; k--) rep(j, 2501) {
    dp[k][j] += dp[k - 1][j - xs[i]];
  }
  int ans = 0;
  rep(i, 1, n + 1) rep(j, 2501) if (dp[i][j]) ans +=
      ((j % i == 0) && (j / i == a) ? dp[i][j] : 0);
  cout << ans << endl;
  system("pause");
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, x, ...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__, REP1, REP2, REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)

template <typename T, typename U> bool maxup(T &a, U &&b) {
  if (a < b) {
    a = b;
    return true;
  };
}
template <typename T, typename U> bool minup(T &a, U &&b) {
  if (a > b) {
    a = b;
    return true;
  };
}

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template <typename T> inline void input(vector<T> &v) {
  for (auto &x : v)
    cin >> x;
}

int dp[51][2501];

signed main() {
  int n, a;
  cin >> n >> a;
  V xs(n);
  input(xs);
  dp[0][0] = 1;
  rep(i, n) for (int k = n; k >= 1; k--) rep(j, 2501) if (j - xs[i] >= 0) {
    dp[k][j] += dp[k - 1][j - xs[i]];
  }
  int ans = 0;
  rep(i, 1, n + 1) rep(j, 2501) if (dp[i][j]) ans +=
      ((j % i == 0) && (j / i == a) ? dp[i][j] : 0);
  cout << ans << endl;
  system("pause");
}
Problem p04013 (C++)

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

using namespace std;

int main(int argc, char *argv[]) {
  int N, A;
  cin >> N >> A;
  vector<int> x(N + 1);

  for (int i = 1; i <= N; i++)
    cin >> x[i];

  long dp[51][51][251] = {};

  for (int j = 0; j <= N; j++)
    dp[j][0][0] = 1;

  for (int s = 0; s <= N * 50; s++) {
    for (int k = 1; k <= N; k++) {
      for (int j = 1; j <= N; j++) {
        if (x[j] > s)
          dp[j][k][s] = dp[j - 1][k][s];
        else
          dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j]];
      }
    }
  }

  long ans = 0;
  for (int k = 1; k <= N; k++)
    ans += dp[N][k][k * A];

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int N, A;
  cin >> N >> A;
  vector<int> x(N + 1);

  for (int i = 1; i <= N; i++)
    cin >> x[i];

  long dp[51][51][2501] = {};

  for (int j = 0; j <= N; j++)
    dp[j][0][0] = 1;

  for (int s = 0; s <= N * 50; s++) {
    for (int k = 1; k <= N; k++) {
      for (int j = 1; j <= N; j++) {
        if (x[j] > s)
          dp[j][k][s] = dp[j - 1][k][s];
        else
          dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j]];
      }
    }
  }

  long ans = 0;
  for (int k = 1; k <= N; k++)
    ans += dp[N][k][k * A];

  cout << ans << endl;

  return 0;
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
long long dp[50][50][2500]; // i番目j個とったとき和がkになる個数
int main() {
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  for (int i = 0; N > i; i++) {
    cin >> x[i];
  }
  dp[0][0][0] = 1;
  dp[0][1][x[0]] = 1;
  for (int i = 1; N > i; i++) {
    for (int j = 0; i + 1 >= j; j++) {
      for (int k = 0; 2500 >= k; k++) {
        dp[i][j][k] = dp[i - 1][j][k];
        if (j && k >= x[i])
          dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
      }
    }
  }
  long long ans = 0;
  for (int j = 1; N >= j; j++) {
    ans += dp[N - 1][j][j * A];
  }
  cout << ans << endl;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
long long dp[51][51][2501]; // i番目j個とったとき和がkになる個数
int main() {
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  for (int i = 0; N > i; i++) {
    cin >> x[i];
  }
  dp[0][0][0] = 1;
  dp[0][1][x[0]] = 1;
  for (int i = 1; N > i; i++) {
    for (int j = 0; i + 1 >= j; j++) {
      for (int k = 0; 2500 >= k; k++) {
        dp[i][j][k] = dp[i - 1][j][k];
        if (j && k >= x[i])
          dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
      }
    }
  }
  long long ans = 0;
  for (int j = 1; N >= j; j++) {
    ans += dp[N - 1][j][j * A];
  }
  cout << ans << endl;
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9 + 7;

ll dp[50][50][3000];

int main() {
  int N, A;
  cin >> N >> A;
  int x[N];
  for (int i = 0; i < N; i++)
    cin >> x[i];
  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < 3000; k++) {
        if (dp[i][j][k] == 0)
          continue;
        // xiを使う場合
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        // xiを使わない場合
        dp[i + 1][j][k] += dp[i][j][k];
      }
    }
  }

  ll sum = 0;
  for (int i = 1; i <= N; i++)
    sum += dp[N][i][A * i];

  cout << sum << endl;
  return 0;
}


Fixed submission:
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9 + 7;

ll dp[60][60][3000];

int main() {
  int N, A;
  cin >> N >> A;
  int x[N];
  for (int i = 0; i < N; i++)
    cin >> x[i];
  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < 3000; k++) {
        if (dp[i][j][k] == 0)
          continue;
        // xiを使う場合
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        // xiを使わない場合
        dp[i + 1][j][k] += dp[i][j][k];
      }
    }
  }

  ll sum = 0;
  for (int i = 1; i <= N; i++)
    sum += dp[N][i][A * i];

  cout << sum << endl;
  return 0;
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX = 255;
ll dp[55][MAX];
int main() {
  int n, a;
  cin >> n >> a;
  dp[0][0] = 1;
  rep(i, n) {
    int x;
    cin >> x;
    rep(ik, i + 1) {
      int k = i - ik;
      rep(v, MAX - x) dp[k + 1][x + v] += dp[k][v];
    }
  }
  ll ans = 0;
  rep(i, n) ans += dp[i + 1][(i + 1) * a];
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX = 2505;
ll dp[55][MAX];
int main() {
  int n, a;
  cin >> n >> a;
  dp[0][0] = 1;
  rep(i, n) {
    int x;
    cin >> x;
    rep(ik, i + 1) {
      int k = i - ik;
      rep(v, MAX - x) dp[k + 1][x + v] += dp[k][v];
    }
  }
  ll ans = 0;
  rep(i, n) ans += dp[i + 1][(i + 1) * a];
  cout << ans << endl;
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> x[i];
    x[i] -= a;
  }
  vector<vector<long>> dp(n, vector<long>(100050, 0));
  dp[0][50000 + x[0]] = 1;
  for (i = 1; i < n; i++) {
    for (j = 0; j < 100000; j++) {
      dp[i][j + x[i]] = dp[i - 1][j] + dp[i - 1][j + x[i]];
    }
    dp[i][50000 + x[i]] += 1;
  }
  cout << dp[n - 1][50000] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> x[i];
    x[i] -= a;
  }
  vector<vector<long>> dp(n, vector<long>(100050, 0));
  dp[0][50000 + x[0]] = 1;
  for (i = 1; i < n; i++) {
    for (j = 100; j < 100000; j++) {
      dp[i][j + x[i]] = dp[i - 1][j] + dp[i - 1][j + x[i]];
    }
    dp[i][50000 + x[i]] += 1;
  }
  cout << dp[n - 1][50000] << endl;
}
Problem p04013 (C++)

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

using namespace std;
typedef long long ll;

int n, a, maxX;
int x[51];
ll dp[51][51][3001]; // dp[i][j][k] num of combination that till ith, select j
                     // number and its sum is k

void solve() {
  dp[0][0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= maxX * n; k++) {
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
      }
    }
  }
  ll cnt = 0;
  for (int i = 1; i <= n; i++) {
    cnt += dp[n][i][i * a];
  }
  cout << cnt << endl;
}

int main() {
  cin >> n >> a;
  maxX = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    maxX = max(maxX, x[i]);
  }
  solve();
}


Fixed submission:
// review
#include <iostream>

using namespace std;
typedef long long ll;

int n, a, maxX;
int x[51];
ll dp[51][51][3001]; // dp[i][j][k] num of combination that till ith, select j
                     // number and its sum is k

void solve() {
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k <= maxX * n; k++) {
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
      }
    }
  }
  ll cnt = 0;
  for (int i = 1; i <= n; i++) {
    cnt += dp[n][i][i * a];
  }
  cout << cnt << endl;
}

int main() {
  cin >> n >> a;
  maxX = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    maxX = max(maxX, x[i]);
  }
  solve();
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  ll n, a;
  cin >> n >> a;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];
  ll mx = *max_element(all(x));
  ll dp[n + 1][n + 1][mx * n + 10];
  rep(i, n + 1) {
    rep(j, n + 1) {
      rep(k, mx * n + 1) { dp[i][j][k] = 0; }
    }
  }

  rep(j, n + 1) {
    rep(k, n + 1) {
      rep(s, mx * n + 1) {
        if (j == 0 && k == 0 && s == 0)
          dp[j][k][s] = 1;
        else if (j >= 1 && s < x[j - 1])
          dp[j][k][s] = dp[j - 1][k][s];
        else if (j >= 1 && k >= 1 && s >= x[j - 1])
          dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
        else
          dp[j][k][s] = 0;
      }
    }
  }

  ll count = 0;
  for (size_t i = 1; i <= n; i++) {
    count += dp[n][i][i * a];
  }
  cout << count << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  ll n, a;
  cin >> n >> a;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];
  ll mx = *max_element(all(x));
  ll dp[n + 10][n + 10][mx * n + 10];
  rep(i, n + 1) {
    rep(j, n + 1) {
      rep(k, mx * n + 1) { dp[i][j][k] = 0; }
    }
  }

  rep(j, n + 1) {
    rep(k, n + 1) {
      rep(s, mx * n + 1) {
        if (j == 0 && k == 0 && s == 0)
          dp[j][k][s] = 1;
        else if (j >= 1 && s < x[j - 1])
          dp[j][k][s] = dp[j - 1][k][s];
        else if (j >= 1 && k >= 1 && s >= x[j - 1])
          dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
        else
          dp[j][k][s] = 0;
      }
    }
  }

  ll count = 0;
  for (size_t i = 1; i <= n; i++) {
    count += dp[n][i][i * a];
  }
  cout << count << endl;
  return 0;
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>

#include <vector>

using namespace std;

long long dp[50][50][2501];

int N;
vector<long long> vlist;

long long process(int max_n, int curr_n, int start_n, int max_v, int curr_v) {
  if (curr_n >= max_n) {
    if (curr_v == max_v)
      return 1;
    return 0;
  }

  long long &ret = dp[curr_n][start_n][curr_v];
  if (ret != -1)
    return ret;

  ret = 0;
  for (int i = start_n; i < N; i++) {
    if (curr_v + vlist[i] <= max_v)
      ret += process(max_n, curr_n + 1, i + 1, max_v, curr_v + vlist[i]);
  }

  return ret;
}

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

  int A;
  cin >> N >> A;

  vlist.assign(N, 0);

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

  long long result = 0;
  for (int i = 1; i <= N; i++) {
    fill_n(&dp[0][0][0], sizeof(dp) / sizeof(long long), -1);
    result += process(i, 0, 0, i * A, 0);
  }

  cout << result;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>

#include <vector>

using namespace std;

long long dp[50][50][2501];

int N;
vector<long long> vlist;

long long process(int max_n, int curr_n, int start_n, int max_v, int curr_v) {
  if (curr_n >= max_n) {
    if (curr_v == max_v)
      return 1;
    return 0;
  } else if (start_n >= N)
    return 0;

  long long &ret = dp[curr_n][start_n][curr_v];
  if (ret != -1)
    return ret;

  ret = 0;
  for (int i = start_n; i < N; i++) {
    if (curr_v + vlist[i] <= max_v)
      ret += process(max_n, curr_n + 1, i + 1, max_v, curr_v + vlist[i]);
  }

  return ret;
}

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

  int A;
  cin >> N >> A;

  vlist.assign(N, 0);

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

  long long result = 0;
  for (int i = 1; i <= N; i++) {
    fill_n(&dp[0][0][0], sizeof(dp) / sizeof(long long), -1);
    result += process(i, 0, 0, i * A, 0);
  }

  cout << result;

  return 0;
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n - 1, i)
#define MAX 51

typedef long long ll;
// dp[i][j][k]:=i枚目までのj枚で和がk
ll dp[MAX][MAX][MAX * MAX];

void solve(void) {
  ll n, a, sum = 0;
  cin >> n >> a;
  ll xs[n];
  rep(n, i) scanf("%lld", &xs[i]);
  sort(xs, xs + n);

  dp[0][0][0] = 1LL;
  Rep(0, n - 1, i) {
    sum += xs[i];
    Rep(0, i, j) {
      Rep(0, sum, k) {
        if (dp[i][j][k]) {
          dp[i + 1][j][k] += dp[i][j][k];
          dp[i + 1][j + 1][k + xs[i]] += dp[i][j][k];
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i * a <= sum; i++) {
    ans += dp[n][i][i * a];
  }
  cout << ans << '\n';
}

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


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n - 1, i)
#define MAX 128

typedef long long ll;
// dp[i][j][k]:=i枚目までのj枚で和がk
ll dp[MAX][MAX][MAX * MAX];

void solve(void) {
  ll n, a, sum = 0;
  cin >> n >> a;
  ll xs[n];
  rep(n, i) scanf("%lld", &xs[i]);
  sort(xs, xs + n);

  dp[0][0][0] = 1LL;
  Rep(0, n - 1, i) {
    sum += xs[i];
    Rep(0, i, j) {
      Rep(0, sum, k) {
        if (dp[i][j][k]) {
          dp[i + 1][j][k] += dp[i][j][k];
          dp[i + 1][j + 1][k + xs[i]] += dp[i][j][k];
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i * a <= sum; i++) {
    ans += dp[n][i][i * a];
  }
  cout << ans << '\n';
}

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int dp[50][50][3000], a[100];
int main() {
  int n, aa;
  cin >> n >> aa;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j >= 0; j--) {
      for (int k = aa * n + 1; k >= 0; k--) {
        dp[i][j][k] += dp[i - 1][j][k];
        if (k >= a[i] && j >= 1)
          dp[i][j][k] += dp[i - 1][j - 1][k - a[i]];
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[n][i][i * aa];
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
ll dp[55][55][3000], a[3000];
int main() {
  int n, aa;
  cin >> n >> aa;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j >= 0; j--) {
      for (int k = aa * n + 1; k >= 0; k--) {
        dp[i][j][k] += dp[i - 1][j][k];
        if (k >= a[i] && j >= 1)
          dp[i][j][k] += dp[i - 1][j - 1][k - a[i]];
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[n][i][i * aa];
  }
  cout << ans << endl;
  return 0;
}
Problem p04013 (C++)

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

using namespace std;

int N, A;
int x[51];
long long dp[3000][52][52];

int main() {
  scanf("%d%d", &N, &A);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &x[i]);
  }
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (int i = 0; i < 2600; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        dp[i + x[j]][j + 1][k + 1] += dp[i][j][k];
        dp[i][j + 1][k] += dp[i][j][k];
      }
    }
  }
  long long answer = 0;
  for (int i = 1; i * A < 3000; ++i) {
    answer += dp[i * A][N][i];
  }
  printf("%lld\n", answer);
  return 0;
}


Fixed submission:
#include <cstdio>
#include <cstring>

using namespace std;

int N, A;
int x[51];
long long dp[3000][52][52];

int main() {
  scanf("%d%d", &N, &A);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &x[i]);
  }
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (int i = 0; i < 2600; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        dp[i + x[j]][j + 1][k + 1] += dp[i][j][k];
        dp[i][j + 1][k] += dp[i][j][k];
      }
    }
  }
  long long answer = 0;
  for (int i = 1; i <= N; ++i) {
    answer += dp[i * A][N][i];
  }
  printf("%lld\n", answer);
  return 0;
}
Problem p04013 (C++)

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

using namespace std;

const int MAX_N = 55;

long long dp[2][MAX_N * MAX_N][MAX_N], ans;

int main() {
  int n, a, x;
  cin >> n >> a;
  dp[0][0][0] = dp[1][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    copy(&dp[1][0][1], &dp[1][n * a][n] + 1, &dp[0][0][1]);
    transform(&dp[1][0][0], &dp[1][n * a - x][n - 1] + 1, &dp[0][x][1],
              &dp[0][x][1], plus<>());
    swap(dp[0], dp[1]);
  }
  for (int k = 1; k <= n; k++)
    ans += dp[1][a * k][k];
  cout << ans;
  return 0;
}

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

using namespace std;

const int MAX_N = 55;

long long dp[2][MAX_N * MAX_N][MAX_N], ans;

int main() {
  int n, a, x;
  cin >> n >> a;
  dp[0][0][0] = dp[1][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    copy(&dp[1][0][1], &dp[1][n * a][n] + 1, &dp[0][0][1]);
    transform(&dp[0][x][1], &dp[0][n * 50][n] + 1, &dp[1][0][0], &dp[0][x][1],
              plus<>());
    swap(dp[0], dp[1]);
  }
  for (int k = 1; k <= n; k++)
    ans += dp[1][a * k][k];
  cout << ans;
  return 0;
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(), V.end()
#define MOD 1000000007

ll dp[50][50][2520];

int main() {
  int N, A;
  cin >> N >> A;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }

  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {        // 何個使いましたか
    for (int j = 0; j < N; j++) {      // 何個目まで見ましたか
      for (int k = 0; k < 2520; k++) { // 現在の値は何ですか
        if (k + X[j] < 2520)
          dp[i + 1][j + 1][k + X[j]] += dp[i][j][k];
        dp[i][j + 1][k] += dp[i][j][k];
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += dp[i][N][i * A];
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(), V.end()
#define MOD 1000000007

ll dp[53][53][2520];

int main() {
  int N, A;
  cin >> N >> A;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }

  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {        // 何個使いましたか
    for (int j = 0; j < N; j++) {      // 何個目まで見ましたか
      for (int k = 0; k < 2520; k++) { // 現在の値は何ですか
        if (k + X[j] < 2520)
          dp[i + 1][j + 1][k + X[j]] += dp[i][j][k];
        dp[i][j + 1][k] += dp[i][j][k];
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += dp[i][N][i * A];
  }
  cout << ans << endl;
}
Problem p04013 (C++)

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

int N, A;

// dp[j][k][s] ... x_1 から x_j から k 枚選んで x_i の合計を s
// にするような選び方の総数 0 ≦ j ≦ N, 0 ≦ k ≦ N, 0 ≦ s ≦ NX
int dp[50][50][2501];

int main() {

  cin >> N >> A;

  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  dp[0][0][0] = 1;

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= 2500; k++) {

        if (0 < j && (k - x[i - 1]) >= 0) {
          dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
        } else {
          dp[i][j][k] = dp[i - 1][j][k];
        }
      }
    }
  }

  long long sum = 0;

  for (int i = 1; i <= N; i++) {
    sum += dp[N][i][i * A];
  }

  cout << sum << endl;

  return 0;
}

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

int N, A;

// dp[j][k][s] ... x_1 から x_j から k 枚選んで x_i の合計を s
// にするような選び方の総数 0 ≦ j ≦ N, 0 ≦ k ≦ N, 0 ≦ s ≦ NX
long long dp[51][51][2501];

int main() {

  cin >> N >> A;

  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  dp[0][0][0] = 1;

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= 2500; k++) {

        if (0 < j && (k - x[i - 1]) >= 0) {
          dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
        } else {
          dp[i][j][k] = dp[i - 1][j][k];
        }
      }
    }
  }

  long long sum = 0;

  for (int i = 1; i <= N; i++) {
    sum += dp[N][i][i * A];
  }

  cout << sum << endl;

  return 0;
}
Problem p04013 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int N, A, X[51];
long long ans = 0, dp[51][51][3005];

int main() {

  cin >> N >> A;

  for (int i = 1; i <= N; i++) {
    cin >> X[i];
  }

  dp[0][0][0] = 1;

  for (int j = 1; j <= N; j++) {
    for (int k = 0; k <= N; k++) {
      for (int s = 0; s <= 30000; s++) {
        // cout << "j: " << j << " k: " << k << " X[j]: " << X[j] << endl;
        if (s < X[j]) {
          dp[j][k][s] = dp[j - 1][k][s];
        } else if (X[j] <= s &&
                   1 <= k) { // k>=1でないと、選ぶ選ばないの話ができない
          dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - X[j]];
        } else {
          dp[j][k][s] = 0;
        }
      }
    }
  }

  for (int k = 1; k <= N; k++) {
    ans += dp[N][k][k * A];
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int N, A, X[51];
long long ans = 0, dp[51][51][3005];

int main() {

  cin >> N >> A;

  for (int i = 1; i <= N; i++) {
    cin >> X[i];
  }

  dp[0][0][0] = 1;

  for (int j = 1; j <= N; j++) {
    for (int k = 0; k <= N; k++) {
      for (int s = 0; s <= 3000; s++) {
        // cout << "j: " << j << " k: " << k << " X[j]: " << X[j] << endl;
        if (s < X[j]) {
          dp[j][k][s] = dp[j - 1][k][s];
        } else if (X[j] <= s &&
                   1 <= k) { // k>=1でないと、選ぶ選ばないの話ができない
          dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - X[j]];
        } else {
          dp[j][k][s] = 0;
        }
      }
    }
  }

  for (int k = 1; k <= N; k++) {
    ans += dp[N][k][k * A];
  }

  cout << ans << endl;

  return 0;
}