Language: C++

#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define INF INT_MAX/3
#define EPS 1e-14

typedef int128_t lli;
typedef pair<lli,lli> P;
typedef tuple<int,int,int> Triple;

void add(P &x, int y) {
  x.first += x.second *y;
}

void sub(P &x, int y) {
  x.first -= x.second * y;
}

void mul(P &x, int y) {
  x.first *= y;
}

lli gcd(lli x, lli y) {
  return (y == 0 ? x : gcd(y, x % y));
}

void simplify(P &x) {
  lli g = gcd(x.first, x.second);
  x.first /= g;
  x.second /= g;
}

void div(P &x, lli y) {
  x.second *= y;
  simplify(x);
}

int main() {
  P x(0, 1);
  int n;
  cin >> n;
  REP(i, n) {
    int o, y;
    cin >> o >> y;
    if (o == 1) add(x, y);
    else if (o == 2) sub(x, y);
    else if (o == 3) mul(x, y);
    else if (o == 4) div(x, y);
    else throw 1;
  }
  cout << x.first / x.second << endl;
  return 0;
}

Compiler output:
a.cc:12:9: error: 'int128_t' does not name a type; did you mean 'int8_t'?
   12 | typedef int128_t lli;
      |         ^~~~~~~~
      |         int8_t
a.cc:13:14: error: 'lli' was not declared in this scope
   13 | typedef pair<lli,lli> P;
      |              ^~~
a.cc:13:18: error: 'lli' was not declared in this scope
   13 | typedef pair<lli,lli> P;
      |                  ^~~
a.cc:13:21: error: template argument 1 is invalid
   13 | typedef pair<lli,lli> P;
      |                     ^
a.cc:13:21: error: template argument 2 is invalid
a.cc: In function 'void add(P&, int)':
a.cc:17:5: error: request for member 'first' in 'x', which is of non-class type 'P' {aka 'int'}
   17 |   x.first += x.second *y;
      |     ^~~~~
a.cc:17:16: error: request for member 'second' in 'x', which is of non-class type 'P' {aka 'int'}
   17 |   x.first += x.second *y;
      |                ^~~~~~
a.cc: In function 'void sub(P&, int)':
a.cc:21:5: error: request for member 'first' in 'x', which is of non-class type 'P' {aka 'int'}
   21 |   x.first -= x.second * y;
      |     ^~~~~
a.cc:21:16: error: request for member 'second' in 'x', which is of non-class type 'P' {aka 'int'}
   21 |   x.first -= x.second * y;
      |                ^~~~~~
a.cc: In function 'void mul(P&, int)':
a.cc:25:5: error: request for member 'first' in 'x', which is of non-class type 'P' {aka 'int'}
   25 |   x.first *= y;
      |     ^~~~~
a.cc: At global scope:
a.cc:28:1: error: 'lli' does not name a type
   28 | lli gcd(lli x, lli y) {
      | ^~~
a.cc: In function 'void simplify(P&)':
a.cc:33:3: error: 'lli' was not declared in this scope
   33 |   lli g = gcd(x.first, x.second);
      |   ^~~
a.cc:34:5: error: request for member 'first' in 'x', which is of non-class type 'P' {aka 'int'}
   34 |   x.first /= g;
      |     ^~~~~
a.cc:34:14: error: 'g' was not declared in this scope
   34 |   x.first /= g;
      |              ^
a.cc:35:5: error: request for member 'second' in 'x', which is of non-class type 'P' {aka 'int'}
   35 |   x.second /= g;
      |     ^~~~~~
a.cc: At global scope:
a.cc:38:16: error: 'lli' has not been declared
   38 | void div(P &x, lli y) {
      |                ^~~
a.cc: In function 'void div(P&, int)':
a.cc:39:5: error: request for member 'second' in 'x', which is of non-class type 'P' {aka 'int'}
   39 |   x.second *= y;
      |     ^~~~~~
a.cc: In function 'int main()':
a.cc:44:11: error: expression list treated as compound expression in initializer [-fpermissive]
   44 |   P x(0, 1);
      |           ^
a.cc:53:25: error: call of overloaded 'div(P&, int&)' is ambiguous
   53 |     else if (o == 4) div(x, y);
      |                      ~~~^~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:992:14: note: candidate: 'div_t div(int, int)'
  992 | extern div_t div (int __numer, int __denom)
      |              ^~~
a.cc:38:6: note: candidate: 'void div(P&, int)'
   38 | void div(P &x, lli y) {
      |      ^~~
/usr/include/c++/14/cstdlib:219:3: note: candidate: 'lldiv_t __gnu_cxx::div(long long int, long long int)'
  219 |   div(long long __n, long long __d)
      |   ^~~
/usr/include/c++/14/cstdlib:181:3: note: candidate: 'ldiv_t std::div(long int, long int)'
  181 |   div(long __i, long __j) _GLIBCXX_NOTHROW { return ldiv(__i, __j); }
      |   ^~~
a.cc:56:13: error: request for member 'first' in 'x', which is of non-class type 'P' {aka 'int'}
   56 |   cout << x.first / x.second << endl;
      |             ^~~~~
a.cc:56:23: error: request for member 'second' in 'x', which is of non-class type 'P' {aka 'int'}
   56 |   cout << x.first / x.second << endl;
      |                       ^~~~~~