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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define int long long
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int mod = 1e9 + 7;
const int sz = 200005;

int fact[sz], inv[sz], ifact[sz];

void make() {
  fact[0] = fact[1] = inv[1] = ifact[0] = ifact[1] = 1;
  for (int i = 2; i < sz; i++) {
    fact[i] = fact[i - 1] * i % mod;
    inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    ifact[i] = ifact[i - 1] * inv[i] % mod;
  }
}

int comb(int n, int k) {
  if (n < k)
    return 0;
  return fact[n] * ifact[k] % mod * ifact[n - k] % mod;
}

void add(int &a, int b) { a = (a + b) % mod; }

signed main() {
  make();

  int N, M, K;
  cin >> N >> M >> K;
  int ans = 0;
  for (int i = 0; i < N * M - 1; i++) {
    for (int j = i + 1; j < N * M; j++) {
      int y1 = i / M, x1 = i % M;
      int y2 = j / M, x2 = j % M;
      int tmp = (abs(y1 - y2) + abs(x1 - x2)) * comb(N * M - 2, K - 2) % mod;
      add(ans, tmp);
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int mod = 1e9 + 7;
const int sz = 200005;

int fact[sz], inv[sz], ifact[sz];

void make() {
  fact[0] = fact[1] = inv[1] = ifact[0] = ifact[1] = 1;
  for (int i = 2; i < sz; i++) {
    fact[i] = fact[i - 1] * i % mod;
    inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    ifact[i] = ifact[i - 1] * inv[i] % mod;
  }
}

int comb(int n, int k) {
  if (n < k)
    return 0;
  return fact[n] * ifact[k] % mod * ifact[n - k] % mod;
}

void add(int &a, int b) { a = (a + b) % mod; }

signed main() {
  make();

  int N, M, K;
  cin >> N >> M >> K;
  int ans = 0;
  for (int d = 1; d < N; d++) {
    int tmp =
        d * (N - d) % mod * M % mod * M % mod * comb(N * M - 2, K - 2) % mod;
    add(ans, tmp);
  }
  for (int d = 1; d < M; d++) {
    int tmp =
        d * (M - d) % mod * N % mod * N % mod * comb(N * M - 2, K - 2) % mod;
    add(ans, tmp);
  }
  cout << ans << endl;
}
Problem p03039 (C++)

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

const int MOD = 1e9 + 7;
const int MAX = 1e5 + 10;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  long long ans = 0;
  COMinit();
  for (int i = 1; i < M; i++) {
    ans = (ans +
           ((((COM(N * M - 2, K - 2) * (M - i) % MOD) * N % MOD) * N % MOD) *
            i % MOD)) %
          MOD;
  }
  for (int i = 1; i < N; i++) {
    ans = (ans +
           ((((COM(N * M - 2, K - 2) * (N - i) % MOD) * M % MOD) * M % MOD) *
            i % MOD)) %
          MOD;
  }
  cout << ans << endl;
}

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

const int MOD = 1e9 + 7;
const int MAX = 2e5 + 10;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  long long ans = 0;
  COMinit();
  for (int i = 1; i < M; i++) {
    ans = (ans +
           ((((COM(N * M - 2, K - 2) * (M - i) % MOD) * N % MOD) * N % MOD) *
            i % MOD)) %
          MOD;
  }
  for (int i = 1; i < N; i++) {
    ans = (ans +
           ((((COM(N * M - 2, K - 2) * (N - i) % MOD) * M % MOD) * M % MOD) *
            i % MOD)) %
          MOD;
  }
  cout << ans << endl;
}
Problem p03040 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int MAX_N = 200000;
int bit[MAX_N + 1] = {0}, n;
int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  while (i <= n) {
    bit[i] += x;
    i += i & -i;
  }
}
int search(int k) {
  ll ok = 200000, ng = -1;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (sum(mid) >= k)
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}
int main() {
  int q, Q[200001][3];
  cin >> q;
  n = MAX_N;
  vector<P> A;
  vec B(200001, -1), C(200001);
  rep(i, q) {
    int c, a, b;
    cin >> c;
    Q[i][0] = c;
    if (c == 1)
      cin >> a >> b, Q[i][1] = a, Q[i][2] = b, A.push_back(P(a, i));
  }
  sort(all(A));
  rep(i, A.size()) B[A[i].second] = i + 1;
  rep(i, B.size()) if (B[i] != -1) C[B[i]] = i;
  ll ans = 0, x, c = 0;
  rep(i, q) {
    if (Q[i][0] == 1) {
      c++;
      if (c == 1)
        ;
      else if (c % 2 == 0)
        ans += abs(Q[i][1] - Q[C[search(c / 2)]][1]);
      else {
        int a = Q[C[search(c / 2)]][1], b = Q[C[search(c / 2 + 1)]][1];
        if (Q[i][1] < a)
          ans += abs(Q[i][1] - a);
        if (b < Q[i][q])
          ans += abs(Q[i][1] - b);
      }
      add(B[i], 1);
      x = Q[C[search((c + 1) / 2)]][1];
      ans += Q[i][2];
    } else {
      cout << x << " " << ans << "\n";
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int MAX_N = 200000;
int bit[MAX_N + 1] = {0}, n;
int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  while (i <= n) {
    bit[i] += x;
    i += i & -i;
  }
}
int search(int k) {
  ll ok = 200000, ng = -1;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (sum(mid) >= k)
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}
int main() {
  int q, Q[200001][3];
  cin >> q;
  n = MAX_N;
  vector<P> A;
  vec B(200001, -1), C(200001);
  rep(i, q) {
    int c, a, b;
    cin >> c;
    Q[i][0] = c;
    if (c == 1)
      cin >> a >> b, Q[i][1] = a, Q[i][2] = b, A.push_back(P(a, i));
  }
  sort(all(A));
  rep(i, A.size()) B[A[i].second] = i + 1;
  rep(i, B.size()) if (B[i] != -1) C[B[i]] = i;
  ll ans = 0, x, c = 0;
  rep(i, q) {
    if (Q[i][0] == 1) {
      c++;
      if (c == 1)
        ;
      else if (c % 2 == 0)
        ans += abs(Q[i][1] - Q[C[search(c / 2)]][1]);
      else {
        int a = Q[C[search(c / 2)]][1], b = Q[C[search(c / 2 + 1)]][1];
        if (Q[i][1] < a)
          ans += abs(Q[i][1] - a);
        if (b < Q[i][1])
          ans += abs(Q[i][1] - b);
      }
      add(B[i], 1);
      x = Q[C[search((c + 1) / 2)]][1];
      ans += Q[i][2];
    } else {
      cout << x << " " << ans << "\n";
    }
  }
}
Problem p03040 (C++)

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

multiset<long long> A, B;
long long bs, as, q, sz;

void lax() {
  while (A.size() > (sz + 1) / 2) {
    multiset<long long>::iterator it = A.end();
    it--;
    as += 2 * (*it);
    B.insert(*it);
    A.erase(*it);
  }
  while (!B.empty()) {
    multiset<long long>::iterator it = A.end();
    it--;
    if (*it > *B.begin()) {
      long long a = *it, b = *B.begin();
      A.erase(it);
      B.erase(B.begin());
      as += 2 * a;
      as -= 2 * b;
      A.insert(b);
      B.insert(a);
    } else
      break;
  }
}
long long geten() {
  multiset<long long>::iterator it = A.end();
  it--;
  return *it;
}

int main() {
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t, a, b;
    cin >> t;
    if (t == 1) {
      cin >> a >> b;
      sz++;
      A.insert(a);
      as -= a;
      bs += b;
      lax();
    } else
      cout << geten() << ' ' << +geten() * (sz % 2) + as + bs << '\n';
  }
}

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

multiset<long long> A, B;
long long bs, as, q, sz;

void lax() {
  while (A.size() > (sz + 1) / 2) {
    multiset<long long>::iterator it = A.end();
    it--;
    as += 2 * (*it);
    B.insert(*it);
    A.erase(it);
  }
  while (!B.empty()) {
    multiset<long long>::iterator it = A.end();
    it--;
    if (*it > *B.begin()) {
      long long a = *it, b = *B.begin();
      A.erase(it);
      B.erase(B.begin());
      as += 2 * a;
      as -= 2 * b;
      A.insert(b);
      B.insert(a);
    } else
      break;
  }
}
long long geten() {
  multiset<long long>::iterator it = A.end();
  it--;
  return *it;
}

int main() {
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t, a, b;
    cin >> t;
    if (t == 1) {
      cin >> a >> b;
      sz++;
      A.insert(a);
      as -= a;
      bs += b;
      lax();
    } else
      cout << geten() << ' ' << +geten() * (sz % 2) + as + bs << '\n';
  }
}
Problem p03040 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c)                                                             \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

  ll bsum = 0;
  multiset<ll> l, r;
  ll lsum = 0, rsum = 0;
  rep(i, Q) {
    int x;
    cin >> x;
    if (x == 1) {
      ll a, b;
      cin >> a >> b;

      bsum += b;
      l.insert(a);
      lsum += a;
      if (l.size() - r.size() > 1) {
        auto itr = --l.end();
        ll x = *itr;
        l.erase(itr);
        lsum -= x;
        r.insert(x);
        rsum += x;
      }
      while (true) {
        auto itrl = --l.end();
        auto itrr = r.begin();
        ll x = *itrl;
        ll y = *itrr;
        if (x <= y)
          break;
        l.erase(itrl);
        lsum -= x;
        r.erase(itrr);
        rsum -= y;
        l.insert(y);
        lsum += y;
        r.insert(x);
        rsum += x;
      }
    } else {
      if (l.size() == 0) {
        cout << 0 << endl;
      } else {
        auto itr = --l.end();
        ll x = *itr;

        ll N = l.size();
        ll M = r.size();
        // cout << N << " " << M << " " << x << endl;

        cout << x << " " << bsum + N * x - lsum + rsum - M * x << endl;
      }
    }
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c)                                                             \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

  ll bsum = 0;
  multiset<ll> l, r;
  ll lsum = 0, rsum = 0;
  rep(i, Q) {
    int x;
    cin >> x;
    if (x == 1) {
      ll a, b;
      cin >> a >> b;

      bsum += b;
      l.insert(a);
      lsum += a;
      if (l.size() - r.size() > 1) {
        auto itr = --l.end();
        ll x = *itr;
        l.erase(itr);
        lsum -= x;
        r.insert(x);
        rsum += x;
      }
      while (true) {
        if (r.size() == 0)
          break;
        auto itrl = --l.end();
        auto itrr = r.begin();
        ll x = *itrl;
        ll y = *itrr;
        if (x <= y)
          break;
        l.erase(itrl);
        lsum -= x;
        r.erase(itrr);
        rsum -= y;
        l.insert(y);
        lsum += y;
        r.insert(x);
        rsum += x;
      }
    } else {
      if (l.size() == 0) {
        cout << 0 << endl;
      } else {
        auto itr = --l.end();
        ll x = *itr;

        ll N = l.size();
        ll M = r.size();
        // cout << N << " " << M << " " << x << endl;

        cout << x << " " << bsum + N * x - lsum + rsum - M * x << endl;
      }
    }
  }

  return 0;
}
Problem p03040 (C++)

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

