criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <string>
#include <queue>
#include "mincostflow.hpp"
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 10000;

int main()
{
    int n, m;
    cin >> n >> m;
    string s[52];
    for(int i = 0; i < n; i++) cin >> s[i];
    P p[102];
    int c = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i][j] == 'o'){
                p[c] = P(i, j);
                c++;
            }
        }
    }
    mcf_graph<ll, ll> g(n * m + c + 2);
    for(int i = 0; i < c; i++){
        int d[52][52];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++) d[i][j] = INF;
        }
        d[p[i].first][p[i].second] = 0;
        queue<P> que;
        que.push(p[i]);
        while(que.size()){
            P q = que.front();
            que.pop();
            int x = q.first, y = q.second;
            g.add_edge(n * m + i, x * m + y, 1, INF - d[x][y]);
            if(x + 1 < n && s[x + 1][y] != '#' && d[x + 1][y] == INF){
                que.push(P(x + 1, y));
                d[x + 1][y] = d[x][y] + 1;
            }
            if(y + 1 < m && s[x][y + 1] != '#' && d[x][y + 1] == INF){
                que.push(P(x, y + 1));
                d[x][y + 1] = d[x][y] + 1;
            }
        }
    }
    for(int i = 0; i < c; i++){
        g.add_edge(n * m + c, n * m + i, 1, 0);
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            g.add_edge(i * m + j, n * m + c + 1, 1, 0);
        }
    }
    cout << INF * c - g.flow(n * m + c, n * m + c + 1).second << endl;
}


Compiler output:
a.cc:4:10: fatal error: mincostflow.hpp: No such file or directory
    4 | #include "mincostflow.hpp"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <queue>
#include "mincostflow.hpp"
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 10000;

int main()
{
    int n, m;
    cin >> n >> m;
    string s[52];
    for(int i = 0; i < n; i++) cin >> s[i];
    P p[52];
    int c = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i][j] == 'o'){
                p[c] = P(i, j);
                c++;
            }
        }
    }
    mcf_graph<ll, ll> g(n * m + c + 2);
    for(int i = 0; i < c; i++){
        int d[52][52];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++) d[i][j] = INF;
        }
        d[p[i].first][p[i].second] = 0;
        queue<P> que;
        que.push(p[i]);
        while(que.size()){
            P q = que.front();
            que.pop();
            int x = q.first, y = q.second;
//            g.add_edge(n * m + i, x * m + y, 1, INF - d[x][y]);
            if(x + 1 < n && s[x + 1][y] != '#' && d[x + 1][y] == INF){
                que.push(P(x + 1, y));
                d[x + 1][y] = d[x][y] + 1;
            }
            if(y + 1 < m && s[x][y + 1] != '#' && d[x][y + 1] == INF){
                que.push(P(x, y + 1));
                d[x][y + 1] = d[x][y] + 1;
            }
        }
    }
    for(int i = 0; i < c; i++){
        g.add_edge(n * m + c, n * m + i, 1, 0);
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            g.add_edge(i * m + j, n * m + c + 1, 1, 0);
        }
    }
    cout << INF * c - g.flow(n * m + c, n * m + c + 1).second << endl;
}


Compiler output:
a.cc:4:10: fatal error: mincostflow.hpp: No such file or directory
    4 | #include "mincostflow.hpp"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <queue>
#include "mincostflow.hpp"
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 10000;

int main()
{
    int n, m;
    cin >> n >> m;
    string s[52];
    for(int i = 0; i < n; i++) cin >> s[i];
    P p[52];
    int c = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i][j] == 'o'){
                p[c] = P(i, j);
                c++;
            }
        }
    }
    mcf_graph<ll, ll> g(n * m + c + 2);
    for(int i = 0; i < c; i++){
        int d[52][52];
        d[p[i].first][p[i].second] = 0;
        queue<P> que;
        que.push(p[i]);
        while(que.size()){
            P q = que.front();
            que.pop();
            int x = q.first, y = q.second;
            g.add_edge(n * m + i, x * m + y, 1, INF - d[x][y]);
            if(x + 1 < n && s[x + 1][y] != '#'){
                que.push(P(x + 1, y));
                d[x + 1][y] = d[x][y] + 1;
            }
            if(y + 1 < m && s[x][y + 1] != '#'){
                que.push(P(x, y + 1));
                d[x][y + 1] = d[x][y] + 1;
            }
        }
    }
    for(int i = 0; i < c; i++){
        g.add_edge(n * m + c, n * m + i, 1, 0);
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            g.add_edge(i * m + j, n * m + c + 1, 1, 0);
        }
    }
    cout << INF * c - g.flow(n * m + c, n * m + c + 1).second << endl;
}


Compiler output:
a.cc:4:10: fatal error: mincostflow.hpp: No such file or directory
    4 | #include "mincostflow.hpp"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;

