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

#include <bits/stdc++.h>using namespace std;typedef long long ll;const int MAX = (1e5)+1; int n;vector<pair<ll, ll> > a;multiset<ll> r, b;long long ans = LLONG_MAX;int main() {	ios::sync_with_stdio(false);	cin.tie(0);	cin >> n;	a.resize(n);	for(int i = 0; i < n; i++) {		cin >> a[i].first >> a[i].second;		if(a[i].first > a[i].second) swap(a[i].first, a[i].second);	}	sort(a.begin(), a.end());	for(auto p: a) {		r.insert(p.first);		b.insert(p.second);	}	ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);	for(auto p: a) {		r.erase(r.find(p.first));		b.erase(b.find(p.second));		r.insert(p.second);		b.insert(p.first);		ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);	}	cout << ans;}

Compiler output:
a.cc:1:31: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>using namespace std;typedef long long ll;const int MAX = (1e5)+1; int n;vector<pair<ll, ll> > a;multiset<ll> r, b;long long ans = LLONG_MAX;int main() {        ios::sync_with_stdio(false);    cin.tie(0);     cin >> n;       a.resize(n);    for(int i = 0; i < n; i++) {            cin >> a[i].first >> a[i].second;               if(a[i].first > a[i].second) swap(a[i].first, a[i].second);     }       sort(a.begin(), a.end());       for(auto p: a) {                r.insert(p.first);              b.insert(p.second);     }       ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);        for(auto p: a) {                r.erase(r.find(p.first));               b.erase(b.find(p.second));              r.insert(p.second);             b.insert(p.first);              ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);        }       cout << ans;}
      |                               ^~~~~~~~~
a.cc:1:10: fatal error: bits/stdc++.h>usin: No such file or directory
    1 | #include <bits/stdc++.h>using namespace std;typedef long long ll;const int MAX = (1e5)+1; int n;vector<pair<ll, ll> > a;multiset<ll> r, b;long long ans = LLONG_MAX;int main() {        ios::sync_with_stdio(false);    cin.tie(0);     cin >> n;       a.resize(n);    for(int i = 0; i < n; i++) {            cin >> a[i].first >> a[i].second;               if(a[i].first > a[i].second) swap(a[i].first, a[i].second);     }       sort(a.begin(), a.end());       for(auto p: a) {                r.insert(p.first);              b.insert(p.second);     }       ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);        for(auto p: a) {                r.erase(r.find(p.first));               b.erase(b.find(p.second));              r.insert(p.second);             b.insert(p.first);              ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);        }       cout << ans;}
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>using namespace std;typedef long long ll;const int MAX = (1e5)+1; int n;vector<pair<ll, ll> > a;multiset<ll> r, b;long long ans = LLONG_MAX;int main() {	ios::sync_with_stdio(false);	cin.tie(0);	cin >> n;	a.resize(n);	for(int i = 0; i < n; i++) {		cin >> a[i].first >> a[i].second;		if(a[i].first > a[i].second) swap(a[i].first, a[i].second);	}		for(auto p: a) {		r.insert(p.first);		b.insert(p.second);	}	ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);	for(auto p: a) {		r.erase(r.find(p.first));		b.erase(b.find(p.second));		r.insert(p.second);		b.insert(p.first);		ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);	}	cout << ans;}

Compiler output:
a.cc:1:31: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>using namespace std;typedef long long ll;const int MAX = (1e5)+1; int n;vector<pair<ll, ll> > a;multiset<ll> r, b;long long ans = LLONG_MAX;int main() {        ios::sync_with_stdio(false);    cin.tie(0);     cin >> n;       a.resize(n);    for(int i = 0; i < n; i++) {            cin >> a[i].first >> a[i].second;               if(a[i].first > a[i].second) swap(a[i].first, a[i].second);     }               for(auto p: a) {                r.insert(p.first);              b.insert(p.second);     }       ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);        for(auto p: a) {                r.erase(r.find(p.first));               b.erase(b.find(p.second));              r.insert(p.second);             b.insert(p.first);              ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);        }       cout << ans;}
      |                               ^~~~~~~~~
a.cc:1:10: fatal error: bits/stdc++.h>usin: No such file or directory
    1 | #include <bits/stdc++.h>using namespace std;typedef long long ll;const int MAX = (1e5)+1; int n;vector<pair<ll, ll> > a;multiset<ll> r, b;long long ans = LLONG_MAX;int main() {        ios::sync_with_stdio(false);    cin.tie(0);     cin >> n;       a.resize(n);    for(int i = 0; i < n; i++) {            cin >> a[i].first >> a[i].second;               if(a[i].first > a[i].second) swap(a[i].first, a[i].second);     }               for(auto p: a) {                r.insert(p.first);              b.insert(p.second);     }       ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);        for(auto p: a) {                r.erase(r.find(p.first));               b.erase(b.find(p.second));              r.insert(p.second);             b.insert(p.first);              ans = min((*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()), ans);        }       cout << ans;}
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <algorithm>
#include <vector>
 
using namespace std;
 
const int inf=1e9;
pair<int,int> v[400010];
vector<int> poz[200010];
 
int main()
{
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n,max1=0,min1=inf,max2=0,min2=inf,a,b;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a,&b);
        v[2*i-1]={a,i};
        v[2*i]={b,i};
        if(a<b) swap(a,b);
        max1=max(max1,a);
        min1=min(min1,a);
        max2=max(max2,b);
        min2=min(min2,b);
    }
    long long sol=1LL*(max1-min1)*(max2-min2);
    sort(v+1,v+1+2*n);
    for(int i=1;i<=2*n;i++) poz[v[i].second].push_back(i);
    a=b=2;
    int nr=0;
    for(int i=1;i<=2*n;i++)
    {
        for(;nr<n && b<2*n;b++)
            if(poz[v[b].second][0]==b || poz[v[b].second][0]<a) nr++;
        if(nr<n) break;
        sol=min(sol,1LL*(v[2*n].first-v[1].first)*(v[b-1].first-v[a].first));
        nr--;
        if(poz[v[a].second][0]==a && poz[v[a].second][1]<b) nr++;
        a++;
    }
    printf("%lld",sol);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'scanf' was not declared in this scope
   15 |     scanf("%d",&n);
      |     ^~~~~
a.cc:42:5: error: 'printf' was not declared in this scope
   42 |     printf("%lld",sol);
      |     ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include <vector>
  +++ |+#include <cstdio>
    3 |
Language: C++

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#define INT long long
#define MOD 1000000007
#define oo (1e18)+1
using namespace std;

INT n, a[200020], b[200020], ans, ma = oo, mb = oo, Ma, Mb, ans = oo;