using namespace std;
typedef long long LL;
const int nn = 1e6 + 5;

int main() {
  LL q, a, b, tipe, l1 = 0, l2 = 0;
  LL tot_l = 0, tot_r = 0, tot = 0;
  priority_queue<LL> pq1, pq2;
  scanf("%d", &q);
  while (q--) {
    scanf("%lld", &tipe);
    if (tipe == 1) {
      scanf("%lld %lld", &a, &b);
      tot += b;
      if (pq1.empty() || a <= pq1.top()) {
        pq1.push(a);
        l1++;
        tot_l += a;
      } else {
        pq2.push(-a);
        l2++;
        tot_r += a;
      }
      if (l1 - l2 > 1) {
        l1--;
        tot_l -= pq1.top();
        tot_r += pq1.top();
        l2++;
        pq2.push(-pq1.top());
        pq1.pop();
      } else if (l2 - l1 > 1) {
        l2--;
        tot_l -= pq2.top();
        tot_r += pq2.top();
        l1++;
        pq1.push(-pq2.top());
        pq2.pop();
      }
    } else {
      if (l1 >= l2) {
        LL ans = pq1.top() * l1 - tot_l + tot_r - l2 * pq1.top() + tot;
        printf("%lld %lld\n", pq1.top(), ans);
      } else {
        LL ans = -pq2.top() * l1 - tot_l + tot_r - l2 * -pq2.top() + tot;
        printf("%lld %lld\n", -pq2.top(), ans);
      }
    }
  }
}

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

