Problem p03168 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine()                                                          \
  int endtime = clock();                                                       \
  cerr << "\n\n"                                                               \
       << "Time elapsed: " << (endtime - begtime) * 1000 / CLOCKS_PER_SEC      \
       << " ms\n\n";                                                           \
  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int, int>
#define pdd pair<db, db>
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vll vector<ll>
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed << setprecision(20)
#define endl '\n'

db dp[3005][3005];
db ans;

int main() {
  start_routine();
  fastio;

  ll n;
  cin >> n;
  db p[n + 1];

  for (ll i = 1; i <= n; i++)
    cin >> p[i];

  dp[0][0] = 1;
  for (ll i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] * p[i];
    dp[0][i] = dp[0][i - 1] * (1.0 - p[i]);
  }

  for (ll i = 1; i <= n; i++)
    for (ll j = 1; j <= n; j++)
      dp[i][j] = (dp[i][j - 1] * (1.0 - p[i + j])) + (dp[i - 1][j] * p[i + j]);

  for (ll i = 0; i <= n; i++)
    for (ll j = 0; j <= n; j++)
      if (i > j && i + j == n)
        ans += dp[i][j];

  cout << stp << ans;

  end_routine();
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine()                                                          \
  int endtime = clock();                                                       \
  cerr << "\n\n"                                                               \
       << "Time elapsed: " << (endtime - begtime) * 1000 / CLOCKS_PER_SEC      \
       << " ms\n\n";                                                           \
  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int, int>
#define pdd pair<db, db>
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vll vector<ll>
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed << setprecision(20)
#define endl '\n'

db dp[3005][3005];
db ans;

int main() {
  start_routine();
  fastio;

  ll n;
  cin >> n;
  db p[n + 1];

  for (ll i = 1; i <= n; i++)
    cin >> p[i];

  dp[0][0] = 1;
  for (ll i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] * p[i];
    dp[0][i] = dp[0][i - 1] * (1.0 - p[i]);
  }

  for (ll i = 1; i <= n; i++)
    for (ll j = 1; j <= n; j++)
      if (i + j <= n)
        dp[i][j] =
            (dp[i][j - 1] * (1.0 - p[i + j])) + (dp[i - 1][j] * p[i + j]);

  for (ll i = 0; i <= n; i++)
    for (ll j = 0; j <= n; j++)
      if (i > j && i + j == n)
        ans += dp[i][j];

  cout << stp << ans;

  end_routine();
}