Problem p02664 (C++)

Buggy submission (status: Runtime Error):
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable : 4786)
#pragma warning(disable : 4996)
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ((X) > 0 ? (X) : (-(X)))
#define S(X) ((X) * (X))
#define SZ(V) (int)V.size()
#define FORN(i, n) for (int i = 0; i < n; i++)
#define FORAB(i, a, b) for (int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C) ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

typedef long long int LL;
// typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VP;
typedef vector<double> VD;
typedef vector<vector<int>> VVI;
typedef vector<string> VS;
typedef long double ld;

#define MAXN 1000006
// #define MAXN 1006

const LL MOD = 1000000007;
// const LL MOD = 998244353;
const LL INF = 2000000000000000001LL; // 2e18 + 1

void solve(int ks) {
  char S[100005];
  scanf("%s", S);
  for (int i = 0; S[i]; i++)
    if (S[i] == '?')
      S[i] = 'D';
  printf("%s\n", S);
}

void gen() {}

int main() {
  double start_time = clock();
#ifdef LOCAL
  freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
  // freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
  //	freopen("out.out", "w", stdout);
#endif

  gen();

  if (0) {
    int T;
    scanf("%d", &T);
    // AIN(T, 1, 5000);
    for (int ks = 1; ks <= T; ks++) {
      solve(ks);
      if (ks % 1 == 0)
        fprintf(stderr, "%d done\n", ks);
    }
  } else {
    solve(0);
  }

  double end_time = clock();
  fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);

  return 0;
}


Fixed submission:
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable : 4786)
#pragma warning(disable : 4996)
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ((X) > 0 ? (X) : (-(X)))
#define S(X) ((X) * (X))
#define SZ(V) (int)V.size()
#define FORN(i, n) for (int i = 0; i < n; i++)
#define FORAB(i, a, b) for (int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C) ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

typedef long long int LL;
// typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VP;
typedef vector<double> VD;
typedef vector<vector<int>> VVI;
typedef vector<string> VS;
typedef long double ld;

#define MAXN 1000006
// #define MAXN 1006

const LL MOD = 1000000007;
// const LL MOD = 998244353;
const LL INF = 2000000000000000001LL; // 2e18 + 1

void solve(int ks) {
  char S[200005];
  scanf("%s", S);
  for (int i = 0; S[i]; i++)
    if (S[i] == '?')
      S[i] = 'D';
  printf("%s\n", S);
}

void gen() {}

int main() {
  double start_time = clock();
#ifdef LOCAL
  freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
  // freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
  //	freopen("out.out", "w", stdout);
#endif

  gen();

  if (0) {
    int T;
    scanf("%d", &T);
    // AIN(T, 1, 5000);
    for (int ks = 1; ks <= T; ks++) {
      solve(ks);
      if (ks % 1 == 0)
        fprintf(stderr, "%d done\n", ks);
    }
  } else {
    solve(0);
  }

  double end_time = clock();
  fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);

  return 0;
}