using namespace std;
typedef long long LL;
const int nn = 1e6 + 5;

int main() {
  LL q, a, b, tipe, l1 = 0, l2 = 0;
  LL tot_l = 0, tot_r = 0, tot = 0;
  priority_queue<LL> pq1, pq2;
  scanf("%lld", &q);
  while (q--) {
    scanf("%lld", &tipe);
    if (tipe == 1) {
      scanf("%lld %lld", &a, &b);
      tot += b;
      if (pq1.empty() || a <= pq1.top()) {
        pq1.push(a);
        l1++;
        tot_l += a;
      } else {
        pq2.push(-a);
        l2++;
        tot_r += a;
      }
      if (l1 - l2 > 1) {
        l1--;
        tot_l -= pq1.top();
        tot_r += pq1.top();
        l2++;
        pq2.push(-pq1.top());
        pq1.pop();
      } else if (l2 - l1 > 1) {
        l2--;
        tot_l -= pq2.top();
        tot_r += pq2.top();
        l1++;
        pq1.push(-pq2.top());
        pq2.pop();
      }
    } else {
      if (l1 >= l2) {
        LL ans = pq1.top() * l1 - tot_l + tot_r - l2 * pq1.top() + tot;
        printf("%lld %lld\n", pq1.top(), ans);
      } else {
        LL ans = -pq2.top() * l1 - tot_l + tot_r - l2 * -pq2.top() + tot;
        printf("%lld %lld\n", -pq2.top(), ans);
      }
    }
  }
}
Problem p03040 (Python)

Buggy submission (status: Runtime Error):
from heapq import heappush, heappushpop

Q = int(input())

b = 0
la = []
sl = 0
ra = []
sr = 0

cnt = 0
for _ in range(Q):
    q = map(int, input().split())
    # print(la, ra)
    if q[0] == 2:
        # 求値
        x = -la[0]
        cl = (cnt + 1) // 2
        cr = cnt - cl
        print(x, (cl * x - sl) + (sr - cr * x) + b)
    else:
        # 更新
        b += q[2]
        cnt += 1
        if cnt % 2 == 1:
            sr += q[1]
            x = heappushpop(ra, q[1])
            sr -= x
            sl += x
            heappush(la, -x)
        else:
            sl += q[1]
            x = heappushpop(la, -q[1])
            x *= -1
            sl -= x
            sr += x
            heappush(ra, x)


