Language: C++

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef pair<int,int> ii;

bool LT(double a,double b) { return !equals(a,b) && a < b ; }

struct Edge {
  int to,cap;
  double cost;
  int rev;
};

const int MAX_V = 1000, IINF = INT_MAX;
int V;
vector<Edge> G[MAX_V];

double h[MAX_V],dist[MAX_V];//////// fpwjefoajfpojeawfopefa
int prevv[MAX_V], preve[MAX_V];


inline void add_edge(int from,int to,int cap,double cost){
  G[from].push_back((Edge){to,cap,cost,G[to].size()});
  G[to].push_back((Edge){from,0,-cost,G[from].size()-1});
}

double min_cost_flow(int s,int t,int f){
  double res = 0;
  fill(h,h+V,0);
  while(LT(0,f)){
    priority_queue<ii,vector<ii>,greater<ii> > Q;
    fill(dist,dist+V,INT_MAX);
    dist[s] = 0;
    Q.push(ii(0,s));
    while( !Q.empty() ){
      ii p = Q.top(); Q.pop();
      int v = p.second;
      if( LT(dist[v],p.first) ) continue;
      for(int i=0;i<G[v].size();i++)      {
	Edge &e = G[v][i];
	if( LT(0,e.cap) && LT(dist[v]+e.cost+h[v]-h[e.to],dist[e.to]) ) {
	  dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
	  prevv[e.to] = v;
	  preve[e.to] = i;
	  Q.push(ii(dist[e.to],e.to));
	}
      }
    }
    if( equals(dist[t],INT_MAX) ) return -1;
    rep(v,V) h[v] += dist[v];
    int d = f;
    for(int v=t;v!=s;v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    res += d * h[t];
    for(int v=t;v!=s;v=prevv[v]) {
      Edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

typedef vector<double> vd;
typedef vector<vd> mat;



vector<double> f(const mat& A,const vd& b){
  int n = A.size();
  mat B(n,vd(n+1));
  rep(i,n) rep(j,n) B[i][j] = A[i][j];
  rep(i,n) B[i][n] = b[i];

  rep(i,n){
    int pivot = i;
    REP(j,i,n) if( LT(abs(B[pivot][i]),abs(B[j][i])) ) pivot = j;
    swap(B[i],B[pivot]);
    if( abs(B[i][i]) < EPS ) return vd();
    REP(j,i+1,n+1) B[i][j] /= B[i][i];
    rep(j,n){
      if( i != j ){
	REP(k,i+1,n+1) B[j][k] -= B[j][i] * B[i][k];
      }
    }
  }  

  vd x(n);
  rep(i,n) x[i] = B[i][n];
  return x;
}

void init(int size=MAX_V){
  rep(i,size) G[i].clear();
}

int main(){
  int T;
  cin >> T;
  while( T-- ){
    int N,s,t,F;
    cin >> N >> s >> t#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef pair<int,int> ii;

bool LT(double a,double b) { return !equals(a,b) && a < b ; }

struct Edge {
  int to,cap;
  double cost;
  int rev;
};

const int MAX_V = 1000, IINF = INT_MAX;
int V;
vector<Edge> G[MAX_V];

double h[MAX_V],dist[MAX_V];//////// fpwjefoajfpojeawfopefa
int prevv[MAX_V], preve[MAX_V];


inline void add_edge(int from,int to,int cap,double cost){
  G[from].push_back((Edge){to,cap,cost,G[to].size()});
  G[to].push_back((Edge){from,0,-cost,G[from].size()-1});
}

double min_cost_flow(int s,int t,int f){
  double res = 0;
  fill(h,h+V,0);
  while(LT(0,f)){
    priority_queue<ii,vector<ii>,greater<ii> > Q;
    fill(dist,dist+V,INT_MAX);
    dist[s] = 0;
    Q.push(ii(0,s));
    while( !Q.empty() ){
      ii p = Q.top(); Q.pop();
      int v = p.second;
      if( LT(dist[v],p.first) ) continue;
      for(int i=0;i<G[v].size();i++)      {
	Edge &e = G[v][i];
	if( LT(0,e.cap) && LT(dist[v]+e.cost+h[v]-h[e.to],dist[e.to]) ) {
	  dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
	  prevv[e.to] = v;
	  preve[e.to] = i;
	  Q.push(ii(dist[e.to],e.to));
	}
      }
    }
    if( equals(dist[t],INT_MAX) ) return -1;
    rep(v,V) h[v] += dist[v];
    int d = f;
    for(int v=t;v!=s;v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    res += d * h[t];
    for(int v=t;v!=s;v=prevv[v]) {
      Edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

typedef vector<double> vd;
typedef vector<vd> mat;



vector<double> f(const mat& A,const vd& b){
  int n = A.size();
  mat B(n,vd(n+1));
  rep(i,n) rep(j,n) B[i][j] = A[i][j];
  rep(i,n) B[i][n] = b[i];

  rep(i,n){
    int pivot = i;
    REP(j,i,n) if( LT(abs(B[pivot][i]),abs(B[j][i])) ) pivot = j;
    swap(B[i],B[pivot]);
    if( abs(B[i][i]) < EPS ) return vd();
    REP(j,i+1,n+1) B[i][j] /= B[i][i];
    rep(j,n){
      if( i != j ){
	REP(k,i+1,n+1) B[j][k] -= B[j][i] * B[i][k];
      }
    }
  }  

  vd x(n);
  rep(i,n) x[i] = B[i][n];
  return x;
}

void init(int size=MAX_V){
  rep(i,size) G[i].clear();
}

int main(){
  int T;
  cin >> T;
  while( T-- ){
    int N,s,t,F;
    cin >> N >> s >> t >> F;
    mat A(N,vector<double>(N,0));
    vector<double> b(N,0);
    rep(i,N) {
      rep(j,N) {
	cin >> A[i][j];
      }
      cin >> b[i];
    }
    
    vector<double> ans = f(A,b);
    
    init();

    rep(i,N) {
      int M;
      cin >> M;
      vector<ii> vec(M);
      rep(j,M) cin >> vec[j].first;
      rep(j,M) cin >> vec[j].second;
      rep(j,M) {
	add_edge(i,vec[j].first,vec[j].second,abs(ans[i]-ans[vec[j].first]));
      }
    }

    V = N;
    double temp = min_cost_flow(s,t,F);
    if( equals(temp,-1) ) puts("impossible");
    else printf("%.10f\n",temp);

  }
  return 0;
}
 >> F;
    mat A(N,vector<double>(N,0));
    vector<double> b(N,0);
    rep(i,N) {
      rep(j,N) {
	cin >> A[i][j];
      }
      cin >> b[i];
    }
    
    vector<double> ans = f(A,b);
    
    init();

    rep(i,N) {
      int M;
      cin >> M;
      vector<ii> vec(M);
      rep(j,M) cin >> vec[j].first;
      rep(j,M) cin >> vec[j].second;
      rep(j,M) {
	add_edge(i,vec[j].first,vec[j].second,abs(ans[i]-ans[vec[j].first]));
      }
    }

    V = N;
    double temp = min_cost_flow(s,t,F);
    if( equals(temp,-1) ) puts("impossible");
    else printf("%.10f\n",temp);

  }
  return 0;
}

Compiler output:
a.cc:108:23: error: stray '#' in program
  108 |     cin >> N >> s >> t#include<bits/stdc++.h>
      |                       ^
a.cc: In function 'void add_edge(int, int, int, double)':
a.cc:29:50: warning: narrowing conversion of 'G[to].std::vector<Edge>::size()' from 'std::vector<Edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   29 |   G[from].push_back((Edge){to,cap,cost,G[to].size()});
      |                                        ~~~~~~~~~~^~
a.cc:30:53: warning: narrowing conversion of '(G[from].std::vector<Edge>::size() - 1)' from 'std::vector<Edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   30 |   G[to].push_back((Edge){from,0,-cost,G[from].size()-1});
      |                                       ~~~~~~~~~~~~~~^~
a.cc: In function 'int main()':
a.cc:108:23: error: expected ';' before 'include'
  108 |     cin >> N >> s >> t#include<bits/stdc++.h>
      |                       ^~~~~~~~
      |                       ;
a.cc:119:28: error: a function-definition is not allowed here before '{' token
  119 | bool LT(double a,double b) { return !equals(a,b) && a < b ; }
      |                            ^
a.cc:135:58: error: a function-definition is not allowed here before '{' token
  135 | inline void add_edge(int from,int to,int cap,double cost){
      |                                                          ^
a.cc:140:40: error: a function-definition is not allowed here before '{' token
  140 | double min_cost_flow(int s,int t,int f){
      |                                        ^
a.cc:182:43: error: a function-definition is not allowed here before '{' token
  182 | vector<double> f(const mat& A,const vd& b){
      |                                           ^
a.cc:206:20: error: local variable 'MAX_V' may not appear in this context
  206 | void init(int size=MAX_V){
      |                    ^~~~~
a.cc:206:26: error: a function-definition is not allowed here before '{' token
  206 | void init(int size=MAX_V){
      |                          ^
a.cc:210:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  210 | int main(){
      |         ^~
a.cc:210:9: note: remove parentheses to default-initialize a variable
  210 | int main(){
      |         ^~
      |         --
a.cc:210:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:210:11: error: a function-definition is not allowed here before '{' token
  210 | int main(){
      |           ^
a.cc:248:2: error: expected primary-expression before '>>' token
  248 |  >> F;
      |  ^~