prithivMLmods/Coder-Stat huggingface dataset:
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

map<string, int> mp;
#define ll long long

int main() {
  int n;
  cin >> n;
  int l[100];
  rep(i, 2 * n) { cin >> l[i]; }
  sort(l, l + 2 * n);
  int ans = 0;
  for (int i = 0; i < n * 2; i += 2) {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

map<string, int> mp;
#define ll long long

int main() {
  int n;
  cin >> n;
  int l[200];
  rep(i, 2 * n) { cin >> l[i]; }
  sort(l, l + 2 * n);
  int ans = 0;
  for (int i = 0; i < n * 2; i += 2) {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int n, i, j, k;
  int l[101];
  // 整数の入力
  scanf("%d", &n);
  // スペース区切りの整数の入力
  for (i = 0; i < n * 2; i++) {
    scanf("%d", &l[i]);
  }

  // 並び替え大きい順
  for (i = 0; i < n * 2; i++) {
    for (j = i + 1; j < n * 2; j++) {
      if (l[i] < l[j]) {
        k = l[i];
        l[i] = l[j];
        l[j] = k;
      }
    }
  }
  k = 0;

  for (i = 0; i < n * 2 - 1; i = i + 2) {
    k += l[i + 1];
    // printf("%d\n", k);
  }
  printf("%d", k);
  /*
  for (i = 0; i < n * 2; i++)
  {
          printf("%d\n", l[i]);
  }*/
  /*
  // 出力
  for ( i = 0; i < n*2; i++)
  {
          printf("%d\n", l[i]);
  }
  */
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int n, i, j, k;
  int l[201];
  // 整数の入力
  scanf("%d", &n);
  // スペース区切りの整数の入力
  for (i = 0; i < n * 2; i++) {
    scanf("%d", &l[i]);
  }

  // 並び替え大きい順
  for (i = 0; i < n * 2; i++) {
    for (j = i + 1; j < n * 2; j++) {
      if (l[i] < l[j]) {
        k = l[i];
        l[i] = l[j];
        l[j] = k;
      }
    }
  }
  k = 0;

  for (i = 0; i < n * 2 - 1; i = i + 2) {
    k += l[i + 1];
    // printf("%d\n", k);
  }
  printf("%d", k);
  /*
  for (i = 0; i < n * 2; i++)
  {
          printf("%d\n", l[i]);
  }*/
  /*
  // 出力
  for ( i = 0; i < n*2; i++)
  {
          printf("%d\n", l[i]);
  }
  */
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int N, L[109];
  cin >> N;

  for (int i = 0; i < 2 * N; i++) {
    cin >> L[i];
  }
  sort(L, L + 2 * N);
  int sum = 0;
  for (int i = 0; i < 2 * N; i += 2) {
    sum += L[i];
  }
  cout << sum << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int N, L[209];
  cin >> N;

  for (int i = 0; i < 2 * N; i++) {
    cin >> L[i];
  }
  sort(L, L + 2 * N);
  int sum = 0;
  for (int i = 0; i < 2 * N; i += 2) {
    sum += L[i];
  }
  cout << sum << endl;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

#define repeat(i, n) for (long long i = 0; (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x, n)                                                       \
  for (long long i = 0; (i) < (n); ++(i))                                      \
  cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x, n)                                                      \
  for (long long i = 0; (i) < (n); ++(i))                                      \
  cerr << #x << "[" << i << "]: " << x[i].first << " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vint L(N);
  repeat(i, N * 2) { cin >> L[i]; }
  sort(L.begin(), L.end());
  int ans = 0;
  repeat(i, N) { ans += L[2 * i]; }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

#define repeat(i, n) for (long long i = 0; (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x, n)                                                       \
  for (long long i = 0; (i) < (n); ++(i))                                      \
  cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x, n)                                                      \
  for (long long i = 0; (i) < (n); ++(i))                                      \
  cerr << #x << "[" << i << "]: " << x[i].first << " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vint L(N * 2);
  repeat(i, N * 2) { cin >> L[i]; }
  sort(L.begin(), L.end());
  int ans = 0;
  repeat(i, N) { ans += L[2 * i]; }
  cout << ans << endl;
  return 0;
}
Problem p04047 (C++)

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

int main() {
  int n;
  cin >> n;
  int l[101];
  for (int i = 0; i < 2 * n; i++)
    cin >> l[i];
  sort(l, l + 2 * n);

  int ret = 0;
  for (int i = 0; i < n; i++)
    ret += min(l[2 * i], l[2 * i + 1]);
  cout << ret << endl;
}

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

int main() {
  int n;
  cin >> n;
  int l[201];
  for (int i = 0; i < 2 * n; i++)
    cin >> l[i];
  sort(l, l + 2 * n);

  int ret = 0;
  for (int i = 0; i < n; i++)
    ret += min(l[2 * i], l[2 * i + 1]);
  cout << ret << endl;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
int main() {
  int n, m, j, t = 0;
  int a[105];
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++)
    scanf("%d", &a[i]);
  sort(a, a + 2 * n);
  for (int i = 0; i < 2 * n - 1; i += 2) {
    t += a[i];
  }
  printf("%d\n", t);
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
int main() {
  int n, m, j, t = 0;
  int a[205];
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++)
    scanf("%d", &a[i]);
  sort(a, a + 2 * n);
  for (int i = 0; i < 2 * n - 1; i += 2) {
    t += a[i];
  }
  printf("%d\n", t);
  return 0;
}
Problem p04047 (C++)

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

using namespace std;
typedef long long int ll;

int main() {
  ll ans = 0;
  int n;
  cin >> n;
  int arr[105];
  for (int i = 0; i < 2 * n; i++)
    cin >> arr[i];
  sort(arr, arr + 2 * n);
  for (int i = 0; i < 2 * n - 1; i += 2)
    ans += arr[i];
  cout << ans;
}


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

using namespace std;
typedef long long int ll;

int main() {
  ll ans = 0;
  int n;
  cin >> n;
  int arr[1000];
  for (int i = 0; i < 2 * n; i++)
    cin >> arr[i];
  sort(arr, arr + 2 * n);
  for (int i = 0; i < 2 * n - 1; i += 2)
    ans += arr[i];
  cout << ans;
}
Problem p04047 (C++)

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

int main() {
  int n;
  int l[100];
  int sum = 0;

  cin >> n;

  for (int i = 0; i < 2 * n; i++) {
    cin >> l[i];
  }

  sort(l, l + n * 2);

  for (int i = 0; i < 2 * n; i += 2) {
    if (l[i + 1] - l[i] > 0) {
      sum += l[i];
    } else {
      sum += l[i + 1];
    }
  }

  cout << sum << endl;

  return (0);
}

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

int main() {
  int n;
  int l[200];
  int sum = 0;

  cin >> n;

  for (int i = 0; i < 2 * n; i++) {
    cin >> l[i];
  }

  sort(l, l + n * 2);

  for (int i = 0; i < 2 * n; i += 2) {
    if (l[i + 1] - l[i] > 0) {
      sum += l[i];
    } else {
      sum += l[i + 1];
    }
  }

  cout << sum << endl;

  return (0);
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ara[n];
  for (int i = 0; i < n * 2; i++) {
    cin >> ara[i];
  }
  sort(ara, ara + 2 * n);
  int sum = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    sum += ara[i];
  }
  cout << sum << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ara[n * 2];
  for (int i = 0; i < n * 2; i++) {
    cin >> ara[i];
  }
  sort(ara, ara + 2 * n);
  int sum = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    sum += ara[i];
  }
  cout << sum << endl;
}
Problem p04047 (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 dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main() {
  int N;
  int L[100];
  cin >> N;
  for (int i = 0; i < 2 * N; i++) {
    cin >> L[i];
  }
  sort(L, L + 2 * N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = ans + L[2 * i];
  }
  cout << ans << 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 dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main() {
  int N;
  int L[200];
  cin >> N;
  for (int i = 0; i < 2 * N; i++) {
    cin >> L[i];
  }
  sort(L, L + 2 * N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = ans + L[2 * i];
  }
  cout << ans << endl;
}
Problem p04047 (C++)

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

using namespace std;
int main() {
  int n, l[111];
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> l[i];
  }
  sort(l, l + 2 * n);
  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    ans += l[i];
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
int main() {
  int n, l[211];
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> l[i];
  }
  sort(l, l + 2 * n);
  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    ans += l[i];
  }
  cout << ans << endl;

  return 0;
}
Problem p04047 (C++)

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