bool poss(INT x)
{

}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>a[i]>>b[i];
        if( a[i] > b[i] ) swap(a[i], b[i]);
        cout<<a[i]<<" "<<b[i]<<endl;
        ma = min( ma, a[i] );
        mb = min( mb, b[i] );
        Ma = max( Ma, a[i] );
        Mb = max( Mb, b[i] );
    }
    if( (Ma-ma)*(Mb-mb) > 0 ) ans = min( ans, (Ma-ma)*(Mb-mb));
    if( (Ma-mb)*(Mb-ma) > 0 ) ans = min( ans, (Ma-mb)*(Mb-ma));
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:12:61: error: redefinition of 'long long int ans'
   12 | INT n, a[200020], b[200020], ans, ma = oo, mb = oo, Ma, Mb, ans = oo;
      |                                                             ^~~
a.cc:12:30: note: 'long long int ans' previously declared here
   12 | INT n, a[200020], b[200020], ans, ma = oo, mb = oo, Ma, Mb, ans = oo;
      |                              ^~~
a.cc: In function 'bool poss(long long int)':
a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N;
	cin >> N;
	vector<pll> v(N);
	rep(i,N) cin >> v[i].fi >> v[i].se;
	ll res = 1e18;
	ll mn[2] = {1e9,1e9}, mx[2] = {0,0};
	pll mnp, mxp;
	rep(i,N) {
		if(v[i].fi > v[i].se) swap(v[i].fi, v[i].se);
		mx[0] = max(mx[0], v[i].fi);
		mn[0] = min(mn[0], v[i].fi);
		mx[1] = max(mx[1], v[i].se);
		mn[1] = min(mn[1], v[i].se);

		if(i == 0) {
			mnp = mxp = v[i];
		}
		else {
			if(mnp.fi > v[i].fi) {
				mnp = v[i];
			}
			if(mxp.se < v[i].se) {
				mxp = v[i];
			}
		}
	}
	res = min(res,(mx[0]-mn[0])*(mx[1]-mn[1]));

	rep(j,2) {
		pll r(min(mnp.se,mxp.fi),max(mnp.se,mxp.fi));
		rep(i,N) {
			if(v[i].se < r.fi)
				r.fi = v[i].se;
			if(r.se < v[i].fi)
				r.se = v[i].fi;
			if(v[i].fi < r.fi && r.se < v[i].se) {
				if(j)
					r.fi = v[i].fi;
				else 
					r.se = v[i].se;
			}
		}
		res = min(res,(mxp.se - mnp.fi)*(r.se - r.fi));
	}
	cout << res << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:21: error: narrowing conversion of '1.0e+9' from 'double' to 'll' {aka 'long long int'} [-Wnarrowing]
   44 |         ll mn[2] = {1e9,1e9}, mx[2] = {0,0};
      |                     ^~~
a.cc:44:25: error: narrowing conversion of '1.0e+9' from 'double' to 'll' {aka 'long long int'} [-Wnarrowing]
   44 |         ll mn[2] = {1e9,1e9}, mx[2] = {0,0};
      |                         ^~~
Language: Java

public class Main {
	
public static void main(String[] args) {
		
		//System.out.println("d");
		
		Scanner sc = new Scanner( System.in );
		int N = sc.nextInt();
		
		int max_x = Integer.MIN_VALUE;
		int max_y = Integer.MIN_VALUE;
		int min_x = Integer.MAX_VALUE;
		int min_y = Integer.MAX_VALUE;
		
		int x = 0;//2つのうち小さいほう
		int y = 0;//2つのうち大きいほう
		int itizi = 0;
		
		for( int i = 0;i < N;i++ ){
			
			x = sc.nextInt();
			y = sc.nextInt();
			
			if( x > y ){
				itizi = y;
				y = x;
				x = itizi;
			}
			
			max_x = Math.max( x, max_x );
			min_x = Math.min( x, min_x );
			max_y = Math.max( y, max_y );
			min_y = Math.min( y, min_y );
			
		}
		
		/*
		System.out.println(max_x);
		System.out.println(min_x);
		System.out.println(max_y);
		System.out.println(min_y);
		*/
		long a = (long)Math.abs(max_x- min_x) * (long)Math.abs(max_y- min_y);
		long b = (long)Math.abs(max_x- min_y) * (long)Math.abs(max_y- min_x);
		
		if( a > b )
			System.out.println( b );
		else
			System.out.println( a );
		
		
	}

}


Compiler output:
Main.java:7: error: cannot find symbol
		Scanner sc = new Scanner( System.in );
		^
  symbol:   class Scanner
  location: class Main
Main.java:7: error: cannot find symbol
		Scanner sc = new Scanner( System.in );
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include<iostream>
#include <vector>
#include <algorithm>
#include<queue>
#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int Cint;
typedef longlong Cint;
using namespace std;

int main(){
	Cint n,x,y,t;
	Cint miny=9000000000,maxy=0,minx=9000000000,maxx=0;
	cin>>n;
	for(Cint i=0;i<n;i++){
		cin>>x>>y;
		if(x>y){
			t=x;x=y;y=t;
		}
		if(miny>y)miny=y;
		if(maxy<y)maxy=y;
		if(minx>x)minx=x;
		if(maxx<x)maxx=x;
	}
	Cint a=(maxx-minx)*(maxy-miny),b=(maxx-miny)*(maxy-minx);
	if(b>=0)cout<<((a>b)?b:a)<<endl;
	else cout<<a<<endl;
	return 0;
}

Compiler output:
a.cc:5:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    5 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <iterator>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <utility>
#include <functional>
#include <stack>
#include <deque>
#include <sstream>
using namespace std;

#define ll long long
#define ld long double
#define pdd pair<double,double>
#define pll pair<ll, ll>
#define pii pair<int,int>

#define mod 1000000007
#define infinity (ll)1e18+1
#define PI 3.14159265358979

#define MP make_pair
#define SZ size()
#define PB push_back

#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>

#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()

