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

#include <cctype>
#include <iostream>
#include <stack>
#include <utility>

using namespace std;

typedef pair<long long, long long> PLL;

const int M = 1000000007;
stack<PLL> num;
stack<char> op;

bool do2() {
  bool flag = false;
  while (!op.empty()) {
    if (op.top() == '&') {
      auto r = num.top();
      num.pop();
      auto l = num.top();
      num.pop();
      auto t = (r.first * l.first) % M;
      num.push(PLL(t, ((l.first + l.second) * (r.first + r.second) - t) % M));
    } else if (op.top() == '~') {
      auto r = num.top();
      num.pop();
      num.push(PLL(r.second, r.first));
    } else {
      break;
    }
    flag = true;
    op.pop();
  }
  return flag;
}

void do3() {
  while (!op.empty()) {
    if (do2()) {
    } else if (op.top() == '|') {
      auto r = num.top();
      num.pop();
      auto l = num.top();
      num.pop();
      auto f = (r.second * l.second) % M;
      num.push(PLL(((l.first + l.second) * (r.first + r.second) - f) % M, f));
      op.pop();
    } else {
      break;
    }
  }
}

int main() {
  char str[1000001];
  cin >> str;
  for (char *p = str; *p;) {
    if (*p == 'x') {
      num.push(PLL(1, 1));
      p++;
      while (isdigit(*p)) {
        p++;
      }
    } else {
      if (*p == ')') {
        do3();
        op.pop();
      } else {
        if (*p == '|') {
          do3();
        } else if (*p == '&') {
          do2();
        }
        op.push(*p);
      }
      p++;
    }
  }
  do3();
  cout << num.top().first << endl;
}

Error: 0

Fixed submission:

#include <iostream>
#include <utility>

using namespace std;

typedef pair<long long, long long> PLL;
const int M = 1000000007;
char str[1000001];
char *p = str;

PLL expression();
PLL term();
PLL factor();

PLL expression() {
  auto l = term();
  while (*p == '|') {
    p++;
    auto r = term();
    auto f = (l.second * r.second) % M;
    l = PLL(((l.first + l.second) * (r.first + r.second) - f) % M, f);
  }
  return l;
}

PLL term() {
  auto l = factor();
  while (*p == '&') {
    p++;
    auto r = factor();
    auto t = (l.first * r.first) % M;
    l = PLL(t, ((l.first + l.second) * (r.first + r.second) - t) % M);
  }
  return l;
}

PLL factor() {
  if (*p == '~') {
    p++;
    auto l = factor();
    return PLL(l.second, l.first);
  } else if (*p == '(') {
    p++;
    auto l = expression();
    p++;
    return l;
  } else {
    p++;
    while (isdigit(*p)) {
      p++;
    }
    return PLL(1, 1);
  }
}

int main() {
  cin >> str;
  cout << expression().first << endl;
}
Problem p01470 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

long long module(long long x, long long m) {
  while (x >= m)
    x -= m;
  return x;
}

long long mul(long long a, long long b, long long mod) {
  if (b == 0)
    return 0;
  long long res = mul(module(a + a, mod), b / 2, mod);
  if (b & 1)
    res = module(res + a, mod);
  return res;
}

long long pow(long long a, long long b, long long mod) {
  if (b == 0)
    return 1;
  long long res = pow(mul(a, a, mod), b / 2, mod);
  if (b & 1)
    res = mul(res, a, mod);
  return res;
}

long long inv(long long a, long long mod) { return pow(a, mod - 2, mod); }