#define ll long long
#define ld long double
#define pr pair<ll, ll>
#define loop(i, n) for (ll i = 0; i < n; ++i)
#define rep(i, x, n) for (ll i = x; i <= n; ++i)
#define iteloop(type, data, name, it)                                          \
  for (type<data>::iterator it = name.begin(); it != name.end(); ++it)
using namespace std;
const ll N = 2e5 + 5;
int n;
int arr[N];
int main() {
  cin.sync_with_stdio(false), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "rt", stdin);
  // freopen("out.txt", "wt" , stdout);
#endif // ONLINE_JUDGE
  cin >> n;
  n *= 2;
  int sum = 0;
  loop(i, n) { cin >> arr[i]; }
  sort(arr, arr + n);
  for (int i = 0; i < n; i += 2) {
    sum += arr[i];
  }
  cout << sum << endl;
}

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

#define ll long long
#define ld long double
#define pr pair<ll, ll>
#define loop(i, n) for (ll i = 0; i < n; ++i)
#define rep(i, x, n) for (ll i = x; i <= n; ++i)
#define iteloop(type, data, name, it)                                          \
  for (type<data>::iterator it = name.begin(); it != name.end(); ++it)
using namespace std;
const ll N = 2e5 + 5;
int n;
int arr[N];
int main() {
  cin.sync_with_stdio(false), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
  // freopen("in.txt", "rt" , stdin);
  // freopen("out.txt", "wt" , stdout);
#endif // ONLINE_JUDGE
  cin >> n;
  n *= 2;
  int sum = 0;
  loop(i, n) { cin >> arr[i]; }
  sort(arr, arr + n);
  for (int i = 0; i < n; i += 2) {
    sum += arr[i];
  }
  cout << sum << endl;
}
Problem p04047 (C++)

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

