Problem p03041 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
//----------------
#define int long long
//----------------
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
#define sdf(x) x = read()
#define For(i, a, b) for (int i = (a); i <= (b); i++)
#define FFor(i, a, b) for (int i = (a); i >= (b); i--)
#define me(a, b) memset(a, b, sizeof(a))
#define mid ((l + ((r - l) / 2)))
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
#define bg1(x) cout << (#x) << ":" << (x) << " " << endl
#define bg2(x, y)                                                              \
  cout << (#x) << ":" << (x) << " " << (#y) << ":" << (y) << " " << endl
#define bg3(x, y, z)                                                           \
  cout << (#x) << ":" << (x) << " " << (#y) << ":" << (y) << " " << (#z)       \
       << ":" << (z) << " " << endl
#define bg4(x, y, z, w)                                                        \
  cout << (#x) << ":" << (x) << " " << (#y) << ":" << (y) << " " << (#z)       \
       << ":" << (z) << " " << (#w) << ":" << (w) << " " << endl
#define bg5(x, y, z, w, k)                                                     \
  cout << (#x) << ":" << (x) << " " << (#y) << ":" << (y) << " " << (#z)       \
       << ":" << (z) << " " << (#w) << ":" << (w) << " " << (#k) << ":" << (k) \
       << " " << endl
#define call(x) cout << x << ":"
#define lll cout << "\n------\n"
int die = 0;
#define Die                                                                    \
  die++;                                                                       \
  if (die > 100000) {                                                          \
    cout << "dead!!!";                                                         \
    exit(0);                                                                   \
  }
#define mk make_pair
#define pb push_back
const double eps = 1e-8;
// srand((unsigned)time(NULL));
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int n, k;
char s[N];

void sol1() {
  s[k] = s[k] - 'A' + 'a';
  printf("%s", s + 1);
}

void rd() {
  sdf(n), sdf(k);
  scanf("%s", s + 1);
  sol1();
}

signed main() {
#ifndef ONLINE_JUDGE
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  rd();
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
//----------------
#define int long long
//----------------
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
#define sdf(x) x = read()
#define For(i, a, b) for (int i = (a); i <= (b); i++)
#define FFor(i, a, b) for (int i = (a); i >= (b); i--)
#define me(a, b) memset(a, b, sizeof(a))
#define mid ((l + ((r - l) / 2)))
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
#define bg1(x) cout << (#x) << ":" << (x) << " " << endl
#define bg2(x, y)                                                              \
  cout << (#x) << ":" << (x) << " " << (#y) << ":" << (y) << " " << endl
#define bg3(x, y, z)                                                           \
  cout << (#x) << ":" << (x) << " " << (#y) << ":" << (y) << " " << (#z)       \
       << ":" << (z) << " " << endl
#define bg4(x, y, z, w)                                                        \
  cout << (#x) << ":" << (x) << " " << (#y) << ":" << (y) << " " << (#z)       \
       << ":" << (z) << " " << (#w) << ":" << (w) << " " << endl
#define bg5(x, y, z, w, k)                                                     \
  cout << (#x) << ":" << (x) << " " << (#y) << ":" << (y) << " " << (#z)       \
       << ":" << (z) << " " << (#w) << ":" << (w) << " " << (#k) << ":" << (k) \
       << " " << endl
#define call(x) cout << x << ":"
#define lll cout << "\n------\n"
int die = 0;
#define Die                                                                    \
  die++;                                                                       \
  if (die > 100000) {                                                          \
    cout << "dead!!!";                                                         \
    exit(0);                                                                   \
  }
#define mk make_pair
#define pb push_back
const double eps = 1e-8;
// srand((unsigned)time(NULL));
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int n, k;
char s[N];

void sol1() {
  s[k] = s[k] - 'A' + 'a';
  printf("%s", s + 1);
}

void rd() {
  sdf(n), sdf(k);
  scanf("%s", s + 1);
  sol1();
}

signed main() { rd(); }