int main() {
  int N;
  const long long P = 10000000019;
  while (cin >> N) {
    long long X = 0;
    for (int i = 0; i < N; i++) {
      int ope;
      long long Y;
      cin >> ope >> Y;
      if (ope == 1) {
        X = (X + Y + P) % P;
      } else if (ope == 2) {
        X = (X - Y + P) % P;
      } else if (ope == 3) {
        X = mul(X, abs(Y), P);
        if (Y < 0) {
          X = (-X + P) % P;
        }
      } else {
        X = mul(X, inv(abs(Y), P), P);
        if (Y < 0) {
          X = (-X + P) % P;
        }
      }
      // cout << X << endl;
    }
    if (X > INT_MAX) {
      X = X - P;
    }
    cout << X << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

long long extgcd(long long a, long long b, long long &x, long long &y) {
  long long d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

long long mul(long long a, long long b, long long mod) {
  if (b == 0)
    return 0;
  long long res = mul((a + a) % mod, b / 2, mod);
  if (b & 1)
    res = (res + a) % mod;
  return res;
}

long long pow(long long a, long long b, long long mod) {
  if (b == 0)
    return 1;
  long long res = pow(mul(a, a, mod), b / 2, mod);
  if (b & 1)
    res = mul(res, a, mod);
  return res;
}

long long inv(long long a, long long mod) { return pow(a, mod - 2, mod); }

int main() {
  int N;
  const long long P = 10000000019;
  while (cin >> N) {
    long long X = 0;
    for (int i = 0; i < N; i++) {
      int ope;
      long long Y;
      cin >> ope >> Y;
      if (ope == 1) {
        X = (X + Y + P) % P;
      } else if (ope == 2) {
        X = (X - Y + P) % P;
      } else if (ope == 3) {
        X = mul(X, abs(Y), P);
        if (Y < 0) {
          X = (-X + P) % P;
        }
      } else {
        X = mul(X, inv(abs(Y), P), P);
        if (Y < 0) {
          X = (-X + P) % P;
        }
      }
      // cout << X << endl;
    }
    if (X > INT_MAX) {
      X = X - P;
    }
    cout << X << endl;
  }
  return 0;
}
Problem p01470 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

typedef long long ll;

ll mod = 8589934609ll;

ll mul(ll x, ll y) { // x * y
  ll res = (x * (y >> 30)) % mod;

  res = (res << 15) % mod;
  res = (res << 15) % mod;
  res += x * (((y >> 30) << 30) ^ y);
  res %= mod;
  return res;
}

ll powmod(ll x, ll p) {
  if (p == 0)
    return 1;
  if (p == 1)
    return x;

  if (p % 2)
    return mul(x, powmod(x, p - 1));
  else
    return powmod(mul(x, x), p / 2);
}

ll modInverse(ll x) { // x^(mod-2)
  return powmod(x, mod - 2);
}

int main() {
  int n, o, y;
  ll ans = 0;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> o >> y;

    switch (o) {
    case 1:
      ans += y;
      ans %= mod;
      break;
    case 2:
      ans -= y;
      ans = (ans + mod) % mod;
      break;
    case 3:
      ans = mul(ans, y);
      break;
    case 4:
      ans = mul(ans, modInverse(y));
      break;
    }
  }

  if (ans >= 1ll << 31)
    ans -= mod;
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

typedef long long ll;

ll mod = 8589934609ll;

ll mul(ll x, ll y) { // x * y
  ll res = (x * (y >> 30)) % mod;
  for (int i = 0; i < 30; ++i)
    res = (res << 1) % mod;
  res += x * (((y >> 30) << 30) ^ y);
  res %= mod;
  return res;
}

ll powmod(ll x, ll p) {
  if (p == 0)
    return 1;
  if (p == 1)
    return x;

  if (p % 2)
    return mul(x, powmod(x, p - 1));
  else
    return powmod(mul(x, x), p / 2);
}

ll modInverse(ll x) { // x^(mod-2)
  return powmod(x, mod - 2);
}

int main() {
  int n, o, y;
  ll ans = 0;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> o >> y;

    switch (o) {
    case 1:
      ans += y;
      ans %= mod;
      break;
    case 2:
      ans -= y;
      ans = (ans + mod) % mod;
      break;
    case 3:
      ans = mul(ans, y);
      break;
    case 4:
      ans = mul(ans, modInverse(y));
      break;
    }
  }

  if (ans >= 1ll << 31)
    ans -= mod;
  cout << ans << endl;
}
Problem p01470 (C++) — buggy submission, verdict: Time Limit Exceeded

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

long long p = 5e9;

long long isprime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return 0;
  }
  return 1;
}