Fixed submission:
from heapq import heappush, heappushpop

Q = int(input())

b = 0
la = []
sl = 0
ra = []
sr = 0

cnt = 0
for _ in range(Q):
    q = tuple(map(int, input().split()))
    # print(la, ra)
    if q[0] == 2:
        # 求値
        x = -la[0]
        cl = (cnt + 1) // 2
        cr = cnt - cl
        print(x, (cl * x - sl) + (sr - cr * x) + b)
    else:
        # 更新
        b += q[2]
        cnt += 1
        if cnt % 2 == 1:
            sr += q[1]
            x = heappushpop(ra, q[1])
            sr -= x
            sl += x
            heappush(la, -x)
        else:
            sl += q[1]
            x = heappushpop(la, -q[1])
            x *= -1
            sl -= x
            sr += x
            heappush(ra, x)
Problem p03041 (C++)

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

  int n, k;
  scanf("%d %d", &n, &k);
  char s[5];
  scanf("%s", &s);
  s[k - 1] = 'a' + s[k - 1] - 'A';
  printf("%s", s);
}


Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {

  int n, k;
  scanf("%d %d", &n, &k);
  char s[100];
  scanf("%s", &s);
  s[k - 1] = 'a' + s[k - 1] - 'A';
  printf("%s", s);
}
Problem p03041 (C++)

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

using namespace std;

char tolower(char c) { return (c + 0x20); }

int main() {
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;

  S.at(K) = tolower(S.at(K));

  cout << S << endl;
}

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

using namespace std;

char tolower(char c) { return (c + 0x20); }

int main() {
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;

  S.at(K - 1) = tolower(S.at(K - 1));

  cout << S << endl;
}
Problem p03041 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s.at(k) = tolower(s.at(k));
  cout << s << endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s.at(k - 1) = s.at(k - 1) + 32;
  cout << s << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main() {
  int n, k;
  string s;
  cin >> n >> k;
  if (s.at(k - 1) == 'A')
    s.at(k - 1) = 'a';
  else if (s.at(k - 1) == 'B')
    s.at(k - 1) = 'b';
  else
    s.at(k - 1) = 'c';
  cout << s << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  if (s.at(k - 1) == 'A')
    s.at(k - 1) = 'a';
  else if (s.at(k - 1) == 'B')
    s.at(k - 1) = 'b';
  else
    s.at(k - 1) = 'c';
  cout << s << endl;
  return 0;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int N, K;
  char string[20];

  scanf("%d %d\n", &N, &K);
  scanf("%s", &string);

  string[K - 1] += 32;

  printf("%s\n", string);

  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int N, K;
  char nama[52];
  scanf("%d%d %s", &N, &K, nama);
  nama[K - 1] = nama[K - 1] + 32;
  printf("%s\n", nama);
  return 0;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  S.at(K) += 'a' - 'A';
  cout << S << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  S.at(K - 1) += 'a' - 'A';
  cout << S << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define P = pair<int, int>;
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (s.at(k) == 'A')
    s.at(k) = 'a';
  if (s.at(k) == 'B')
    s.at(k) = 'b';
  if (s.at(k) == 'C')
    s.at(k) = 'c';
  cout << s << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define P = pair<int, int>;
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (s.at(k - 1) == 'A')
    s.at(k - 1) = 'a';
  if (s.at(k - 1) == 'B')
    s.at(k - 1) = 'b';
  if (s.at(k - 1) == 'C')
    s.at(k - 1) = 'c';
  cout << s << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define P pair<int, int>
#define pb push_back
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  k--;
  if (s[k] == 'A') {
    s[k] = 'a';
  } else if (s[k] == 'B') {
    s[k] = 'b';
  } else {
    s[k] = 'c';
  }
  cout << s << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define P pair<int, int>
#define pb push_back
int main() {
  string s;

  int n, k;
  cin >> n >> k >> s;
  k--;
  if (s[k] == 'A') {
    s[k] = 'a';
  } else if (s[k] == 'B') {
    s[k] = 'b';
  } else {
    s[k] = 'c';
  }
  cout << s << endl;
}
Problem p03041 (C++)

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

int main() {
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  if (S.at(K) == 'A') {
    S.at(K) = 'a';
  } else if (S.at(K) == 'B') {
    S.at(K) = 'b';
  } else {
    S.at(K) = 'c';
  }
  cout << S << endl;
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K;
  K -= 1;
  cin >> S;
  if (S.at(K) == 'A') {
    S.at(K) = 'a';
  } else if (S.at(K) == 'B') {
    S.at(K) = 'b';
  } else {
    S.at(K) = 'c';
  }
  cout << S << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  s.at(b) += 32;
  cout << s << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  s.at(b - 1) += 32;
  cout << s << endl;
}
Problem p03041 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  if (s.at(K) == 'A')
    s.at(K) = 'a';
  if (s.at(K) == 'B')
    s.at(K) = 'b';
  if (s.at(K) == 'C')
    s.at(K) = 'c';
  cout << s << endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  K--;
  if (s.at(K) == 'A')
    s.at(K) = 'a';
  if (s.at(K) == 'B')
    s.at(K) = 'b';
  if (s.at(K) == 'C')
    s.at(K) = 'c';
  cout << s << endl;
}
Problem p03041 (C++)

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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S.at(K) == 'A')
    S.at(K) = 'a';
  if (S.at(K) == 'B')
    S.at(K) = 'b';
  if (S.at(K) == 'C')
    S.at(K) = 'c';
  cout << S << endl;
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S.at(K - 1) == 'A')
    S.at(K - 1) = 'a';
  if (S.at(K - 1) == 'B')
    S.at(K - 1) = 'b';
  if (S.at(K - 1) == 'C')
    S.at(K - 1) = 'c';
  cout << S << endl;
}
Problem p03041 (C++)

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

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  if (s.at(k) == 'A')
    s.at(k) = 'a';
  if (s.at(k) == 'B')
    s.at(k) = 'b';
  if (s.at(k) == 'C')
    s.at(k) = 'c';
  cout << s << endl;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  if (s.at(k - 1) == 'A')
    s.at(k - 1) = 'a';
  if (s.at(k - 1) == 'B')
    s.at(k - 1) = 'b';
  if (s.at(k - 1) == 'C')
    s.at(k - 1) = 'c';
  cout << s << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define loop(i, a, b) for (ll i = a; i < b; i++)