int main() {
  map<int, int> mp;
  long long int a, b = 0, c[105];
  string str;
  cin >> a;
  for (int i = 0; i < 2 * a; i++) {
    cin >> c[i];
  }
  sort(c, c + 2 * a);
  for (int i = 0; i < a; i++) {
    b += c[2 * i];
  }
  cout << b;
}


Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  map<int, int> mp;
  long long int a, b = 0, c[1600];
  string str;
  cin >> a;
  for (int i = 0; i < 2 * a; i++) {
    cin >> c[i];
  }
  sort(c, c + 2 * a);
  for (int i = 0; i < a; i++) {
    b += c[2 * i];
  }
  cout << b;
}
Problem p04047 (C++)

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

int main(int argc, char const *argv[]) {
  int n;
  int a[105];
  cin >> n;
  for (int i = 0; i < 2 * n; ++i) {
    cin >> a[i];
  }
  sort(a, a + 2 * n);
  int sum = 0;
  for (int i = 0; i < 2 * n; i = i + 2) {
    sum += a[i];
    // printf("%d\n", sum);
  }
  printf("%d\n", sum);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, k) for (int i = j; i <= k; i++)
int sum, a[2010] = {0}, n;
inline void into() {
  scanf("%d", &n);
  n = n << 1;
  rep(i, 1, n) scanf("%d", &a[i]);
}
inline void work() {
  sort(a + 1, a + 1 + n);
  rep(i, 1, n) if (i & 1) sum += a[i];
}
inline void outo() { printf("%d\n", sum); }
int main() {
  into();
  work();
  outo();
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for (int i = int(s); i != int(e); i++)
#define FORIT(i, c)                                                            \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main() {
  int N;
  cin >> N;
  int L[N];
  FOR(i, 0, 2 * N) cin >> L[i];
  sort(L, L + 2 * N);
  int ans = 0;
  FOR(i, 0, N) { ans += L[2 * i]; }
  cout << ans << endl;
  return 0;
}


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

#define FOR(i, s, e) for (int i = int(s); i != int(e); i++)
#define FORIT(i, c)                                                            \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main() {
  int N;
  cin >> N;
  int L[2 * N];
  FOR(i, 0, 2 * N) cin >> L[i];
  sort(L, L + 2 * N);
  int ans = 0;
  FOR(i, 0, N) { ans += L[2 * i]; }
  cout << ans << endl;
  return 0;
}
Problem p04047 (C++)

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

int main() {
  int n, res[101];
  cin >> n;
  for (int i = 0; i < n * 2; i++) {
    cin >> res[i];
  }
  sort(res, res + n * 2);
  int ct = 0;
  for (int i = 0; i < n; i++) {
    ct += min(res[i * 2], res[i * 2 + 1]);
  }
  cout << ct << endl;
}


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

