alexjercan/bugnet huggingface dataset:
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

// 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
  seen[v] = true; // v を訪問済にする
  int score = 0;

  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v])
      continue; // next_v が探索済だったらスルー

    // 負荷さ優先探索中の処理

    dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
  }
  return score;
}

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem);
    num = num % rem;
  }
  return ans;
}
*/

int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == '?')
      t.at(i) = 'D';
  }
  cout << t << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

// 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
  seen[v] = true; // v を訪問済にする
  int score = 0;

  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v])
      continue; // next_v が探索済だったらスルー

    // 負荷さ優先探索中の処理

    dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
  }
  return score;
}

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem);
    num = num % rem;
  }
  return ans;
}
*/

ll Lucas(ll N) {
  if (N == 0) {
    return 2;
  } else if (N == 1) {
    return 1;
  }
  ll ans;
  ans = Lucas(N - 1) + Lucas(N - 2);

  return ans;
}

int main() {
  string S;
  cin >> S;

  for (int i = 0; i < (int)S.size(); i++) {
    if (i == 0 && S.at(i) == '?') {
      if (S.at(i + 1) == 'D') {
        S.at(i) = 'P';
      } else if (S.at(i + 1) == 'P') {
        S.at(i) = 'D';
      } else {
        S.at(i) = 'P';
        S.at(i + 1) = 'D';
      }
    }

    if (S.at(i) == '?') {
      if (S.at(i - 1) == 'P') {
        S.at(i) = 'D';
      } else {
        if (S.at(i + 1) == 'D') {
          S.at(i) = 'P';
        } else if (S.at(i + 1) == 'P') {
          S.at(i) = 'D';
        } else {
          S.at(i) = 'P';
          S.at(i + 1) = 'D';
        }
      }
    }
  }

  cout << S << endl;

  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string s;
  cin >> s;

  if (s.find("?") == string::npos) {
    cout << s;
    // cout << "? ga naiyo\\n";
    return 0;
  }

  size_t position_Phatena = 0;
  size_t position_2hatena = 0;
  size_t position_hatenaD = 0;
  size_t position_hatena = 0;

  while (s.find("?") != string::npos) {
    //    if((position_Phatena = s.find("P?") ) != string::npos){
    //    	s[position_hatenaD+1] = 'D';
    //    }
    //  	if( (position_2hatena = s.find("??") ) != string::npos){
    //      s[position_2hatena] = 'P';
    //      s[position_2hatena+1] = 'D';
    //    }
    //    if((position_hatenaD = s.find("?D") ) != string::npos){
    //    	s[position_hatenaD] = 'P';
    //    }
    if ((position_hatena = s.find("?")) != string::npos) {
      s[position_hatena] = 'D';
    }
  }

  //  cout << s.find("??") << endl;

  cout << s;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string s;
  cin >> s;

  if (s.find("?") == string::npos) {
    cout << s;
    // cout << "? ga naiyo\\n";
    return 0;
  }

  size_t position_Phatena = 0;
  size_t position_2hatena = 0;
  size_t position_hatenaD = 0;
  size_t position_hatena = 0;

  while (s.find("?") != string::npos) {
    if ((position_Phatena = s.find("P?")) != string::npos) {
      s[position_hatenaD + 1] = 'D';
    }
    if ((position_2hatena = s.find("????")) != string::npos) {
      s[position_2hatena] = 'P';
      s[position_2hatena + 1] = 'D';
    }
    //    if((position_hatenaD = s.find("?D") ) != string::npos){
    //    	s[position_hatenaD] = 'P';
    //    }
    if ((position_hatena = s.find("?")) != string::npos) {
      s[position_hatena] = 'D';
    }
  }

  //  cout << s.find("??") << endl;

  cout << s;

  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
std::string replaceStringAll(std::string str, const std::string &replace,
                             const std::string &with) {
  if (!replace.empty()) {
    std::size_t pos = 0;
    while ((pos = str.find(replace, pos)) != std::string::npos) {
      str.replace(pos, replace.length(), with);
      pos += with.length();
    }
  }
  return str;
}
int count(string T) {
  int k = 0;
  for (int i = 0; i < T.length(); i++) {
    char Now = T.at(i);
    static bool flag = false;
    switch (Now) {
    case 'P':
      flag = true;
      break;
    case 'D':
      k++;
      if (flag) {
        k++;
        flag = false;
      }
      break;
    }
  }
  return k;
}
int main(void) {
  string T;
  cin >> T;
  T = replaceStringAll(T, "?", "D");
  cout << T << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string T;
  cin >> T;
  int k = 0;
  for (int i = 0; i < T.length(); i++) {
    char Now = T.at(i);
    static bool flag = false;
    switch (Now) {
    case 'P':
      flag = true;
      break;
    case 'D':
      k++;
      if (flag) {
        k++;
        flag = false;
      }
      break;
    case '?':
      if (flag || (T.at(i + 1) == 'P' && i < T.length() - 1)) {
        T.at(i) = 'D';
        flag = false;
        k += 2;
      } else {
        T.at(i) = 'P';
        flag = true;
      }
      break;
    }
  }
  cout << T << endl;
  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.length(); i++)
    if (t[i] == '?')
      t[i] = 'D';
  cout << t << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
int main() {
  string T;
  cin >> T;
  for (int i = 0; T.length(); i++)
    if (T[i] == '?')
      T[i] = 'D';
  cout << T << endl;
  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;

int main() {
  string T;
  cin >> T;
  for (int i = 0; i < T.size(); i++) {
    if (T[i] == '?')
      T[i] = 'D';
    cout << T[i];
  }
  cout << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

int main() {
  string T, tmp;
  int cnt_d, cnt_p;
  cin >> T;
  for (int i = 0; i < T.size() - 1; i++) {
    tmp[i] = T[i];
    if (T[i] == '?') {
      T[i] = 'P';
    }
    if (T[i] == 'D')
      cnt_p++;
    if (T[i] == 'P' && T[i + 1] == 'D')
      cnt_p++;
  }

  if (tmp[0] == '?')
    tmp[0] = 'D';
  if (tmp[0] == 'D')
    cnt_d++;
  for (int i = 1; i < tmp.size(); i++) {
    if (tmp[i] == '?')
      tmp[i] = 'D';
    if (tmp[i] == 'D')
      cnt_d++;
    if (tmp[i] == 'D' && tmp[i - 1] == 'P')
      cnt_d++;
  }

  if (cnt_p > cnt_d) {
    for (int i = 0; i < T.size(); i++) {
      cout << T[i];
    }
    cout << endl;
  } else {
    for (int i = 0; i < tmp.size(); i++) {
      cout << tmp[i];
    }
    cout << endl;
  }
  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?') {
      s[i] = 'D';
    }
  }
  cout << s << endl;
}

Error: WA

Fixed submission:

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

int main() {
  string t;
  cin >> t;
  for (int i = 1; i < t.size(); i++) {
    if (t[i - 1] == 'P' && t[i] == '?') {
      t[i] = 'D';
    } else if (t[i - 1] == '?' && t[i] == 'D') {
      t[i] = 'P';
    }
  }
  for (int i = 0; i < t.size() - 2; i++) {
    if (t[i] == '?' && t[i + 1] == '?' && t[i + 2] == 'P') {
      t[i] = 'P';
      t[i + 1] = 'D';
    } else if (t[i] == '?' && t[i + 1] == '?' && t[i + 2] == 'D') {
      t[i] = 'D';
      t[i + 1] = 'P';
    }
  }
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == '?') {
      t[i] = 'D';
    }
  }
  cout << t << endl;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string T;
  cin >> T;
  int L = T.size();

  for (int i = 0; i < L; i++) {
    char &c = T.at(i);

    if (c == '?')
      c = 'D';
  }

  cout << T << endl;
}