#define loope(i, a, b) for (ll i = a; i <= b; i++)
#define test()                                                                 \
  ull t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define puu pair<ull, ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vull vector<ull>
#define nl cout << endl
#define sp cout << " "
#define MOD 1000000007
#define all(x) x.begin(), x.end()

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fastio();
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define loop(i, a, b) for (ll i = a; i < b; i++)
#define loope(i, a, b) for (ll i = a; i <= b; i++)
#define test()                                                                 \
  ull t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define puu pair<ull, ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vull vector<ull>
#define nl cout << endl
#define sp cout << " "
#define MOD 1000000007
#define all(x) x.begin(), x.end()

int main() {
  // #ifndef ONLINE_JUDGE
  //       freopen("input.txt", "r", stdin);
  //       freopen("output.txt", "w", stdout);
  //   #endif
  //   fastio();
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
int main() {
  int N, K;

  cin >> N >> K;
  string S;
  cin >> S;

  if (S.at(K) == 'A') {
    S.at(K) = 'a';
  } else if (S.at(K) == 'B') {
    S.at(K) = 'b';
  } else if (S.at(K) == 'C') {
    S.at(K) = 'c';
  }
  cout << S << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
int main() {
  int N, K;

  cin >> N >> K;
  string S;
  cin >> S;

  if (S.at(K - 1) == 'A') {
    S.at(K - 1) = 'a';
  } else if (S.at(K - 1) == 'B') {
    S.at(K - 1) = 'b';
  } else if (S.at(K - 1) == 'C') {
    S.at(K - 1) = 'c';
  }
  cout << S << endl;
}
Problem p03041 (C++)

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n;
  cin >> n;
  char s[n];
  int k;
  cin >> k;
  cin >> s;
  s[k - 1] = s[k - 1] + 32;
  cout << s;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n;
  cin >> n;
  char s[n];
  int k;
  cin >> k;
  cin >> s;
  s[k - 1] = s[k - 1] + 32;
  cout << s;
}
Problem p03041 (C++)

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

int main(void) {
  int n, k;
  string s;
  cin >> n >> k >> s;

  s.at(k) += 'a' - 'A';

  cout << s << endl;

  return 0;
}


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

int main(void) {
  int n, k;
  string s;
  cin >> n >> k >> s;

  s.at(k - 1) += 'a' - 'A';

  cout << s << endl;

  return 0;
}
Problem p03041 (Python)

Buggy submission (status: Runtime Error):
n, k = map(int, input().split())
s = input()

print(s.replace(s[k], s[k].lower()))


Fixed submission:
n, k = map(int, input().split())
s = input()
print(s[: k - 1] + s[k - 1].lower() + s[k:])
Problem p03041 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-


def main():
    _, K = map(int, input().split(" "))
    S = input()

    S[K - 1] = S[K - 1].lower()

    print(S)


if __name__ == "__main__":
    main()


Fixed submission:
# -*- coding: utf-8 -*-


def main():
    _, K = map(int, input().split(" "))
    S = input()

    print(S[: K - 1] + S[K - 1].lower() + S[K:])


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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {

  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());

  int n, k;
  string s;
  cin >> n >> k >> s;
  k--;

  if (s[k] == 'A') {
    s[k] = 'a';
  }
  if (s[k] == 'B') {
    s[k] = 'b';
  }
  if (s[k] == 'C') {
    s[k] = 'c';
  }

  cout << s << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {

  int n, k;
  string s;
  cin >> n >> k >> s;
  k--;

  if (s[k] == 'A') {
    s[k] = 'a';
  }
  if (s[k] == 'B') {
    s[k] = 'b';
  }
  if (s[k] == 'C') {
    s[k] = 'c';
  }

  cout << s << endl;

  return 0;
}
Problem p03041 (C++)

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

int main() {
  int n;
  int k;
  char s[n + 1];

  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%s", &s);

  char j = k - 1;

  s[j] += 32;

  printf("%s\n", s);

  return 0;
}


Fixed submission:
#include <stdio.h>

int main() {
  char name[52];
  int b;
  int c;
  scanf("%d %d", &c, &b);
  getchar();
  scanf("%[^\n]", name);
  name[b - 1] += 32;
  printf("%s", name);
  return 0;
}
Problem p03041 (C++)

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

#define int long long
#define ll long long
#define f1(i, a, b) for (i = a; i < b; i++)
#define f2(i, a, b) for (i = a; i >= b; i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod = 1000000007;
int i, j;
ll temp;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  f1(i, 0, n) {
    if (i == k - 1)
      cout << char(s[i] - 'A' + 'a');
    else
      cout << s[i];
  }
  return 0;
}

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