int main() {
  int n, res[10001];
  cin >> n;
  for (int i = 0; i < n * 2; i++) {
    cin >> res[i];
  }
  sort(res, res + n * 2);
  int ct = 0;
  for (int i = 0; i < n; i++) {
    ct += min(res[i * 2], res[i * 2 + 1]);
  }
  cout << ct << endl;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
// ↓✟MLE魔、TLE魔✟
#define int long long
// ↑✟MLE魔、TLE魔✟
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool prime(int a) {
  if (a == 1)
    return false;
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0)
      return false;
  }
  return true;
}
signed main() {
  int n, l[100], ans = 0;
  cin >> n;
  rep(i, n * 2) cin >> l[i];
  sort(l, l + n * 2);
  rep(i, n) ans += l[i * 2];
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
// ↓✟MLE魔、TLE魔✟
#define int long long
// ↑✟MLE魔、TLE魔✟
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool prime(int a) {
  if (a == 1)
    return false;
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0)
      return false;
  }
  return true;
}
signed main() {
  int n, l[200], ans = 0;
  cin >> n;
  rep(i, n * 2) cin >> l[i];
  sort(l, l + n * 2);
  rep(i, n) ans += l[i * 2];
  cout << ans << endl;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i, m, n) for (ll i = (m); i < (n); i++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x, y) cout << (x) << " " << (y) << endl;
#define printa(x, n)                                                           \
  for (ll i = 0; i < n; i++) {                                                 \
    cout << (x[i]) << " \n"[i == n - 1];                                       \
  }
#define printp(x, n)                                                           \
  for (ll i = 0; i < n; i++) {                                                 \
    cout << "(" << x[i].first << ", " << x[i].second << ") ";                  \
  }                                                                            \
  cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  ll L[110];
  cin >> N;
  rep(i, 0, 2 * N) cin >> L[i];
  sort(L, L + 2 * N);
  ll ans = 0;
  rep(i, 0, N) { ans += min(L[2 * i], L[2 * i + 1]); }
  print(ans);
}

Fixed submission:
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i, m, n) for (ll i = (m); i < (n); i++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x, y) cout << (x) << " " << (y) << endl;
#define printa(x, n)                                                           \
  for (ll i = 0; i < n; i++) {                                                 \
    cout << (x[i]) << " \n"[i == n - 1];                                       \
  }
#define printp(x, n)                                                           \
  for (ll i = 0; i < n; i++) {                                                 \
    cout << "(" << x[i].first << ", " << x[i].second << ") ";                  \
  }                                                                            \
  cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  ll L[210];
  cin >> N;
  rep(i, 0, 2 * N) cin >> L[i];
  sort(L, L + 2 * N);
  ll ans = 0;
  rep(i, 0, N) { ans += min(L[2 * i], L[2 * i + 1]); }
  print(ans);
}
Problem p04047 (C++)

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

using namespace std;

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

  int l[105];
  for (int i = 0; i < 2 * n; i++) {
    scanf("%d", &l[i]);
  }
  sort(l, l + 2 * n);

  int ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (i % 2 == 0)
      ans += l[i];
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

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

  int l[210];
  for (int i = 0; i < 2 * n; i++) {
    scanf("%d", &l[i]);
  }
  sort(l, l + 2 * n);

  int ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (i % 2 == 0)
      ans += l[i];
  }
  cout << ans << endl;

  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  int n, l[100];
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; i++)
    cin >> l[i];
  sort(l, l + n);
  ll sum = 0;
  for (int i = 0; i < n; i += 2) {
    sum += l[i];
  }
  cout << sum << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  int n, l[200];
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; i++)
    cin >> l[i];
  sort(l, l + n);
  ll sum = 0;
  for (int i = 0; i < n; i += 2) {
    sum += l[i];
  }
  cout << sum << endl;
}
Problem p04047 (C++)

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

using namespace std;

