Language: C++

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000003;

int main(){
    ll n; cin >> n;
    if(n%2 == 0){
        prtl((n-1)*n/2);
        rep(i, 1, n+1){
            rep(j, i+1, n+1){
                if(i+j == n+1){
                    continue;
                }else{
                    prt(i); prt(" "); prtl(j);
                }
            }
        }
    }else{
        prtl((n-1)*(n-1)/2);
        rep(i, 1, n){
            rep(j, i+1, n+1){
                if(i+j == n){
                    continue;
                }else{
                    prt(i); prt(" "); prtl(j);
                }
            }
        }
    }
}#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000003;

int main(){
    ll n; cin >> n;
    if(n%2 == 0){
        prtl((n-1)*n/2);
        rep(i, 1, n+1){
            rep(j, i+1, n+1){
                if(i+j == n+1){
                    continue;
                }else{
                    prt(i); prt(" "); prtl(j);
                }
            }
        }
    }else{
        prtl((n-1)*(n-1)/2);
        rep(i, 1, n){
            rep(j, i+1, n+1){
                if(i+j == n){
                    continue;
                }else{
                    prt(i); prt(" "); prtl(j);
                }
            }
        }
    }
}

Compiler output:
a.cc:57:2: error: stray '#' in program
   57 | }#pragma GCC optimize ("O3")
      |  ^
a.cc:57:3: error: 'pragma' does not name a type; did you mean '_Pragma'?
   57 | }#pragma GCC optimize ("O3")
      |   ^~~~~~
      |   _Pragma
a.cc:85:4: error: redefinition of 'll INF'
   85 | ll INF = 1LL<<60;
      |    ^~~
a.cc:29:4: note: 'll INF' previously defined here
   29 | ll INF = 1LL<<60;
      |    ^~~
a.cc:86:4: error: redefinition of 'll M'
   86 | ll M = 1000003;
      |    ^
a.cc:30:4: note: 'll M' previously defined here
   30 | ll M = 1000003;
      |    ^
a.cc:88:5: error: redefinition of 'int main()'
   88 | int main(){
      |     ^~~~
a.cc:32:5: note: 'int main()' previously defined here
   32 | int main(){
      |     ^~~~