Language: C++

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define int long long;

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename T> class Dinic {
public:
    struct edge{
        int to;
        T cap;
        int rev;
    };
    vector<vector<edge> > G;
    vector<int> level,iter;
    int n;
    Dinic(int node_size){
        n = node_size;
        G.resize(node_size),level.resize(node_size),iter.resize(node_size);
    }
    //辺を張る
    void add_edge(int from,int to,T cap)
    {
    	G[from].push_back((edge){to,cap,(int)G[to].size()});
    	G[to].push_back((edge){from,(T)0,(int)G[from].size()-1});
    }
    void bfs(int s)
    {
    	fill(level.begin(),level.end(),-1);
    	queue<int> que;
    	level[s] = 0;
    	que.push(s);
    	while(!que.empty()){
    		int v = que.front();
    		que.pop();
    		rep(i,G[v].size()){
    			edge &e = G[v][i];
    			if(e.cap > 0 && level[e.to] < 0){
    				level[e.to] = level[v] + 1;
    				que.push(e.to);
    			}
    		}
    	}
    }
    T dfs(int v,int t,T f)
    {
    	if(v==t){
    		return f;
    	}
    	for(int &i = iter[v];i<(int)G[v].size();i++){
    		edge &e = G[v][i];
    		if(e.cap > 0 && level[v] < level[e.to]){
    			T d = dfs(e.to,t,min(f,e.cap));
    			if(d>0){
    				e.cap -= d;
    				G[e.to][e.rev].cap += d;
    				return d;
    			}
    		}
    	}
    	return 0;
    }
    //最大流を計算
    T solve(int s,int t)
    {
    	T flow = 0;
    	for(;;){
    		bfs(s);
    		if(level[t]<0){
    			return flow;
    		}
    		fill(iter.begin(),iter.end(),0);
    		T f;
    		while((f=dfs(s,t,numeric_limits<T>::max())) > 0){
    			flow += f;
    		}
    	}
    }
};

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vp vec(n);
    rep(i,n){
        cin >> vec[i].fi >> vec[i].se;
    }
    sort(all(vec));
    vi m(n),x(n);
    rep(i,n){
        m[i] = vec[i].fi,x[i] = -vec[i].se;
    }
    Dinic<ll> dn(n+2);
    int add = max(0,-*min_element(all(x)));
    rep(i,n){
        dn.add_edge(n,i,x[i]+add);
    }
    rep(i,n){
        dn.add_edge(i,n+1,add);
    }
    rep(i,n){
        rep(j,i){
            if(m[i] % m[j] == 0){
                dn.add_edge(j,i,(1LL << 50));
            }
        }
    }
    cout << -dn.solve(n,n+1) + add*n << "\n";
    return 0;
}


Compiler output:
a.cc:23:18: error: wrong number of template arguments (1, should be 2)
   23 | #define int long long;
      |                  ^~~~
a.cc:27:14: note: in expansion of macro 'int'
   27 | typedef pair<int,int> P;
      |              ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
   89 |     struct pair;
      |            ^~~~
a.cc:27:1: warning: 'typedef' was ignored in this declaration
   27 | typedef pair<int,int> P;
      | ^~~~~~~
a.cc:27:17: error: expected unqualified-id before ',' token
   27 | typedef pair<int,int> P;
      |                 ^
a.cc:23:13: error: expected unqualified-id before 'long'
   23 | #define int long long;
      |             ^~~~
a.cc:27:18: note: in expansion of macro 'int'
   27 | typedef pair<int,int> P;
      |                  ^~~
a.cc:27:21: error: expected unqualified-id before '>' token
   27 | typedef pair<int,int> P;
      |                     ^
a.cc:23:18: error: template argument 1 is invalid
   23 | #define int long long;
      |                  ^~~~
a.cc:29:16: note: in expansion of macro 'int'
   29 | typedef vector<int> vi;
      |                ^~~
a.cc:23:18: error: template argument 2 is invalid
   23 | #define int long long;
      |                  ^~~~
a.cc:29:16: note: in expansion of macro 'int'
   29 | typedef vector<int> vi;
      |                ^~~
a.cc:29:1: warning: 'typedef' was ignored in this declaration
   29 | typedef vector<int> vi;
      | ^~~~~~~