int main() {
  int N, L[101];
  cin >> N;
  for (int i = 0; i < 2 * N; i++)
    cin >> L[i];
  sort(L, L + 2 * N, greater<int>());
  int ans = 0;
  for (int i = 0; i < 2 * N; i += 2) {
    ans += min(L[i], L[i + 1]);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
  int N, L[201];
  cin >> N;
  for (int i = 0; i < 2 * N; i++)
    cin >> L[i];
  sort(L, L + 2 * N, greater<int>());
  int ans = 0;
  for (int i = 0; i < 2 * N; i += 2) {
    ans += min(L[i], L[i + 1]);
  }
  cout << ans << endl;
  return 0;
}
Problem p04047 (C++)

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

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const double INF = 1e9;
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

int main() {
  int N;
  cin >> N;
  int L[102];
  REP(i, N * 2) cin >> L[i];
  sort(L, L + 2 * N);
  int sum = 0;
  REP(i, N) { sum += L[2 * i]; }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const double INF = 1e9;
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

int main() {
  int N;
  cin >> N;
  int L[202];
  REP(i, N * 2) cin >> L[i];
  sort(L, L + 2 * N);
  int sum = 0;
  REP(i, N) { sum += L[2 * i]; }
  cout << sum << endl;
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n * 2);
  for (int i = 0; i < n * 2; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int x = 0;
  for (int i = 0; i < n * 2; i + 2) {
    x = x + vec.at(i);
  }
  cout << x << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n * 2);
  for (int i = 0; i < n * 2; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int x = 0;
  for (int i = 0; i < n; i++) {
    x = x + vec.at(i * 2);
  }
  cout << x << endl;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
//* AuThOr GaRyMr *//
#include <bits/stdc++.h>
#define rb(a, b, c) for (int a = b; a <= c; ++a)
#define rl(a, b, c) for (int a = b; a >= c; --a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a, b) make_pair(a, b)
#define FIR first
#define SEC second
using namespace std;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> mp;
typedef pair<mp, mp> superpair;
int main() {
  int n;
  //	n*=2;
  int l[101];
  scanf("%d", &n);
  n *= 2;
  rb(i, 1, n) { scanf("%d", &l[i]); }
  sort(l + 1, l + 1 + n);
  int sum = 0;
  rb(i, 1, n) {
    //		cout<<i<<endl;
    sum += l[i];
    i++;
  }
  cout << sum;
  return 0;
}

Fixed submission:
//* AuThOr GaRyMr *//
#include <bits/stdc++.h>
#define rb(a, b, c) for (int a = b; a <= c; ++a)
#define rl(a, b, c) for (int a = b; a >= c; --a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a, b) make_pair(a, b)
#define FIR first
#define SEC second
using namespace std;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> mp;
typedef pair<mp, mp> superpair;
int main() {
  int n;
  //	n*=2;
  int l[500];
  scanf("%d", &n);
  n *= 2;
  rb(i, 1, n) { scanf("%d", &l[i]); }
  sort(l + 1, l + 1 + n);
  int sum = 0;
  rb(i, 1, n) {
    //		cout<<i<<endl;
    sum += l[i];
    i++;
  }
  cout << sum;
  return 0;
}
Problem p04047 (C++)

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

int main() {
  int n, ans;
  int L[100];
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> L[i];
  }
  sort(L, L + 2 * n);
  ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      ans += L[i];
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n, ans;
  int L[200];
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> L[i];
  }
  sort(L, L + 2 * n);
  ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      ans += L[i];
    }
  }
  cout << ans << endl;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[101];
  cin >> n;
  n *= 2;
  for (int i = 1; i <= n; i++)
    cin >> arr[i];
  sort(arr + 1, arr + n + 1);
  int ans = 0;

  for (int i = 1; i <= n; i += 2) {
    ans += arr[i];
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[201];
  cin >> n;
  n *= 2;
  for (int i = 1; i <= n; i++)
    cin >> arr[i];
  sort(arr + 1, arr + n + 1);
  int ans = 0;

  for (int i = 1; i <= n; i += 2) {
    ans += arr[i];
  }
  cout << ans;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, j;
  while (cin >> t) {
    int arr[110];
    for (i = 0; i < 2 * t; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + i);
    int s = 0;
    for (j = 0; j < 2 * t; j++) {
      if (j % 2 == 0)
        s += arr[j];
    }
    cout << s << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, j;
  while (cin >> t) {
    int arr[1000];
    for (i = 0; i < 2 * t; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + i);
    int s = 0;
    for (j = 0; j < 2 * t; j++) {
      if (j % 2 == 0)
        s += arr[j];
    }
    cout << s << endl;
  }
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):

#include <bits/stdc++.h>
typedef long long int lli;
#define mp make_pair

using namespace std;

int main() {
  int n;
  cin >> n;

  int a[105];
  for (int i = 0; i < 2 * n; i++)
    cin >> a[i];
  sort(a, a + 2 * n);

  int ans = 0;
  for (int i = 0; i < 2 * n; i++)
    ans += (i % 2 ? 0 : a[i]);

  cout << ans << "\n";

  return 0;
}

Fixed submission:

#include <bits/stdc++.h>
typedef long long int lli;
#define mp make_pair

using namespace std;

int main() {
  int n;
  cin >> n;

  int a[205];
  for (int i = 0; i < 2 * n; i++)
    cin >> a[i];
  sort(a, a + 2 * n);

  int ans = 0;
  for (int i = 0; i < 2 * n; i++)
    ans += (i % 2 ? 0 : a[i]);

  cout << ans << "\n";

  return 0;
}
Problem p04047 (C++)

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

using namespace std;

int main() {
  int n, l[100] = {}, i, sum = 0;

  scanf("%d", &n);
  for (i = 0; i < n * 2; i++) {
    scanf("%d", &l[i]);
  }

  sort(l, l + n * 2);

  for (i = 0; i < n * 2; i += 2) {
    sum += l[i];
  }

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

  return 0;
}

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

using namespace std;

int main() {
  int n, l[201] = {}, i, sum = 0;

  scanf("%d", &n);
  for (i = 0; i < n * 2; i++) {
    scanf("%d", &l[i]);
  }

  sort(l, l + n * 2);

  for (i = 0; i < n * 2; i += 2) {
    sum += l[i];
  }

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

  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <time.h>
#include <vector>
#define _USE_MATH_DEFINES
#define LL long long
#define UN unsigned
using namespace std;
const double PI = acos(-1.0);

int max_num(int ary[], int length) {
  int max = ary[0];
  for (int i = 1; i < length; i++)
    if (max < ary[i])
      max = ary[i];
  return max;
}

int max_ord(int ary[], int length) {
  int max;
  max = max_num(ary, length);
  for (int i = 0; i < length; i++) {
    if (ary[i] == max)
      return i;
  }
  return -1;
}

int min_num(int ary[], int length) {
  int min = ary[0];
  for (int i = 1; i < length; i++)
    if (min > ary[i])
      min = ary[i];
  return min;
}

int min_ord(int ary[], int length) {
  int min;
  min = min_num(ary, length);
  for (int i = 0; i < length; i++) {
    if (ary[i] == min)
      return i;
  }
  return -1;
}

int main() {
  int n, l[101], ans = 0;
  cin >> n;
  for (int i = 0; i < n * 2; i++)
    cin >> l[i];
  sort(l, l + n * 2);
  for (int i = 0; i < n * 2; i += 2) {
    ans += min(l[i], l[i + 1]);
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <time.h>
#include <vector>
#define _USE_MATH_DEFINES
#define LL long long
#define UN unsigned
using namespace std;
const double PI = acos(-1.0);

int max_num(int ary[], int length) {
  int max = ary[0];
  for (int i = 1; i < length; i++)
    if (max < ary[i])
      max = ary[i];
  return max;
}

int max_ord(int ary[], int length) {
  int max;
  max = max_num(ary, length);
  for (int i = 0; i < length; i++) {
    if (ary[i] == max)
      return i;
  }
  return -1;
}

int min_num(int ary[], int length) {
  int min = ary[0];
  for (int i = 1; i < length; i++)
    if (min > ary[i])
      min = ary[i];
  return min;
}

int min_ord(int ary[], int length) {
  int min;
  min = min_num(ary, length);
  for (int i = 0; i < length; i++) {
    if (ary[i] == min)
      return i;
  }
  return -1;
}

int main() {
  int n, l[200], ans = 0;
  cin >> n;
  for (int i = 0; i < n * 2; i++)
    cin >> l[i];
  sort(l, l + n * 2);
  for (int i = 0; i < n * 2; i += 2) {
    ans += min(l[i], l[i + 1]);
  }
  cout << ans << endl;
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> L;
  int tmp, ret = 0;
  cin >> N;
  for (int i = 0; i < 2 * N; i++) {
    cin >> tmp;
    L.push_back(tmp);
  }
  sort(L.begin(), L.end());

  for (int i = 0; i < N; i++) {
    ret += L[2 * i];
  }
  cout << ret << endl;
  return ret;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> L;
  int tmp, ret = 0;
  cin >> N;
  for (int i = 0; i < 2 * N; i++) {
    cin >> tmp;
    L.push_back(tmp);
  }
  sort(L.begin(), L.end());

  for (int i = 0; i < N; i++) {
    ret += L[2 * i];
  }
  cout << ret << endl;
  return 0;
}
Problem p04047 (C++)

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

using ll = long long;
typedef std::pair<int, int> p;

ll min(ll a, ll b) {
  if (a >= b)
    return b;
  else
    return a;
}
ll max(ll a, ll b) {
  if (a >= b)
    return a;
  else
    return b;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int d[210];
bool flag = true;
bool fl = true;
struct edge {
  int to, cost;
};
std::vector<edge> v[100];
bool used[210];

int main() {
  int n, a[100], ans = 0;
  std::cin >> n;
  for (int i = 0; i < n * 2; i++) {
    std::cin >> a[i];
  }
  std::sort(a, a + n * 2);
  for (int i = 0; i < n * 2; i += 2) {
    ans += min(a[i], a[i + 1]);
  }
  std::cout << ans << std::endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using ll = long long;
typedef std::pair<int, int> p;

ll min(ll a, ll b) {
  if (a >= b)
    return b;
  else
    return a;
}
ll max(ll a, ll b) {
  if (a >= b)
    return a;
  else
    return b;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int d[210];
bool flag = true;
bool fl = true;
struct edge {
  int to, cost;
};
std::vector<edge> v[100];
bool used[210];

int main() {
  int n, a[210], ans = 0;
  std::cin >> n;
  for (int i = 0; i < n * 2; i++) {
    std::cin >> a[i];
  }
  std::sort(a, a + n * 2);
  for (int i = 0; i < n * 2; i += 2) {
    ans += min(a[i], a[i + 1]);
  }
  std::cout << ans << std::endl;
  return 0;
}
Problem p04047 (C++)

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

using namespace std;

int main() {
  int n;
  int num[101];
  int sum = 0;

  cin >> n;

  for (int i = 0; i < 2 * n; i++)
    cin >> num[i];

  sort(num, num + (n * 2));

  for (int i = 0; i < 2 * n; i += 2) {
    sum += min(num[i], num[i + 1]);
  }

  cout << sum << endl;
}


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

using namespace std;

int main() {
  int n;
  int num[1010];
  int sum = 0;

  cin >> n;

  for (int i = 0; i < 2 * n; i++)
    cin >> num[i];

  sort(num, num + (n * 2));

  for (int i = 0; i < 2 * n; i += 2) {
    sum += min(num[i], num[i + 1]);
  }

  cout << sum << endl;
}
Problem p04047 (C++)

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

int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
  unordered_set<int> uset;
  int a[100], n;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  sort(a, a + 2 * n);
  int res = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    res += a[i];
  }
  cout << res << "\n";
  return 0;
}

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

int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
  unordered_set<int> uset;
  int a[200], n;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  sort(a, a + 2 * n);
  int res = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    res += a[i];
  }
  cout << res << "\n";
  return 0;
}
Problem p04047 (C++)

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

int main() {
  int n, a[101];
  cin >> n;
  for (int i = 1; i <= 2 * n; i++)
    cin >> a[i];
  sort(a + 1, a + 2 * n + 1, greater<int>());
  int l = 0;
  for (int i = 1; i <= n; i++)
    l += a[2 * i];
  cout << l;
  return 0;
}


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

int main() {
  int n, a[201];
  cin >> n;
  for (int i = 1; i <= 2 * n; i++)
    cin >> a[i];
  sort(a + 1, a + 2 * n + 1, greater<int>());
  int l = 0;
  for (int i = 1; i <= n; i++)
    l += a[2 * i];
  cout << l;
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n * 2; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int c = 0;
  for (int i = 0; i < n; i++) {
    c += a.at(i * 2);
  }
  cout << c << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n * 2);
  for (int i = 0; i < n * 2; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int c = 0;
  for (int i = 0; i < n; i++) {
    c += a.at(i * 2);
  }
  cout << c << endl;
}
Problem p04047 (C++)

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define in ,
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define dep(i, a, n) for (int i = (a); i >= (n); i--)
#define mod 1e9 + 7

__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  int a[100];
  cin >> n;
  rep(i, 0, n * 2) cin >> a[i];

  sort(a, a + n * 2);
  int ans = 0;
  for (int i = n * 2 - 2; i >= 0; i -= 2) {
    ans += a[i];
  }

  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define in ,
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define dep(i, a, n) for (int i = (a); i >= (n); i--)
#define mod 1e9 + 7

__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  int a[200];
  cin >> n;
  rep(i, 0, n * 2) cin >> a[i];

  sort(a, a + n * 2);
  int ans = 0;
  for (int i = n * 2 - 2; i >= 0; i -= 2) {
    ans += a[i];
  }

  cout << ans << endl;
}
Problem p04047 (C++)

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

int main() {
  int N;
  cin >> N;
  int L[N];
  for (int i = 0; i < 2 * N; i++)
    cin >> L[i];
  sort(L, L + 2 * N);
  int sum = 0;
  for (int i = 0; i < N; i++)
    sum += L[2 * i];
  cout << sum << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int L[2 * N];
  for (int i = 0; i < 2 * N; i++)
    cin >> L[i];
  sort(L, L + 2 * N);
  int sum = 0;
  for (int i = 0; i < N; i++)
    sum += L[2 * i];
  cout << sum << endl;

  return 0;
}
Problem p04047 (C++)

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

int main() {
  int n, i, sum = 0;
  int x[105];
  cin >> n;
  for (i = 0; i < 2 * n; i++) {
    cin >> x[i];
  }
  sort(x, x + 2 * n);
  for (i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      sum += x[i];
    }
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int n, i, sum = 0;
  int x[205];
  cin >> n;
  for (i = 0; i < 2 * n; i++) {
    cin >> x[i];
  }
  sort(x, x + 2 * n);
  for (i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      sum += x[i];
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p04047 (C++)

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

int main() {
  int n;
  cin >> n;
  int l[100];
  int ans = 0;
  for (int i = 0; i < 2 * n; i++)
    cin >> l[i];
  sort(l, l + 2 * n);
  for (int i = 0; i < 2 * n; i += 2)
    ans += l[i];
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  int l[200];
  int ans = 0;
  for (int i = 0; i < 2 * n; i++)
    cin >> l[i];
  sort(l, l + 2 * n);
  for (int i = 0; i < 2 * n; i += 2)
    ans += l[i];
  cout << ans << endl;
}
Problem p04047 (C++)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l[101];
  cin >> n;
  rep(i, 2 * n) { cin >> l[i]; }
  sort(l, l + 2 * n);
  int sum = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    sum += l[i];
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l[201];
  cin >> n;
  rep(i, 2 * n) { cin >> l[i]; }
  sort(l, l + 2 * n);
  int sum = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    sum += l[i];
  }
  cout << sum << endl;
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll, int, int> p;
typedef vector<int> vi;
set<int> st;
int N, ans = 0;
vi L(105);

int main(int argc, char const *argv[]) {
  cin >> N;
  for (int i = 0; i < 2 * N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end(), greater<int>());
  for (int i = 0; i < 2 * N - 1; i += 2) {
    if (L[i] > L[i + 1])
      ans += L[i + 1];
    else
      ans += L[i];
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll, int, int> p;
typedef vector<int> vi;
set<int> st;
int N, ans = 0;
vi L(205);

int main(int argc, char const *argv[]) {
  cin >> N;
  for (int i = 0; i < 2 * N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end(), greater<int>());
  for (int i = 0; i < 2 * N - 1; i += 2) {
    if (L[i] > L[i + 1])
      ans += L[i + 1];
    else
      ans += L[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p04047 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-')
      f = -1;
  for (; isdigit(ch); ch = getchar())
    x = (x << 3) + (x << 1) + (ch ^ '0');
  return x * f;
}
int n;
int a[202];
int Ans;
int main() {
#ifndef ONLINE_JUDGE
  freopen("AT1979.in", "r", stdin);
  freopen("AT1979.out", "w", stdout);
#endif
  n = read();
  for (register int i = 1; i <= 2 * n; ++i)
    a[i] = read();
  sort(a + 1, a + 2 * n + 1);
  for (register int i = 1; i <= 2 * n; i += 2)
    Ans += a[i];
  cout << Ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-')
      f = -1;
  for (; isdigit(ch); ch = getchar())
    x = (x << 3) + (x << 1) + (ch ^ '0');
  return x * f;
}
int n;
int a[202];
int Ans;
int main() {
  n = read();
  for (register int i = 1; i <= 2 * n; ++i)
    a[i] = read();
  sort(a + 1, a + 2 * n + 1);
  for (register int i = 1; i <= 2 * n; i += 2)
    Ans += a[i];
  cout << Ans << endl;
  return 0;
}