Error: TLE

Fixed submission:

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

void cnt(string &X, string &Y, int &Z) {
  int W = X.size();
  bool flag = false;
  int e = 0;
  for (int i = 0; i < W; i++) {
    char d = X.at(i);

    if (d == 'P') {
      flag = true;
      continue;
    }
    if (d == 'D') {
      e++;
      if (flag) {
        e++;
      }
    }

    flag = false;
  }

  if (Z < e) {
    Z = e;
    Y = X;
  }

  return;
}

void ctst(int &V, vector<vector<int>> &W, string &X, string &Y, int Z) {
  cnt(X, Y, V);

  int f = W.at(0).size();

  for (int i = 0; i < f; i++) {
    int d = W.at(0).at(i);
    int &e = W.at(1).at(i);

    if (e == 0) {
      e = 1;
      X.at(d) = 'D';
      ctst(V, W, X, Y, Z - 1);

      X.at(d) = 'P';
      e = 0;
    }
  }

  return;
}

int main() {
  string T;
  int L;

  cin >> T;
  L = T.size();
  int m = 0;

  for (int i = 0; i < L; i++) {
    if (T.at(i) == '?')
      m++;
  }

  vector<vector<int>> Qlist(2, vector<int>(m));

  int n = 0;
  for (int i = 0; i < L; i++) {
    if (T.at(i) == '?') {
      Qlist.at(0).at(n) = i;
      n++;
      T.at(i) = 'P';
    }

    if (n == m)
      break;
  }

  string U = T;
  int o = 0;
  int p = 0;
  ctst(p, Qlist, T, U, o);

  cout << U << endl;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(_, a, b) for (int _ = a; _ < b; _++)
#define per(_, a, b) for (int _ = b - 1; _ >= a; _--)
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
string s;
int main() {
  cin >> s;
  rep(i, 0, s.length()) {
    if (s[i] == '?') {
      s[i] = 'D';
    }
  }
  cout << s;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(_, a, b) for (int _ = a; _ < b; _++)
#define per(_, a, b) for (int _ = b - 1; _ >= a; _--)
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
char s[200050];
int main() {
  cin >> s;
  rep(i, 0, strlen(s)) {
    if (s[i] == '?') {
      if (s[i + 1] == 'D' && s[i - 1] != 'P' && i + 1 < strlen(s))
        s[i] = 'P';
      else
        s[i] = 'D';
    }
  }
  cout << s;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

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

//'P''D'
void solve(std::string T) {
  long long size = T.size();
  for (int i = 0; i < size; i++) {
    if (T[i] == '?' && T[i - 1] == 'P') {
      T.replace(i, 1, "D");
    } else if (T[i] == '?' && T[i + 1] == 'D') {
      T.replace(i, 1, "P");
    } else if (T[i] == '?' && T[i + 1] == '?') {
      T.replace(i, 2, "PD");
      i++;
    } else if (T[i] == '?') {
      T.replace(i, 1, "D");
    }
  }
  cout << T << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  std::string T;
  std::cin >> T;
  solve(T);
  return 0;
}


Error: TLE

Fixed submission:

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

//'P''D'
void solve(std::string T) {
  string S;
  long long size = T.size();
  for (int i = 0; i < size; i++) {
    if (T[i] == '?' && T[i - 1] == 'P') {
      S = S + 'D';
    } else if (T[i] == '?' && T[i + 1] == 'D') {
      S = S + 'P';
    } else if (T[i] == '?' && T[i + 1] == '?') {
      S = S + 'P';
      S = S + 'D';
      i++;
    } else if (T[i] == '?') {
      S = S + 'D';
    } else {
      S = S + T[i];
    }
  }
  cout << S << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  std::string T;
  std::cin >> T;
  solve(T);
  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

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

const int maxn = 2e5 + 10;

int n, m;
char s[200005];

int main() {
  cin >> (s + 1);
  int len = strlen(s + 1), ans = 0;
  for (int i = 1; i <= len; i++) {
    if (s[i] == '?')
      s[i] = 'D';
  }
  cout << s + 1 << endl;
}

Error: 0

Fixed submission:

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

int n, m;
char s[100005];

int main() {
  cin >> (s + 1);
  int len = strlen(s + 1), ans = 0;
  for (int i = 1; i <= len; i++) {
    if (s[i] == '?') {
      if (s[i - 1] == 'D')
        s[i] = 'P';
      else
        s[i] = 'D';
    }
  }
  cout << s + 1 << endl;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>

using namespace std;
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      // 1e4
#define base10_5 100000     // 1e5
#define base10_6 1000000    // 1e6
#define base10_7 10000000   // 1e7
#define base10_8 100000000  // 1e8
#define base10_9 1000000000 // 1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

// #include <stack>
// #include <queue>

string ans_Yes = "Yes";
string ans_No = "No";
string ans_yes = "yes";
string ans_no = "no";
string ReplaceString(std::string String1 // 置き換え対象
                     ,
                     std::string String2 // 検索対象
                     ,
                     std::string String3 // 置き換える内容
) {
  std::string::size_type Pos(String1.find(String2));

  while (Pos != std::string::npos) {
    String1.replace(Pos, String2.length(), String3);
    Pos = String1.find(String2, Pos + String3.length());
  }

  return String1;
}
ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

int main() {

  string T;
  string S = "";
  cin >> T;

  cout << ReplaceString(T, "?", "D") << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>

using namespace std;
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      // 1e4
#define base10_5 100000     // 1e5
#define base10_6 1000000    // 1e6
#define base10_7 10000000   // 1e7
#define base10_8 100000000  // 1e8
#define base10_9 1000000000 // 1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

// #include <stack>
// #include <queue>

string ans_Yes = "Yes";
string ans_No = "No";
string ans_yes = "yes";
string ans_no = "no";

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

int main() {

  string T;
  string S = "";
  cin >> T;

  rep(ti, T.size()) {
    string tmp;
    tmp = T.substr(ti, 1);
    if (tmp == "?") {
      S = S + "D";
    } else {
      S = S + tmp;
    }
  }
  cout << S << endl;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>

int main() {
  static char T[200001];
  scanf("%s", T);

  size_t len = strlen(T);
  for (size_t i = 0; i < len; i++) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }
  printf("%s\\n", T);

  return 0;
}


Error: WA

Fixed submission:

#include <stdio.h>
#include <string.h>

int main() {
  static char T[100001];
  scanf("%s", T);

  size_t len = strlen(T);
  for (size_t i = 0; i < len; i++) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }
  printf("%s\\n", T);

  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

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

  string input;

  cin >> input;

  string pd = input;
  string capital, preCapital, ans;

  for (int i = 0; i < (int)pd.size(); ++i) {
    if (pd[i] == '?') {
      ans += 'D';
    } else {
      ans += pd[i];
    }
  }

  printf("%s\\n", ans.c_str());

  return 0;
}

Error: TLE

Fixed submission:

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

  string input;

  cin >> input;

  string pd = input;
  string capital, preCapital, ans;

  for (int i = 0; i < (int)pd.size(); ++i) {

    if (pd[i] == '?') {
      capital = 'D';
    } else {
      capital = pd[i];
    }

    ans = ans + capital;
  }

  printf("%s\\n", ans.c_str());

  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll t = 1;
  // cin >> t;
  while (t--) {
    string s;
    cin >> s;
    std::replace(s.begin(), s.end(), '?', 'D'); // replace all 'x' to 'y'
    cout << s << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll t = 1;
  // cin >> t;
  while (t--) {
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '?') {
        ans = ans + 'D';
      } else
        ans = ans + s[i];
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

char arr[200000 + 10];

int main() {
  scanf("%s", arr);
  int len = strlen(arr);
  for (int i = 0; i < len; i++) {
    if (arr[i] != '?')
      printf("%c", arr[i]);
    else
      printf("D");
  }
  printf("\\n");
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

char arr[200000 + 10];

int main() {
  scanf("%s", arr);
  for (int i = 0; i < strlen(arr); i++) {
    if (arr[i] != '?')
      printf("%c", arr[i]);
    else
      printf("D");
  }
  printf("\\n");
  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string T;
  cin >> T;
  rep(i, T.size()) {
    if (T.at(i) == '?')
      T.at(i) = 'D';
  }
  cout << T << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string T;
  cin >> T;

  if (T.at(0) == '?') {
    if (T.at(1) != 'P')
      T.at(0) = 'P';
  }
  for (int i = 1; i < T.size() - 1; i++) {
    if (T.at(i) == '?') {
      if (T.at(i + 1) != 'P' && T.at(i - 1) == 'D') {
        T.at(i) = 'P';
      } else
        T.at(i) = 'D';
    }
  }
  if (T.at(T.size() - 1) == '?') {
    T.at(T.size() - 1) = 'D';
  }
  cout << T << endl;

  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int i;
string t;

string easy() {
  for (i = 1; i < t.size(); i++) {
    if (t[i] == '?') {
      t[i] = 'D';
    }
  }
  return t;
}

int main() {
  cin >> t;
  int s = 0;
  for (i = 0; i < t.size(); i++) {
    if (t[i] == 'P')
      break;
    else
      easy();
  }
  for (i = 1; i < t.size(); i++) {
    if (t[i] == 'D' && t[i - 1] == '?') {
      t[i - 1] = 'P';
    }
    if (t[i] == '?' && t[i - 1] == 'P') {
      t[i] = 'D';
    }
  }
  for (i = 0; i < t.size(); i++) {
    if (t[i] == '?')
      t[i] = 'D';
  }
  cout << t << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int i;
string t;

int easy() {
  for (i = 1; i < t.size(); i++) {
    if (t[i] == '?') {
      t[i] = 'D';
    }
  }
}

int main() {
  cin >> t;
  int s = 0;
  for (i = 0; i < t.size(); i++) {
    if (t[i] == 'P')
      break;
    else
      easy();
  }
  for (i = 1; i < t.size(); i++) {
    if (t[i] == 'D' && t[i - 1] == '?') {
      t[i - 1] = 'P';
    }
    if (t[i] == '?' && t[i - 1] == 'P') {
      t[i] = 'D';
    }
  }
  for (i = 0; i < t.size(); i++) {
    if (t[i] == '?')
      t[i] = 'D';
  }
  cout << t << endl;
  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == '?') {
      t.at(i) = 'D';
    }
  }
  cout << t << endl;
}

Error: 0

Fixed submission:

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

int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == '?') {
      if (i < t.size() - 1) {
        if (t.at(i + 1) == 'D') {
          t.at(i) = 'P';
        }
        if (i > 0) {
          if (t.at(i - 1) == 'P') {
            t.at(i) = 'D';
          } else {
            t.at(i) = 'P';
          }
        }
      } else {
        if (t.at(i - 1) == 'P') {
          t.at(i) = 'D';
        } else {
          t.at(i) = 'P';
        }
      }
    }
  }
  cout << t << endl;
}
Problem p02664 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using p = pair<int, int>;

int main() {

  string s;
  cin >> s;

  int len = s.size();
  rep(i, len) {
    if (s.at(i) == '?') {
      s.at(i) = 'D';
    }
  }
  cout << s << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using p = pair<int, int>;

int main() {

  string s;
  cin >> s;
  // cout << s << endl;

  int len = s.size();
  // cout << len << endl;
  rep(i, len) {

    if (s.at(i) == '?') {

      if (s.at(i - 1) == 'P' || i == len - 1) {
        s.at(i) = 'D';
      } else {
        if (s.at(i + 1) == 'D') {
          s.at(i) = 'P';
        } else if (s.at(i + 1) == 'P') {
          s.at(i) = 'D';
        } else {
          s.at(i) = 'P';
          // s.at(i+1) = 'D';
          // i++;
        }
      }
    }
    // cout << s.at(i) << endl;
  }
  cout << s << endl;

  return 0;
}
Problem p02664 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const ll mod = 998244353;
int a, b, c, d, e;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  a = s.size();
  for (int i = 0; i < a; i++) {
    if (s[i] == '?')
      s[i] = 'D';
  }
  cout << s;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const ll mod = 998244353;
int a, b, c, d, e;
char s[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == '?')
      s[i] = 'D';
  }
  cout << s;
  return 0;
}