a.cc:29:19: error: expected unqualified-id before '>' token
   29 | typedef vector<int> vi;
      |                   ^
a.cc:30:16: error: 'vi' was not declared in this scope; did you mean 'fi'?
   30 | typedef vector<vi> vvi;
      |                ^~
      |                fi
a.cc:30:18: error: template argument 1 is invalid
   30 | typedef vector<vi> vvi;
      |                  ^
a.cc:30:18: error: template argument 2 is invalid
a.cc:34:16: error: 'P' was not declared in this scope
   34 | typedef vector<P> vp;
      |                ^
a.cc:34:17: error: template argument 1 is invalid
   34 | typedef vector<P> vp;
      |                 ^
a.cc:34:17: error: template argument 2 is invalid
a.cc:23:18: error: declaration does not declare anything [-fpermissive]
   23 | #define int long long;
      |                  ^~~~
a.cc:37:7: note: in expansion of macro 'int'
   37 | const int MAX_N = 100005;
      |       ^~~
a.cc:37:11: error: 'MAX_N' does not name a type
   37 | const int MAX_N = 100005;
      |           ^~~~~
a.cc:23:18: error: declaration does not declare anything [-fpermissive]
   23 | #define int long long;
      |                  ^~~~
a.cc:42:9: note: in expansion of macro 'int'
   42 |         int to;
      |         ^~~
a.cc:42:13: error: 'to' does not name a type; did you mean 'tm'?
   42 |         int to;
      |             ^~
      |             tm
a.cc:23:18: error: declaration does not declare anything [-fpermissive]
   23 | #define int long long;
      |                  ^~~~
a.cc:44:9: note: in expansion of macro 'int'
   44 |         int rev;
      |         ^~~
a.cc:44:13: error: 'rev' does not name a type; did you mean 'rep'?
   44 |         int rev;
      |             ^~~
      |             rep
a.cc:23:18: error: template argument 1 is invalid
   23 | #define int long long;
      |                  ^~~~
a.cc:47:12: note: in expansion of macro 'int'
   47 |     vector<int> level,iter;
      |            ^~~
a.cc:23:18: error: template argument 2 is invalid
   23 | #define int long long;
      |                  ^~~~
a.cc:47:12: note: in expansion of macro 'int'
   47 |     vector<int> level,iter;
      |            ^~~
a.cc:47:15: error: expected unqualified-id before '>' token
   47 |     vector<int> level,iter;
      |               ^
a.cc:23:18: error: declaration does not declare anything [-fpermissive]
   23 | #define int long long;
      |                  ^~~~
a.cc:48:5: note: in expansion of macro 'int'
   48 |     int n;
      |     ^~~
a.cc:48:9: error: 'n' does not name a type
   48 |     int n;
      |         ^
a.cc:23:22: error: expected ')' before ';' token
   23 | #define int long long;
      |                      ^
