Language: C++

#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int P = 1e9 + 7 ; 
const int N = 2e5 + 5 ; 
int n, m, fac[N], inv[N], a[N], Ans ; 
int fpow( int x, int k ) {
	int ans = 1, base = x ; 
	while( k ) {
		if( k & 1 ) ans = ans * base % P ; 
		base = base * base % P, k >>= 1 ; 
	} return ans ; 
}
int C( int y, int x ) {
	if( y < x ) return 0 ; 
	return fac[y]  inv[x] % P  inv[y - x] % P ; 
}
signed main()
{
	n = gi(), m = gi() ; inv[0] = fac[0] = 1 ; 
	rep( i, 1, n ) fac[i] = fac[i - 1] * i % P ; 
	rep( i, 1, n ) inv[i] = fpow( fac[i], P - 2 ) ;
	rep( i, 1, n ) a[i] = gi() ; 
	sort( a + 1, a + n + 1 ) ; int x ;
	rep( i, 1, n ) {
		Ans = ( Ans + a[i] * C(i - 1, m - 1) % P ) % P ; 
	}
	rep( i, 1, n ) {
		Ans = ( Ans - a[i] * C(n - i, m - 1) % P + P ) % P ; 
	}
	printf("%I64d\n", Ans ) ;
	return 0 ;
}

Compiler output:
a.cc: In function 'long long int C(long long int, long long int)':
a.cc:24:22: error: expected ';' before 'inv'
   24 |         return fac[y]  inv[x] % P  inv[y - x] % P ;
      |                      ^ ~~~
      |                      ;
a.cc:24:34: error: expected ';' before 'inv'
   24 |         return fac[y]  inv[x] % P  inv[y - x] % P ;
      |                                  ^ ~~~
      |                                  ;
a.cc: In function 'int main()':
a.cc:29:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   29 |         rep( i, 1, n ) fac[i] = fac[i - 1] * i % P ;
      |              ^
a.cc:3:42: note: in definition of macro 'rep'
    3 | #define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
      |                                          ^
a.cc:30:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   30 |         rep( i, 1, n ) inv[i] = fpow( fac[i], P - 2 ) ;
      |              ^
a.cc:3:42: note: in definition of macro 'rep'
    3 | #define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
      |                                          ^
a.cc:31:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   31 |         rep( i, 1, n ) a[i] = gi() ;
      |              ^
a.cc:3:42: note: in definition of macro 'rep'
    3 | #define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
      |                                          ^
a.cc:33:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |         rep( i, 1, n ) {
      |              ^
a.cc:3:42: note: in definition of macro 'rep'
    3 | #define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
      |                                          ^
a.cc:36:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |         rep( i, 1, n ) {
      |              ^
a.cc:3:42: note: in definition of macro 'rep'
    3 | #define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
      |                                          ^