#define int long long
#define ll long long
#define f1(i, a, b) for (i = a; i < b; i++)
#define f2(i, a, b) for (i = a; i >= b; i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod = 1000000007;
int i, j;
ll temp;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // #ifndef ONLINE_JUDGE
  //     freopen("in.txt","r",stdin);
  //     freopen("out.txt","w",stdout);
  // #endif
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  f1(i, 0, n) {
    if (i == k - 1)
      cout << char(s[i] - 'A' + 'a');
    else
      cout << s[i];
  }
  return 0;
}
Problem p03041 (C++)

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

#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define Max(x, y, z) max(x, max(y, z))
#define Min(x, y, z) min(x, min(y, z))
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int Please_accept_my_solution_;

/*
    Don't be like my girlfriend
    Accept me🙏🙏 ;) !
*/

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  IOS int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (k == i + 1)
      cout << char(32 + s[i]);
    else
      cout << s[i];
  }

  return 0;
}


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

#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define Max(x, y, z) max(x, max(y, z))
#define Min(x, y, z) min(x, min(y, z))
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int Please_accept_my_solution_;

/*
    Don't be like my girlfriend
    Accept me🙏🙏 ;) !
*/

int main() {

  IOS int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (k == i + 1)
      cout << char(32 + s[i]);
    else
      cout << s[i];
  }

  return 0;
}
Problem p03041 (C++)

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

int main() {
  int n, k;
  char s[n];
  cin >> n >> k >> s;
  s[k - 1] += 32;
  printf("%s\n", s);

  return 0;
}

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

int main() {
  int n, k;
  char s[100];
  cin >> n >> k;
  cin >> s;
  s[k - 1] += 32;
  printf("%s\n", s);

  return 0;
}
Problem p03041 (C++)

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

int main() {
  int size, th;
  string thing;

  cin >> size >> th;

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

  for (int i = 0; i < size; i++) {
    if (i == th - 1) {
      putchar(tolower(thing[th - 1]));
    } else {
      cout << thing[i];
    }
  }
}

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

int main() {
  int size, th;
  string thing;

  cin >> size >> th >> thing;

  for (int i = 0; i < size; i++) {
    if (i == th - 1) {
      putchar(tolower(thing[th - 1]));
    } else {
      cout << thing[i];
    }
  }
}
Problem p03041 (C++)

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

int main() {
  string S;
  int N, K;

  cin >> N >> K >> S;

  if (S.at(K) == 'A') {
    S.at(K) = 'a';
  } else if (S.at(K) == 'B') {
    S.at(K) = 'b';
  } else if (S.at(K) == 'C') {
    S.at(K) = 'c';
  }

  cout << S << endl;
}

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

int main() {
  string S;
  int N, K;

  cin >> N >> K >> S;

  if (S.at(K - 1) == 'A') {
    S.at(K - 1) = 'a';
  } else if (S.at(K - 1) == 'B') {
    S.at(K - 1) = 'b';
  } else if (S.at(K - 1) == 'C') {
    S.at(K - 1) = 'c';
  }

  cout << S << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  string X, Atoa;
  cin >> A >> B >> X;
  Atoa = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < 26; i++) {
    if (X.at(B) == Atoa.at(i)) {
      X.at(B) = Atoa.at(i + 26);
      break;
    }
  }
  cout << X << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  string X, Atoa;
  cin >> A >> B >> X;
  Atoa = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < 26; i++) {
    if (X.at(B - 1) == Atoa.at(i)) {
      X.at(B - 1) = Atoa.at(i + 26);
      break;
    }
  }
  cout << X << endl;
}
Problem p03041 (C++)

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

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int n, k;
  cin >> n >> k;
  char A[n];
  cin >> A;
  A[k - 1] = A[k - 1] + 32;
  cout << A << "\n";

  return 0;
}

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

