Problem p02841 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
#include <string>
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const double PI = acos(-1.0);
const int MOD = pow(10, 9) + 7;

#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

inline void finish() {
  cout << -1 << endl;
  exit(0);
}

template <typename T> inline void debug(vector<T> v) {
  cout << "[";
  for (size_t i = 0; i < v.size() - 1; ++i) {
    cout << v[i] << ", ";
  }
  cout << v[v.size() - 1] << "]" << endl;
}

class Pos {
public:
  double x, y;
  Pos(double x, double y) {
    this->x = x;
    this->y = y;
  }
  Pos() {
    x = 0.0;
    y = 0.0;
  }
};

class Mod {
  static inline ll Add(ll a, ll b) { return (a + b) % MOD; }

  static inline ll Sub(ll a, ll b) {
    ll ans = (a - b) % MOD;
    return (ans < 0) ? (ans + MOD) : ans;
  }

  static inline ll Mul(ll a, ll b) { return (a * b) % MOD; }

  static inline ll Div(ll a, ll b) { return (a % MOD) * modinv(b, MOD) % MOD; }
};

inline double distance(Pos p1, Pos p2) {
  return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

inline int Kaijo(int n) {
  int ans = 1;
  for (int i = 2; i <= n; ++i) {
    ans *= i;
  }
  return ans;
}

template <typename T> inline int keta(T num) { return to_string(num).length(); }

void Main();
inline void DebugMain() {
  while (true) {
    Main();
    cout << endl;
  }
}

int main() {
  bool debug = true;
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  if (debug) {
    cout << "\x1b[41m"
         << "Debug Mode このまま提出すると死" << endl;
  }
  try {
    (debug) ? DebugMain() : Main();
  } catch (exception &e) {
    cout << e.what() << endl;
  }
  return 0;
}

inline void Main() {
  int m1, m2, d1, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 == m2) {
    cout << 0;
  } else {
    cout << 1;
  }
}

Fixed submission:
#include "bits/stdc++.h"
#include <string>
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const double PI = acos(-1.0);
const int MOD = pow(10, 9) + 7;

#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

inline void finish() {
  cout << -1 << endl;
  exit(0);
}

template <typename T> inline void debug(vector<T> v) {
  cout << "[";
  for (size_t i = 0; i < v.size() - 1; ++i) {
    cout << v[i] << ", ";
  }
  cout << v[v.size() - 1] << "]" << endl;
}

class Pos {
public:
  double x, y;
  Pos(double x, double y) {
    this->x = x;
    this->y = y;
  }
  Pos() {
    x = 0.0;
    y = 0.0;
  }
};

class Mod {
  static inline ll Add(ll a, ll b) { return (a + b) % MOD; }

  static inline ll Sub(ll a, ll b) {
    ll ans = (a - b) % MOD;
    return (ans < 0) ? (ans + MOD) : ans;
  }

  static inline ll Mul(ll a, ll b) { return (a * b) % MOD; }

  static inline ll Div(ll a, ll b) { return (a % MOD) * modinv(b, MOD) % MOD; }
};

inline double distance(Pos p1, Pos p2) {
  return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

inline int Kaijo(int n) {
  int ans = 1;
  for (int i = 2; i <= n; ++i) {
    ans *= i;
  }
  return ans;
}

template <typename T> inline int keta(T num) { return to_string(num).length(); }

void Main();
inline void DebugMain() {
  while (true) {
    Main();
    cout << endl;
  }
}

int main() {
  bool debug = false;
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  if (debug) {
    cout << "\x1b[41m"
         << "Debug Mode このまま提出すると死" << endl;
  }
  try {
    (debug) ? DebugMain() : Main();
  } catch (exception &e) {
    cout << e.what() << endl;
  }
  return 0;
}

inline void Main() {
  int m1, m2, d1, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 == m2) {
    cout << 0;
  } else {
    cout << 1;
  }
}