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

Buggy submission (status: Runtime Error):
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define ll long long
#define ld long double
using namespace std;

const int N = 2e5 + 1000, OO = 1e9 + 100, M = 1e9 + 7, P = 6151, SQ = 120,
          lg = 100;
typedef pair<int, int> pii;
int a[N];

int32_t main() {
  use_fast;
  int n, m;
  cin >> n >> m;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int x = a[i];
    int k = 0;
    x /= 2;
    while (x % 2 == 0) {
      x /= 2;
      k++;
    }
    v.pb(k);
  }
  sort(v.begin(), v.end());
  if (v[(int)v.size() - 1] != v[0])
    return cout << 0, 0;
  int lc = 1;
  for (int i = 1; i <= n; i++) {
    a[i] /= 2;
    int h = __gcd(a[i], lc);
    lc = (lc * a[i]) / h;
  }
  m /= lc;
  cout << (m + 1) / 2 << endl;
  return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ...
*/

Fixed submission:
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std;

const int N = 2e5 + 1000, OO = 1e9 + 100, M = 1e9 + 7, P = 6151, SQ = 120,
          lg = 100;
typedef pair<int, int> pii;
int a[N];

int32_t main() {
  use_fast;
  int n, m;
  cin >> n >> m;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int x = a[i];
    int k = 0;
    x /= 2;
    while (x % 2 == 0) {
      x /= 2;
      k++;
    }
    v.pb(k);
  }
  sort(v.begin(), v.end());
  if (v[(int)v.size() - 1] != v[0])
    return cout << 0, 0;
  int lc = 1;
  for (int i = 1; i <= n; i++) {
    a[i] /= 2;
    int h = __gcd(a[i], lc);
    lc = (lc * a[i]) / h;
  }
  m /= lc;
  cout << (m + 1) / 2 << endl;
  return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ...