int main() {

  int n, k;
  cin >> n >> k;
  char A[n];
  cin >> A;
  A[k - 1] = A[k - 1] + 32;
  cout << A << "\n";

  return 0;
}
Problem p03041 (Python)

Buggy submission (status: Runtime Error):
n, k = map(int, input().split())
s = input()
s[k - 1] = s[k - 1].lower()
print(s)


Fixed submission:
n, k = map(int, input().split())
s = input()
print(s[: k - 1] + s[k - 1].lower() + s[k:])
Problem p03041 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
K = int(input())
S = input()
s1 = S[: K - 1]
s2 = S[K:]

if S[K - 1] == "A":
    s = s1 + "a" + s2

elif S[K - 1] == "B":
    s = s1 + "b" + s2

else:
    s = s1 + "c" + s2

print(s)


Fixed submission:
nums = input().split()
N = int(nums[0])
K = int(nums[1])
S = input()
s1 = S[: K - 1]
s2 = S[K:]

if S[K - 1] == "A":
    s = s1 + "a" + s2

elif S[K - 1] == "B":
    s = s1 + "b" + s2

else:
    s = s1 + "c" + s2

print(s)
Problem p03041 (Python)

Buggy submission (status: Runtime Error):
N, K = map(int, input().split())
S = str(input())
if S[K - 1] == "A":
    S[K - 1] = "a"
    print("".join(S))
elif S[K - 1] == "B":
    S[K - 1] = "b"
    print("".join(S))
else:
    S[K - 1] = "c"
    print("".join(S))


Fixed submission:
N, K = map(int, input().split())
S = list(input())
if S[K - 1] == "A":
    S[K - 1] = "a"
    print("".join(S))
elif S[K - 1] == "B":
    S[K - 1] = "b"
    print("".join(S))
else:
    S[K - 1] = "c"
    print("".join(S))
Problem p03041 (Python)

Buggy submission (status: Runtime Error):
N = input()
K = input()
S = list(input())

S[K - 1] = S[K - 1].lower()
print("".join(S))


Fixed submission:
N, K = (int(i) for i in input().split())
S = list(input())

S[K - 1] = S[K - 1].lower()
print("".join(S))
Problem p03041 (C++)

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

int main() {
  int N, K, X;
  char nama[12];

  scanf("%d %d %d", &N, &K, &X);
  scanf("%s", &nama);
  X = K - 1;
  nama[X] = nama[X] + 32;

  printf("%s", nama);

  return 0;
}

Fixed submission:
#include <stdio.h>

int main() {
  int n, k;
  char s[52];
  scanf("%d%d", &n, &k);
  scanf("%s", &s);
  s[k - 1] += 32;
  printf("%s\n", s);
  return 0;
}
Problem p03041 (C++)

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

int main() {

  int N;
  int K;
  int cnt = 0;
  std::cin >> N >> K;
  if (N < 1 || 50 < N)
    std::cout << "Error!(1 <= N <= 50)" << std::endl;
  if (K > N)
    std::cout << "Error!3(K > N)" << std::endl;
  char *s;
  std ::cin >> s;
  std::string tmp = std::string(s);

  if (std::islower(s[K - 1])) {
    s[K - 1] = toupper(s[K - 1]);
  } else {
    s[K - 1] = tolower(s[K - 1]);
  }

  std::cout << s << std::endl;
  return 0;
}

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

int main() {

  int N;
  int K;
  char s[50];
  std::cin >> N >> K >> s;
  std::string tmp = std::string(s);

  if (std::islower(s[K - 1])) {
    s[K - 1] = toupper(s[K - 1]);
  } else {
    s[K - 1] = tolower(s[K - 1]);
  }

  std::cout << s << std::endl;
  return 0;
}
Problem p03041 (Python)

Buggy submission (status: Runtime Error):
n, k = map(int, input().split())
s = list(input())
s[k] = s[k].lower()
print("".join(s))


Fixed submission:
n, k = map(int, input().split())
s = list(input())
s[k - 1] = s[k - 1].lower()
print("".join(s))
Problem p03041 (C++)

Buggy submission (status: Time Limit Exceeded):
#pragma warning(disable : 4996)
#include <stdio.h>

int main() {
  int n, k;
  char s[51];

  scanf("%d %d", &n, &k);
  scanf("%s", s);
  /*
  printf("%d %d", 'a', 'A');
  while (1);
  */
  s[k - 1] += 32;
  printf("%s", s);
  while (1)
    ;
}

Fixed submission:
#pragma warning(disable : 4996)
#include <stdio.h>

int main() {
  int n, k;
  char s[51];

  scanf("%d %d", &n, &k);
  scanf("%s", s);
  /*
  printf("%d %d", 'a', 'A');
  while (1);
  */
  s[k - 1] += 32;
  printf("%s", s);
}
Problem p03041 (C++)

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

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  s.at(k) = tolower(s.at(k));
  cout << s << endl;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  s.at(k - 1) = tolower(s.at(k - 1));
  cout << s << endl;
}
Problem p03041 (C++)

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