a.cc:49:11: note: in expansion of macro 'int'
   49 |     Dinic(int node_size){
      |           ^~~
a.cc:49:10: note: to match this '('
   49 |     Dinic(int node_size){
      |          ^
a.cc:49:15: error: 'node_size' does not name a type
   49 |     Dinic(int node_size){
      |               ^~~~~~~~~
a.cc:23:22: error: expected ')' before ';' token
   23 | #define int long long;
      |                      ^
a.cc:54:19: note: in expansion of macro 'int'
   54 |     void add_edge(int from,int to,T cap)
      |                   ^~~
a.cc:54:18: note: to match this '('
   54 |     void add_edge(int from,int to,T cap)
      |                  ^
a.cc:54:23: error: 'from' does not name a type
   54 |     void add_edge(int from,int to,T cap)
      |                       ^~~~
a.cc:54:32: error: 'to' does not name a type; did you mean 'tm'?
   54 |     void add_edge(int from,int to,T cap)
      |                                ^~
      |                                tm
a.cc:23:22: error: expected ')' before ';' token
   23 | #define int long long;
      |                      ^
a.cc:59:14: note: in expansion of macro 'int'
   59 |     void bfs(int s)
      |              ^~~
a.cc:59:13: note: to match this '('
   59 |     void bfs(int s)
      |             ^
a.cc:59:18: error: 's' does not name a type
   59 |     void bfs(int s)
      |                  ^
a.cc:23:22: error: expected ')' before ';' token
   23 | #define int long long;
      |                      ^
a.cc:77:11: note: in expansion of macro 'int'
   77 |     T dfs(int v,int t,T f)
      |           ^~~
a.cc:77:10: note: to match this '('
   77 |     T dfs(int v,int t,T f)
      |          ^
a.cc:77:15: error: 'v' does not name a type
   77 |     T dfs(int v,int t,T f)
      |               ^
a.cc:77:21: error: 't' does not name a type
   77 |     T dfs(int v,int t,T f)
      |                     ^
a.cc:23:22: error: expected ')' before ';' token
   23 | #define int long long;
      |                      ^
a.cc:96:13: note: in expansion of macro 'int'
   96 |     T solve(int s,int t)
      |             ^~~
a.cc:96:12: note: to match this '('
   96 |     T solve(int s,int t)
      |            ^
a.cc:96:17: error: 's' does not name a type
   96 |     T solve(int s,int t)
      |                 ^
a.cc:96:23: error: 't' does not name a type
   96 |     T solve(int s,int t)
      |                       ^
a.cc: In function 'int main()':
a.cc:23:18: error: declaration does not declare anything [-fpermissive]
   23 | #define int long long;
      |                  ^~~~
a.cc:117:5: note: in expansion of macro 'int'
  117 |     int n;
      |     ^~~
a.cc:117:9: error: 'n' was not declared in this scope; did you mean 'yn'?
  117 |     int n;
      |         ^
      |         yn
a.cc:23:18: error: declaration does not declare anything [-fpermissive]
   23 | #define int long long;
      |                  ^~~~
a.cc:6:22: note: in expansion of macro 'int'
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                      ^~~
a.cc:120:5: note: in expansion of macro 'rep'
  120 |     rep(i,n){
      |     ^~~
a.cc:120:9: error: 'i' was not declared in this scope; did you mean 'fi'?
  120 |     rep(i,n){
      |         ^
a.cc:6:26: note: in definition of macro 'rep'
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                          ^
a.cc:23:13: error: expected primary-expression before 'long'
   23 | #define int long long;
      |             ^~~~
a.cc:6:33: note: in expansion of macro 'int'
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                                 ^~~
a.cc:120:5: note: in expansion of macro 'rep'
  120 |     rep(i,n){
      |     ^~~
a.cc:23:13: error: expected ')' before 'long'
   23 | #define int long long;
      |             ^~~~
a.cc:6:33: note: in expansion of macro 'int'
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                                 ^~~
a.cc:120:5: note: in expansion of macro 'rep'
  120 |     rep(i,n){
      |     ^~~
a.cc:6:32: note: to match this '('
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                                ^
a.cc:120:5: note: in expansion of macro 'rep'
  120 |     rep(i,n){
      |     ^~~
a.cc:23:22: error: expected ')' before ';' token
   23 | #define int long long;
      |                      ^
a.cc:6:33: note: in expansion of macro 'int'
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                                 ^~~
a.cc:120:5: note: in expansion of macro 'rep'
  120 |     rep(i,n){
      |     ^~~
a.cc:6:21: note: to match this '('
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                     ^
a.cc:120:5: note: in expansion of macro 'rep'
  120 |     rep(i,n){
      |     ^~~
a.cc:6:36: error: expected primary-expression before ')' token
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                                    ^
a.cc:120:5: note: in expansion of macro 'rep'
  120 |     rep(i,n){
      |     ^~~
a.cc:120:9: error: 'i' was not declared in this scope; did you mean 'fi'?
  120 |     rep(i,n){
      |         ^
a.cc:6:43: note: in definition of macro 'rep'
    6 | #define rep(i,n) for(int i=0;i<(int)(n);++i)
      |                                           ^
a.cc:10:20: error: request for member 'begin' in 'vec', which is of non-class type 'vp' {aka 'int'}
   10 | #define all(v) (v).begin(),(v).end()
      |                    ^~~~~
a.cc:123:10: note: in expansion of macro 'all'
  123 |     sort(all(vec));
      |          ^~~
a.cc:10:32: error: request for member 'end' in 'vec', which is of non-class type 'vp' {aka 'int'}
   10 | #define all(v) (v).begin(),(v).end()
      |                                ^~~
a.cc:1