int main() {
	int n, m;
    cin >> n >> m;
    vector<string> grid(n);
    for (int i = 0; i < n; ++i) {
        cin >> gris[i];
    }

    ll ans = 0;
    for (int i = n-1; i >= 0; --i) {
        for (int j = m-1; j >= 0; --j) {
            if(grid[i][j] != 'o') continue;
            vector<vector<int>> poss(n, vector<int>(m, 0));
            queue<pair<int, int>> q;
            q.emplace(i, j);
            while(q.size()) {
                auto p = q.front();
                q.pop();
                int cx = p.first, cy = p.second;
                poss[cx][cy] = 1;
                for (int di = 0; di < 2; ++di) {
                    int nx = cx + di;
                    int ny = cy + (di ^ 1);
                    if(nx >= n || ny >= m) continue;
                    if(grid[nx][ny] == '#') continue;
                    q.emplace(nx, ny);
                }
            }
            int maxi = i, maxj = j;
            for (int ii = 0; ii < n; ++ii) {
                for (int jj = 0; jj < m; ++jj) {
                    if(poss[ii][jj] == 0) continue;
                    int score = (ii - i) + (jj - j);
                    if(score >= (maxi - i) + (maxj - j)) {
                        maxi = ii;
                        maxj = jj;
                    }
                }
            }
            ans += (maxi - i) + (maxj - j);
            grid[maxi][maxj] = '#';
        }
    }
    cout << ans << endl;
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
string arr[55];
int vis[55][55],ck1[2555],ck2[111],sz[111];
vector<int> v2[2555];
lld nn[111][55][55];
set<pair<int,pi> > s[111];
int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int e=0;e<n;e++) cin >> arr[e];
	vector<pair<pi,pi> > dp;
	int num = 1;
	for(int e=0;e<n;e++){
		for(int p=0;p<m;p++){
			if(arr[e][p]=='o'){
				memset(vis,0,sizeof(vis));
				int tot = 0;
				vector<pair<int,pi> > v;
				vis[e][p] = 1;
				v.push_back(mk(0,mk(e,p)));
				for(int y=e;y<n;y++){
					for(int x=p;x<m;x++){
						if(y==e&&x==p) continue;
						if(arr[y][x]=='#') continue;
						bool suc = false;
						if(y>e&&vis[y-1][x]) suc = true;
						if(x>p&&vis[y][x-1]) suc = true;
						if(!suc) continue;
						vis[y][x] = 1;
						nn[num][y][x] = abs(y-e) + abs(x-p);
						v2[y*m+x].push_back(num);
						v.push_back(mk(abs(y-e)+abs(x-p),mk(y,x)));
						tot++;
					}
				}
				sz[num] = tot;
				for(int e=0;e<sz(v);e++){
					s[num].insert(mk(-v[e].x,v[e].y));
				}
				num++;
			}
		}
	}
	int ans = 0;
	for(int e=1;e<num;e++){
		int lim = 1e9;
		for(int p=1;p<num;p++){
			if(ck2[p]) continue;
			lim = min(lim,sz(s[p]));
		}
		if(sz(s[p])==lim) break;
		int mx = -1,wh=-1;
		for(int p=1;p<num;p++){
			if(ck2[p]) continue;
			if(sz(s[p])==lim){
				set<pair<int,pi> >::iterator it = s[p].begin();
				int vv = -it->x;
				if(vv>mx){
					mx = vv;
					wh = p;
				}
			}
		}
		if(mx==-1) break;
		ck2[wh] = 1;
		ans += mx;
		set<pair<int,pi> >::iterator it = s[wh].begin();
		int y = it->y.x;
		int x = it->y.y;
		for(int p=0;p<sz(v2[y*m+x]);p++){
			int nx = v2[y*m+x][p];
			s[nx].erase(mk(-nn[nx][y][x],mk(y,x)));
		}
	}
	printf("%d",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:75:25: error: 'p' was not declared in this scope
   75 |                 if(sz(s[p])==lim) break;
      |                         ^
a.cc:19:20: note: in definition of macro 'sz'
   19 | #define sz(x) (int)x.size()
      |                    ^
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;

#define BIG 10000

int main(){
	int n, m;
	cin>>n>>m;
	vector<string> s(n);
	rep(i, n) cin>>s[i];

	mcf_graph<int, int> g(n*m*2+2);
	int b=n*m*2, t=n*m*2+1, ura=n*m;
	rep(i, n) rep(j, m){
		if(i+1<n) g.add_edge(ura+i*m+j, ura+(i+1)*m+j, BIG, BIG);
		if(j+1<m) g.add_edge(ura+i*m+j, ura+i*m+j+1, BIG, BIG);
	}
	rep(i, n) rep(j, m){
		if(s[i][j]!='#'){
			g.add_edge(i*m+j, ura+i*m+j, 1, BIG);
			if(i+1<n && s[i+1][j]!='#') g.add_edge(i*m+j, (i+1)*m+j, BIG, BIG-1);
			if(j+1<m && s[i][j+1]!='#') g.add_edge(i*m+j, i*m+j+1, BIG, BIG-1);
		}
		if(s[i][j]=='o'){
			g.add_edge(b, i*m+j, 1, BIG);
		}
	}
	g.add_edge(ura+(n-1)*m+(m-1), t, BIG, BIG);
	// g.add_edge(b, t, BIG, BIG);

	// auto vp=g.slope(b, t);
	// int mx=0;
	// for(auto p : vp) mx=max(mx, BIG*p.first - p.second);
	// cout<<"sum"<<sum<<endl;
	// cout<<p.first<<" "<<p.second<<endl;
	auto p=g.flow(b, t);
	int sum=0;
	auto es=g.edges();
	for(auto e : es) sum+=e.flow;
	int ans=BIG*sum - p.second;

	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#include <atcoder/mincostflow>

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<std::string> s(n);
	for(int i = 0; i < n; i++) cin >> s[i];

	int offset = n * m;
	auto idx = [&](int i, int j) { return i * m + j; };
	const int S = offset + offset;
	const int T = offset + offset + 1;
	const i64 INF = 1e9;

	i64 cnt = 0;
	atcoder::mcf_graph<int, i64> g(offset * 2 + 2);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(s[i][j] == '#') continue;
			if(i + 1 < n and s[i + 1][j] != '#') {
				g.add_edge(idx(i, j), idx(i + 1, j), INF, -1);
			}
			if(j + 1 < m and s[i][j + 1] != '#') {
				g.add_edge(idx(i, j), idx(i, j + 1), INF, -1);
			}
			if(s[i][j] == 'o') {
				g.add_edge(S, idx(i, j), 1, INF);
				cnt++;
			}
			g.add_edge(idx(i, j), T, 1, INF);
		}
	}
	auto [flow, cost] = g.flow(S, T);

	printf("%lld\n", 2 * cnt * INF - cost);
	return 0;
}


