Problem p03041 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<double, double> pdd;
using namespace std;

#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 testcase;                                                                \
  cin >> testcase;                                                             \
  while (testcase--)
#define pb push_back
#define mkp make_pair
#define nl cout << "\n"
#define prime 1000000007
#define debug(x) cout << (#x) << " : " << x, nl
#define debug2(x, y) cout << (#x) << " : " << x << " " << (#y) << " : " << y, nl
#define debug3(x, y, z)                                                        \
  cout << (#x) << " : " << x << " " << (#y) << " : " << y << " " << (#z)       \
       << " : " << z,                                                          \
      nl
#define f first
#define s second
#define oa(a, n)                                                               \
  loop(i, 0, n) cout << a[i] << " ";                                           \
  nl;
#define ov(a)                                                                  \
  loop(i, 0, a.size()) cout << a[i] << " ";                                    \
  nl;
#define MOD(a) (((a % prime) + prime) % prime)

int main() {
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

  ll n, k, i;

  cin >> n >> k;

  string s;
  cin >> s;

  if (islower(s[k - 1]) == 0) {
    s[k - 1] = s[k - 1] + 32;
  }

  cout << s;
}

Fixed submission:
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<double, double> pdd;
using namespace std;

#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 testcase;                                                                \
  cin >> testcase;                                                             \
  while (testcase--)
#define pb push_back
#define mkp make_pair
#define nl cout << "\n"
#define prime 1000000007
#define debug(x) cout << (#x) << " : " << x, nl
#define debug2(x, y) cout << (#x) << " : " << x << " " << (#y) << " : " << y, nl
#define debug3(x, y, z)                                                        \
  cout << (#x) << " : " << x << " " << (#y) << " : " << y << " " << (#z)       \
       << " : " << z,                                                          \
      nl
#define f first
#define s second
#define oa(a, n)                                                               \
  loop(i, 0, n) cout << a[i] << " ";                                           \
  nl;
#define ov(a)                                                                  \
  loop(i, 0, a.size()) cout << a[i] << " ";                                    \
  nl;
#define MOD(a) (((a % prime) + prime) % prime)

int main() {

  ll n, k, i;

  cin >> n >> k;

  string s;
  cin >> s;

  if (islower(s[k - 1]) == 0) {
    s[k - 1] = s[k - 1] + 32;
  }

  cout << s;
}