*/
Problem p02814 (C++)

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

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int f(int x) {
  int res = 0;
  while (x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  ll N, M;
  cin >> N >> M;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  rep(i, N) {
    if (a[i] % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  int t = f(a[0]);
  rep(i, N) {
    if (f(a[i] != t)) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t; // 2でt回割る
  }
  M >>= t;

  ll l = 1;
  rep(i, N) {
    l = lcm(l, a[i]);
    if (l > M) {
      cout << 0 << endl;
      return 0;
    }
  }

  M /= l;
  int ans = (M + 1) / 2;
  cout << ans << endl;
  return 0;
}


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

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int f(int x) {
  int res = 0;
  while (x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  ll N, M;
  cin >> N >> M;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  rep(i, N) {
    if (a[i] % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  int t = f(a[0]);
  rep(i, N) {
    if (f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t; // 2でt回割る
  }
  M >>= t;

  ll l = 1;
  rep(i, N) {
    l = lcm(l, a[i]);
    if (l > M) {
      cout << 0 << endl;
      return 0;
    }
  }

  M /= l;
  int ans = (M + 1) / 2;
  cout << ans << endl;
  return 0;
}
Problem p02814 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int Max = 1000000;

long gcd(long a, long b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
long lcm(int c, int d) { return c * d / gcd(c, d); }

int main() {
  long N;
  long M;
  cin >> N >> M;
  long a;
  long b[N];

  for (long i = 0; i < N; i++) {
    cin >> a;
    b[i] = a / 2;
  }

  long r = 1;
  while (b[0] % 2 == 0) {
    r *= 2;
    b[0] /= 2;
  }

  for (long i = 1; i < N; i++) {
    if ((b[i] % r) != 0) {
      cout << 0 << endl;
      return 0;
    }
    b[i] /= r;
    if (b[i] % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  long l = b[0];
  for (long i = 1; i < N; i++) {
    l = lcm(l, b[i]);
  }

  cout << (M / (l * r) + 1) / 2 << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int Max = 1000000;

long gcd(long a, long b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
long lcm(long c, long d) { return c * d / gcd(c, d); }

int main() {
  long N;
  long M;
  cin >> N >> M;
  long a;
  long b[N];

  for (long i = 0; i < N; i++) {
    cin >> a;
    b[i] = a / 2;
  }

  long r = 1;
  while (b[0] % 2 == 0) {
    r *= 2;
    b[0] /= 2;
  }

  for (long i = 1; i < N; i++) {
    if ((b[i] % r) != 0) {
      cout << 0 << endl;
      return 0;
    }
    b[i] /= r;
    if (b[i] % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  long l = b[0];
  for (long i = 1; i < N; i++) {
    l = lcm(l, b[i]);
  }

  cout << (M / (l * r) + 1) / 2 << endl;

  return 0;
}
Problem p02814 (Python)

Buggy submission (status: Time Limit Exceeded):
from sys import stdin
import fractions

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g % A[i], A[i])

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)


Fixed submission:
from sys import stdin
import fractions

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g % A[i], A[i])
    if g > M:
        print(0)
        exit()

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)
Problem p02814 (C++)

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

#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n, m, a[100000], x = 1, M;

signed main() {
  cin >> n >> m;
  rep(i, n) {
    cin >> a[i];
    M = max(M, a[i]);
    x = a[i] * x / __gcd(a[i], x);
    if (x > 3000000000)
      x = 0;
  }
  if (x % 2) {
    cout << 0 << endl;
    return 0;
  }
  x /= 2;
  cout << (m / x + 1) / 2 << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n, m, a[100000], x = 1, M;

signed main() {
  cin >> n >> m;
  rep(i, n) {
    cin >> a[i];
    M = max(M, a[i]);
    x = a[i] * x / __gcd(a[i], x);
    if (x > 3000000000)
      x = 0;
  }
  if (x % 2) {
    cout << 0 << endl;
    return 0;
  }
  x /= 2;
  bool f = true;
  rep(i, n) {
    if ((double)x / a[i] - (int)(x / a[i]) != 0.5)
      f = false;
  }
  if (f)
    cout << (m / x + 1) / 2 << endl;
  else
    cout << 0 << endl;
}
Problem p02814 (Python)

Buggy submission (status: Runtime Error):
import sys
from math import gcd
from functools import reduce

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60


def lcm(x, y):
    return x * y // gcd(x, y)


def main():
    N, M, *A = map(int, read().split())
    A = [a // 2 for a in A]

    semi_lcm = reduce(lcm, A)
    for a in A[1:]:
        semi_lcm = lcm(semi_lcm, a)
        if semi_lcm > M or semi_lcm // a % 2 == 0:
            print(0)
            return

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from fractions import gcd
from functools import reduce

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60


def lcm(x, y):
    return x * y // gcd(x, y)


def main():
    N, M, *A = map(int, read().split())
    A = [a // 2 for a in A]

    semi_lcm = reduce(lcm, A)
    for a in A[1:]:
        semi_lcm = lcm(semi_lcm, a)
        if semi_lcm > M or semi_lcm // a % 2 == 0:
            print(0)
            return

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == "__main__":
    main()
Problem p02815 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define V vector
#define RE return
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a, b) memset(a, b, sizeof(a))
using namespace std;
int a[100005], mod = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  FOR(i, 1, n) cin >> a[i];
  int ans = 0;
  sort(a + 1, a + n + 1, greater<int>());
  FOR(i, 1, n) ans = ans + a[i] * (i + 1), ans = ans % mod;
  FOR(i, 1, 2 * n - 2) { ans = ans * 2 % mod; }
  cout << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define V vector
#define RE return
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a, b) memset(a, b, sizeof(a))
using namespace std;
int a[200005], mod = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  FOR(i, 1, n) cin >> a[i];
  int ans = 0;
  sort(a + 1, a + n + 1, greater<int>());
  FOR(i, 1, n) ans = ans + a[i] * (i + 1), ans = ans % mod;
  FOR(i, 1, 2 * n - 2) { ans = ans * 2 % mod; }
  cout << ans;
  return 0;
}
Problem p02815 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 100010, P = 1e9 + 7;
int n, qp, ans, c[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
  }
  sort(c + 1, c + n + 1);
  qp = 1;
  for (int i = 1; i <= 2 * n - 2; i++) {
    qp = (qp + qp) % P;
  }
  for (int i = 1; i <= n; i++) {
    ans = (ans + (1ll * c[i] * (((1ll * (n - i + 1) * qp) % P + qp) % P)) % P) %
          P;
  }
  printf("%d\n", ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 200010, P = 1e9 + 7;
int n, qp, ans, c[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
  }
  sort(c + 1, c + n + 1);
  qp = 1;
  for (int i = 1; i <= 2 * n - 2; i++) {
    qp = (qp + qp) % P;
  }
  for (int i = 1; i <= n; i++) {
    ans = (ans + (1ll * c[i] * (((1ll * (n - i + 1) * qp) % P + qp) % P)) % P) %
          P;
  }
  printf("%d\n", ans);
  return 0;
}
Problem p02815 (Python)

Buggy submission (status: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
sys.setrecursionlimit(10**5)


def main():
    n0 = int(input())
    c0 = list(map(int, readline().split()))
    c0.sort(reverse=True)

    ans = 0
    mul = pow(2, n0 - 1, MOD)
    add = pow(2, n0 - 2, MOD)

    for i, cc in enumerate(c0, 1):
        ans += cc * mul
        ans %= MOD
        mul += add
        mul %= MOD

    ans *= pow(2, n0, MOD)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
sys.setrecursionlimit(10**5)


def main():
    n0 = int(input())
    c0 = list(map(int, readline().split()))
    c0.sort(reverse=True)

    ans = 0
    mul = pow(2, n0 - 1, MOD)
    add = pow(2, max(0, n0 - 2), MOD)

    for i, cc in enumerate(c0, 1):
        ans += cc * mul
        ans %= MOD
        mul += add
        mul %= MOD

    ans *= pow(2, n0, MOD)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()
Problem p02815 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
c = sorted([int(_) for _ in input().split()])
mod = 10**9 + 7
ans = 0
for i in range(n):
    ans += c[i] * 2 ** (2 * n - 2) * (n - i + 1)
    ans %= mod
print(ans)


Fixed submission:
n = int(input())
c = sorted([int(_) for _ in input().split()])
mod = 10**9 + 7
ans = 0
for i in range(n):
    ans += c[i] * pow(2, 2 * n - 2, mod) * (n - i + 1)
    ans %= mod
print(ans)
Problem p02815 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
long long a[100005], mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return res % mod;
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  long long num = qpow(4, n - 1), sum = 0;
  for (long long i = 1; i <= n; i++) {
    sum += num % mod * (n - i + 2) % mod * a[i] % mod;
    sum %= mod;
  }
  cout << sum % mod << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long a[200005], mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return res % mod;
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  long long num = qpow(4, n - 1), sum = 0;
  for (long long i = 1; i <= n; i++) {
    sum += num % mod * (n - i + 2) % mod * a[i] % mod;
    sum %= mod;
  }
  cout << sum % mod << endl;
}
Problem p02815 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

vector<ll> costs;
ll dp[200000];
ll fact[200000];

ll power(ll a, ll b) {
  if (b == 0)
    return 1;

  if (b == 1)
    return a;
  else if (b % 2 == 0) {
    ll temp = power(a, b / 2);
    return (temp * temp) % mod;
  } else
    return (power(a, b - 1) * a) % mod;
}

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

  fact[0] = 1;

  for (int i = 1; i <= n; i++)
    fact[i] = (fact[i - 1] * i) % mod;

  for (int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    costs.push_back(num);
  }

  sort(costs.begin(), costs.end(), greater<int>());

  dp[1] = (costs[0] * 2) % mod;

  for (int i = 2; i <= n; i++) {
    dp[i] = (dp[i - 1] * 4) % mod;
    ll temp = 0;

    ll power2n = power(2, i - 2);

    temp += (((costs[i - 1] * (power2n)) % mod) * (i + 1)) % mod;

    temp *= (power2n * 4) % mod;
    dp[i] += temp % mod;

    dp[i] %= mod;
  }

  printf("%lld\n", dp[n]);

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

vector<ll> costs;
ll dp[200001];
ll fact[200000];

ll power(ll a, ll b) {
  if (b == 0)
    return 1;

  if (b == 1)
    return a;
  else if (b % 2 == 0) {
    ll temp = power(a, b / 2);
    return (temp * temp) % mod;
  } else
    return (power(a, b - 1) * a) % mod;
}

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

  fact[0] = 1;

  for (int i = 1; i <= n; i++)
    fact[i] = (fact[i - 1] * i) % mod;

  for (int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    costs.push_back(num);
  }

  sort(costs.begin(), costs.end(), greater<int>());

  dp[1] = (costs[0] * 2) % mod;

  for (int i = 2; i <= n; i++) {
    dp[i] = (dp[i - 1] * 4) % mod;
    ll temp = 0;

    ll power2n = power(2, i - 2);

    temp += (((costs[i - 1] * (power2n)) % mod) * (i + 1)) % mod;

    temp *= (power2n * 4) % mod;
    dp[i] += temp % mod;

    dp[i] %= mod;
  }

  printf("%lld\n", dp[n]);

  return 0;
}
Problem p02815 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define LAR(a, b) ((a) = max((a), (b)))
#define SML(a, b) ((a) = min((a), (b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
#define MOD 1'000'000'007LL
ll c[N];

int main() {
  int n;
  scanf("%d", &n);
  REP(i, n) scanf("%lld", c + i);
  sort(c, c + n, greater<ll>());
  ll ans = 0;
  REP(i, n) ans = (ans + c[i] * (i + 2)) % MOD;
  REP(i, 2 * n - 2) ans = ans * 2 % MOD;
  printf("%lld\n", ans);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define LAR(a, b) ((a) = max((a), (b)))
#define SML(a, b) ((a) = min((a), (b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
#define MOD 1'000'000'007LL
ll c[N];

int main() {
  int n;
  scanf("%d", &n);
  REP(i, n) scanf("%lld", c + i);
  sort(c, c + n, greater<ll>());
  ll ans = 0;
  REP(i, n) ans = (ans + c[i] * (i + 2)) % MOD;
  REP(i, 2 * n - 2) ans = ans * 2 % MOD;
  printf("%lld\n", ans);
}
Problem p02815 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
constexpr int MX = 100005, MOD = 1e9 + 7;
int n;
ll c[MX], ans;
ll exp(ll ret, ll n) {
  for (ll b = 2; n; n /= 2, (b *= b) %= MOD)
    if (n % 2)
      (ret *= b) %= MOD;
  return ret;
}
int main() {
  scanf("%d", &n);
  rep(i, n) scanf("%lld", c + i);
  sort(c, c + n, greater<ll>());
  rep(i, n)(ans += c[i] * (i + 2)) %= MOD;
  printf("%lld\n", exp(ans, n * 2 - 2));
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
constexpr int MX = 200005, MOD = 1e9 + 7;
int n;
ll c[MX], ans;
ll exp(ll ret, ll n) {
  for (ll b = 2; n; n /= 2, (b *= b) %= MOD)
    if (n % 2)
      (ret *= b) %= MOD;
  return ret;
}
int main() {
  scanf("%d", &n);
  rep(i, n) scanf("%lld", c + i);
  sort(c, c + n, greater<ll>());
  rep(i, n)(ans += c[i] * (i + 2)) %= MOD;
  printf("%lld\n", exp(ans, n * 2 - 2));
}
Problem p02815 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#define pi acos(-1)
#define p 1000000007
using namespace std;
int N, c[101010];
long long f2[303030], ans, F[101010];
int n, m;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &c[i]);
  sort(c + 1, c + n + 1);

  f2[0] = 1;
  for (int i = 1; i <= n; i++)
    f2[i] = f2[i - 1] * 2LL % p;

  F[0] = 1;
  for (int i = 1; i <= n; i++)
    F[i] = (2LL * F[i - 1] % p + f2[i - 1]) % p;
  for (int i = 1; i <= n; i++)
    (ans += 1LL * c[i] * f2[i - 1] % p * F[n - i] % p) %= p;
  printf("%lld\n", 1LL * ans * f2[n] % p);
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#define pi acos(-1)
#define p 1000000007
using namespace std;
int N, c[201010];
long long f2[303030], ans, F[201010];
int n, m;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &c[i]);
  sort(c + 1, c + n + 1);

  f2[0] = 1;
  for (int i = 1; i <= n; i++)
    f2[i] = f2[i - 1] * 2LL % p;

  F[0] = 1;
  for (int i = 1; i <= n; i++)
    F[i] = (2LL * F[i - 1] % p + f2[i - 1]) % p;
  for (int i = 1; i <= n; i++)
    (ans += 1LL * c[i] * f2[i - 1] % p * F[n - i] % p) %= p;
  printf("%lld\n", 1LL * ans * f2[n] % p);
  return 0;
}
Problem p02815 (C++)

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

#define int long long

const int maxn = 1e5 + 5, mod = 1e9 + 7;
int P2[maxn], P3[maxn], C[maxn];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  P2[0] = P3[0] = 1;
  for (int i = 1; i < maxn; i++) {
    P2[i] = P2[i - 1] * 2 % mod;
    P3[i] = P3[i - 1] * 4 % mod;
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> C[i];
  sort(C, C + n);
  reverse(C, C + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += C[i] * P2[i + 1] % mod * P3[n - i - 1] % mod *
           (P2[i] + P2[max(0ll, i - 1)] * i % mod) % mod;
    ans %= mod;
    //		cout << i << ' ' << C[i] << ' ' << ans << endl;
  }
  cout << ans;
}


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

#define int long long

const int maxn = 2e5 + 5, mod = 1e9 + 7;
int P2[maxn], P3[maxn], C[maxn];

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  P2[0] = P3[0] = 1;
  for (int i = 1; i < maxn; i++) {
    P2[i] = P2[i - 1] * 2 % mod;
    P3[i] = P3[i - 1] * 4 % mod;
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> C[i];
  sort(C, C + n);
  reverse(C, C + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += C[i] * P2[i + 1] % mod * P3[n - i - 1] % mod *
           (P2[i] + P2[max(0ll, i - 1)] * i % mod) % mod;
    ans %= mod;
    //		cout << i << ' ' << C[i] << ' ' << ans << endl;
  }
  cout << ans;
}
Problem p02816 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int h = 126257;
const int mod = 1e9 + 7;
int a[200001], b[400001];
LL p[400001];
int A[30][400001];
int B[2][30][200001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    scanf("%d", &b[i]);
  for (int i = n + 1; i <= n + n; i++)
    a[i] = a[i - n];

  p[0] = 1;
  for (int i = 1; i <= n + n; i++)
    p[i] = p[i - 1] * h % mod;
  for (int i = 1; i <= n + n; i++) {
    for (int j = 0; j < 30; j++) {
      A[j][i] = (A[j][i - 1] + ((a[i] >> j) & 1) * p[i]) % mod;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 30; j++) {
      B[0][j][i] = (B[0][j][i - 1] + ((b[i] >> j) & 1) * p[i]) % mod;
      B[1][j][i] = (B[1][j][i - 1] + ((1 - ((b[i] >> j) & 1)) * p[i])) % mod;
    }
  }

  for (int i = 1; i <= n; i++) {
    int x = a[i] ^ b[1];

    bool ok = 1;
    for (int j = 0; j < 30; j++) {
      if ((x >> j) & 1) {
        int Pa = (A[j][i + n - 1] - A[j][i - 1] + mod) % mod *
                 p[n + n - (i + n - 1)] % mod;
        int Pb = B[1][j][n] * p[n + n - n] % mod;
        if (Pa != Pb) {
          ok = 0;
          break;
        }
      } else {
        int Pa = (A[j][i + n - 1] - A[j][i - 1] + mod) % mod *
                 p[n + n - (i + n - 1)] % mod;
        int Pb = B[0][j][n] * p[n + n - n] % mod;
        if (Pa != Pb) {
          ok = 0;
          break;
        }
      }
    }
    if (ok)
      printf("%d %d\n", i - 1, x);
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int h = 126257;
const int mod = 1e9 + 7;
int a[400001], b[200001];
LL p[400001];
int A[30][400001];
int B[2][30][200001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    scanf("%d", &b[i]);
  for (int i = n + 1; i <= n + n; i++)
    a[i] = a[i - n];

  p[0] = 1;
  for (int i = 1; i <= n + n; i++)
    p[i] = p[i - 1] * h % mod;
  for (int i = 1; i <= n + n; i++) {
    for (int j = 0; j < 30; j++) {
      A[j][i] = (A[j][i - 1] + ((a[i] >> j) & 1) * p[i]) % mod;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 30; j++) {
      B[0][j][i] = (B[0][j][i - 1] + ((b[i] >> j) & 1) * p[i]) % mod;
      B[1][j][i] = (B[1][j][i - 1] + ((1 - ((b[i] >> j) & 1)) * p[i])) % mod;
    }
  }

  for (int i = 1; i <= n; i++) {
    int x = a[i] ^ b[1];

    bool ok = 1;
    for (int j = 0; j < 30; j++) {
      if ((x >> j) & 1) {
        int Pa = (A[j][i + n - 1] - A[j][i - 1] + mod) % mod *
                 p[n + n - (i + n - 1)] % mod;
        int Pb = B[1][j][n] * p[n + n - n] % mod;
        if (Pa != Pb) {
          ok = 0;
          break;
        }
      } else {
        int Pa = (A[j][i + n - 1] - A[j][i - 1] + mod) % mod *
                 p[n + n - (i + n - 1)] % mod;
        int Pb = B[0][j][n] * p[n + n - n] % mod;
        if (Pa != Pb) {
          ok = 0;
          break;
        }
      }
    }
    if (ok)
      printf("%d %d\n", i - 1, x);
  }
}
Problem p02817 (Python)

Buggy submission (status: Runtime Error):
s, t = input()
print(s + t)


Fixed submission:
s, t = map(str, input().split())
print(t + s)
Problem p02817 (Python)

Buggy submission (status: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

s, t = map(str, input().split())

print(f"{t}{s}")


Fixed submission:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

s, t = map(str, input().split())

print("{}{}".format(t, s))
Problem p02817 (Python)

Buggy submission (status: Runtime Error):
S, T = map(str, input().split())
print(T + S).split("")


Fixed submission:
S, T = input().split()
print(T + S)
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, n, k) for (ll i = (n); i < (k); i++)
#define ALL(a) (a).begin(), (a).end()
string n, m, ans = 0;
void Main() {
  cin >> n >> m;

  cout << m << n << endl;
}
int main() {
  Main();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, n, k) for (ll i = (n); i < (k); i++)
#define ALL(a) (a).begin(), (a).end()
string n, m;
void Main() {
  cin >> n >> m;

  cout << m << n << endl;
}
int main() {
  Main();
  return 0;
}
Problem p02817 (Python)

Buggy submission (status: Runtime Error):
s, t = map(int, input().split())
print(s + t)


Fixed submission:
s, t = input().split()
print(t + s)
Problem p02817 (C++)

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

int main() {
  char nama1[9];
  char nama2[13];

  scanf("%s", &nama1);
  scanf("%s", &nama2);

  printf("%s%s", nama2, nama1);

  return 0;
}

Fixed submission:
#include <stdio.h>

int main() {
  char S[100], T[100];
  scanf("%s %s", &S, &T);
  printf("%s%s\n", T, S);
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void delete_space(char *x) {
  while (*x != '\0') {
    if (*x == '\n') {
      *x = '\0';
    }
    x++;
  }
}

int main() {
  char s[100], t[200];

  scanf("%s %s", &s, &t);
  delete_space(s);
  delete_space(t);

  strcat(t, s);

  printf("%s", t);

  return 0;
}


Fixed submission:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void delete_space(char *x) {
  while (*x != '\0') {
    if (*x == '\n') {
      *x = '\0';
    }
    x++;
  }
}

int main() {
  char s[256], t[256];

  scanf("%s %s", &s, &t);
  delete_space(s);
  delete_space(t);

  strcat(t, s);

  printf("%s", t);

  return 0;
}
Problem p02817 (C++)

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

void function(char *s, char *t) {
  strcat(t, s);
  cout << t << endl;
}

int main() {
  char s[50];
  char t[50];
  cin >> s;
  cin >> t;
  function(s, t);
  return 0;
}


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

void function(char *s, char *t) {
  strcat(t, s);
  cout << t << endl;
}

int main() {
  char s[500];
  char t[500];
  cin >> s;
  cin >> t;
  function(s, t);
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define IN insert
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define NL cout << endl
#define ll long long int
#define ld long double
#define vl vector<ll>
#define sl set<ll>
#define ml map<ll, ll>
#define sc set<char>
#define li list<ll>
#define vp vector<pair<ll, ll>>
#define vs vector<string>
#define ss set<string>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define REPIT(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define N (ll) pow(2, 32) - 1
#define mod (ll)1000000007
using namespace std;
vl f;
void sieve(ll m) {
  REP(i, 1, sqrt(m) + 1) {
    if (m % i == 0) {
      f.PB(i);
      if (m / i != i)
        f.PB(m / i);
    }
  }
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    string s, t, a = "";
    cin >> s >> t;
    a += t;
    a += s;
    cout << a << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define IN insert
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define NL cout << endl
#define ll long long int
#define ld long double
#define vl vector<ll>
#define sl set<ll>
#define ml map<ll, ll>
#define sc set<char>
#define li list<ll>
#define vp vector<pair<ll, ll>>
#define vs vector<string>
#define ss set<string>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define REPIT(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define N (ll) pow(2, 32) - 1
#define mod (ll)1000000007
using namespace std;
vl f;
void sieve(ll m) {
  REP(i, 1, sqrt(m) + 1) {
    if (m % i == 0) {
      f.PB(i);
      if (m / i != i)
        f.PB(m / i);
    }
  }
}
int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    string s, t, a = "";
    cin >> s >> t;
    a += t;
    a += s;
    cout << a << endl;
  }
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
int main(void) {
  char S[110];
  char T[110];
  scanf("%s", S);
  scanf("%s", T);

  printf("%s\n", strcat(T, S));
  return 0;
}

Fixed submission:
#include <stdio.h>
#include <string.h>
int main(void) {
  char S[110];
  char T[110];
  scanf("%s", S);
  scanf("%s", T);

  printf("%s%s\n", T, S);
  return 0;
}
Problem p02817 (C++)

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

int main() {
  string S, T;
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++) {
    cout << T.at(i) << S.at(i);
  }
  cout << endl;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  cout << T << S << endl;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
  /*ll t;
  cin>>t;
  while(t--)*/
  char s[101], t[101];
  cin >> s >> t;

  strcat(t, s);
  cout << t;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
  /*ll t;
  cin>>t;
  while(t--)*/
  char s[101], t[203];
  cin >> s >> t;

  strcat(t, s);
  cout << t;
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>

int main() {
  char s[100], t[100];
  scanf("%s%s", s, t);
  strcat(t, s);
  printf("%s", t);
  return 0;
}

Fixed submission:
#include <stdio.h>
#include <string.h>

int main() {
  char s[100], t[100];
  scanf("%s%s", s, t);
  // strcat(t, s);
  printf("%s%s", t, s);
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

int main() {
  char s[200], t[200];
  cin >> s >> t;

  cout << strcat(t, s) << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

int main() {
  char s[205], t[205];
  cin >> s >> t;

  cout << strcat(t, s) << endl;
}
Problem p02817 (C++)

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

int main() {
  char s[200], t[200];
  scanf("%s%s", &s, &t);
  strcat(t, s);
  printf("%s", t);
  return 0;
}

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

int main() {
  char s[200], t[200];
  scanf("%s%s", &s, &t);
  printf("%s%s", t, s);
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {

  char stringa[20];
  char stringb[15];

  scanf("%s %s", &stringa, &stringb);
  printf("%s%s", stringb, stringa);

  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {

  char stringa[120];
  char stringb[120];

  scanf("%s %s", &stringa, &stringb);
  printf("%s%s", stringb, stringa);

  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  char s[105], t[105];
  cin >> s >> t;
  strcat(t, s);
  cout << t << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  char s[105], t[210];
  cin >> s >> t;
  strcat(t, s);
  cout << t << endl;
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>

int main() {
  char S[100], T[100];
  scanf("%s%s", &S, &T);
  strcat(T, S);
  printf("%s", T);

  return 0;
}

Fixed submission:
#include <stdio.h>
#include <string.h>

int main() {
  char S[255], T[255];
  scanf("%s%s", S, T);
  strcat(T, S);
  printf("%s", T);

  return 0;
}
Problem p02817 (C++)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main() {
  char s[120], t[120];
  cin >> s >> t;
  strcat(t, s);
  cout << t << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main() {
  char s[400], t[400];
  cin >> s >> t;
  strcat(t, s);
  cout << t << endl;
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
// AnkitCode99
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define all(v) (v.begin(), v.end())
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, a, b) for (long long int i = a; i < b; i++)
#define nrep(i, a, b) for (long long int i = a; i >= b; i--)
using namespace std;
int main() {
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string s, t;
  cin >> t >> s;
  cout << s + t << endl;
}

Fixed submission:
// AnkitCode99
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define all(v) (v.begin(), v.end())
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, a, b) for (long long int i = a; i < b; i++)
#define nrep(i, a, b) for (long long int i = a; i >= b; i--)
using namespace std;
int main() {
  fast;
  string s, t;
  cin >> t >> s;
  cout << s + t << endl;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char a[100], b[100];
  cin >> a >> b;
  printf(strcat(b, a));
}

Fixed submission:
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char a[10000], b[10000];
  cin >> a >> b;
  printf(strcat(b, a));
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
#define N 105
int main() {
  char S[N], T[N];
  while (scanf("%s%s", S, T) != EOF) {
    strcat(T, S);
    printf("%s\n", T);
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
#include <string.h>
#define N 105
int main() {
  char S[N], T[210];
  while (scanf("%s%s", S, T) != EOF) {
    strcat(T, S);
    printf("%s\n", T);
  }
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
int main() {
  char S[200], T[200];
  scanf("%s %s", S, T);
  // strcat(T, S);
  printf("%s", strcat(T, S));
  return 0;
}


Fixed submission:
#include <stdio.h>
#include <string.h>
int main() {
  char S[205], T[205];
  scanf("%s %s", S, T);
  // strcat(T, S);
  printf("%s", strcat(T, S));
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  char name[20];
  char list[20];
  scanf("%s %s", &name, &list);
  printf("%s%s", list, name);
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  char S[101];
  char T[101];
  scanf("%s %s", &S, &T);
  printf("%s%s", T, S);
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  char s[10];
  char t[10];
  scanf("%s %s", s, t);
  printf("%s%s\n", t, s);
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  char s[105];
  char t[105];

  scanf("%s %s", &s, &t);
  printf("%s%s\n", t, s);
  return 0;
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {

  char S[88], T[88];
  scanf("%s %s", S, T);
  printf("%s %S\n", S, T);

  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  char S[150];
  char T[150];
  scanf("%s", &S);
  scanf("%s", &T);
  printf("%s", T);
  printf("%s", S);

  return 0;
}
Problem p02817 (C++)

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

using namespace std;
typedef long long ll;

int main() {
  char s[101], t[101];
  scanf("%s", s);
  scanf("%s", t);
  printf("%s", strcat(t, s));
}


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

using namespace std;
typedef long long ll;

int main() {
  char s[101], t[101];
  scanf("%s", s);
  scanf("%s", t);
  printf("%s%s", t, s);
}
Problem p02817 (C++)

Buggy submission (status: Runtime Error):
/*
 *
 *   Bismillah Hir Rahman Nir Raheem
 *   Name: Jaied Al Sabid
 *
 */

#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s, t, r;

  cin >> s >> t;

  r += t[0];
  r += t[1];
  r += t.substr(2);
  r += s;

  cout << r << endl;

  return 0;
}


Fixed submission:
/*
 *
 *   Bismillah Hir Rahman Nir Raheem
 *   Name: Jaied Al Sabid
 *
 */

#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s, t, r;

  cin >> s >> t;

  cout << t << s << endl;

  return 0;
}
Problem p02817 (C++)

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

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
}

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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
}
Problem p02817 (C++)

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

int main() {
  string strN, strM;
  cin >> strN >> strM;
  for (int i = 0; i < 100; i++) {
    cout << strM.at(i) << strN.at(i);
  }
}


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

int main() {
  string strN, strM;
  cin >> strN >> strM;
  cout << strM << strN;
}
Problem p02817 (Python)

Buggy submission (status: Runtime Error):
s, t = list(input().split().rstrip())
print(t + s)


Fixed submission:
s, t = input().rstrip().split()
print(t + s)
Problem p02817 (Python)

Buggy submission (status: Runtime Error):
In = list(map(int, input().split()))
sin = set(In)
print("Yes" if len(sin) == 2 else "No")


Fixed submission:
S, T = input().split()
print(T + S)
Problem p02817 (Python)

Buggy submission (status: Runtime Error):
S = input()
T = input()
print(T + S)


Fixed submission:
s, t = input().split()
ans = t + s
print(ans)
Problem p02818 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define FAST                                                                   \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);
#define _ << ' ' <<
using ll = long long int;

signed main() {
  FAST ll A, B, K;
  cin >> A >> B >> K;
  for (ll i = 0; i < K; i++) {
    if (!A && !B)
      break;
    if (A > 0)
      A--;
    else
      B--;
  }
  cout << A _ B << endl;
}

Fixed submission:
#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define FAST                                                                   \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);
#define _ << ' ' <<
using ll = long long int;

signed main() {
  FAST ll A, B, K;
  cin >> A >> B >> K;
  ll tmp = 0;
  if (K >= A) {
    tmp = K - A;
    A = 0;
  } else
    A -= K;

  B -= tmp;
  if (B < 0)
    B = 0;
  cout << A _ B << endl;
}
Problem p02818 (C++)

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

int main() {
  long A, B, K;
  cin >> A >> B >> K;
  for (long i = 0; i < K; i++) {
    if (A >= 1) {
      A -= 1;
    } else if (B >= 1) {
      B -= 1;
    }
  }
  cout << A << " " << B << "\n";
  return 0;
}

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

int main() {
  long A, B, K;
  cin >> A >> B >> K;
  long temp = A;
  if (K >= A) {
    A = 0;
  } else if (K < A) {
    A -= K;
  }
  if (A == 0) {
    B -= (K - temp);
  }
  if (B < 0) {
    B = 0;
  }
  cout << A << " " << B << "\n";
  return 0;
}
Problem p02818 (C++)

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

int main() {
  int64_t A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < K; i++) {
    if (A > 0) {
      --A;
    } else if (A == 0 && B > 0) {
      --B;
    } else if (A == 0 && B == 0) {
      break;
    }
  }
  cout << A << " " << B << endl;
}

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

int main() {
  int64_t A, B, K;
  cin >> A >> B >> K;
  if (A > K) {
    A = A - K;
  } else if (A + B <= K) {
    A = 0;
    B = 0;
  } else {
    B -= K - A;
    A = 0;
  }
  cout << A << " " << B << endl;
}
Problem p02818 (Python)

Buggy submission (status: Time Limit Exceeded):
A, B, K = [int(_) for _ in input().split()]
for i in range(K):
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
print(A, B)


Fixed submission:
A, B, K = [int(_) for _ in input().split()]
if A >= K:
    print(A - K, B)
else:
    print(0, max(0, B - (K - A)))
Problem p02818 (Python)

Buggy submission (status: Runtime Error):
a, b, k = list(map(int, input().split()))
a_ans = a - min(a, k)
if a_ans == 0:
    b_ans = b - min(b, k - a)
print("{} {}".format(a_ans, b_ans))


Fixed submission:
a, b, k = list(map(int, input().split()))
a_ans = a - min(a, k)
if a_ans == 0:
    b_ans = b - min(b, k - a)
else:
    b_ans = b
print("{} {}".format(a_ans, b_ans))
Problem p02818 (Python)

Buggy submission (status: Runtime Error):
a, b, k = input().split()
print(max(a - k, 0), b - max(k - a, 0))


Fixed submission:
a, b, k = map(int, input().split())
print(max(a - k, 0), max(b - max(k - a, 0), 0))
Problem p02818 (C++)

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

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

using namespace std;

int main() {
  chinko a, b, k;
  cin >> a >> b >> k;
  for (chinko i = 0; i < k; i++) {
    if (a > 0)
      a--;
    else if (b > 0)
      b--;
    else
      break;
  }
  cout << a << " " << b << endl;
  return 0;
}

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

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

using namespace std;

int main() {
  chinko a, b, k;
  cin >> a >> b >> k;

  if (k < a)
    cout << a - k << " " << b << endl;
  else if (k <= a + b)
    cout << 0 << " " << b - (k - a) << endl;
  else
    cout << 0 << " " << 0 << endl;

  return 0;
}