Compiler output:
a.cc:17:10: fatal error: atcoder/mincostflow: No such file or directory
   17 | #include <atcoder/mincostflow>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#line 1 "main.cpp"
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#include <atcoder/mincostflow>

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<std::string> s(n);
	for(int i = 0; i < n; i++) cin >> s[i];

	int offset = n * m;
	auto idx = [&](int i, int j) { return i * m + j; };
	const int S = offset + offset;
	const int T = offset + offset + 1;
	const i64 INF = 1e9;

	i64 cnt = 0;
	atcoder::mcf_graph<int, i64> g(offset * 2 + 2);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(s[i][j] == '#') continue;
			if(i + 1 < n and s[i + 1][j] != '#') {
				g.add_edge(idx(i, j), idx(i + 1, j), INF, -1);
			}
			if(j + 1 < m and s[i][j + 1] != '#') {
				g.add_edge(idx(i, j), idx(i, j + 1), INF, -1);
			}
			if(s[i][j] == 'o') {
				g.add_edge(S, idx(i, j), 1, INF);
				cnt++;
			}
			g.add_edge(idx(i, j), T, 1, INF);
		}
	}
	auto [flow, cost] = g.flow(S, T);

	printf("%lld\n", 2 * cnt * INF - cost);
	return 0;
}


Compiler output:
main.cpp:17:10: fatal error: atcoder/mincostflow: No such file or directory
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N, M;
  cin >> N >> M;
  string S[N];
  for (int i = 0; i < N; i++) cin >> S[i];
  long long ans = 0;
  long long dp[N][M];
  int dir[N][M];
  for (bool update = true; update;) {
    update = false;
    for (int i = N - 1; i >= 0; i--) {
      for (int j = M - 1; j >= 0; j--) {
        if (S[i][j] == '#') {
          dp[i][j] = -1;
          dir[i][j] = -1;
          continue;
        }
        dp[i][j] = 0;
        dir[i][j] = -1;
        if (i + 1 < N && dp[i][j] < dp[i + 1][j] + 1) {
          dp[i][j] = dp[i + 1][j] + 1;
          dir[i][j] = 1;
        }
        if (j + 1 < M && dp[i][j] < dp[i][j + 1] + 1) {
          dp[i][j] = dp[i][j + 1] + 1;
          dir[i][j] = 2;
        }
        if (S[i][j] == 'o') {
          update = true;
          while (dir[i][j] != -1) {
            if (dir[i][j] == 1) {
              swap(S[i][j], S[i + 1][j]);
              i++;
            } else {
              swap(S[i][j], S[i][j + 1]);
              j++;
            }
            ans++;
          }
          S[i][j] = '#';
          i = -1;
          j = -1;
          break;
        }
      }
    }
    // debugArray(S, N);
  }
  cout << ans << '\n';
  return 0;
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#include <atcoder/mincostflow>