int main()
{
	int n;
	cin >> n;

	vll x(n), y(n);
	FOR(i, 0, n)
	{
		scanf("%ld %ld", &x[i], &y[i]);
		if (x[i] < y[i])
			swap(x[i], y[i]);
	}


	vector<pll> way(n), ex(n);
	FOR(i, 0, n)
	{
		way[i] = MP(y[i], i);
		ex[i] = MP(x[i], i);
	}

	sort(ALL(way));
	sort(ALL(ex));
	
	ll maxR, maxB, minR, minB;

	minR = way[0].first;

	//max = R
	
	maxR = ex[n - 1].first;

	minB = x[way[0].second];
	maxB = y[ex[n - 1].second];

	FOR(i, 0, n)
	{
		if (x[i] < minB)
			minB = x[i];
		if (y[i] > maxB)
			maxB = y[i];
	}


	ll ans =  abs((maxR -

Compiler output:
a.cc: In function 'int main()':
a.cc:93:30: error: expected primary-expression at end of input
   93 |         ll ans =  abs((maxR -
      |                              ^
a.cc:93:30: error: expected ')' at end of input
   93 |         ll ans =  abs((maxR -
      |                       ~      ^
      |                              )
a.cc:93:30: error: expected '}' at end of input
a.cc:50:1: note: to match this '{'
   50 | {
      | ^
Language: C++

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

typedef long long LL;
typedef vector<int> vi;

int N, Q, A, B;
LL posL, posR;
vi X;

int binser(int l, int r, int src){
    int ret = l;
    while(l <= r){
        int mid = (l+r)/2;
        if(X[mid] <= src){
            ret = max(ret, mid);
            l = mid + 1;
        }else{
            r = mid - 1;
        }
    }
    
    return ret;
}

LL solve(int l, int r){
    LL ret = 1e18;
    int idx = l;
    
    LL tmp1 = abs(posL - X[r]);
    if(tmp1 < ret){
        idx = r;
        ret = tmp1;
    }

    LL tmp2 = abs(posR - X[l]) + abs(X[l] - X[r]);
    if(tmp2 < ret){
        idx = l-1;
        ret = tmp2;
    }

    for(l = l+1;l < r; l++){
        LL tmp = abs(posL - X[l]) + abs(posR - X[l+1]) + abs(X[l+1] - X[r]);
        
        if(tmp < ret){
            ret = tmp;
            idx = l;
        }
    }

    posL = X[idx];
    if(idx < r) posR = X[idx+1];
    return ret;
}

LL minimum_time(int n, int q, int a, int b, vi x) {
    N = n; Q = q; A = a; B = b; X = x;
    
    LL ret = 0;
    posL = min(A, B);
    posR = max(A, B);

    for(int i = 0; i < Q; i++){
        if(posL <= X[i] && X[i] <= posR){
            int idxLmt = binser(i, Q-1, posR);
            ret += solve(i, idxLmt);
            i = idxLmt;
        }else if(X[i] <= posL){
            ret += abs(X[i] - posL);
            posL = X[i];
        }else if(posR <= X[i]){
            ret += abs(X[i] - posR);
            posR = X[i];
        }
    }

    ret += min(abs(posL - LL(X[Q-1])), abs(posR - LL(X[Q-1])));

    return ret;
}
bool isSorted(){
  for (int i = 1; i < Q; ++i) {
            if (!(X[i - 1] <= X[i])) {
                return false;
            }
        }

        return true;

}

int main() {
  scanf("%d %d %d %d", &N, &Q, &A, &B);
  X.resize(Q);
  for (int i = 0; i < Q; ++i) {
    scanf("%d", &X[i]);
  }
  if(!isSorted()) while(true){}
  printf("%lld\n", minimum_time());
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:99:32: error: too few arguments to function 'LL minimum_time(int, int, int, int, vi)'
   99 |   printf("%lld\n", minimum_time());
      |                    ~~~~~~~~~~~~^~
a.cc:56:4: note: declared here
   56 | LL minimum_time(int n, int q, int a, int b, vi x) {
      |    ^~~~~~~~~~~~
Language: C++

#include "moves.h"

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

typedef long long LL;
typedef vector<int> vi;

int N, Q, A, B;
LL posL, posR;
vi X;

int binser(int l, int r, int src){
    int ret = l;
    while(l <= r){
        int mid = (l+r)/2;
        if(X[mid] <= src){
            ret = max(ret, mid);
            l = mid + 1;
        }else{
            r = mid - 1;
        }
    }
    
    return ret;
}

LL solve(int l, int r){
    LL ret = 1e18;
    int idx = l;
    
    LL tmp1 = abs(posL - X[r]);
    if(tmp1 < ret){
        idx = r;
        ret = tmp1;
    }

    LL tmp2 = abs(posR - X[l]) + abs(X[l] - X[r]);
    if(tmp2 < ret){
        idx = l-1;
        ret = tmp2;
    }

    for(l = l+1;l < r; l++){
        LL tmp = abs(posL - X[l]) + abs(posR - X[l+1]) + abs(X[l+1] - X[r]);
        
        if(tmp < ret){
            ret = tmp;
            idx = l;
        }
    }

    posL = X[idx];
    if(idx < r) posR = X[idx+1];
    return ret;
}

LL minimum_time(int n, int q, int a, int b, vi x) {
    N = n; Q = q; A = a; B = b; X = x;
    
    LL ret = 0;
    posL = min(A, B);
    posR = max(A, B);

    for(int i = 0; i < Q; i++){
        if(posL <= X[i] && X[i] <= posR){
            int idxLmt = binser(i, Q-1, posR);
            ret += solve(i, idxLmt);
            i = idxLmt;
        }else if(X[i] <= posL){
            ret += abs(X[i] - posL);
            posL = X[i];
        }else if(posR <= X[i]){
            ret += abs(X[i] - posR);
            posR = X[i];
        }
    }

    ret += min(abs(posL - LL(X[Q-1])), abs(posR - LL(X[Q-1])));

    return ret;
}
bool isSorted(){
  for (int i = 1; i < Q; ++i) {
            if (!(X[i - 1] <= X[i])) {
                return false;
            }
        }

        return true;

}

int main() {
  scanf("%d %d %d %d", &N, &Q, &A, &B);
  X.resize(Q);
  for (int i = 0; i < Q; ++i) {
    scanf("%d", &X[i]);
  }
  if(!isSorted()) while(true){}
  printf("%lld\n", minimum_time());
  return 0;
}

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

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

typedef long long LL;
typedef vector<int> vi;

#define PB push_back

const int MAXQ = 205;
const int MAXN = 205;

LL N, Q, A, B;
vi X;
LL memo[MAXQ][MAXN][MAXN];

LL mini(LL a, LL b){
    if(a == -1) return b;
    else if(b == -1) return a;
    else if(a < b) return a;
    else return b;
}

LL dp(int id, int pA, int pB){
    if(id == Q){
        return memo[id][pA][pB] = 0;
    }

    int nxt = X[id];
    if(memo[id + 1][nxt][pB] == -1)
        memo[id+1][nxt][pB] = abs(nxt-pA) + dp(id+1, nxt, pB);
    
    if(memo[id + 1][pA][nxt] == -1)
        memo[id+1][pA][nxt] = abs(nxt-pB) + dp(id+1, pA, nxt);

    return memo[id][pA][pB] = min(memo[id+1][nxt][pB], memo[id+1][pA][nxt]);
}

LL minimum_time(int n, int q, int a, int b, vi x) {
    N = n; Q = q; A = a; B = b; X = x;
    memset(memo, -1, sizeof(memo));
    return dp(0, A, B);
}

int main() {
  scanf("%d %d %d %d", &N, &Q, &A, &B);
  X.resize(Q);
  for (int i = 0; i < Q; ++i) {
    scanf("%d", &X[i]);
  }
  if(N > 200 || Q > 200) while(true){}
  printf("%lld\n", minimum_time());
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:32: error: too few arguments to function 'LL minimum_time(int, int, int, int, vi)'
   51 |   printf("%lld\n", minimum_time());
      |                    ~~~~~~~~~~~~^~
a.cc:38:4: note: declared here
   38 | LL minimum_time(int n, int q, int a, int b, vi x) {
      |    ^~~~~~~~~~~~
Language: C++

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

typedef long long LL;
typedef vector<int> vi;

#define PB push_back

const int MAXQ = 205;
const int MAXN = 205;

LL N, Q, A, B;
vi X;
LL memo[MAXQ][MAXN][MAXN];

LL mini(LL a, LL b){
    if(a == -1) return b;
    else if(b == -1) return a;
    else if(a < b) return a;
    else return b;
}

LL dp(int id, int pA, int pB){
    if(id == Q){
        memo[id][pA][pB] = 0;
        return memo[id][pA][pB];
    }

    int nxt = X[id];
    if(memo[id][nxt][pB] == -1){
        memo[id+1][nxt][pB] = dp(id+1, nxt, pB) + abs(nxt-pA);    
    }

    if(memo[id][pA][nxt] == -1){
        memo[id+1][pA][nxt] = dp(id+1, pA, nxt) + abs(nxt-pB);
    }

    memo[id][pA][pB] = min(memo[id+1][nxt][pB], memo[id+1][pA][nxt]);
    return memo[id][pA][pB];
}

LL minimum_time() {
    memset(memo, -1, sizeof(memo));
    return dp(0, a, b);
}

int main() {
  scanf("%d %d %d %d", &N, &Q, &A, &B);
  for (int i = 0; i < Q; ++i) {
    scanf("%d", &X[i]);
  }

  printf("%lld\n", minimum_time());
  return 0;
}


Compiler output:
a.cc: In function 'LL minimum_time()':
a.cc:44:18: error: 'a' was not declared in this scope
   44 |     return dp(0, a, b);
      |                  ^
a.cc:44:21: error: 'b' was not declared in this scope
   44 |     return dp(0, a, b);
      |                     ^
Language: C++

#include "moves.h"

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

typedef long long LL;
typedef vector<int> vi;

#define PB push_back

const int MAXQ = 205;
const int MAXN = 205;

LL N, Q, A, B;
vi X;
LL memo[MAXQ][MAXN][MAXN];

LL mini(LL a, LL b){
    if(a == -1) return b;
    else if(b == -1) return a;
    else if(a < b) return a;
    else return b;
}

LL dp(int id, int pA, int pB){
    if(id == Q){
        memo[id][pA][pB] = 0;
        return memo[id][pA][pB];
    }

    int nxt = X[id];
    if(memo[id][nxt][pB] == -1){
        memo[id+1][nxt][pB] = dp(id+1, nxt, pB) + abs(nxt-pA);    
    }

    if(memo[id][pA][nxt] == -1){
        memo[id+1][pA][nxt] = dp(id+1, pA, nxt) + abs(nxt-pB);
    }

    memo[id][pA][pB] = min(memo[id+1][nxt][pB], memo[id+1][pA][nxt]);
    return memo[id][pA][pB];
}

LL minimum_time() {
    memset(memo, -1, sizeof(memo));
    return dp(0, a, b);
}

int main() {
  scanf("%d %d %d %d", &N, &Q, &A, &B);
  for (int i = 0; i < Q; ++i) {
    scanf("%d", &X[i]);
  }

  printf("%lld\n", minimum_time());
  return 0;
}

Compiler output:
a.cc:1:10: fatal error: moves.h: No such file or directory
    1 | #include "moves.h"
      |          ^~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>
#define NMAX 200000
#define INF 1e11
#define abs(a) ((a) > 0 ? (a) : -(a))
#define min(a, b) ((a) < (b) ? (a) : (b))
long long bit[NMAX+1], revbit[NMAX+1], dp[NMAX+1];

void add(int index, int value, int size);
int max(int index);
int main(void)
{
  int i, n, q, a, b;
  long long qsum = 0, ans = INF;
  scanf("%d %d %d %d", &n, &q, &a, &b);
  for (i = 0; i <= n; i++) bit[i] = revbit[i] = dp[i] = INF;
  dp[a] = 0;
  add(a, -a, n);
  revadd(a, a, n);
  while (q--) {;
    long long tmin, rtmin, res;
    a = b;
    scanf("%d", &b);
    qsum += abs(a - b);
    tmin = minimize(b) + b;
    rtmin = revminimize(b) - b;
    res = min(tmin, rtmin) - abs(a - b);
    if (dp[a] > res) {
      dp[a] = res;
      add(a, res - a, n);
      revadd(a, res + a, n);
    }
  }
  for (i = 0; i <= n; i++) {
    if (ans > dp[i]) ans = dp[i];
  }
  printf("%lld\n", ans + qsum);
}

void add(int index, int value, int size)
{
  while (index <= size) {
    if (bit[index] < value) bit[index] = value;
    index += index & (-index);
  }
}

int max(int index)
{
  int bmax = 0;
  while (index > 0) {
    if (bmax < bit[index]) bmax = bit[index];
    index -= index & (-index);
  }
  return bmax;
}

Compiler output:
main.c: In function 'main':
main.c:18:3: error: implicit declaration of function 'revadd' [-Wimplicit-function-declaration]
   18 |   revadd(a, a, n);
      |   ^~~~~~
main.c:24:12: error: implicit declaration of function 'minimize' [-Wimplicit-function-declaration]
   24 |     tmin = minimize(b) + b;
      |            ^~~~~~~~
main.c:25:13: error: implicit declaration of function 'revminimize' [-Wimplicit-function-declaration]
   25 |     rtmin = revminimize(b) - b;
      |             ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;
const int maxn = 2e5 + 100;
LL Plus[maxn*4], Minus[maxn*4], tag[maxn*4];
inline LL abs(LL x) { return x < 0 ? -x : x; }
inline void Puttag(int o, LL v){
    Plus[o] += v;
    Minus[o] += v;
    tag[o] += v;
}
inline void Pushdown(int o){
    if(!tag[o]) return;
    Puttag(o*2, tag[o]);
    Puttag(o*2+1, tag[o]);
    tag[o] = 0;
}
inline void Maintain(int o){
    Plus[o] = min(Plus[o*2], Plus[o*2+1]);
    Minus[o] = min(Minus[o*2], Minus[o*2+1]);
}
inline bool Cut(int x) { return false; }
inline bool Check(int x) { return true; }
inline void Change(int o, int l, int r, int L, int R, LL v){
    if(L > r || R < l || Cut(o)) return;
    if(L <= l && r <= R && Check(o)){
        Puttag(o, v); return;
    }
    int mid = (l+r)/2; Pushdown(o);
    Change(o*2, l, mid, L, R, v);
    Change(o*2+1, mid+1, r, L, R, v);
    Maintain(o);
}
inline long long Query(int o, int l, int r, int L, int R, int ty){
    if(L > r || R < l || Cut(o)) return 1e18;
    if(L <= l && r <= R){
        return ty ? Plus[o] : Minus[o];
    }
    int mid = (l+r)/2; Pushdown(o);
    ans = min(Query(o*2+1, mid+1, r, L, R, ty), Query(o*2, l, mid, L, R, ty));
    Maintain(o);
    return ans;
}
inline void Insert(int o, int l, int r, int k, LL v, int ty){
    if(l == r) {
        if(ty) Plus[o] = v; else Minus[o] = v;
        return;
    }
    int mid = (l+r)/2; Pushdown(o);
    if(k <= mid) Insert(o*2, l, mid, k, v, ty);
    else Insert(o*2+1, mid+1, r, k, v, ty);
    Maintain(o);
}

int N, Q, A, B;
int x[maxn];
int main(){
    scanf("%d %d %d %d", &N, &Q, &A, &B);
    for(int i = 1; i <= Q; i++) scanf("%d", &x[i]);
    x[0] = B;
    // dp[i][x] = dp[i-1][x] + ||
    // dp[i][x[i-1]] = all(dp[i-1][x]+|x-x[i]|)
    // x <= x[i] -> dp[i-1][x] + x[i] - x
    // x > x[i] -> dp[i-1][x] + x - x[i]
    memset(Plus, 1, sizeof(Plus));
    memset(Minus, 1, sizeof(Minus));
    Insert(1, 1, N, A, A, 1);
    Insert(1, 1, N, A, -A, 0);
    for(int i = 1; i <= Q; i++){
        LL ans = min(Query(1, 1, N, 1, x[i], 0) + x[i], Query(1, 1, N, x[i]+1, N, 1) - x[i]);
        Change(1, 1, N, 1, x[i-1]-1, abs(x[i] - x[i-1]));
        Change(1, 1, N, x[i-1]+1, N, abs(x[i] - x[i-1]));

        Insert(1, 1, N, x[i-1], ans + x[i-1], 1);
        Insert(1, 1, N, x[i-1], ans - x[i-1], 0);
    }
    LL ans = 1e18;
    for(int i = 1; i <= N; i++){
        ans = min(ans, Query(1, 1, N, i, i, 0) + i);
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'long long int Query(int, int, int, int, int, int)':
a.cc:47:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |     ans = min(Query(o*2+1, mid+1, r, L, R, ty), Query(o*2, l, mid, L, R, ty));
      |     ^~~
      |     abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=3000000;
long long n,m,a1,b1,i,tmp,ans;
long long p[N],p1[N],s[N],s1[N],a[N];
void update(int x,int k)
{ p1[x*2]+=p1[x]; p1[x*2+1]+=p1[x];
   p[x*2]+=p1[x]; p[x*2+1]+=p1[x];
  p1[x]=0;
  s1[x*2]+=s1[x]; s1[x*2+1]+=s1[x];
  s[x*2]+=s1[x]; s[x*2+1]+=s1[x];
  s1[x]=0;}
void renew(int x)
{
   p[x]=min(p[x*2],p[x*2+1]);
	s[x]=min(s[x*2],s[x*2+1]); 
}
void getmin(int q,int l,int r,int pos,int zhi)
{
	update(q,2);
	if (l==r) 
	{  p[q]=1ll*zhi+pos; s[q]=1ll*zhi-pos; 	return;}
    int mid=(l+r)/2;
    if (pos<=mid)  getmin(q*2,l,mid,pos,zhi);
              else getmin(q*2+1,mid+1,r,pos,zhi);
    renew(q);
}
long long query(int q,int l,int r,int x,int y,int k)
{
	if (x>y) return 2e10; 
	if ((x<=l)&&(r<=y))  {  	return (k)? p[q]:s[q];}
	else
	{     update(q,k);
		//int mid=(l+r)/2;
		long long ans1=1e10,ans2=1e10;
		if (x>=mid+1) return query(q*2+1,mid+1,r,x,y,k);
	else if (y<=mid)  return query(q*2,l,mid,x,y,k);
	else return(min(query(q*2+1,mid+1,r,mid+1,y,k),query(q*2,l,mid,x,mid,k)));  }
	}
int main()
{
  cin>>n>>m>>a1>>b1;
  for (int i=1;i<=m;i++)
  scanf("%d",&a[i]);
  memset(p,0x3f,sizeof(p));
  memset(s,0x3f,sizeof(s));
  getmin(1,1,n,a1,0);  a[0]=b1;
  for (int i=1;i<=m;i++)
  { // cout<<a[i]<<' '<<query(1,1,n,1,a[i],0)<<' '<<query(1,1,n,a[i]+1,n,1)<<endl;
      tmp=min(query(1,1,n,1,a[i],0)+a[i],query(1,1,n,a[i]+1,n,1)-a[i]);
      //cout<<a[i-1]<<' '<<tmp<<endl;
     // for (int j=1;j<=n;j++)
      //{ cout<<i<<' '<<j<<' '<<query(1,1,n,j,j,0)+j<<endl;}
      p[1]+=abs(a[i]-a[i-1]); s[1]=abs(a[i]-a[i-1]); p1[1]+=abs(a[i]-a[i-1]);s1[1]+=abs(a[i]-a[i-1]);
      //cout<<p1[1]<<' '<<s1[1]<<endl;
      getmin(1,1,n,a[i-1],tmp);
  }
  ans=2e10;
  for ( i=1;i<=n;i++)
  {ans=min(ans,query(1,1,n,i,i,0)+i); }
  cout<<ans;
}


Compiler output:
a.cc: In function 'long long int query(int, int, int, int, int, int)':
a.cc:36:24: error: 'mid' was not declared in this scope
   36 |                 if (x>=mid+1) return query(q*2+1,mid+1,r,x,y,k);
      |                        ^~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)

using ll = long long;

constexpr long long INFL = LLONG_MAX / 2;


class SegTree {
public:
	int n;	// 葉の数
	vector<ll> dat;	// 各ノードの値
	
	ll def = INFL;	// デフォルト値（零元）
	
	// 区間クエリを決める関数
	ll operation(ll a, ll b) {
		return min(a, b);
	}

	// 初期化（n_は必要な要素数）
	SegTree(int n_) {
		n = 1;
		while (n < n_) {
			n *= 2;
		}
		dat = vector<ll>(2 * n - 1, def);
	}

	// 場所i(0-indexed)の値をxに更新
	void change(int i, ll x) {
		i += n - 1;
		dat[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = operation(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}

	// 場所i(0-indexed)の値を返す
	ll at(int i) {
		return dat[i + n - 1];
	}

	// 区間[a,b)の値。ノードk=[l,r)に着目している。
	ll _query(int a, int b, int k, int l, int r) {
		if (b <= a) return def;	// 不正な区間の指定
		if (r <= a || b <= l)return def;  // 交差しない
		if (a <= l && r <= b)return dat[k];   // a,l,r,bの順で完全に含まれる
		else {
			ll c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);    // 左の子
			ll c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);    // 右の子
			return operation(c1, c2);
		}
	}

	// 内部クエリ_query()を呼び出す
	ll query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
};

int main(void) {
	int N, Q, A, B;
	cin >> N >> Q >> A >> B;
	A--; B--;	// 座標を0-indexedに変更する
	vector<int> x(Q + 1);

	x[0] = A;	// 計算しやすいよう、0番目のクエリの値をAにする
	rep(i, Q) {
		cin >> x[i + 1];
		x[i + 1]--;		// 座標を0-indexedに変更する
	}

	// 左側担当と右側担当のセグ木を用意
	SegTree dpl(N);	// dp[i]-i を格納
	SegTree dpr(N);	// dp[i]+i を格納

	// dp[B] = 0, dp[他] = ∞
	dpl.change(B, 0 - B);
	dpr.change(B, 0 + B);

	// 全要素に一律に足す値
	ll add = 0;

	repr(q, 1, Q + 1) {
		// 一律に足す値
		int diff = abs(x[q] - x[q - 1]);
		add += diff;

		// 更新すべきはdp[x[q-1]]のみ

		// 新しい値を計算
		// dplの区間 [0, x[q]) 、dprの区間 [x[q], N) の最小値をx[q]で補正した値の小さい方）
		ll newval = min(dpl.query(0, x[q]) + x[q],
						dpr.query(x[q], N) - x[q]);

		// diffを足すことを考慮して、[真の値-diff]に更新
		dpl.change(x[q - 1], newval - diff - x[q - 1]);
		dpr.change(x[q - 1], newval - diff + x[q - 1]);
	}

	// 最小コストの計算
	ll ans = INFL;
	rep(i, N) {
		// dp[i]の値は、dpl[i]+i か dpr[i]-i のどちらでも計算できる
		ans = min(ans, dpl.at(i) + i);
	}

	// 全体に足す値を足して答えを出力
	cout << ans + add << endl;

	return 0;
}


Compiler output:
a.cc:13:28: error: 'LLONG_MAX' was not declared in this scope
   13 | constexpr long long INFL = LLONG_MAX / 2;
      |                            ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;

long long dp[500][500][500];

int main() {
        int n, q, A, B;
        scanf("%d%d%d%d", &n, &q, &A, &B);
        vector<int> x(q);
        for (int i = 0; i < q; i ++) scanf("%d", &x[i]);
        memset(dp, -1, sizeof dp);
        dp[0][A][B] = 0;
        for (int i = 0; i < q; i ++) {
                for (int a = 1; a <= n; a ++) {
                        for (int b = 1; b <= n; b ++) {
                                if (dp[i][a][b] == -1) continue;
                                int X = x[i];
                                dp[i + 1][X][b] = dp[i][a][b] + abs(X - a);
                                dp[i + 1][a][X] = dp[i][a][b] + abs(X - b);
                        }
                }
        }
        long long ans = INFL;
        for (int i = 1; i <= n; i ++) {
                for (int j = 1; j <= n; j ++) {
                        if (~dp[q][i][j]) {
                                ans = min(ans, dp[q][i][j]);
                        }
                }
        }
        printf("%lld\n", ans);
        return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'memset' was not declared in this scope
   19 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <set>
  +++ |+#include <cstring>
    8 | using namespace std;
Language: C++

#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int INF = 1e9, SEGMENT_TREE_SIZE = 1 << 19;

long long f[200005];
struct info{int L, R;};
info merge(info a, info b) {info x = {f[a.L]-a.L < f[b.L]-b.L ? a.L : b.L, f[a.R]+a.R < f[b.R]+b.R ? a.R : b.R}; return(x);}

template <class T>
class SegmentTree {
    T * a; int * L, * R;
    void divide(int i, int l, int r) {
        L[i] = l; R[i] = r;
        if (L[i] == R[i]) return;
        divide(2*i+1, l, (l+r)/2);
        divide(2*i+2, (l+r)/2+1, r);
    }
    void update(int i, int pos, T x) {
        if (L[i] > pos || R[i] < pos) return;
        if (L[i] == pos && R[i] == pos) {a[i] = x; return;}
        update(2*i+1, pos, x);
        update(2*i+2, pos, x);
        a[i] = merge(a[2*i+1], a[2*i+2]);
    }
    T search(int i, int l, int r) {
        if (L[i] >= l && R[i] <= r) return a[i];
        if (R[2*i+1] >= r) return search(2*i+1, l, r);
        if (L[2*i+2] <= l) return search(2*i+2, l, r);
        return merge(search(2*i+1, l, r), search(2*i+2, l, r));
    }
public:
    SegmentTree(int l, int r) {
        a = new T [SEGMENT_TREE_SIZE];
        L = new int [SEGMENT_TREE_SIZE];
        R = new int [SEGMENT_TREE_SIZE];
        divide(0, l, r);
    }
    setval(int pos, T x) {update(0, pos, x);}
    T getval(int l, int r) {return search(0, l, r);}
};

int main() {
    int N, Q, A, B; scanf("%d%d%d%d", &N, &Q, &A, &B);
    fill(f + 1, f + N + 1, INF); f[A] = 0;
    SegmentTree<info> T(1, N);
    for (int i = 1; i <= N; ++i) {info x = {i, i}; T.setval(i, x);}
    int cur, prv = B; long long inc = 0, ans = 0;
    for (int i = 1; i <= Q; ++i) {
        scanf("%d", &cur); inc += abs(cur - prv);
        int l = T.getval(0, cur).L, r = T.getval(cur, N).R;
        ans = min(ans, f[prv] = min(f[l] + cur - l, f[r] - cur + r) - abs(cur - prv));
        info x = {prv, prv}; T.setval(prv, x); prv = cur;
    }
    printf("%lld", ans + inc);
    return 0;
}


Compiler output:
a.cc:40:5: error: ISO C++ forbids declaration of 'setval' with no type [-fpermissive]
   40 |     setval(int pos, T x) {update(0, pos, x);}
      |     ^~~~~~
a.cc: In member function 'int SegmentTree<T>::setval(int, T)':
a.cc:40:45: warning: no return statement in function returning non-void [-Wreturn-type]
   40 |     setval(int pos, T x) {update(0, pos, x);}
      |                                             ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1e13;

const int INF = INT_MAX;

template <typename T>
struct SegmentTree {
    int n;
    vector<T> data;

    //使うときは、この3つを適宜変更する
    static T INITIAL_VALUE;
    static T merge(T x, T y); 
    void updateNode(int k, T x);

    SegmentTree(int size) {
        n = 1;
        while (n < size) n *= 2;
        data.resize(2 * n - 1, INITIAL_VALUE);
    }

    T getLeaf(int k) {
        return data[k + n - 1];
    }
    
    void update(int k, T x) {
        k += n - 1; //葉の節点
        updateNode(k, x);
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }
    
    //区間[a, b)に対するクエリに答える
    //k:節点番号, [l, r):節点に対応する区間
    T query(int a, int b, int k, int l, int r) {
        //[a, b)と[l, r)が交差しない場合
        if (r <= a || b <= l) return INITIAL_VALUE;
        //[a, b)が[l, r)を含む場合、節点の値
        if (a <= l && r <= b) return data[k];
        else {
            //二つの子をマージ
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return merge(vl, vr);
        }
    }
    
    //外から呼ぶ用
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};

//使うときは以下3つを変更
template <typename T>
T SegmentTree<T>::INITIAL_VALUE = INF;

template <typename T>
T SegmentTree<T>::merge(T x, T y) {
    return min(x, y);
}

template <typename T>
void SegmentTree<T>::updateNode(int k, T x) {
    data[k] = x;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	ll a;
	cin >> n >> q >> a;
	a--;
	vector<ll> x(q + 1);
	cin >> x[0];
	x[0]--;
	for (int i = 1; i <= q; i++) {
		cin >> x[i];
		x[i]--;
	}

	SegmentTree<ll> st1(n), st2(n);

	st1.update(a, -a);
	st2.update(a, a);

	ll add = 0;
	for (int i = 1; i <= q; i++) {
		ll tmp = INF;
		tmp = min(tmp, st1.query(0, x[i]) + x[i]);
		tmp = min(tmp, st2.query(x[i], n) - x[i]);
		tmp += add;
		add += abs(x[i] - x[i - 1]);
		ll tar = st1.getLeaf(x[i - 1]) + x[i - 1] + add;
		if (tar <= tmp) continue;
		tmp -= add;
		st1.update(x[i - 1], tmp - x[i - 1]);
		st2.update(x[i - 1], tmp + x[i - 1]);
	}

	ll ans = INF;
	for (int i = 0; i < n; i++) {
		ans = min(ans, st1.getLeaf(i) + i);
	}
	ans += add;
	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc:9:11: error: conflicting declaration 'const int INF'
    9 | const int INF = INT_MAX;
      |           ^~~
a.cc:7:10: note: previous declaration as 'const ll INF'
    7 | const ll INF = 1e13;
      |          ^~~
Language: C++

#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  
  char d=a.at(0),e=b.at(0),f=c.at(0);
  int d,e,f;
  char rr=d-32,ee=e-32,ff=f-32;
  cout<<rr<<ee<<ff;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:7: error: conflicting declaration 'int d'
    9 |   int d,e,f;
      |       ^
a.cc:8:8: note: previous declaration as 'char d'
    8 |   char d=a.at(0),e=b.at(0),f=c.at(0);
      |        ^
a.cc:9:9: error: conflicting declaration 'int e'
    9 |   int d,e,f;
      |         ^
a.cc:8:18: note: previous declaration as 'char e'
    8 |   char d=a.at(0),e=b.at(0),f=c.at(0);
      |                  ^
a.cc:9:11: error: conflicting declaration 'int f'
    9 |   int d,e,f;
      |           ^
a.cc:8:28: note: previous declaration as 'char f'
    8 |   char d=a.at(0),e=b.at(0),f=c.at(0);
      |                            ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  
  int d=a.at(0)-32,e=b.at(0)-32,f=c.at(0)-32;
  char d,e,f;
  cout<<d<<e<<f;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: conflicting declaration 'char d'
    9 |   char d,e,f;
      |        ^
a.cc:8:7: note: previous declaration as 'int d'
    8 |   int d=a.at(0)-32,e=b.at(0)-32,f=c.at(0)-32;
      |       ^
a.cc:9:10: error: conflicting declaration 'char e'
    9 |   char d,e,f;
      |          ^
a.cc:8:20: note: previous declaration as 'int e'
    8 |   int d=a.at(0)-32,e=b.at(0)-32,f=c.at(0)-32;
      |                    ^
a.cc:9:12: error: conflicting declaration 'char f'
    9 |   char d,e,f;
      |            ^
a.cc:8:33: note: previous declaration as 'int f'
    8 |   int d=a.at(0)-32,e=b.at(0)-32,f=c.at(0)-32;
      |                                 ^
Language: C++

using namespace std;
int main() {
  
   // ios_base::sync_with_stdio(false); 
    
    //cin.tie(NULL); 
    
    //cout.tie(NULL); 
  	string s;
    for(int i=0;i<3;i++){
      string str;
      cin>>str;
      toupper(str[0]);
      s+=str[0];
    }
  cout<<s;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'string' was not declared in this scope
    9 |         string s;
      |         ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:11:13: error: expected ';' before 'str'
   11 |       string str;
      |             ^~~~
      |             ;
a.cc:12:7: error: 'cin' was not declared in this scope
   12 |       cin>>str;
      |       ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:12:12: error: 'str' was not declared in this scope; did you mean 'std'?
   12 |       cin>>str;
      |            ^~~
      |            std
a.cc:13:7: error: 'toupper' was not declared in this scope
   13 |       toupper(str[0]);
      |       ^~~~~~~
a.cc:14:7: error: 's' was not declared in this scope
   14 |       s+=str[0];
      |       ^
a.cc:16:3: error: 'cout' was not declared in this scope
   16 |   cout<<s;
      |   ^~~~
a.cc:16:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:16:9: error: 's' was not declared in this scope
   16 |   cout<<s;
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  
   // ios_base::sync_with_stdio(false); 
    
    //cin.tie(NULL); 
    
    //cout.tie(NULL); 
  	string s;
    for(int i=0;i<3;i++){
      string str;
      cin>>str;
      to_upper(str[0]);
      s+=str[0];
    }
  cout<<s;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:7: error: 'to_upper' was not declared in this scope; did you mean 'towupper'?
   14 |       to_upper(str[0]);
      |       ^~~~~~~~
      |       towupper
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  
   // ios_base::sync_with_stdio(false); 
    
    //cin.tie(NULL); 
    
    //cout.tie(NULL); 
  	string s;
    for(int i=0;i<3;i++){
      string str;
      cin>>str;
      s+=to_upper(str[0]);
    }
  cout<<s;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'to_upper' was not declared in this scope; did you mean 'towupper'?
   14 |       s+=to_upper(str[0]);
      |          ^~~~~~~~
      |          towupper
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  
    ios_base::sync_with_stdio(false); 
    
    cin.tie(NULL); 
    
    cout.tie(NULL); 
  	string s;
    for(int i=0;i<3;i++){
      string str;
      cin>>str;
      s+=to_upper(str[0]);
    }
  cout<<s;
  return 0;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'to_upper' was not declared in this scope; did you mean 'towupper'?
   14 |       s+=to_upper(str[0]);
      |          ^~~~~~~~
      |          towupper
Language: C

#include<stdio.h>
int main(){
  char a,b,c;
  scanf("%s%s%s",&a,&b,&c);
  printf("%c%c%c",a[0]-32,b[0]-32,c[0]-32);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:20: error: subscripted value is neither array nor pointer nor vector
    5 |   printf("%c%c%c",a[0]-32,b[0]-32,c[0]-32);
      |                    ^
main.c:5:28: error: subscripted value is neither array nor pointer nor vector
    5 |   printf("%c%c%c",a[0]-32,b[0]-32,c[0]-32);
      |                            ^
main.c:5:36: error: subscripted value is neither array nor pointer nor vector
    5 |   printf("%c%c%c",a[0]-32,b[0]-32,c[0]-32);
      |                                    ^
Language: C

#include<stdio.h>
#include<string.h>
int main(){
  char a[10],b[10],c[10];
  scanf("%d %d %d",&a,&b,&c);
  int a[0],b[0],c[0];
  int g=a[0]-32,h=b[0]-32;y=c[0]-32;
  char g,h,y;
  printf("%c%c%c",g,h,y);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:6:7: error: conflicting types for 'a'; have 'int[0]'
    6 |   int a[0],b[0],c[0];
      |       ^
main.c:4:8: note: previous declaration of 'a' with type 'char[10]'
    4 |   char a[10],b[10],c[10];
      |        ^
main.c:6:12: error: conflicting types for 'b'; have 'int[0]'
    6 |   int a[0],b[0],c[0];
      |            ^
main.c:4:14: note: previous declaration of 'b' with type 'char[10]'
    4 |   char a[10],b[10],c[10];
      |              ^
main.c:6:17: error: conflicting types for 'c'; have 'int[0]'
    6 |   int a[0],b[0],c[0];
      |                 ^
main.c:4:20: note: previous declaration of 'c' with type 'char[10]'
    4 |   char a[10],b[10],c[10];
      |                    ^
main.c:7:27: error: 'y' undeclared (first use in this function)
    7 |   int g=a[0]-32,h=b[0]-32;y=c[0]-32;
      |                           ^
main.c:7:27: note: each undeclared identifier is reported only once for each function it appears in
main.c:8:8: error: conflicting types for 'g'; have 'char'
    8 |   char g,h,y;
      |        ^
main.c:7:7: note: previous definition of 'g' with type 'int'
    7 |   int g=a[0]-32,h=b[0]-32;y=c[0]-32;
      |       ^
main.c:8:10: error: conflicting types for 'h'; have 'char'
    8 |   char g,h,y;
      |          ^
main.c:7:17: note: previous definition of 'h' with type 'int'
    7 |   int g=a[0]-32,h=b[0]-32;y=c[0]-32;
      |                 ^
Language: C

#include<stdio.h>
#include<string.h>
int main(){
  char a[],b[],c[];
  scanf("%d %d %d",&a,&b,&c);
  int a[0],b[0],c[0];
  int g=a[0]-32,h=b[0]-32;y=c[0]-32;
  char g,h,y;
  printf("%c%c%c",g,h,y);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:8: error: array size missing in 'a'
    4 |   char a[],b[],c[];
      |        ^
main.c:4:12: error: array size missing in 'b'
    4 |   char a[],b[],c[];
      |            ^
main.c:4:16: error: array size missing in 'c'
    4 |   char a[],b[],c[];
      |                ^
main.c:6:7: error: conflicting types for 'a'; have 'int[0]'
    6 |   int a[0],b[0],c[0];
      |       ^
main.c:4:8: note: previous declaration of 'a' with type 'char[1]'
    4 |   char a[],b[],c[];
      |        ^
main.c:6:12: error: conflicting types for 'b'; have 'int[0]'
    6 |   int a[0],b[0],c[0];
      |            ^
main.c:4:12: note: previous declaration of 'b' with type 'char[1]'
    4 |   char a[],b[],c[];
      |            ^
main.c:6:17: error: conflicting types for 'c'; have 'int[0]'
    6 |   int a[0],b[0],c[0];
      |                 ^
main.c:4:16: note: previous declaration of 'c' with type 'char[1]'
    4 |   char a[],b[],c[];
      |                ^
main.c:7:27: error: 'y' undeclared (first use in this function)
    7 |   int g=a[0]-32,h=b[0]-32;y=c[0]-32;
      |                           ^
main.c:7:27: note: each undeclared identifier is reported only once for each function it appears in
main.c:8:8: error: conflicting types for 'g'; have 'char'
    8 |   char g,h,y;
      |        ^
main.c:7:7: note: previous definition of 'g' with type 'int'
    7 |   int g=a[0]-32,h=b[0]-32;y=c[0]-32;
      |       ^
main.c:8:10: error: conflicting types for 'h'; have 'char'
    8 |   char g,h,y;
      |          ^
main.c:7:17: note: previous definition of 'h' with type 'int'
    7 |   int g=a[0]-32,h=b[0]-32;y=c[0]-32;
      |                 ^