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

#include <bits/stdc++.h>

using namespace std;
long long p, n, m, z;
long long t[1000], a[1000], b[1000], c[100000], d[100000], f[3][100000];
int main() {
  p = 1000000007;
  cin >> n >> m;
  t[0] = 1;
  for (int i = 1; i <= 105; i++)
    t[i] = (t[i - 1] * 2) % p;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
  }
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= t[n] - 1; i++) {
      if ((1 & i >> a[j] - 1) && (1 & i >> b[j] - 1))
        c[i]++;
      if ((1 & i >> a[j] - 1) || (1 & i >> b[j] - 1))
        d[i]++;
    }
  for (int i = 1; i <= 2; i++)
    for (int j = 0; j <= t[n] - 1; j++) {
      if (!(j & i))
        continue;
      f[i][j] = t[c[j]];
      for (int k = j; k >= 1; k = (k - 1) & j) {
        f[i][j] = (f[i][j] + p - f[i][j - k] * t[c[k]]) % p;
      }
    }
  for (int i = 0; i <= t[n] - 1; i++)
    for (int j = 0; j <= t[n] - 1; j++) {
      if ((i & j) != 0 || c[i] + c[j] != c[i | j])
        continue;
      z = (z + (f[1][i] * f[2][j]) % p * t[m - d[i | j]]) % p;
    }
  cout << (t[m] - z + p) % p << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