#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
#define INF2 100000000
//const long long MOD = 1000000007;
long long MOD = 998244353;

using namespace std;
using namespace atcoder;

int d[2600][2600];
char str[55][55];

void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int i, j;
    for (i = 0; i < n; i++) {
        scanf("%s", str[i]);
    }
#define POSI(i,j) ((i)*m+(j))

    int num = n * m;
    for (i = 0; i < num; i++) {
        for (j = 0; j < num; j++) {
            d[i][j] = (i == j ? 0 : INF2);
        }
    }

    vector<int> v;
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            if (str[i][j] == '#') continue;
            if (str[i][j] == 'o') v.push_back(POSI(i, j));

            {
                int i2 = i + 1, j2 = j;
                if (i2 < n && str[i2][j2]!='#') {
                    d[POSI(i, j)][POSI(i2, j2)] = 1;
                }
            }
            {
                int i2 = i, j2 = j+1;
                if (j2 < m && str[i2][j2] != '#') {
                    d[POSI(i, j)][POSI(i2, j2)] = 1;
                }
            }
        }
    }

    {
        for (int k = 0; k < num; ++k)
            for (int i = 0; i < num; ++i)
                for (int j = 0; j < num; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    int sizv = v.size();
    /**
     * generate (s -> o -> all -> t) graph
     * i-th o    correspond to vertex i
     * i-th posi correspond to vertex sizv + i
     **/
    mcf_graph<int, long long> g(sizv + num + 2);
    int s = sizv+num, t = s+1;
    const long long BIG = 1'000'000'000;

    // we can "waste" the flow
    g.add_edge(s, t, num, BIG);

    int k;
    for (k = 0; k < sizv; k++) {
        g.add_edge(s, k, 1, 0);
    }
    for (i = 0; i < num; i++) {
        g.add_edge(sizv+i, t, 1, 0);
    }
    for (k = 0; k < sizv; k++) {
        for (i = 0; i < num; i++) {
            if (d[v[k]][i] == INF2) {
                ;
            }
            else {
                g.add_edge(k, sizv + i, 1, -d[v[k]][i]);
            }
        }
    }
    auto result = g.flow(s, t, sizv);
    printf("%lld\n", -result.second);

    return;
}

int main()
{
#if 1
    solve();
#else
    pre();

    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Compiler output:
a.cc:18:10: fatal error: atcoder/mincostflow: No such file or directory
   18 | #include <atcoder/mincostflow>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <atcoder/mincostflow>

int mind[100][50][50]; // [start][y][x];
int dy[] = {0,1}, dx[] = {1,0};

int main() {
	int N, M;
	cin >> N >> M;
	
	vector<string> maps(N);
	REP(i, N) cin >> maps[i];
	
	fill(mind[0][0], mind[N][0], INF);
	
	auto isin = [&](int y, int x) -> bool {
		return x >= 0 && x < M && y >= 0 && y < N;
	};
	
	vector<pii> starts;
	REP(sty, N) REP(stx, M) {
		if (maps[sty][stx] == 'o') {
			queue<pii> que;
			mind[starts.size()][sty][stx] = 0;
			que.emplace(sty, stx);
			
			while (!que.empty()) {
				int cy = que.front().first, cx = que.front().second;
				que.pop();
				
				REP(i, 2) {
					int ny = cy + dy[i], nx = cx + dx[i];
					if (!isin(ny, nx) || maps[ny][nx] == '#') continue;
					if (chmin(mind[starts.size()][ny][nx], mind[starts.size()][cy][cx] + 1)) {
						que.emplace(ny, nx);
					}
				}
			}
			
			// printf("sty = %d, stx = %d\n", sty, stx);
			// REP(i, N) {
			// 	REP(j, M) {
			// 		printf("%d ", mind[starts.size()][i][j] == INF ? -1 : mind[starts.size()][i][j]);
			// 	}
			// 	puts("");
			// }
			
			starts.emplace_back(sty, stx);
		}
	}
	
	int source = N * M + starts.size(), sink = N * M + starts.size() + 1;
	atcoder::mcf_graph<int, int> g(sink + 1);
	
	// int mx_flow = N * M * starts.size() + 1000;
	int ansbase = 0;
	// koma i は N * M + i
	REP(i, starts.size()) {
		int sty = starts[i].first, stx = starts[i].second;
		int dmax = 0;
		REP(y, N) REP(x, M) if (mind[i][y][x] != INF) chmax(dmax, mind[i][y][x]);
		ansbase += dmax;
		REP(y, N) REP(x, M) if (mind[i][y][x] != INF) {
			// コマ i から (y, x)
			g.add_edge(N * M + i, y * N + x, 1, dmax - mind[i][y][x]);
			
			// printf("koma %d -> (y,x)=(%d,%d)\n", i, y, x);
		}
		
		// source から コマ i
		g.add_edge(source, N * M + i, 1, 0);
	}
	
	REP(y, N) REP(x, M) {
		if (maps[y][x] != '#') {
			// (y, x) から sink
			g.add_edge(y * N + x, sink, 1, 0);
		}
	}
	
	pii fdat = g.flow(source, sink, starts.size());
	
	// printf("flow = %d\n", fdat.first);
	cout << ansbase - fdat.second;
	return 0;
}


Compiler output:
a.cc:18:10: fatal error: atcoder/mincostflow: No such file or directory
   18 | #include <atcoder/mincostflow>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int encode (int i, int j, int w) { return i * w + j; }
P decode (int k, int w) { return P{k / w, k % w}; }
const ll BIG = (ll)1e9, MED = (ll)1e5;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w; cin >> h >> w;
    vector<string> s(h); rep (i, h) cin >> s[i];
    int start = h * w, goal = h * w + 1;
    mcf_graph<ll, ll> mcf(h * w + 2);    
    int pins = 0;
    rep (i, h) {
        rep (j, w) {
            int p = encode(i, j, w);
            if (s[i][j] == 'o') {
                mcf.add_edge(start, p, 1, 0);
                pins++;
            }
            if (s[i][j] == '#') continue;
            mcf.add_edge(p, goal, 1, (h + w - i - j) * BIG);
            rep (d, 2) {
                int y = i + dy[d], x = j + dx[d];
                if (y < 0 || x < 0 || y >= h || x >= w) continue;
                if (s[y][x] != '#') {
                    int q = encode(y, x, w);
                    // mcf.add_edge(p, q, 1, BIG - 1);
                    mcf.add_edge(p, q, h * w, BIG - 1);
                }
            }
        }
    }
    auto res = mcf.flow(start, goal, pins);
    // eprintf("flow:%lld cost:%lld\n", res.first, res.second);
    auto edges = mcf.edges();
    ll ans = 0;
    for (auto &e : edges) {
        // eprintf("%d->%d %lld/%lld %lld\n", e.from, e.to, e.flow, e.cap, e.cost);
        if (e.from != start && e.to != goal) ans += e.flow;
    }
    cout << ans << "\n";

    /***************************************************/
    /* Submit this code from the browser if using ACL! */
    /***************************************************/
    return 0;
}

Compiler output:
a.cc:25:10: fatal error: atcoder/all: No such file or directory
   25 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

//Bismillahirrahmanirrahim

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 53;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,finx,finy,mx,vis[li][li];
int cev;
string s;
char c[li][li];
vector<int> v;

inline void dfs(int sat,int sut,int der){
	if(sat>n || sat<1 || sut>m || sut<1)return ;
	//~ if(vis[sat][sut])return;
	if(c[sat][sut]!='.')return;
	if(der>mx){mx=der;finx=sat;finy=sut;}
	//~ vis[sat][sut]=1;
	dfs(sat+1,sut,der+1);
	dfs(sat,sut+1,der+1);
}

int main(void){
	scanf("%d %d",&n,&m);
	FOR{
		for(int j=1;j<=m;j++)scanf(" %c",&c[i][j]);
	}
	
		for(int j=m;j>=1;j--){
			for(int i=n;i>=1;i--){
			if(c[i][j]=='o'){
				mx=-1;
				//~ memset(vis,0,sizeof(vis));
				c[i][j]='.';
				dfs(i,j,0);
				cev+=mx;
				c[finx][finy]='o';
			}
		}
	}
	printf("%d\n",cev);
	return 0;
}



Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:6:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:186:14: note: called from here
  186 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~
Language: C++

//Bismillahirrahmanirrahim

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 53;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,finx,finy,mx,vis[li][li];
int cev;
string s;
char c[li][li];
vector<int> v;

inline void dfs(int sat,int sut,int der){
	if(sat>n || sat<1 || sut>m || sut<1)return ;
	if(vis[sat][sut])return;
	if(c[sat][sut]!='.')return;
	if(der>mx){mx=der;finx=sat;finy=sut;}
	vis[sat][sut]=1;
	dfs(sat+1,sut,der+1);
	dfs(sat,sut+1,der+1);
}

int main(void){
	scanf("%d %d",&n,&m);
	FOR{
		for(int j=1;j<=m;j++)scanf(" %c",&c[i][j]);
	}
	for(int i=n;i>=1;i--){
		for(int j=m;j>=1;j--){
			if(c[i][j]=='o'){
				mx=-1;
				memset(vis,0,sizeof(vis));
				c[i][j]='.';
				dfs(i,j,0);
				cev+=mx;
				c[finx][finy]='o';
			}
		}
	}
	printf("%d\n",cev);
	return 0;
}



Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:6:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:186:14: note: called from here
  186 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;


const int MAX_V= 5005;
 
struct edge{
  int to,cap,cost,rev;
  edge(int to,int cap,int cost,int rev) :
    to(to),cap(cap),cost(cost),rev(rev) {}
};
  
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
  
void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(edge(to,cap,cost,G[to].size()));
  G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  while(f>0){
    fill(dist,dist+MAX_V,MAX); dist[s] = 0;
    bool update=true;
    while(update){
      update=false;
      for(int v=0; v<MAX_V; v++){
        if(dist[v]==MAX) continue;
        for(int i=0; i<(int)G[v].size(); i++){
          edge &e=G[v][i];
          if(e.cap>0 && dist[e.to]>dist[v]+e.cost){
            dist[e.to]=dist[v]+e.cost;
            prevv[e.to]=v; preve[e.to]=i; update=true;
          }
        }
      }
    }
    if(dist[t]==MAX) return -1;
    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*dist[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;
}

ll d[55][55];

void Main() {
  ll n,m;
  cin >> n >> m;
  vector<string> s(n);
  rep(i,n) R s[i];
  ll cnt=0;
  rep(i,n) {
    rep(j,m) {
      if(s[i][j]!='#') add_edge(i*m+j+n*m,5002,1,0);
      if(s[i][j]=='o') {
        cnt++;
        add_edge(5001,i*m+j,1,0);
        REP(x,i,n)REP(y,j,m) d[x][y]=-MAX;
        d[i][j]=0;
        REP(x,i,n) {
          REP(y,j,m) {
            if(d[x][y]!=-MAX) add_edge(i*m+j,x*m+y+n*m,1,-d[x][y]);
            REP(k,1,3) {
              int xx=x+dx[k],yy=y+dy[k];
              if(check(n,m,xx,yy)&&s[xx][yy]!='#') {
                d[xx][yy]=max(d[xx][yy],d[x][y]+1);
              }
            }
          }
        }
      }
    }
  }
  pr(-min_cost_flow(5001,5002,cnt));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;

ll n, k;
const int D = 18;

struct Db {
    vector<vector<ll>> d, s;
    Db(vector<ll> x) {
        d.resize(n+1, vector<ll>(D, n));
        s.resize(n+1, vector<ll>(D, 0));
        int jj = n;
        rrep(i, n) {
            while (x[i]+k<=x[jj-1]) jj--;
            d[i][0] = jj;
            s[i][0] = jj;
        }
        rep(j, D) {
            if (j==0) continue;
            rep(i, n) {
                d[i][j] = d[d[i][j-1]][j-1];
                s[i][j] = s[i][j-1] + s[d[i][j-1]][j-1];
            }
        }
        //debug(d[0][0]);
    }
    ll cnt = 0;
    ll get(int l, int r) {
        ll res = l;
        cnt = 1;
        rrep(i, D) {
            ll now = 1<<i;
            if (d[l][i]>r) continue;
            res += s[l][i];
            l = d[l][i];
            cnt += now;
            //debug(res);
        }
        return res;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    cin >> n >> k;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    Db db1(x);
    
    vector<ll> y(n);
    rep(i, n) {
        y[i] = -x[n-1-i];
    }
    
    Db db2(y);
    
    ll q;
    cin >> q;
    rep(qi, q) {
        ll l, r;
        cin >> l >> r;
        l--; r--;
        ll sum1 = db1.get(l, r);
        //debug(sum1);
        ll ans = db1.cnt;
        //debug(db1.cnt);
        ll sum2 = db2.get(n-1-r, n-1-l);
        //debug(sum2);
        //debug(db2.cnt);
        sum2 = db2.cnt*(n-1) - sum2;
        ans += (sum2-sum1);
        pr(ans);
    }
    
    return 0;
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

//#define _GLIBCXX_DEBUG
#include <cstdio>
#include <cstdint>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

const unsigned int mod = 998244353;

struct mint {
  unsigned int x;
  mint():x(0) {}
  mint(int64_t x_) {
    int64_t v = int64_t(x_ % mod);
    if(v < 0) v += mod;
    x = (unsigned int)v;
  }
  static mint row(int v) {
    mint v_;
    v_.x = v;
    return v_;
  }
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    u_int64_t z = x;
    z *= a.x;
    x = (unsigned int)(z % mod);
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  friend bool operator==(const mint &a, const mint &b) {return a.x == b.x;}
  friend bool operator!=(const mint &a, const mint &b) {return a.x != b.x;}
  mint &operator++() {
    x++;
    if(x == mod) x = 0;
    return *this;
  }
  mint &operator--() {
    if(x == 0) x = mod;
    x--;
    return *this;
  }
  mint operator++(int) {
    mint result = *this;
    ++*this;
    return result;
  }
  mint operator--(int) {
    mint result = *this;
    --*this;
    return result;
  }
  mint pow(int64_t t) const {
    mint x_ = *this, r = 1;
    while(t) {
      if(t&1) r *= x_;
      x_ *= x_;
      t >>= 1;
    }
    return r;
  }
  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

#define N 200100

//head

int n, k;
int p[N];
mint u[N], _u[N];
mint ans;
mint bit1[N], bit2[N];
void add(int i, mint x, mint *bit) {
  while(i <= n) {
    bit[i] += x;
    i += i&-i;
  }
}
mint sum(int i, mint *bit) {
  mint res;
  while(i) {
    res += bit[i];
    i &= i-1;
  }
  return res;
}

int main() {
  scanf("%d%d", &n, &k);
  rep(i, n) scanf("%d", p+i);
  const mint g = mint(k-1)/k, _g = g.inv(), gg = mint(2).inv();
  u[0] = _u[0] = 1;
  rep(i, n-1) {
    if(i < k-1) {
      u[i+1] = u[i];
      _u[i+1] = _u[i];
    }
    else {
      u[i+1] = u[i]*g;
      _u[i+1] = _u[i]*_g;
    }
  }
  rep(i, n) {
    ans += sum(p[i], bit1)*gg*u[i];
    ans -= sum(p[i], bit2)-i;
    ans -= (sum(n, bit1)-sum(p[i], bit1))*gg*u[i];
    add(p[i], _u[i], bit1);
    add(p[i], 1, bit2);
  }
  printf("%d\n", ans.x);
}

Compiler output:
a.cc: In member function 'mint& mint::operator*=(mint)':
a.cc:32:5: error: 'u_int64_t' was not declared in this scope; did you mean 'uint64_t'?
   32 |     u_int64_t z = x;
      |     ^~~~~~~~~
      |     uint64_t
a.cc:33:5: error: 'z' was not declared in this scope
   33 |     z *= a.x;
      |     ^
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

using mint = modint998244353;

struct S{
    ll num;
    mint psum;
};
S e(){ return S{0, 0}; }
S op(S x, S y){ return S{x.num + y.num, x.psum + y.psum}; }

int main(){
    ll n, k;
    cin >> n >> k;

    vector<ll> p(n);
    REP(i, n){
        cin >> p.at(i);
        p.at(i)--;
    }

    const mint q = mint(k - 1) / mint(k);
    const mint qinv = q.inv();

    // cerr << "q=" << q.val() << ", qinv=" << qinv.val() << endl;

    segtree<S, op, e> st(n);

    mint ans = 0;

    REP(i, n){
        const ll pi = p.at(i);
        const ll fi = max(i - k + 1, 0LL);

        const auto sd = st.prod(0, pi);
        mint tmp1 = q.pow(fi) * sd.psum / 2;

        const auto su = st.prod(pi + 1, n);
        mint tmp2 = su.num - q.pow(fi) * su.psum / 2;

        mint tmp = tmp1 + tmp2;

        // cerr << "i=" << i << ", tmp=" << tmp.val() << ", tmp1=" << tmp1.val() << ", tmp2=" << tmp2.val() << endl;
        ans += tmp;

        st.set(pi, S{1, qinv.pow(fi)});
    }

    cout << ans.val() << endl;

    return 0;
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
using namespace std;
const int N=200005,M=998244353;
int n,k,p[N],i,a[N],q[N];
long long tree[N],m[N],ans[N];
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		s=s*s%M;
		b>>=1;
	}
	return ans;
}
void modify(int x,int y)
{
	while(x<=n)
	{
		tree[x]+=y;
		x+=-x&x;
	}
}
int Query(int x)
{
	long long s=0;
	while(x)
	{
		s+=tree[x];
		x-=-x&x;
	}
	return s%M;
}
void dfs(int l,int r)
{
	if(l==r)
		return;
	int mid=l+r>>1,i;
	long long s=0,tot=0;
	for(i=l;i<=mid;++i)
	{
		modify(p[i],m[i]);
		tot=(tot+m[i])%M;
	}
	for(i=r;i>mid;--i)
	{
		ans[i]=(ans[i]+s)%M;
		s=(s+tot-Query(p[i]))%M;
	}
	for(i=l;i<=mid;++i)
		modify(p[i],-m[i]);
	s=0;
	for(i=mid+1;i<=r;++i)
		modify(p[i],1);
	for(i=l;i<=mid;++i)
	{
		s=(s+Query(p[i])*m[i])%M;
		ans[i]=(ans[i]+s)%M;
	}
	for(i=mid+1;i<=r;++i)
		modify(p[i],-1);
	dfs(l,mid);
	dfs(mid+1,r);
}
int main()
{
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&p[i]);
		q[p[i]]=i;
	}
	long long in=qpow(k,M-2);
	long long iw=in*(k-1)%M;
	long long iiw=qpow(iw,M-2);
	for(i=1;i<=n;++i)
		m[i]=in*qpow(iw,n-max(i,k))%M;
	dfs(1,n);
	long long s=((n-k)*qpow(2,M-2)%M*(k-1)%M+1ll*k*(k-1)/2%M*qpow(2,M-2))%M;
	for(i=n-k;i>=1;--i)
		s=(s+ans[i+k-1]*qpow(iiw,n-i-k+1))%M;
	cout<<(s%M+M)%M;
}


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <String>
using namespace std;
int main(int argc, const char * argv[]) {
    string s ;
    cin>>s;
    if (s[s.size()-1]=='s')
        s+='es',cout<<s<<endl;
    else s+='s',cout<<s<<endl;
    return 0;
}


Compiler output:
a.cc:2:10: fatal error: String: No such file or directory
    2 | #include <String>
      |          ^~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<string>
using namespace std;

int main(){
  string s;
  cin>>s;
  int len=s.length();
  if(s[len-1]=='s') cout<<s+"es"<<endl;
  else cout<<s+"s"<<ensl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:21: error: 'ensl' was not declared in this scope
   10 |   else cout<<s+"s"<<ensl;
      |                     ^~~~
Language: C

#include <iostream>
using namespace std;

int main() {
    string input;
    cin >> input;
    int len = input.length();
    cout << len << endl;
    if (input[len-1] == 's'){
        input = input + "es";
    }else if(input[len-1] != 's'){
        input = input + 's';
    }
    cout << input << endl;
    return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

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

int main() {
    string s;
    cin >> s;
    int l = s.size();
    if(s[l] == 's') {
        s += "es";
    }
    else {
        s += "s"
    }
    cout << s;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: expected ';' before '}' token
   13 |         s += "s"
      |                 ^
      |                 ;
   14 |     }
      |     ~
Language: C++

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

int main() {
    string s;
    cin >> s;
    if(s[s.size] == s) {
        s += "es";
    }
    else s += "s";
    cout << s;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: invalid use of non-static member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
    8 |     if(s[s.size] == s) {
      |         ^
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:1076:7: note: declared here
 1076 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
Language: C++

#include<iostream>
#include<string>
using namespace std;
 
int main(){
  	
  		char a[100];
        cin >> a;
  		
  			if (a.back==s)
            {	cout << a + "es";
            }
  			else 
              cout << a + "s";
  		
		
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:31: error: request for member 'back' in 'a', which is of non-class type 'char [100]'
   10 |                         if (a.back==s)
      |                               ^~~~
a.cc:10:37: error: 's' was not declared in this scope
   10 |                         if (a.back==s)
      |                                     ^
a.cc:11:27: error: invalid operands of types 'char [100]' and 'const char [3]' to binary 'operator+'
   11 |             {   cout << a + "es";
      |                         ~ ^ ~~~~
      |                         |   |
      |                         |   const char [3]
      |                         char [100]
a.cc:14:25: error: invalid operands of types 'char [100]' and 'const char [2]' to binary 'operator+'
   14 |               cout << a + "s";
      |                       ~ ^ ~~~
      |                       |   |
      |                       |   const char [2]
      |                       char [100]
Language: C++

#include<iostream>
#include<string>
using namespace std;

int main(){
  	
  		char a[100];
        cin >> a;
  		
  			if (str.back==s)
            {	cout << a + "es";
            }
  			else 
              cout << a + "s";
  		
		
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:29: error: 'str' was not declared in this scope; did you mean 'std'?
   10 |                         if (str.back==s)
      |                             ^~~
      |                             std
a.cc:10:39: error: 's' was not declared in this scope
   10 |                         if (str.back==s)
      |                                       ^
a.cc:11:27: error: invalid operands of types 'char [100]' and 'const char [3]' to binary 'operator+'
   11 |             {   cout << a + "es";
      |                         ~ ^ ~~~~
      |                         |   |
      |                         |   const char [3]
      |                         char [100]
a.cc:14:25: error: invalid operands of types 'char [100]' and 'const char [2]' to binary 'operator+'
   14 |               cout << a + "s";
      |                       ~ ^ ~~~
      |                       |   |
      |                       |   const char [2]
      |                       char [100]
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s[sz(s)-1]=='s'){
    cout<<s<<"es"<<endl;
  }
  else{
    cout<<s<<'s'<<endl;
  }
}
}


Compiler output:
a.cc:60:1: error: expected declaration before '}' token
   60 | }
      | ^