Language: C++

#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 10e20
static const int MAX_N=10e5,MAX_M=10e5;
int N,M;
int maxs=-1,mini=INF,ans,res;
int A[MAX_N],B[MAX_N],C[MAX_N];
int a,b,c,d,e,f,g;
int x,y,z;
int main(void){
	cin >> N >> M;
	for(int i=0;i<N;i++)
		cin >> A[i];
	sort(A,A+N);
	for(int i=N-1;i>=1;i--)
		B[i-1]=A[i]-A[i-1];
	sort(B,B+N-1);
	for(int i=0;i<M-1;i++)
		ans+=B[i];
	cout << ans << endl;
	return 0;
}#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 10e20
static const int MAX_N=10e5,MAX_M=10e5;
int N,M;
int maxs=-1,mini=INF,ans,res;
int A[MAX_N],B[MAX_N],C[MAX_N];
int a,b,c,d,e,f,g;
int x,y,z;
int main(void){
	cin >> N >> M;
	for(int i=0;i<N;i++)
		cin >> A[i];
	sort(A,A+N);
	for(int i=N-1;i>=1;i--)
		B[i-1]=A[i]-A[i-1];
	sort(B,B+N-1);
	for(int i=0;i<M-1;i++)
		ans+=B[i];
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:25:2: error: stray '#' in program
   25 | }#include<iostream>
      |  ^
a.cc:6:13: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+21' to '2147483647' [-Woverflow]
    6 | #define INF 10e20
      |             ^~~~~
a.cc:9:18: note: in expansion of macro 'INF'
    9 | int maxs=-1,mini=INF,ans,res;
      |                  ^~~
a.cc:25:3: error: 'include' does not name a type
   25 | }#include<iostream>
      |   ^~~~~~~
a.cc:31:18: error: redefinition of 'const int MAX_N'
   31 | static const int MAX_N=10e5,MAX_M=10e5;
      |                  ^~~~~
a.cc:7:18: note: 'const int MAX_N' previously defined here
    7 | static const int MAX_N=10e5,MAX_M=10e5;
      |                  ^~~~~
a.cc:31:29: error: redefinition of 'const int MAX_M'
   31 | static const int MAX_N=10e5,MAX_M=10e5;
      |                             ^~~~~
a.cc:7:29: note: 'const int MAX_M' previously defined here
    7 | static const int MAX_N=10e5,MAX_M=10e5;
      |                             ^~~~~
a.cc:32:5: error: redefinition of 'int N'
   32 | int N,M;
      |     ^
a.cc:8:5: note: 'int N' previously declared here
    8 | int N,M;
      |     ^
a.cc:32:7: error: redefinition of 'int M'
   32 | int N,M;
      |       ^
a.cc:8:7: note: 'int M' previously declared here
    8 | int N,M;
      |       ^
a.cc:33:5: error: redefinition of 'int maxs'
   33 | int maxs=-1,mini=INF,ans,res;
      |     ^~~~
a.cc:9:5: note: 'int maxs' previously defined here
    9 | int maxs=-1,mini=INF,ans,res;
      |     ^~~~
a.cc:33:13: error: redefinition of 'int mini'
   33 | int maxs=-1,mini=INF,ans,res;
      |             ^~~~
a.cc:9:13: note: 'int mini' previously defined here
    9 | int maxs=-1,mini=INF,ans,res;
      |             ^~~~
a.cc:33:22: error: redefinition of 'int ans'
   33 | int maxs=-1,mini=INF,ans,res;
      |                      ^~~
a.cc:9:22: note: 'int ans' previously declared here
    9 | int maxs=-1,mini=INF,ans,res;
      |                      ^~~
a.cc:33:26: error: redefinition of 'int res'
   33 | int maxs=-1,mini=INF,ans,res;
      |                          ^~~
a.cc:9:26: note: 'int res' previously declared here
    9 | int maxs=-1,mini=INF,ans,res;
      |                          ^~~
a.cc:34:5: error: redefinition of 'int A [1000000]'
   34 | int A[MAX_N],B[MAX_N],C[MAX_N];
      |     ^
a.cc:10:5: note: 'int A [1000000]' previously declared here
   10 | int A[MAX_N],B[MAX_N],C[MAX_N];
      |     ^
a.cc:34:14: error: redefinition of 'int B [1000000]'
   34 | int A[MAX_N],B[MAX_N],C[MAX_N];
      |              ^
a.cc:10:14: note: 'int B [1000000]' previously declared here
   10 | int A[MAX_N],B[MAX_N],C[MAX_N];
      |              ^
a.cc:34:23: error: redefinition of 'int C [1000000]'
   34 | int A[MAX_N],B[MAX_N],C[MAX_N];
      |                       ^
a.cc:10:23: note: 'int C [1000000]' previously declared here
   10 | int A[MAX_N],B[MAX_N],C[MAX_N];
      |                       ^
a.cc:35:5: error: redefinition of 'int a'
   35 | int a,b,c,d,e,f,g;
      |     ^
a.cc:11:5: note: 'int a' previously declared here
   11 | int a,b,c,d,e,f,g;
      |     ^
a.cc:35:7: error: redefinition of 'int b'
   35 | int a,b,c,d,e,f,g;
      |       ^
a.cc:11:7: note: 'int b' previously declared here
   11 | int a,b,c,d,e,f,g;
      |       ^
a.cc:35:9: error: redefinition of 'int c'
   35 | int a,b,c,d,e,f,g;
      |         ^
a.cc:11:9: note: 'int c' previously declared here
   11 | int a,b,c,d,e,f,g;
      |         ^
a.cc:35:11: error: redefinition of 'int d'
   35 | int a,b,c,d,e,f,g;
      |           ^
a.cc:11:11: note: 'int d' previously declared here
   11 | int a,b,c,d,e,f,g;
      |           ^
a.cc:35:13: error: redefinition of 'int e'
   35 | int a,b,c,d,e,f,g;
      |             ^
a.cc:11:13: note: 'int e' previously declared here
   11 | int a,b,c,d,e,f,g;
      |             ^
a.cc:35:15: error: redefinition of 'int f'
   35 | int a,b,c,d,e,f,g;
      |               ^
a.cc:11:15: note: 'int f' previously declared here
   11 | int a,b,c,d,e,f,g;
      |               ^
a.cc:35:17: error: redefinition of 'int g'
   35 | int a,b,c,d,e,f,g;
      |                 ^
a.cc:11:17: note: 'int g' previously declared here
   11 | int a,b,c,d,e,f,g;
      |                 ^
a.cc:36:5: error: redefinition of 'int x'
   36 | int x,y,z;
      |     ^
a.cc:12:5: note: 'int x' previously declared here
   12 | int x,y,z;
      |     ^
a.cc:36:7: error: redefinition of 'int y'
   36 | int x,y,z;
      |       ^
a.cc:12:7: note: 'int y' previously declared here
   12 | int x,y,z;
      |       ^
a.cc:36:9: error: redefinition of 'int z'
   36 | int x,y,z;
      |         ^
a.cc:12:9: note: 'int z' previously declared here
   12 | int x,y,z;
      |         ^
a.cc:37:5: error: redefinition of 'int main()'
   37 | int main(void){
      |     ^~~~
a.cc:13:5: note: 'int main()' previously defined here
   13 | int main(void){
      |     ^~~~