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

#include<stdio.h>
void sort(int[] x);

int main(){
  int n,m,sum = 0;
  scanf("%d%d",&n,&m);
  int x[m];
  for(int i = 0;i < m;i++){
    scanf("%d",&x[i]);
  }
  sort(x[m]);
  int max[m-1];
  for(int i = 0;i < m-1;i++){  
      max[i] = x[i] - x[i+1];
  }

  sort(max[m]);
  for(int i = 0;i < n-1;i++){
    sum += max[i];
  }
  
  printf("%d",x[0]-x[m]-sum);
}  
      
void sort(int[] x){
  int tmp;
   for(int i = 0;i < n-1;i++){  
     if(x[i] < x[i+1]){
       tmp = x[i];
       x[i] = x[i+1];
       x[i+1] = tmp;
     }
  }
}
  

Compiler output:
main.c:2:17: error: expected ';', ',' or ')' before 'x'
    2 | void sort(int[] x);
      |                 ^
main.c: In function 'main':
main.c:11:3: error: implicit declaration of function 'sort' [-Wimplicit-function-declaration]
   11 |   sort(x[m]);
      |   ^~~~
main.c: At top level:
main.c:25:17: error: expected ';', ',' or ')' before 'x'
   25 | void sort(int[] x){
      |                 ^
Language: C

#include<stdio.h>

int main() {
   int N,M,tmp;
   scanf("%d %d", &N,&M);
   int X[M];
   for(int i = 0; i < M; i++) {
      scanf("%d", &X[i]);
   }
   
   for(int i = 0; i < M; i++) {
      for(int j = i+1; j < M; j++) {
         if(X[i] > X[j]) {
            tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
         }
      }
   }

   if(N >= M) {
      printf("%d", 0);
   } else if() {
   }
}


Compiler output:
main.c: In function 'main':
main.c:23:14: error: expected expression before ')' token
   23 |    } else if() {
      |              ^
Language: C++

#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(){

    int n,m;

    cin >> n >> m;

    int x[m];

    for(int i=0; i<m; i++){
        cin >> x[i];
    }

    int y[m-1];

    for(int i=0; i<m-1; i++){
        y[i] = abs(x[i] - x[i+1]);
    }

    sort(y, y+m-1);

    int c = 0;

    for(int i=0; i<(m-1-n); i++){
        c+=y[i];
    }

    cout << c << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   26 |     sort(y, y+m-1);
      |     ^~~~
      |     short
Language: C++

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

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> X(M);
    for(ll i=0;i<M;i++){
        cin >> X[i];
    }

    sort(X.begin(),X.end());

    vector<ll> sa(M-1);

    for(ll i=0;i<M;i++){
        sa[i]=X[i+1]-X[i];
    }

    sort(sa.begin(),sa.end());
    reverse(sa.begin(),sa.end());

    ll ju=X[M-1]-X[0];

    if(ju<=N){
      cout << 0 << endl;
    }
  
  else if{
    for(ll i=0;i<N-1;i++){
      ju=ju-sa[i];
    }
  
    

    cout << ju << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:10: error: expected '(' before '{' token
   30 |   else if{
      |          ^
      |          (
Language: C++

#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int compare_int(const void *a, const void *b) { 
  return *(int*) a-*(int*) b;
}

int main()
{
	int n, m, i, cnt=0;
	scanf("%d %d", &n, &m);
	int x[100000], r[100000];
	lop(i, m){ scanf("%d", &x[i]); }
	
	if(n>=m){ printf("0"); return 0; }
	qsort(x, m, sizeof(int), compare_int);
	
	for(i=1; i<m; i++){
		r[i]=x[i]-x[i-1];
	}
	qsort(r, m, sizeof(int), compare_int);
	for(i=0; i<=m-n; i++){
		cnt+=r[i];
	}
	
	printf("%d", cnt);
	
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'qsort' was not declared in this scope
   17 |         qsort(x, m, sizeof(int), compare_int);
      |         ^~~~~
Language: C++

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

int main(){
  int n,m;
  cin >> n >> m;
  
  if(m=<n)
    cout << 0 << endl;
  
  else{
    vector<int> x(m);
    for(int i=0;i<m;i++)
      cin >> x.at(i);
    sort(x.begin(),x.end());
    vector<int> y(m-1);
    for(int i=0;i<m-1;i++)
      y.at(i)=x.at(i+1)-x.at(i);
    sort(y.begin(),y.end());
    
    int k=0;
    for(int i=0;i<m-n;i++)
      k+=y.at(i);
    
    cout << k << endl;
    
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:8: error: expected primary-expression before '<' token
    8 |   if(m=<n)
      |        ^
Language: C++

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m)cin >> x[i];
    sort(x.begin(),x.end());
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    vector<int> d(m-1)
    rep(i,m-1)d[i] = x[i+1] - x[i];
    sort(d.begin(),d.end());
    int ans = 0;
    rep(i,m-n) ans += d[i];
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:18: error: expected ',' or ';' before 'for'
    2 | #define rep(i,n) for(int i = 0;i < (n);i++)
      |                  ^~~
a.cc:18:5: note: in expansion of macro 'rep'
   18 |     rep(i,m-1)d[i] = x[i+1] - x[i];
      |     ^~~
a.cc:18:9: error: 'i' was not declared in this scope
   18 |     rep(i,m-1)d[i] = x[i+1] - x[i];
      |         ^
a.cc:2:32: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i = 0;i < (n);i++)
      |                                ^
Language: C++

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m)cin >> x[i];
    sort(x.begin(),x.end());
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    rep(i,m-1)d[i] = x[i+1] - x[i];
    sort(d.begin(),d.end());
    int ans = 0;
    rep(i,m-n) ans += d[i];
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:15: error: 'd' was not declared in this scope
   17 |     rep(i,m-1)d[i] = x[i+1] - x[i];
      |               ^
a.cc:18:10: error: 'd' was not declared in this scope
   18 |     sort(d.begin(),d.end());
      |          ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> x(M);
	vector<ll> l(M - 1);
	for (ll i = 0; i < M; i++)
	{
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	for (ll i = 0; i < M - 1; i++)
	{
		l[i] = x[i + 1] - x[i];
	}
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	ll ans = 0;
	for (ll i = 0; i < N - 1; i++)
	{
		ans += l[i];
	}
	cout << x[M - 1] - x[0] - ans; << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:40: error: expected primary-expression before '<<' token
   33 |         cout << x[M - 1] - x[0] - ans; << endl;
      |                                        ^~
Language: C++

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

int main() {
    int N, M; cin >> N >> M;
    vector<long long> X(M);
    for (int i = 0; i < M; ++i) cin >> X[i];
    sort(X.begin(), X.end());
        
    vector<long long> diffs;
    for (int i = 1; i < X.size(); ++i) diffs.push_back(X[i] - X[i-1]);//push_back=新たな要素を末尾に追加
    sort(diffs.begin(), diffs.end(), greater<long long>());//大きい順にソート
        
    long long res = X[i] - X[0];
    for (int i = 0; i < min(diffs.size(), N-1); ++i) res -= diffs[i];
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:23: error: 'i' was not declared in this scope
   16 |     long long res = X[i] - X[0];
      |                       ^
a.cc:17:28: error: no matching function for call to 'min(std::vector<long long int>::size_type, int)'
   17 |     for (int i = 0; i < min(diffs.size(), N-1); ++i) res -= diffs[i];
      |                         ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:17:28: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   17 |     for (int i = 0; i < min(diffs.size(), N-1); ++i) res -= diffs[i];
      |                         ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:17:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   17 |     for (int i = 0; i < min(diffs.size(), N-1); ++i) res -= diffs[i];
      |                         ~~~^~~~~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int N, M, i, x[100000], l[100000];
	long long sum = 0;
	scanf("%d %d\n", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d ", &x[i]);
	}
	if (N >= M) {
		printf("0");
		return 0;
	}
	qsort(x, M, sizeof(int), (int(*)(const void *,const void*))compar);
	for (i = 0; i < M - 1; i++) {
		l[i] = x[i + 1] - x[i];
	}
	qsort(l, N - M - 1, sizeof(int), (int(*)(const void*, const void*))compar);
	for (i = 0; i < M - N; i++) {
		sum += l[i];
	}
	printf("%lld\n", sum);

	return 0;
}

int compar(const int*val1, const int*val2) {
	if (*val1 < *val2) return -1;
	else if (*val1 == *val2) return 0;
	else return  1;
}

Compiler output:
main.c: In function 'main':
main.c:15:68: error: 'compar' undeclared (first use in this function)
   15 |         qsort(x, M, sizeof(int), (int(*)(const void *,const void*))compar);
      |                                                                    ^~~~~~
main.c:15:68: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int n,m;
  cin >> n >> m;
  vi x(m),xsa(m-1);
  REP(i,m) {
    cin >> x[i];
  }
  sort(ALL(x));
  REP(i,m-1) {
    xsa[i]= x[i+1]-x[i];
  }
  sort(ALL(xsa));
  if(n>=m) {
    int ans=0;
  } else {
    int ans=0;
    REP(i,m-n) {
      ans+=xsa[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   64 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

n,m=map(int,input().split())
s=list(map(int,input().split()))

s.sort()
term=[]

for i in range(m-1):
    term.append(s[i+1]-s[i])

term.sort()

for i in range(n-1):
    del term[-1]

print(sum(term))

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,m=map(int,input().split())
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int;

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

  if (n >= m)
  {
    cout << 0;
  }

  vector<int> x(m);
  for (int i = 0; i < m; i++)
  {
    cin >> x[i];
  }

  sort(x.begin(), x.end());
  vector<int> d(m - 1);

  for (int i = 0; i < m - 1; i++)
  {
    d[i] = x[i + 1] - x[i];
  }

  sort(d.begin(), d.end());

  int ans = 0;
  for (int i = 0; i < d.size() - (n - 1); i++)
  {
    ans += d[i];
  }

  cout << ans;
}

Compiler output:
a.cc:5:19: error: declaration does not declare anything [-fpermissive]
    5 | typedef long long int;
      |                   ^~~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include < stdio.h >
#include < vector >
#include < algorithm >
using namespace std;
typedef long long ll;
#define rep(n) for ( int i =0; i < n ; i ++)
int N, M;
int P[100000], Y[100000], X[10000];
vector<int> d;
int main()
{
	scanf("%d %d ", &N, &M);
	rep(M) scanf("%d", &X[i]);
	rep(M - 1)d.push_back(X[i + 1] - X[i]);
	sort(d.begin(), d.end(), std::greater<int>());
	int sum = 0;
	rep(M - N + 1)sum += d[i];
	printf("%d", sum);
}

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

#define _CRT_SECURE_NO_WARNINGS
#include < cstdio >
#include < vector >
#include < algorithm >
using namespace std;
typedef long long ll;
#define rep(n) for ( int i =0; i < n ; i ++)
int N, M;
int P[100000], Y[100000], X[10000];
vector<int> d;
int main()
{
	scanf("%d %d ", &N, &M);
	rep(M) scanf("%d", &X[i]);
	rep(M - 1)d.push_back(X[i + 1] - X[i]);
	sort(d.begin(), d.end(), std::greater<int>());
	int sum = 0;
	rep(M - N + 1)sum += d[i];
	printf("%d", sum);
}

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

#include<bits/stdc++.h>
using namespace std;
bool cmp(int x,int y)
{
	return x>y;
}
int n,m,a[100005],ans,c[100005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++) cin>>a[i];
	sort(a+1,a+1+m);
	for(int i=1;i<m;i++) c[i]=a[i+1]-a[i],ans+=c[i];
	sort(c+1,c+n,cmp);
	for(int i=1;i<=n-1) ans-=c[i];
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:27: error: expected ';' before ')' token
   14 |         for(int i=1;i<=n-1) ans-=c[i];
      |                           ^
      |                           ;
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}


int main(){
	int n, m;
	int *x, *x_diff;
	int sum=0;
	scanf("%d%d\n", &n, &m);
	if(n>=m){
		printf("0\n");
		return 0;
	}
	x = (int*)malloc(sizeof(int) * m);
	x_diff = (int*)malloc(sizeof(int) * (m-1));
	for(int i=0; i<n; i++){
		scanf("%d", &x[i]);
	}
	qsort(x, m, sizeof(int), asc);
	for(int i=0; i<m-1; i++){
		x_diff[i] = x[i+1] - x[i];
	}
	qsort(x_diff, m-1, sizeof(int), asc);
	for(int i=0; i<m-n; i++){
		sum += x_diff[i];
	}
	printf("%d", sum);
	free(x);
	fres(x_diff);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'fres' was not declared in this scope; did you mean 'free'?
   36 |         fres(x_diff);
      |         ^~~~
      |         free
Language: C++

#include<bits/stdc++.h>

using namespace std;
template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}
int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  vector<int> v(m),v2(m);Inparray(v,m);sort(All(v));
  v2[0]=0;
  for (int i = 1; i < m; ++i){
  	v2[i]=v[i]-v[i-1];
  }
  sort(All(v2));
  // Printarray(v2,m);
  int ans=0;
  for (int i = 0; i < m-n+1; ++i)ans+=v2[i];
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:45: error: 'All' was not declared in this scope
   11 |   vector<int> v(m),v2(m);Inparray(v,m);sort(All(v));
      |                                             ^~~
Language: C++

#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>X(m);
	rep(i, m) {
		cin >> X[i];
	}
	sort(X.begin(), X.end());
	vector<ll>dist(m - 1);
	ll ans = X[m - 1] - X[0];
	rep(i, m - 1) {
		dist[i] = X[i + 1] - X[i];
	}
	sort(dist.begin(), dist.end(),greater<ll>());
	rep(i, n - 1) {
		ans -= dist[i];
	}
	else cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:9: error: 'else' without a previous 'if'
   55 |         else cout << ans << endl;
      |         ^~~~
Language: C++

#include <iostream>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int X[M];
    int D[M-1];
    int sum = 0;
    for(int i=0; i<M; i++){
        cin >> X[i];
    }

    if(M == 1 || N >= M){
        cout << 0 << endl;
        return 0;
    }

    sort(X, X + M);
    for(int i=0; i<M-1; i++){
        D[i] = X[i+1] - X[i];
        sum += D[i];
    }
    sort(D, D + M - 1, greater<int>() );
    for(int i=0; i<N-1; i++){
        sum -= D[i];
    }
    cout << sum << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |     sort(X, X + M);
      |     ^~~~
      |     short
Language: C++

#include <iostream>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    if(M == 1 || N > M){
        cout << 0 << endl;
        return 0;
    }
    int X[M];
    int D[M-1];
    int sum = 0;
    for(int i=0; i<M; i++){
        cin >> X[i];
    }
    sort(X, X + M);
    for(int i=0; i<M-1; i++){
        D[i] = X[i+1] - X[i];
        sum += D[i];
    }
    for(int i=0; i<M - 1; i++) cout << D[i] << endl;
    sort(D, D + M - 1, greater<int>() );
    for(int i=0; i<N-1; i++){
        sum -= D[i];
    }
    cout << sum << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |     sort(X, X + M);
      |     ^~~~
      |     short
Language: C++

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M), dist;
  for (int i = 0; i < M; i++) cin >> X[i];
  if (M <= N) {
    cout << 0 << endl;
    return 0;
  }
  sort(X.begin(), X.end());
  for (int i = 1; i < M; i++) {
    dist.__emplace_back(X[i] - X[i - 1]);
  }
  sort(dist.begin(), dist.end());
  for (int i = 0; i < N - 1; i++) {
    dist.pop_back();
  }

  cout << accumulate(dist.begin(), dist.end(), 0) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:10: error: 'class std::vector<int>' has no member named '__emplace_back'; did you mean 'emplace_back'?
   18 |     dist.__emplace_back(X[i] - X[i - 1]);
      |          ^~~~~~~~~~~~~~
      |          emplace_back
Language: C++

#include<bits/stdc++.h>
#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)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,m;
  cin>>n>>m;
  vll x(m);
  rep(i,m) cin>>x[i];
  sort(all(x));
  vll y(m-1);
  rep(i,m-1){
    y[i]=x[i+1]-x[i];
  }
  if(n==1){
    ll ans=0;
    rep(i,m-1){
      ans+=y[i];
    }
    COUT(ans);
  }
  else{
    sort(all(y));
    n--;
    ll ans=0;
    rep(i,m-1-n){
      ans=y[i];
    }
    COUT(ans);

Compiler output:
a.cc: In function 'int main()':
a.cc:62:15: error: expected '}' at end of input
   62 |     COUT(ans);
      |               ^
a.cc:55:7: note: to match this '{'
   55 |   else{
      |       ^
a.cc:62:15: error: expected '}' at end of input
   62 |     COUT(ans);
      |               ^
a.cc:38:11: note: to match this '{'
   38 | int main(){
      |           ^
Language: C++

    #include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;

    ll gcd(ll a,ll b){
        if(a%b == 0)return b;
        else return gcd(b,a%b);
      }


    int main(){
      int n,m;
      cin>>n>>m;
      VEC(int,x,m);
      if(n>=m){
        cout<<0<<endl;
        return 0;
      }
      sort(x.begin(),x.end(),);
      auto dist = vec(int,m-1);
      rep(i,m-1)dist[i] = x[i+1]-x[i];
      int ans = abs(x[m-1]-x[0]);
      sort(dist.begin(),dist.end(),greater<int>());
      rep(i,n-1)ans -= dist[i];
      cout<<ans<<endl;
    }


Compiler output:
a.cc: In function 'int main()':
a.cc:40:30: error: expected primary-expression before ')' token
   40 |       sort(x.begin(),x.end(),);
      |                              ^
Language: C++

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

int main() {
  int N,M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
  }
  else if {
      vector<int> vec(M);
      for (int i = 0; i < M ;i++) {
          cin >> vec.at(i);
      }

      sort(vec.begin(),vec.end());

      vector<int> dist(M-1);
      for (int i = 0; i < M -1; i++) {
          dist.at(i) = vec.at(i+1) - vec.at(i);
      }

      sort(dist.begin(),dist.end());

      int ans = 0;
      for (int i = 0; i < M-1-(N-1);i++){
          ans += dist.at(i);
      } 
      cout << ans << endl;
  }
}
   

Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: expected '(' before '{' token
   10 |   else if {
      |           ^
      |           (
Language: C++

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

int main() {
  int N,M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
  }
  else if {
     vector<int> vec(M);
 	 for (int i = 0; i < M ; i++) {
    	cin >> vec.at(i);
     }
    
    
  	 sort(vec.begin(),vec.end());
  
 	 vector<int> dist(M-1);
  	 for (int i = 0; i < M-1; i++) {
    	int a = vec.at(i+1) - vec.at(i);
    	dist.at(i) = a;
  	 }
  	 sort(dist.begin(),dist.end());
  
 	 int ans = 0;
  	 for (int i = 0; i < M-1-(N-1); i++) {
      	 ans += dist.at(i);
 	 }
  	 cout << ans << endl;
  }
}
   

Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: expected '(' before '{' token
   10 |   else if {
      |           ^
      |           (
Language: C++

int main() {
  int N,M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
  }
  else if {
     vector<int> vec(M);
 	 for (int i = 0; i < M ; i++) {
    	cin >> vec.at(i);
     }
    
    
  	 sort(vec.begin(),vec.end());
  
 	 vector<int> dist(M-1);
  	 for (int i = 0; i < M-1; i++) {
    	int a = vec.at(i+1) - vec.at(i);
    	dist.at(i) = a;
  	 }
  	 sort(dist.begin(),dist.end());
  
 	 int ans = 0;
  	 for (int i = 0; i < M-1-(N-1); i++) {
      	 ans += dist.at(i);
 	 }
  	 cout << ans << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> N >> M;
      |   ^~~
a.cc:5:5: error: 'cout' was not declared in this scope
    5 |     cout << 0 << endl;
      |     ^~~~
a.cc:5:18: error: 'endl' was not declared in this scope
    5 |     cout << 0 << endl;
      |                  ^~~~
a.cc:7:11: error: expected '(' before '{' token
    7 |   else if {
      |           ^
      |           (
Language: C++

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

int main() {
  int N,M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
  }
  else if {
    vector<int> vec(M);
    for (int i = 0; i < M; i++) {
      cin >> vec.at(i);
    }
    
    sort(vec.begin(),vec.end());
    
    vector<int> dist(M-1);
    for (int i = 0; i <M -1; i++) {
      dist.at(i) = vec.at(i+1) - vec.at(i-1);
    }
    
    sort(dist.begin(),dist.end());
    
    int ans = 0;
    for (int i = 0; i < M-1-(N-1); i++) {
      ans += dist.at(i);
    }
    
    cout << ans << endl;
  }
}




Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: expected '(' before '{' token
   10 |   else if {
      |           ^
      |           (
Language: C++

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

int main() {
  int N,M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
  }
  else if {
      vector<int> vec(M);
 	 for (int i = 0; i < M ; i++) {
    	cin >> vec.at(i);
  	}
  	sort(vec.begin(),vec.end());
  
 	 vector<int> dist(M-1);
  	for (int i = 0; i < M-1; i++) {
    	int a = vec.at(i+1) - vec.at(i);
    	dist.at(i) = a;
  	}
  	sort(dist.begin(),dist.end());
  
 	 int ans = 0;
  	for (int i = 0; i < M-1-(N-1); i++) {
    	ans += dist.at(i);
 	 }
  	cout << ans << endl;
    

  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: expected '(' before '{' token
   10 |   else if {
      |           ^
      |           (
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

int main() {
  int N,M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
    continue;
  }
  else if {
      vector<int> vec(M);
 	 for (int i = 0; i < M ; i++) {
    	cin >> vec.at(i);
  	}
  	sort(vec.begin(),vec.end());
  
 	 vector<int> dist(M-1);
  	for (int i = 0; i < M-1; i++) {
    	int a = vec.at(i+1) - vec.at(i);
    	dist.at(i) = a;
  	}
  	sort(dist.begin(),dist.end());
  
 	 int ans = 0;
  	for (int i = 0; i < M-1-(N-1); i++) {
    	ans += dist.at(i);
 	 }
  	cout << ans << endl;
    

  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: continue statement not within a loop
    9 |     continue;
      |     ^~~~~~~~
a.cc:11:11: error: expected '(' before '{' token
   11 |   else if {
      |           ^
      |           (
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

int main() {
  int N,M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
    continue;
  }
  vector<int> vec(M);
  for (int i = 0; i < M ; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  vector<int> dist(M-1);
  for (int i = 0; i < M-1; i++) {
    int a = vec.at(i+1) - vec.at(i);
    dist.at(i) = a;
  }
  sort(dist.begin(),dist.end());
  
  int ans = 0;
  for (int i = 0; i < M-1-(N-1); i++) {
    ans += dist.at(i);
  }
  cout << ans << endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: continue statement not within a loop
    9 |     continue;
      |     ^~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n, m;
  	cin >> n >> m;
  int arr[m];
    //storing in array
  	for(int i = 0; i < m; i++)
      cin >> arr[i];
  	// sorting the array
  	sort(arr, arr+m);
  	if(n < m){
    	int arr1[m-1];
      for (int i = 0; i < m-1; i++)
        arr1[i] = arr[i+1]-arr[i];
      // sorting arr1 -- difference array
      sort(arr1, arr1+m-1);
      // summing up
      cout << accumulate(arr1, arr1+m-n, 0)<<'\n';
    }
  else cout << "0\n";

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: 'accumulate' was not declared in this scope
   20 |       cout << accumulate(arr1, arr1+m-n, 0)<<'\n';
      |               ^~~~~~~~~~
Language: C++

n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
d = sorted([x[i + 1] - x[i] for i in range(m - 1)])
print(sum(d[:1-n]))

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,m = map(int,input().split())
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x.at(i);
  sort(x.begin(),x.end());
  //int ans = x.at(m-1) - x.at(0);
  if(n >= m){
    cout << 0 << endl;
    return 0;
  }
  vector<int> d(m-1);
  rep(i,m-1){
    d.at(i) = x.at(i+1) - x.at(i);
  }
  sort(d.begin(),d.end(),greater<int>());
  int r = n - 1;
  rep(i,r) ans -= d.at(i);
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |   rep(i,r) ans -= d.at(i);
      |            ^~~
      |            abs
a.cc:32:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(long long int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n,k;
  cin>>k>>n;
  vector<long long int> v(n),w(n-1);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  rep(i,n-1){
    w[i]=v[i+1]-v[i];
  }
  sort(w.begin(),w.end(),greater<int>());
  long long int ans=Svec(w);
  rep(i,k-1){
    ans-=w[i];
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:26: error: could not convert 'w' from 'vector<long long int>' to 'vector<int>'
   78 |   long long int ans=Svec(w);
      |                          ^
      |                          |
      |                          vector<long long int>
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  int n, m; cin >> n >> m;
  vi p(m); rep(i, m) cin >> p[i];

  ll ans = 0;
  if (n < m){
  sort(all(p));
  vi d(m - 1);
  rep(i, m - 1) d[i] = p[i + 1] - p[i];
  sort(all(d));
  rep(i, m - n) ans += d[i];

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

Compiler output:
a.cc: In function 'int main()':
a.cc:62:2: error: expected '}' at end of input
   62 | }
      |  ^
a.cc:47:11: note: to match this '{'
   47 | int main(){
      |           ^
Language: C++

n, m = map(int,input().split())
coords = sorted(list(map(int,input().split())))

diff = []
for i in range(1,len(coords)):
	diff.append((coords[i]-coords[i-1], i))

diff.sort()

indexes = [x[1] for x in diff[-1:-min(n,m):-1]]

final_index = [0]
for i in indexes:
	final_index.append(i)
	final_index.append(i-1)

final_index.append(len(coords)-1)
final_index.sort()

total = 0
for i in range(1,len(final_index),2):
	total += coords[final_index[i]]-coords[final_index[i-1]]

print(total)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, m = map(int,input().split())
      | ^
Language: Java

import java.util.*;

public class C {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] ary = new int[k];
		for( int i = 0; i < k; i++ ) ary[i] = in.nextInt();
		Arrays.sort(ary);
		int ans = 0;
		if( k != 1 ) {
			int[] diffs = new int[k-1];
			for( int i = 0; i < k-1; i++ ) diffs[i] = ary[i+1] - ary[i];
			Arrays.sort(diffs);
			//System.out.println(Arrays.toString(diffs));
			for( int i = 0; i < k-n; i++ ) ans += diffs[i];
		}
		System.out.println(ans);
	}
}

Compiler output:
Main.java:3: error: class C is public, should be declared in a file named C.java
public class C {
       ^
1 error
Language: Java

import java.util.*;
import java.io.*;

public class Streamline {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws IOException {
		String[] line1 = br.readLine().split(" ");
		int n = Integer.parseInt(line1[0]);
		int m = Integer.parseInt(line1[1]);

		if(n <= m) {
			String[] line2 = br.readLine().split(" ");
			int[] arr = new int[m];
			for(int i = 0; i < m; i++) {
				arr[i] = Integer.parseInt(line2[i]);
			}

			Arrays.sort(arr);

			Distances[] dists = new Distances[m-1];

			for(int i = 0; i < m-1; i++) {
				dists[i] = new Distances(arr[i+1]-arr[i], i);
			}

			Arrays.sort(dists, new DistanceComparator());
			// for(Distances d : dists) {
			// 	System.out.println(d.getDistance());
			// }

			int[] newDists = new int[n-1];
			for(int i = dists.length-n+1; i < dists.length; i++) {
				int currIndex = i - (dists.length-n+1);
				newDists[currIndex] = dists[i].getIndex();
			}
			Arrays.sort(newDists);

			int ans = 0;
			for(int i = 0; i < newDists.length-1; i++) {
				int indexA = newDists[i]+1;
				int indexB = newDists[i+1];
				ans += (arr[indexB] - arr[indexA]);
			}
			ans += (arr[newDists[0]] - arr[0]);
			ans += (arr[m-1] - arr[newDists[newDists.length-1]+1]);

			// System.out.println(Arrays.toString(newDists));
			System.out.println(ans);
		}
		else {
			System.out.println(0);
		}
	}

	private static class Distances {
		int distance;
		int index;

		public Distances(int d, int i) {
			distance = d;
			index = i;
		}

		public int getDistance() {
			return distance;
		}

		public int getIndex() {
			return index;
		}
	}

	private static class DistanceComparator implements Comparator<Distances> {
		public int compare(Distances d1, Distances d2) {
			Integer a = new Integer(d1.getDistance());
			Integer b = new Integer(d2.getDistance());
			return a.compareTo(b);
		}
	}
}

Compiler output:
Main.java:4: error: class Streamline is public, should be declared in a file named Streamline.java
public class Streamline {
       ^
Main.java:76: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal
			Integer a = new Integer(d1.getDistance());
			            ^
Main.java:77: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal
			Integer b = new Integer(d2.getDistance());
			            ^
1 error
2 warnings
Language: Java

import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
        hayami saori = new hayami();
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		int N = saori_hayami();
		int M = saori_hayami();
		int[] X = new int[M];
		for(int i=0; i<M; i++){
			X[i] = saori_hayami();
		}
		Arrays.sort(X);
		int[] diff = new int[M-1];
		for(int i=0; i<M-1; i++){
			diff[i] = X[i+1] - X[i];
		}
		Arrays.sort(diff);
		if(N>=M){
			ans = 0;
		}else{
			for(int i=0; i<M-N; i++){
				ans += diff[i];
			}
		}
		System.out.println(ans);
		
	}
	
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Compiler output:
Main.java:10: error: cannot find symbol
		int N = saori_hayami();
		        ^
  symbol:   method saori_hayami()
  location: class Main
Main.java:11: error: cannot find symbol
		int M = saori_hayami();
		        ^
  symbol:   method saori_hayami()
  location: class Main
Main.java:14: error: cannot find symbol
			X[i] = saori_hayami();
			       ^
  symbol:   method saori_hayami()
  location: class Main
3 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m;
  cin >> n >> m;
  if(n >= m) {
    cout 0;
    return 0;
  }
  vector<int> x(m);
  rep(i,m) cin >> x.at(i);
  sort(x.begin(),x.end());
  vector<int64_t> y(m-1);
  rep(i,m-1) {
    y.at(i) = abs(x.at(i+1) - x.at(i));
  }
  sort(y.begin(),y.end());
  reverse(y.begin(),y.end());
  int p=0;
  for(int i=n-1;i>0;i--) {
    y.at(p) = 0;
    p++;
  }
  int64_t ans = 0;
  rep(i,m-1) 
    ans += y.at(i);
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: expected ';' before numeric constant
    9 |     cout 0;
      |         ^~
      |         ;
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m;
  cin >> n >> m;
  if(n >= m) {
    cout 0;
    return 0;
  vector<int> x(m);
  rep(i,m) cin >> x.at(i);
  sort(x.begin(),x.end());
  vector<int64_t> y(m-1);
  rep(i,m-1) {
    y.at(i) = abs(x.at(i+1) - x.at(i));
  }
  sort(y.begin(),y.end());
  reverse(y.begin(),y.end());
  int p=0;
  for(int i=n-1;i>0;i--) {
    y.at(p) = 0;
    p++;
  }
  int64_t ans = 0;
  rep(i,m-1) 
    ans += y.at(i);
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: expected ';' before numeric constant
    9 |     cout 0;
      |         ^~
      |         ;
a.cc:29:2: error: expected '}' at end of input
   29 | }
      |  ^
a.cc:5:13: note: to match this '{'
    5 | int main () {
      |             ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x.at(i);
  sort(x.begin(),x.end());
  vector<int64_t> y(m-1);
  rep(i,m-1) {
    if(m == 1) y = x.at(i);
    y.at(i) = abs(x.at(i+1) - x.at(i));
  }
  sort(y.begin(),y.end());
  reverse(y.begin(),y.end());
  int p=0;
  if(m >= 2) {
    for(int i=n-1;i>0;i--) {
      y.at(p) = 0;
      p++;
    }
  }
  int64_t ans = 0;
  rep(i,m-1) 
    ans += y.at(i);
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:26: error: no match for 'operator=' (operand types are 'std::vector<long int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   13 |     if(m == 1) y = x.at(i);
      |                          ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'const std::vector<long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::initializer_list<long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x.at(i);
  sort(x.begin(),x.end());
  vector<int64_t> y(m-1);
  rep(i,m-1)
    if(m == 1) y = x.at(i);
    y.at(i) = abs(x.at(i+1) - x.at(i));
  sort(y.begin(),y.end());
  reverse(y.begin(),y.end());
  int p=0;
  if(m >= 2) {
    for(int i=n-1;i>0;i--) {
      y.at(p) = 0;
      p++;
    }
  }
  int64_t ans = 0;
  rep(i,m-1) 
    ans += y.at(i);
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:26: error: no match for 'operator=' (operand types are 'std::vector<long int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   13 |     if(m == 1) y = x.at(i);
      |                          ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'const std::vector<long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::initializer_list<long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:14:10: error: 'i' was not declared in this scope
   14 |     y.at(i) = abs(x.at(i+1) - x.at(i));
      |          ^