Problem p03090 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define FastRead                                                               \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i, a, n) for (int i = (a); i <= (n); ++i)
#define RFOR(i, a, n) for (int i = (n); i >= (a); --i)
#define FI(i, n) for (int i = 0; i < (n); ++i)
#define ZERO(a) memset((a), 0, sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(), g.end()
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including
// tree_order_statistics_node_updat using namespace __gnu_pbds; typedef tree<ll,
// null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
// ordered_set;

// I am questioning life and universe and
// everything else after looking at this

void solve() {
  ll n;
  cin >> n;

  vector<ll> graph[n + 1];
  ll to_be_made = n;

  if (n % 2 == 0)
    to_be_made++;

  vector<pair<ll, ll>> pairs;
  for (ll i = 1; i <= n / 2; i++) {
    pairs.push_back({i, to_be_made - i});
  }

  for (ll i = 0; i < pairs.size(); i++) {
    for (ll j = i + 1; j < pairs.size(); i++) {
      graph[pairs[i].first].push_back(pairs[j].first);
      graph[pairs[i].first].push_back(pairs[j].second);
      graph[pairs[i].second].push_back(pairs[j].first);
      graph[pairs[i].second].push_back(pairs[j].second);
    }
    if (n % 2 == 1) {
      graph[n].push_back(pairs[i].first);
      graph[n].push_back(pairs[i].second);
    }
  }

  vector<pair<ll, ll>> edges;

  for (ll i = 1; i <= n; i++) {
    for (ll v : graph[i]) {
      edges.push_back({i, v});
    }
  }

  cout << edges.size() << endl;

  for (auto x : edges) {
    cout << x.first << " " << x.second << endl;
  }
}

signed main() {

  FastRead;

  ll t;
  t = 1;
  // cin>>t;
  while (t--)
    solve();
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define FastRead                                                               \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i, a, n) for (int i = (a); i <= (n); ++i)
#define RFOR(i, a, n) for (int i = (n); i >= (a); --i)
#define FI(i, n) for (int i = 0; i < (n); ++i)
#define ZERO(a) memset((a), 0, sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(), g.end()
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including
// tree_order_statistics_node_updat using namespace __gnu_pbds; typedef tree<ll,
// null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
// ordered_set;

// I am questioning life and universe and
// everything else after looking at this

void solve() {
  ll n;
  cin >> n;

  vector<ll> graph[n + 1];
  ll to_be_made = n;

  if (n % 2 == 0)
    to_be_made++;

  vector<pair<ll, ll>> pairs;
  for (ll i = 1; i <= n / 2; i++) {
    pairs.push_back({i, to_be_made - i});
  }

  for (ll i = 0; i < pairs.size(); i++) {
    for (ll j = i + 1; j < pairs.size(); j++) {
      graph[pairs[i].first].push_back(pairs[j].first);
      graph[pairs[i].first].push_back(pairs[j].second);
      graph[pairs[i].second].push_back(pairs[j].first);
      graph[pairs[i].second].push_back(pairs[j].second);
    }
    if (n % 2 == 1) {
      graph[n].push_back(pairs[i].first);
      graph[n].push_back(pairs[i].second);
    }
  }

  vector<pair<ll, ll>> edges;

  for (ll i = 1; i <= n; i++) {
    for (ll v : graph[i]) {
      edges.push_back({i, v});
    }
  }

  cout << edges.size() << endl;

  for (auto x : edges) {
    cout << x.first << " " << x.second << endl;
  }
}

signed main() {

  FastRead;

  ll t;
  t = 1;
  // cin>>t;
  while (t--)
    solve();
}