int main() {
  int n, k;

  string s;

  cin >> n >> k >> s;

  s.at(k) = s.at(k) + 0x20;

  for (int i = 0; i < s.size(); i++) {
    cout << s.at(i);
  }
}

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

int main() {
  int n, k;

  string s;

  cin >> n >> k >> s;

  s.at(k - 1) = s.at(k - 1) + 0x20;

  for (int i = 0; i < s.size(); i++) {
    cout << s.at(i);
  }
}
Problem p03041 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  string s;
  getline(cin, s);
  s.at(K - 1) = s.at(K - 1) + 0x20;
  cout << s << endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<char> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
    if (i == K - 1) {
      s.at(i) += 0x20;
    }
    cout << s.at(i);
  }
  cout << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  char s[k];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  s[k - 1] += 32;
  for (int i = 0; i < n; i++) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  char s[50];
  cin >> s;
  if (s[k - 1] == 'A')
    s[k - 1] = 'a';
  else if (s[k - 1] == 'B')
    s[k - 1] = 'b';
  else
    s[k - 1] = 'c';
  cout << s << endl;
}
Problem p03041 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S.at(K) == 'A')
    S.at(K) = 'a';
  if (S.at(K) == 'B')
    S.at(K) = 'b';
  if (S.at(K) == 'C')
    S.at(K) = 'c';
  cout << S << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S.at(K - 1) == 'A')
    S.at(K - 1) = 'a';
  if (S.at(K - 1) == 'B')
    S.at(K - 1) = 'b';
  if (S.at(K - 1) == 'C')
    S.at(K - 1) = 'c';
  cout << S << endl;
}
Problem p03041 (C++)

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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  S[B--] -= 32;
  cout << S << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  int C = B - 1;
  cin >> C;
  S[C] += 32;
  cout << S << endl;
}
Problem p03041 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<char> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  if (x.at(K) = 'A')
    x.at(K) = 'a';
  if (x.at(K) = 'B')
    x.at(K) = 'b';
  if (x.at(K) = 'C')
    x.at(K) = 'c';
  for (int j = 0; j < N; j++) {
    cout << x.at(j);
  }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  char S[N + 1];
  cin >> S;
  if (S[K - 1] == 'A')
    S[K - 1] = 'a';
  if (S[K - 1] == 'B')
    S[K - 1] = 'b';
  if (S[K - 1] == 'C')
    S[K - 1] = 'c';
  cout << S << endl;
  return 0;
}
Problem p03041 (C++)

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

int main() {
  int a, b;
  string c;
  cin >> a >> b;
  cin >> c;
  if (c.at(b) == 'A')
    c.at(b) == 'a';
  if (c.at(b) == 'B')
    c.at(b) == 'b';
  if (c.at(b) == 'C')
    c.at(b) == 'c';
  cout << c << endl;
}


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

int main() {
  int a, b;
  string c;
  cin >> a >> b;
  cin >> c;

  if (c.at(b - 1) == 'A')
    c.at(b - 1) = 'a';
  if (c.at(b - 1) == 'B')
    c.at(b - 1) = 'b';
  if (c.at(b - 1) == 'C')
    c.at(b - 1) = 'c';
  cout << c << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  if (s.at(k - 1) == 'A') {
    s.at(k - 1) = 'a';
  } else if (s.at(k) == 'B') {
    s.at(k - 1) = 'b';
  } else {
    s.at(k - 1) = 'c';
  }
  cout << s << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  char in[55];
  int a, b;
  cin >> a >> b >> in;
  in[b - 1] += 32;
  cout << in << endl;
}
Problem p03041 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  char s[3];
  for (int i = 0; i < n; i++)
    cin >> s[i];
  s[k - 1] = s[k - 1] + 32;
  for (int i = 0; i < n; i++)
    cout << s[i];
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  char s[n];
  for (int i = 0; i < n; i++)
    cin >> s[i];
  s[k - 1] = s[k - 1] + 32;
  for (int i = 0; i < n; i++)
    cout << s[i];
  return 0;
}
Problem p03041 (C++)

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

int main() {
  int n, k;
  string s;
  char a;
  cin >> n >> k >> s;
  a = s.at(k);
  if (a == 'A') {
    s.at(k - 1) = 'a';
  } else if (a == 'B') {
    s.at(k - 1) = 'b';
  } else {
    s.at(k - 1) = 'c';
  }
  cout << s << endl;
}

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

int main() {
  int n, k;
  string s;
  char a;
  cin >> n >> k >> s;
  a = s.at(k - 1);
  if (a == 'A') {
    s.at(k - 1) = 'a';
  } else if (a == 'B') {
    s.at(k - 1) = 'b';
  } else {
    s.at(k - 1) = 'c';
  }
  cout << s << endl;
}
Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  string S;
  (char)tolower(S.at(K - 1));
  cout << S << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S.at(K - 1) == 'A')
    S.at(K - 1) = 'a';
  else if (S.at(K - 1) == 'B')
    S.at(K - 1) = 'b';
  else
    S.at(K - 1) = 'c';
  cout << S << endl;
}