Problem p02909 (C++)

Buggy submission (status: Runtime Error):
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

// i hope i get better

// Task name:
#define Task ""
using namespace std;

// Include
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

// Define
#define reset(x, value) memset((x), (value), sizeof((x)))
#define fr(i, a, b) for (int i = (a); i <= (b); i++)
#define FR(i, a, b) for (int i = (a); i < (b); i++)
#define frr(i, a, b) for (int i = (a); i >= (b); i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl "\n"
#define bit(x, i) (x >> i) & 1
#define all(x) (x).begin(), (x).end()
#define optimize(x) (x).resize(unique(all(x)) - (x).begin())
#define Inpf freopen(Task ".inp", "r", stdin)
#define Outf freopen(Task ".out", "w", stdout)
#define fasterIO                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

// typedef
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;

const int base = 131;
const int MOD = 1e9 + 7;
const ll MM = 1ll * MOD * MOD;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void AddMOD(int &x, int y) {
  x += y;
  if (x >= MOD)
    x -= MOD;
}
int Gcd(int x, int y) {
  if (y == 0)
    return x;
  return Gcd(y, x % y);
}
template <class T> inline void Gmax(T &x, T y) { x = max((x), (y)); }
template <class T> inline void Gmin(T &x, T y) { x = min((x), (y)); }

void exit_with_runtime() {
  db x = 1.0 * clock() / CLOCKS_PER_SEC;
  cerr << "\n\n---------------------\nTime elapsed: " << x << " s.\n\n";
  if (x > 1)
    cerr << "TIME LIMIT EXCEEDED!\n\n";
  exit(0);
}

// --------------------------------------------------------------------
const int maxn = 2e5 + 5;
// --------------------------------------------------------------------

string str[] = {"Sunny", "Cloudy", "Rainy"};

void Solve() {
  string s;
  cin >> s;
  for (int i = 0; i <= 2; i++)
    if (s == str[i])
      cout << str[(i + 1) % 3];
}

int main() {
#ifndef ONLINE_JUDGE
  Inpf;
  Outf;
#endif // ONLINE_JUDGE
  fasterIO;
  int test = 1;
  //    cin >> test;
  while (test--)
    Solve();

  // Did you check with the special test case n = 0, n = 1??
  exit_with_runtime();
}

// Goodbye, see u again


Fixed submission:
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

// i hope i get better

// Task name:
#define Task ""
using namespace std;

// Include
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

// Define
#define reset(x, value) memset((x), (value), sizeof((x)))
#define fr(i, a, b) for (int i = (a); i <= (b); i++)
#define FR(i, a, b) for (int i = (a); i < (b); i++)
#define frr(i, a, b) for (int i = (a); i >= (b); i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl "\n"
#define bit(x, i) (x >> i) & 1
#define all(x) (x).begin(), (x).end()
#define optimize(x) (x).resize(unique(all(x)) - (x).begin())
#define Inpf freopen(Task ".inp", "r", stdin)
#define Outf freopen(Task ".out", "w", stdout)
#define fasterIO                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

// typedef
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;

const int base = 131;
const int MOD = 1e9 + 7;
const ll MM = 1ll * MOD * MOD;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void AddMOD(int &x, int y) {
  x += y;
  if (x >= MOD)
    x -= MOD;
}
int Gcd(int x, int y) {
  if (y == 0)
    return x;
  return Gcd(y, x % y);
}
template <class T> inline void Gmax(T &x, T y) { x = max((x), (y)); }
template <class T> inline void Gmin(T &x, T y) { x = min((x), (y)); }

void exit_with_runtime() {
  db x = 1.0 * clock() / CLOCKS_PER_SEC;
  cerr << "\n\n---------------------\nTime elapsed: " << x << " s.\n\n";
  if (x > 1)
    cerr << "TIME LIMIT EXCEEDED!\n\n";
  exit(0);
}

// --------------------------------------------------------------------
const int maxn = 2e5 + 5;
// --------------------------------------------------------------------

string str[] = {"Sunny", "Cloudy", "Rainy"};

void Solve() {
  string s;
  cin >> s;
  for (int i = 0; i <= 2; i++)
    if (s == str[i])
      cout << str[(i + 1) % 3];
}

int main() {
#ifndef ONLINE_JUDGE
//    Inpf;
//    Outf;
#endif // ONLINE_JUDGE
  fasterIO;
  int test = 1;
  //    cin >> test;
  while (test--)
    Solve();

  // Did you check with the special test case n = 0, n = 1??
  exit_with_runtime();
}

// Goodbye, see u again