Problem p03435 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <random>
#include <set>
#include <stdio.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define Matrix vector<vector<int>>
#define kektor vector
#define pp pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;

int RandInt(int min, int max) {
  if (max < min) {
    swap(min, max);
  }
  random_device rd;
  mt19937 mt(rd());
  uniform_int_distribution<int> dist(min, max);
  return dist(mt);
}

struct Node {
  int l, r, x;
  Node(int _l, int _r, int _x) : l(_l), r(_r), x(_x) {}
  Node() : l(-1), r(-1), x(0) {}
};

const int maxn = 2e5 + 1, mod = 1e9;
bool debug = false;
int gr[3][3];

void solve() {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> gr[i][j];
    }
  }
  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      for (int k = 0; k <= 100; ++k) {
        int b1 = gr[0][0] - i;
        int b2 = gr[0][1] - i;
        int b3 = gr[0][2] - i;
        if (b1 >= 0 && b2 >= 0 && b3 >= 0) {
          if (j + b1 == gr[1][0] && j + b2 == gr[1][1] && j + b3 == gr[1][2] &&
              k + b1 == gr[2][0] && k + b2 == gr[2][1] && k + b3 == gr[2][2]) {
            cout << "Yes";
            return;
          }
        }
      }
    }
  }
  cout << "No";
}

signed main() {
  /*!

  !*/
  cout.precision(10);
  cout << fixed;
  if (!debug) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  freopen("TASK.in", "r", stdin);
  freopen("TASK.out", "w", stdout);
  solve();
  return 0;
}


Fixed submission:
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <random>
#include <set>
#include <stdio.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define Matrix vector<vector<int>>
#define kektor vector
#define pp pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;

int RandInt(int min, int max) {
  if (max < min) {
    swap(min, max);
  }
  random_device rd;
  mt19937 mt(rd());
  uniform_int_distribution<int> dist(min, max);
  return dist(mt);
}

struct Node {
  int l, r, x;
  Node(int _l, int _r, int _x) : l(_l), r(_r), x(_x) {}
  Node() : l(-1), r(-1), x(0) {}
};

const int maxn = 2e5 + 1, mod = 1e9;
bool debug = false;
int gr[3][3];

void solve() {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> gr[i][j];
    }
  }
  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      for (int k = 0; k <= 100; ++k) {
        int b1 = gr[0][0] - i;
        int b2 = gr[0][1] - i;
        int b3 = gr[0][2] - i;
        if (b1 >= 0 && b2 >= 0 && b3 >= 0) {
          if (j + b1 == gr[1][0] && j + b2 == gr[1][1] && j + b3 == gr[1][2] &&
              k + b1 == gr[2][0] && k + b2 == gr[2][1] && k + b3 == gr[2][2]) {
            cout << "Yes";
            return;
          }
        }
      }
    }
  }
  cout << "No";
}

signed main() {
  /*!

  !*/
  cout.precision(10);
  cout << fixed;
  if (!debug) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  //   freopen("TASK.in", "r", stdin);
  // freopen("TASK.out", "w", stdout);
  solve();
  return 0;
}