long long p, n, m, z;
long long t[100000], a[100000], b[1000], c[100000], d[100000], f[2][100000];
int main() {
  p = 1000000007;
  cin >> n >> m;
  t[0] = 1;
  for (int i = 1; i <= 105; i++)
    t[i] = (t[i - 1] * 2) % p;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
  }
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= t[n] - 1; i++) {
      if ((1 & i >> a[j] - 1) && (1 & i >> b[j] - 1))
        c[i]++;
      if ((1 & i >> a[j] - 1) || (1 & i >> b[j] - 1))
        d[i]++;
    }
  for (int i = 1; i <= 2; i++)
    for (int j = 0; j <= t[n] - 1; j++) {
      if (!(j & i))
        continue;
      f[i][j] = t[c[j]];
      for (int k = j; k >= 1; k = (k - 1) & j) {
        f[i][j] = (f[i][j] + p - f[i][j - k] * t[c[k]]) % p;
      }
    }
  for (int i = 0; i <= t[n] - 1; i++)
    for (int j = 0; j <= t[n] - 1; j++) {
      if ((i & j) != 0 || c[i] + c[j] != c[i | j])
        continue;
      z = (z + (f[1][i] * f[2][j]) % p * t[m - d[i | j]]) % p;
    }
  cout << (t[m] - z + p) % p << endl;
}
Problem p03513 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Tubtet(i, k) for (k = (i - 1) & i; k; k = (k - 1) & i)
#define Subset(i, k) for (k = i; k; k = (k - 1) & i)
using namespace std;
inline int read() {
  int res = 0;
  bool bo = 0;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    bo = 1;
  else
    res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  return bo ? ~res + 1 : res;
}
const int N = 17, M = 405, C = (1 << 15) + 5, PYZ = 1e9 + 7;
int n, m, g[N][N], f[3][C], c[C], d[C], Cm, p[M], ans;
int main() {
  int i, j, k, x, y;
  n = read();
  m = read();
  p[0] = 1;
  For(i, 1, m) x = read(), y = read(), g[x][y]++, p[i] = 2ll * p[i - 1] % PYZ;
  Cm = (1 << n) - 1;
  For(i, 0, Cm) For(j, 1, n) For(k, 1, n) if (g[j][k]) {
    if (((i >> j - 1) & 1) && ((i >> k - 1) & 1))
      c[i] += g[j][k];
    if (((i >> j - 1) & 1) || ((i >> k - 1) & 1))
      d[i] += g[j][k];
  }
  For(k, 1, 2) For(i, 0, Cm) {
    if (!((i >> k - 1) & 1))
      continue;
    f[k][i] = p[c[i]];
    Tubtet(i, j) {
      if (!((j >> k - 1) & 1))
        continue;
      f[k][i] = (f[k][i] - 1ll * f[k][j] * p[c[i - j]] % PYZ + PYZ) % PYZ;
    }
  }
  ans = p[m];
  For(i, 0, Cm) {
    if (!(i & 1) || ((i >> 1) & 1))
      continue;
    Subset(Cm - i, j) {
      if (!((j >> 1) & 1) || c[i] + c[j] < c[i + j])
        continue;
      ans =
          (ans - 1ll * f[1][i] * f[2][j] % PYZ * p[m - d[i + j]] % PYZ + PYZ) %
          PYZ;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, m, i, j, x, y, k, mx, ans, f[2][100010], c[100010], d[100001], fac[10001],
    p = 1e9 + 7, du[201][201];
int main() {
  scanf("%lld%lld", &n, &m);
  fac[0] = 1;
  for (i = 1; i <= m; i++) {
    scanf("%lld%lld", &x, &y);
    x--;
    y--;
    du[x][y]++;
    fac[i] = fac[i - 1] * 2 % p;
  }
  mx = 1 << m;
  for (i = 0; i < mx; i++)
    for (j = 0; j < n; j++)
      for (k = 0; k < n; k++)
        if (du[k][j]) {
          if ((i & (1 << j)) && (i & (1 << k)))
            c[i] += du[k][j];
          if ((i & (1 << j)) || (i & (1 << k)))
            d[i] += du[k][j];
        }
  for (k = 0; k < 2; k++)
    for (i = 0; i < mx; i++)
      if (i & (1 << k)) {
        f[k][i] = fac[c[i]];
        for (j = (i - 1) & i; j; j = (j - 1) & i)
          if (j & (1 << k))
            f[k][i] = (f[k][i] - f[k][j] * fac[c[i - j]] % p + p) % p;
      }
  ans = fac[m];
  // printf("%lld\\n",ans);
  for (i = 0; i < mx; i++) {
    if (!(i & 1) || (i & 2))
      continue;
    for (j = mx - 1 - i; j; j = (j - 1) & (mx - 1 - i)) {
      if (!(j & (1 << 1)) || c[i] + c[j] < c[i + j])
        continue;
      ans = (ans - f[0][i] * f[1][j] % p * fac[m - d[i + j]] % p + p) % p;
    }
  }
  printf("%lld", ans);
}
Problem p03513 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN = 35000;
const int Mod = 1e9 + 7;
struct gao {
  int A, B;
} Edge[MAXN];
int Ans, End, n, m, Two[MAXN] = {1}, A[MAXN], B[MAXN], F[3][MAXN];
int main() {
  scanf("%d%d", &n, &m), End = (1 << n) - 1;
  for (rg int i = 1; i <= m; i++)
    scanf("%d%d", &Edge[i].A, &Edge[i].B);
  for (rg int i = 1; i <= m; i++)
    Two[i] = (Two[i - 1] << 1) % Mod;
  for (rg int i = 1; i <= End; i++)
    for (rg int j = 1; j <= m; j++) {
      if ((i & (1 << (Edge[j].A - 1))) && (i & (1 << (Edge[j].B - 1))))
        A[i]++;
      if ((i & (1 << (Edge[j].A - 1))) || (i & (1 << (Edge[j].B - 1))))
        B[i]++;
    }
  for (rg int S = 1; S <= End; S++) {
    F[1][S] = Two[A[S]] * (S & 1), F[2][S] = Two[A[S]] * (S >> 1 & 1);
    for (rg int T = (S - 1) & S; T; T = (T - 1) & S) {
      if (T & 1)
        F[1][S] = (F[1][S] - 1ll * F[1][T] * Two[A[S ^ T]]) % Mod;
      if (T & 2)
        F[2][S] = (F[2][S] - 1ll * F[2][T] * Two[A[S ^ T]]) % Mod;
    }
  }
  for (rg int S = 1; S <= End; S++)
    for (rg int T = (End ^ S); T; T = (T - 1) & (End ^ S)) {
      if (A[S] + A[T] != A[S | T] || ~S & 1 || ~T & 2)
        continue;
      Ans = (Ans - 1ll * F[1][S] * F[2][T] % Mod * Two[A[End ^ S ^ T]]) % Mod;
    }
  printf("%lld\\n", (1ll * Ans + Two[m] + Mod) % Mod);
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN = 35000;
const int Mod = 1e9 + 7;
struct gao {
  int u, v, Next;
} Edge[MAXN];
int Ans, Meet, n, m, Es = 1, First[MAXN], Ban[MAXN];
int Vis[MAXN];
inline void Link(rg int u, rg int v) {
  Edge[++Es] = (gao){u, v, First[u]}, First[u] = Es;
}
inline void Dfs(rg int Now, rg int Mark) {
  if (Mark == 2 && Vis[Now] == 1)
    Meet = 1;
  Vis[Now] = Mark;
  for (rg int i = First[Now]; i != -1; i = Edge[i].Next)
    if (Vis[Edge[i].v] != Vis[Now] && !Ban[i])
      Dfs(Edge[i].v, Mark);
}
inline void Check() {
  for (rg int i = 1; i <= n; i++)
    Vis[i] = 0;
  Meet = 0, Dfs(1, 1), Dfs(2, 2), Ans += Meet;
}
inline int Dfs(rg int Now) {
  if (Now > m * 2)
    return Check(), 0;
  Ban[Now] = 0, Ban[Now ^ 1] = 1, Dfs(Now + 2), Ban[Now] = 1, Ban[Now ^ 1] = 0,
  Dfs(Now + 2);
}
int main() {
  scanf("%d%d", &n, &m);
  memset(First, -1, sizeof(First));
  for (rg int i = 1, u, v; i <= m; i++)
    scanf("%d%d", &u, &v), Link(u, v), Link(v, u);
  Dfs(2), printf("%d\\n", Ans);
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
  long long n, p[1000001];
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++)
    scanf("%d", &p[i]);
  sort(p, p + n * 2);
  double ans = 0;
  for (int i = 0; i < 2 * n; i++)
    ans += (p[i] * i) / (double)(n * 2 - 1);
  printf("%.10lf\\n", ans);
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
  int n, p[100001];
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++)
    scanf("%d", &p[i]);
  sort(p, p + n * 2);
  double ans = 0;
  for (int i = 0; i < 2 * n; i++)
    ans += (p[i] * i) / (double)(n * 2 - 1);
  printf("%.10lf\\n", ans);
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int a[222222], n;
int main() {
  scanf("%d", &n);
  n *= 2;
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  sort(a, a + n);
  double res = 0;
  for (int i = n - 1; i >= 0; i--) {
    res += a[i] / (n - 1.0) * i;
  }
  printf("%.12lf\\n", res);
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int a[111111], n;
int main() {
  scanf("%d", &n);
  n *= 2;
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  sort(a, a + n);
  double res = 0;
  for (int i = n - 1; i >= 0; i--) {
    res += a[i] / (n - 1.0) * i;
  }
  printf("%.12lf\\n", res);
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

const int N = 3e5 + 5;
int n, s[N];
long long ans;

void init() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= 2 * n; ++i)
    scanf("%d", &s[i]);
  sort(s + 1, s + 2 * n + 1);
}

void work() {
  int i;
  for (i = 1; i <= 2 * n; ++i)
    ans += 1LL * (i - 1) * s[i];
  printf("%.12lf\\n", 1.0 * ans / (2 * n - 1));
}

int main() {
  init();
  work();
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define For(i, a, b) for (i = a; i <= b; i++)
using namespace std;
inline int read() {
  int res = 0;
  bool bo = 0;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    bo = 1;
  else
    res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  return bo ? ~res + 1 : res;
}
const int N = 1e5 + 5;
int i, n, p[N];
double ans;
int main() {
  n = (read() << 1) - 1;
  For(i, 0, n) p[i] = read();
  sort(p, p + n + 1);
  For(i, 0, n) ans += 1.0 * i * p[i] / n;
  printf("%.10lf\\n", ans);
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
long long ans, n, a[1000001];
int main() {
  cin >> n;
  for (int i = 0; i < n * 2; i++) {
    cin >> a[i];
  }
  sort(a, a + n * 2);
  for (int i = 0; i < 2 * n; i++) {
    ans += 1 * i * a[i];
  }
  printf("%.12lf\\n", 1.0 * ans / (2 * n - 1));
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define For(i, a, b) for (i = a; i <= b; i++)
using namespace std;
inline int read() {
  int res = 0;
  bool bo = 0;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    bo = 1;
  else
    res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  return bo ? ~res + 1 : res;
}
const int N = 1e5 + 5;
int i, n, p[N];
double ans;
int main() {
  n = (read() << 1) - 1;
  For(i, 0, n) p[i] = read();
  sort(p, p + n + 1);
  For(i, 0, n) ans += 1.0 * i * p[i] / n;
  printf("%.10f\\n", ans);
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
ll n, p[300005];

int main() {
  scanf("%lld", &n);
  n *= 2;
  for (int i = 0; i < n; i++)
    scanf("%lld", &p[i]);
  // calc i=[0, 2n) i*pi/(2n-1)
  double x = 0;
  sort(p, p + n);
  for (int i = 0; i < n; i++)
    x += 1.0 * p[i] / (n - 1.) * i;
  printf("%.12lf\\n", x);
  return 0;
}


Error: WA

Fixed submission:

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

typedef long long ll;
ll n, p[100005];

int main() {
  scanf("%lld", &n);
  n *= 2;
  for (int i = 0; i < n; i++)
    scanf("%lld", &p[i]);
  // calc i=[0, 2n) i*pi/(2n-1)
  double x = 0;
  sort(p, p + n);
  for (int i = 0; i < n; i++)
    x += p[i] / (n - 1.) * i;
  printf("%.12lf\\n", x);
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
int n, p[200009];
long long sum = 0;
int main() {
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; i++)
    cin >> p[i];
  sort(p, p + n);
  for (int i = 0; i < n; i++) {
    sum += 1LL * i * p[i];
  }
  printf("%.15Lf\\n", 1.0L * sum / (n - 1));
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
int n, p[100009];
long long sum = 0;
int main() {
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; i++)
    cin >> p[i];
  sort(p, p + n);
  for (int i = 0; i < n; i++) {
    sum += 1LL * i * p[i];
  }
  printf("%.15Lf\\n", 1.0L * sum / (n - 1));
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
long long ans, n, a[1000001];
int main() {
  cin >> n;
  for (int i = 0; i < n * 2; i++) {
    cin >> a[i];
  }
  sort(a, a + n * 2);
  for (int i = 0; i < 2 * n; i++) {
    ans += 1 * i * a[i];
  }
  printf("%.12lf\\n", 1.0 * ans / (2 * n - 1));
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long ans, n, a[100001];
int main() {
  cin >> n;
  for (int i = 0; i < n * 2; i++) {
    cin >> a[i];
  }
  sort(a, a + n * 2);
  for (int i = 0; i < 2 * n; i++) {
    ans += i * a[i];
  }
  printf("%.12lf\\n", 1.0 * ans / (2 * n - 1));
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define _rep(i, n) _repl(i, 0, n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(x) (x).begin(), (x).end()
#define uniq(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string) { cout << endl; }
template <class H, class... T> void _dbg(string s, H h, T... t) {
  int l = s.find(',');
  cout << s.substr(0, l) << " = " << h << ", ";
  _dbg(s.substr(l + 1), t...);
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
  o << "(" << p.fi << "," << p.se << ")";
  return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}

#define INF 1120000000

int main() {
  int n;
  cin >> n;
  vector<int> p(2 * n);
  rep(i, 2 * n) cin >> p[i];
  sort(all(p));

  double ans = 0;
  rep(i, 2 * n) { ans += (2 * n - i - 1.0) / (2 * n - 1.0) * p[2 * n - 1 - i]; }

  printf("%.10f\\n", ans);

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define _rep(i, n) _repl(i, 0, n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(x) (x).begin(), (x).end()
#define uniq(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string) { cout << endl; }
template <class H, class... T> void _dbg(string s, H h, T... t) {
  int l = s.find(',');
  cout << s.substr(0, l) << " = " << h << ", ";
  _dbg(s.substr(l + 1), t...);
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
  o << "(" << p.fi << "," << p.se << ")";
  return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}

#define INF 1120000000

int main() {
  int n;
  cin >> n;
  vector<int> p(2 * n);
  rep(i, 2 * n) cin >> p[i];

  double ans = 0;
  rep(i, 2 * n) { ans += (2 * n - i - 1.0) / (2 * n - 1.0) * p[1 * n - 1 - i]; }

  printf("%.10f\\n", ans);

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define For(i, a, b) for (i = a; i <= b; i++)
using namespace std;
inline int read() {
  int res = 0;
  bool bo = 0;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    bo = 1;
  else
    res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  return bo ? ~res + 1 : res;
}
const int N = 2e5 + 5;
int i, n, p[N];
double ans;
int main() {
  n = (read() << 1) - 1;
  For(i, 0, n) p[i] = read();
  sort(p, p + n + 1);
  For(i, 0, n) ans += 1.0 * i * p[i] / n;
  printf("%.10lf\\n", ans);
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define For(i, a, b) for (i = a; i <= b; i++)
using namespace std;
inline int read() {
  int res = 0;
  bool bo = 0;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    bo = 1;
  else
    res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  return bo ? ~res + 1 : res;
}
const int N = 1e5 + 5;
int i, n, p[N];
double ans;
int main() {
  n = (read() << 1) - 1;
  For(i, 0, n) p[i] = read();
  sort(p, p + n + 1);
  For(i, 0, n) ans += 1.0 * i * p[i] / n;
  printf("%.10f\\n", ans);
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iomanip>
#include <iostream>
using namespace std;
int n, a[200009];
int main() {
  cin >> n;
  for (int i = 0; i < 2 * n; i++)
    cin >> a[i];
  sort(a, a + 2 * n);
  long long ret = 0;
  for (int i = 0; i < 2 * n; i++)
    ret += 1LL * a[i] * i;
  cout << fixed << setprecision(15) << 1.0L * ret / (2 * n - 1) << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
using namespace std;
int n, a[100009];
int main() {
  cin >> n;
  for (int i = 0; i < 2 * n; i++)
    cin >> a[i];
  sort(a, a + n);
  long long ret = 0;
  for (int i = 0; i < 2 * n; i++)
    ret += 1LL * a[i] * i;
  cout << fixed << setprecision(15) << 1.0L * ret / (2 * n - 1) << endl;
  return 0;
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
  double p[200005];
  int n;
  cin >> n;
  rep(i, 2 * n) cin >> p[i];
  sort(p, p + 2 * n, greater<double>());
  double sum = 0;
  rep(i, 2 * n) sum += (2.0 * n - i - 1.0) / (2.0 * n - 1.0) * p[i];
  printf("%.10f\\n", sum);
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
  double p[100005];
  int n;
  cin >> n;
  rep(i, 2 * n) cin >> p[i];
  sort(p, p + 2 * n, greater<double>());
  double sum = 0;
  rep(i, 2 * n) sum += (2.0 * n - i - 1.0) / (2.0 * n - 1.0) * p[i];
  printf("%.10f\\n", sum);
}
Problem p03514 (C++) — buggy submission, verdict: Runtime Error

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

const int MAXN = 2e5 + 5;

int N;
int a[MAXN];

int main() {
  scanf("%d", &N);
  N *= 2;
  for (int i = 0; i < N; i++)
    scanf("%d", a + i);

  sort(a, a + N);

  double sol = 0;
  for (int i = 0; i < N; i++)
    sol += (double)i * a[i];

  printf("%.10lf\\n", sol / (N - 1));

  return 0;
}

Error: WA

Fixed submission:

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

const int MAXN = 1e5 + 5;

int N;
int a[MAXN];

int main() {
  scanf("%d", &N);
  N *= 2;
  for (int i = 0; i < N; i++)
    scanf("%d", a + i);

  sort(a, a + N);

  double sol = 0;
  for (int i = 0; i < N; i++)
    sol += (double)i * a[i];

  printf("%.10lf\\n", sol / (N - 1));

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

#include <bits/stdc++.h>
#define N 400005
using namespace std;
long /*double*/ long ans = 0;
long long n, a[N];
template <typename T> inline void read(T &x) {
  int f = 0;
  int orz = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      orz = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= orz;
  x = f;
}
template <typename T> void write(T x) {
  /*if (x==INF)
  {
      write(-1);
      return;
  }*/
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x >= 10)
    write(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  read(n);
  n = n << 1;
  for (register int i = 1; i <= n; i++)
    read(a[i]);
  sort(a + 1, a + n + 1);
  for (register int i = 1; i <= n; i++)
    ans = ans + (unsigned long long)a[i] * (i - 1);
  /*ans/=(n-1);*/
  printf("%.13Lf", (long double)ans / (n - 1));
  putchar('\\n');
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define N 100005
using namespace std;
long /*double*/ long ans = 0;
long long n, a[N];
template <typename T> inline void read(T &x) {
  int f = 0;
  int orz = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      orz = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= orz;
  x = f;
}
template <typename T> void write(T x) {
  /*if (x==INF)
  {
      write(-1);
      return;
  }*/
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x >= 10)
    write(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  read(n);
  n = n << 1;
  for (register int i = 1; i <= n; i++)
    read(a[i]);
  sort(a + 1, a + n + 1);
  for (register int i = 1; i <= n; i++)
    ans = ans + (unsigned long long)a[i] * (i - 1);
  /*ans/=(n-1);*/
  printf("%.13Lf", (long double)ans / (n - 1));
  putchar('\\n');
  return 0;
}