inline long long mul(long long a, long long b) {
  long long res = 0;
  while (b) {
    if (b & 1) {
      res += a;
      if (res >= p)
        res -= p;
    }
    a *= 2;
    if (a >= p)
      a -= p;
    b >>= 1;
  }
  return res;
}

inline long long bpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = mul(res, a);
      res %= p;
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int main() {
  while (!isprime(p))
    p++;

  int N;
  cin >> N;
  long long X = 0;
  for (int i = 0; i < N; i++) {
    long long op, Y;
    scanf("%lld %lld", &op, &Y);
    Y = (Y + p) % p;
    if (op == 1) { //+
      X = X + Y;
      X %= p;
    } else if (op == 2) { //-
      X = X - Y;
      X %= p;
    } else if (op == 3) { //*
      X = mul(X, Y);
    } else { // /
      X = mul(X, bpow(Y, p - 2));
    }
    X = (X + p) % p;
  }
  if (X < (1ll << 31)) {
    cout << X << endl;
  } else {
    cout << X - p << endl;
  }
}

Error: TLE

Fixed submission:

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

long long p = 5e9;

long long isprime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return 0;
  }
  return 1;
}

inline long long mul(long long a, long long b) {
  if (a < b)
    swap(a, b);
  if (b == 0)
    return 0;
  long long c = mul((2 * a) % p, b / 2);
  if (b & 1)
    c += a;
  return c % p;
}

inline long long bpow(long long a, long long b) {
  if (b == 0)
    return 1;
  long long c = bpow(mul(a, a) % p, b / 2);
  if (b & 1)
    c = mul(c, a);
  return c % p;
}

int main() {
  while (!isprime(p))
    p++;

  int N;
  cin >> N;
  long long X = 0;
  for (int i = 0; i < N; i++) {
    long long op, Y;
    scanf("%lld %lld", &op, &Y);
    Y = (Y + p) % p;
    if (op == 1) { //+
      X = X + Y;
      X %= p;
    } else if (op == 2) { //-
      X = X - Y;
      X %= p;
    } else if (op == 3) { //*
      X = mul(X, Y);
    } else { // /
      X = mul(X, bpow(Y, p - 2));
    }
    X = (X + p) % p;
  }
  if (X < (1ll << 31)) {
    cout << X << endl;
  } else {
    cout << X - p << endl;
  }
}
Problem p01471 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
struct node {
  double w, v, u;
};
vector<node> list;
bool cmp(node A, node B) { return A.v / A.w > B.v / B.w; }
int main() {
  // freopen("input.txt","r",stdin);
  int N;
  double W;
  while (scanf("%d%lf", &N, &W) == 2) {
    list.clear();
    double ans = 0.0;
    for (int i = 0; i < N; i++) {
      node obj;
      scanf("%lf%lf", &obj.w, &obj.v);
      obj.u = obj.v / obj.w;
      if (obj.w <= 0 && obj.v >= 0) {
        W -= obj.w;
        ans += obj.v;
        continue;
      }
      if (obj.w >= 0 && obj.v <= 0)
        continue;
      if (obj.w <= 0 && obj.v <= 0) {
        W -= obj.w;
        ans += obj.v;
        obj.w *= -1.0;
        obj.v *= -1.0;
      }
      list.push_back(obj);
    }
    sort(list.begin(), list.end(), cmp);
    for (int i = 0; i < list.size(); i++) {
      if (list[i].w <= W) {
        W -= list[i].w;
        ans += list[i].v;
      } else {
        ans += list[i].u * W;
        W = 0.0;
      }
    }
    printf("%.8lf\\n", ans);
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
struct node {
  double w, v, u;
};
vector<node> list;
bool cmp(node A, node B) { return A.v / A.w > B.v / B.w; }
int main() {
  // freopen("input.txt","r",stdin);
  int N;
  double W;
  while (scanf("%d%lf", &N, &W) == 2) {
    list.clear();
    double ans = 0.0;
    for (int i = 0; i < N; i++) {
      node obj;
      scanf("%lf%lf", &obj.w, &obj.v);
      obj.u = obj.v / obj.w;
      if (obj.w <= 0 && obj.v >= 0) {
        W -= obj.w;
        ans += obj.v;
        continue;
      }
      if (obj.w >= 0 && obj.v <= 0)
        continue;
      if (obj.w <= 0 && obj.v <= 0) {
        W -= obj.w;
        ans += obj.v;
        obj.w *= -1.0;
        obj.v *= -1.0;
      }
      list.push_back(obj);
    }
    sort(list.begin(), list.end(), cmp);
    for (int i = 0; i < N; i++) {
      if (list[i].w <= W) {
        W -= list[i].w;
        ans += list[i].v;
      } else {
        ans += list[i].u * W;
        W = 0.0;
      }
    }
    printf("%.8lf\\n", ans);
  }
  return 0;
}
Problem p01473 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define ALL(T) T.begin(), T.end()

long long fact(long long n);

int main() {
  string S;
  cin >> S;
  map<char, int> chrs;

  for (char c = 'a'; c <= 'z'; c++) {
    chrs[c] = 0;
  }

  for (int i = 0; i < S.size(); i++) {
    chrs[S[i]]++;
  }

  int oddc = 0;
  int odd = 0;
  vector<int> hchrc;

  for (map<char, int>::iterator it = chrs.begin(); it != chrs.end(); it++) {
    if (it->second % 2) {
      odd = it->second;
      oddc++;
    } else {
      if (it->second) {
        hchrc.push_back((it->second) / 2);
      }
    }
  }

  long long int res = 0;

  if (oddc < 2) {
    odd = (odd - 1) / 2;
    hchrc.push_back(odd);
    int sum = 0;
    for (int i = 0; i < hchrc.size(); i++) {
      sum += hchrc[i];
    }
    res = 1;
    res *= fact(sum);
    for (int i = 0; i < hchrc.size(); i++) {
      res /= fact(hchrc[i]);
    }
  }

  cout << res << endl;

  return 0;
}

long long fact(long long n) {
  if (n <= 1) {
    return 1;
  } else {
    return n * fact(n - 1);
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define ALL(T) T.begin(), T.end()

long long fact(long long n);

int main() {
  string S;
  cin >> S;
  map<char, int> chrs;

  for (char c = 'a'; c <= 'z'; c++) {
    chrs[c] = 0;
  }

  for (int i = 0; i < S.size(); i++) {
    chrs[S[i]]++;
  }

  int oddc = 0;
  int odd = 0;
  vector<int> hchrc;

  for (map<char, int>::iterator it = chrs.begin(); it != chrs.end(); it++) {
    if (it->second % 2) {
      odd = it->second;
      oddc++;
    } else {
      if (it->second) {
        hchrc.push_back((it->second) / 2);
      }
    }
  }

  long long int res = 0;

  if (oddc < 2) {
    odd = (odd - 1) / 2;
    int sum = 0;
    for (int i = 0; i < hchrc.size(); i++) {
      sum += hchrc[i];
    }
    if (oddc && odd) {
      sum += odd;
    }
    res = 1;
    res *= fact(sum);
    for (int i = 0; i < hchrc.size(); i++) {
      res /= fact(hchrc[i]);
    }
    if (oddc && odd) {
      res /= fact(odd);
    }
  }

  cout << res << endl;

  return 0;
}

long long fact(long long n) {
  if (n == 1) {
    return 1;
  } else {
    return n * fact(n - 1);
  }
}
Problem p01473 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <iostream>
using namespace std;
int main() {
  unsigned long long int FACTORIAL[21];
  FACTORIAL[0] = 1;
  for (int i = 1; i < 21; i++)
    FACTORIAL[i] = FACTORIAL[i - 1] * i;
  string s;
  int odd = 0;
  cin >> s;
  int num[26] = {};
  unsigned long long int ans;
  for (int i = 0; i < s.size(); i++) {
    num[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    odd += num[i] & 1;
  }
  if (odd > 1) {
    cout << 0 << endl;
  } else {
    ans = FACTORIAL[s.size() / 2];
    for (int i = 0; i < 26; i++) {
      ans /= FACTORIAL[num[i] / 2];
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:


#include <iostream>
#include <map>
#include <vector>
using namespace std;
unsigned long long int factorial(unsigned long long int n) {
  if (n == 1)
    return 1;
  return n * factorial(n - 1);
}
int main() {
  string s;
  int odd = 0;
  cin >> s;
  unsigned long long int ans;
  vector<unsigned long long int> v;
  map<char, unsigned long long int> m;
  map<char, unsigned long long int>::iterator it;
  for (int i = 0; i < s.size(); i++) {
    m[s[i]]++;
  }
  for (it = m.begin(); it != m.end(); it++) {
    if ((it->second) & 1) {
      odd++;
    } else {
      v.push_back((it->second) / 2);
    }
  }
  if (odd > 1) {
    cout << 0 << endl;
  } else {
    ans = factorial(s.size() / 2);
    for (int i = 0; i < v.size(); i++)
      ans /= factorial(v[i]);
    cout << ans << endl;
  }
}
Problem p01473 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

ll fact(int n) {
  ll ret = 1;
  for (int i = 1; i <= n; i++)
    ret *= i;
  return ret;
}

int main() {
  int al[30] = {};

  string s;
  cin >> s;
  rep(i, s.size()) { al[s[i] - 'a']++; }

  int even = 0, odd = 0;
  ll div = 1;
  rep(i, 28) {
    if (al[i] == 0)
      continue;
    if (al[i] % 2 == 0) {
      even += al[i] / 2;
      div *= fact(al[i] / 2);
    } else {
      odd++;
      even += (al[i] - 1) / 2;
      if (al[i] > 1)
        div *= (al[i] - 1) / 2;
    }
  }

  if (odd > 1) {
    cout << 0 << endl;
  } else {
    cout << fact(even) / div << endl;
  }
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

ll fact(int n) {
  ll ret = 1;
  for (int i = 1; i <= n; i++)
    ret *= i;
  return ret;
}

int main() {
  int al[30] = {};

  string s;
  cin >> s;
  rep(i, s.size()) { al[s[i] - 'a']++; }

  vector<char> p;
  int even = 0, odd = 0;
  rep(i, 28) {
    if (al[i] == 0)
      continue;
    if (al[i] % 2 == 0) {
      even++;
      rep(j, al[i] / 2) p.pb('a' + i);
    } else
      odd++;
  }

  if (odd > 1) {
    cout << 0 << endl;
  } else {
    ll c = 0;
    do {
      c++;
    } while (next_permutation(all(p)));
    cout << c << endl;
  }
}
Problem p01473 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
#include <string>
#define rep(i, a, b) for (int i = a; i < b; i++)

using namespace std;
typedef long long ll;
string s;

ll fact(ll x) {
  if (x == 0)
    return 1;
  return x * fact(x - 1);
}

int main() {
  cin >> s;
  map<char, int> mp;
  rep(i, 0, s.size()) mp[s[i]]++;

  int cnt = 0;
  int sum = 0;
  ll ans;
  map<char, int>::iterator itr = mp.begin();
  while (itr != mp.end()) {
    // cout << itr->first << " "<< itr->second << endl;
    if (itr->second % 2 == 1) {
      (itr->second)--;
      cnt++;
    }
    sum += itr->second / 2;
    itr++;
  }
  if (s.size() == 1) {
    cout << 1 << endl;
  } else if (cnt > 0 && s.size() % 2 == 0)
    cout << 0 << endl;
  else if (cnt > 1)
    cout << 0 << endl;
  else {
    ans = fact(sum);
    itr = mp.begin();
    while (itr != mp.end()) {
      // cout << itr->first << " A "<< itr->second << endl;
      ans /= fact(itr->second / 2);
      itr++;
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <map>
#include <string>
#define rep(i, a, b) for (int i = a; i < b; i++)

using namespace std;
typedef long long ll;
string s;

ll fact(ll x) {
  if (x == 1)
    return 1;
  return x * fact(x - 1);
}

int main() {
  cin >> s;
  map<char, int> mp;
  rep(i, 0, s.size()) mp[s[i]]++;

  int cnt = 0;
  int sum = 0;
  ll ans;
  map<char, int>::iterator itr = mp.begin();
  while (itr != mp.end()) {
    // cout << itr->first << " "<< itr->second << endl;
    if (itr->second % 2 == 1) {
      (itr->second)--;
      cnt++;
    }
    sum += itr->second / 2;
    itr++;
  }
  if (s.size() == 1) {
    cout << 1 << endl;
  } else if (cnt > 0 && s.size() % 2 == 0)
    cout << 0 << endl;
  else if (cnt > 1)
    cout << 0 << endl;
  else {
    ans = fact(sum);
    itr = mp.begin();
    while (itr != mp.end()) {
      // cout << itr->first << " A "<< itr->second << endl;
      ans /= fact(itr->second / 2);
      itr++;
    }
    cout << ans << endl;
  }
}
Problem p01473 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int, int> P;
const int INF = 1000000000;

long long int f(int n) {
  if (n <= 1)
    return 1;
  return f(n - 1) * n;
}

int main() {
  char s[50];
  static int x[30];
  int um = 0, om = 0, lm = 0;
  long long int result;
  scanf("%s", s);
  rep(i, strlen(s)) { x[s[i] - 'a']++; }
  rep(i, 26) {
    if (x[i] > 0)
      um += x[i];
    if (x[i] % 2 == 1)
      om++;
  }
  if (um % 2 == 0 && om > 0) {
    result = 0;
  } else if (um % 2 == 1 && om != 1) {
    result = 0;
  } else {

    // printf("%d",lm);
    rep(i, 26) if (x[i] > 0) {
      /*if(x[i]%2==0){
              x[i]/=2;
      }else if(x[i]%2==1){
              x[i]/=2;
      }*/
      x[i] /= 2;
      lm += x[i];
    }

    // printf("%d",lm);
    // if(om==1)lm--;
    // printf("%d",lm);
    result = f(lm);
    rep(i, 26) if (x[i] > 0) { result /= f(x[i]); }
  }
  printf("%lld\\n", result);
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int, int> P;
const int INF = 1000000000;

long long int f(int n) {
  if (n == 1)
    return 1;
  return f(n - 1) * n;
}

int main() {
  char s[50];
  static int x[30];
  int um = 0, om = 0, lm = 0;
  long long int result;
  scanf("%s", s);
  rep(i, strlen(s)) { x[s[i] - 'a']++; }
  rep(i, 26) {
    if (x[i] > 0)
      um += x[i];
    if (x[i] % 2 == 1)
      om++;
  }
  if (um % 2 == 0 && om > 0) {
    result = 0;
  } else if (um % 2 == 1 && om != 1) {
    result = 0;
  } else {

    // printf("%d",lm);
    rep(i, 26) if (x[i] > 0) {
      if (x[i] % 2 == 0) {
        x[i] /= 2;
      } else if (x[i] % 2 == 1) {
        x[i] = x[i] / 2;
      }
      lm += x[i];
    }

    // printf("%d",lm);
    // if(om==1)lm--;
    // printf("%d",lm);
    result = f(lm);
    rep(i, 26) if (x[i] > 0) { result /= f(x[i]); }
  }
  printf("%lld\\n", result);
  return 0;
}