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

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

#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define ull unsigned long long
#define vc vector
#define SQ(j) (j)*(j)
#define ch first
#define range second
//
//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define sz(xxx) ((int)(xxx.size()))
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

//#define printf(...) (0)
#define db(x) if(DEBUG) {cout << #x << " = " << x << endl;}
#define dbCont(x) if(DEBUG) {cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;}

using namespace std;

template<class K, class V>
ostream &operator<<(ostream &out, pair<K, V> &elem) {
    out << "{" << elem.first << "," << elem.second << "}";
    return out;
}

// 4:13

int DEBUG = 1;

using namespace std;

const int N = 50;
int n,m;

char x[N][N];

int di[] = {0,1,0,-1};
int dj[] = {1,0,-1,0};

bool ins(int i, int j){
    return 0 <= i && i < n && 0 <= j && j < m;
}

int get(int si, int sj){

    queue<int> q;

    int dist[N][N];
    loop(i,n) loop(j,m) dist[i][j] = INT_MAX;

    int used[N][N];
    loop(i,n) loop(j,m) used[i][j] = 0;

    q.push(si);
    q.push(sj);
    used[si][sj] = 1;
    dist[si][sj] = 0;
    while(!q.empty()){
        int fi = q.front(); q.pop();
        int fj = q.front(); q.pop();

        loop(d,4){
            int ti = fi+ di[d];
            int tj = fj+ dj[d];
            if(ins(ti, tj) && !used[ti][tj] && x[ti][tj] == '.'){
                used[ti][tj] = 1;
                dist[ti][tj] = dist[fi][fj] + 1;
                q.push(ti);
                q.push(tj);
            }
        }
    }

    int mx = 0;
    loop(i,n){
        loop(j,m){
            if(used[i][j]) {
                mx = max(mx, dist[i][j]);
            }
        }
    }
    return mx;


}

int main() {
    cin >> n >> m;
    loop(i,n){
        string s;
        cin >> s;
        loop(j,m){
            x[i][j] = s[j];
        }
    }

    int ans = 0;
    loop(si,n){
        loop(sj, m){
            if(x[si][sj] == '.'){
                int mx = get(si,sj);

                ans = max(ans, mx);
            }
        }
    }

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

/*

7
1 0 0 5 0 0 2

 */

Compiler output:
a.cc: In function 'int get(int, int)':
a.cc:80:38: error: 'INT_MAX' was not declared in this scope
   80 |     loop(i,n) loop(j,m) dist[i][j] = INT_MAX;
      |                                      ^~~~~~~
a.cc:21:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   20 | #include <bitset>
  +++ |+#include <climits>
   21 |
Language: C++

#include <bits/stdc++.h>
#include "../lib/graph/graph.hpp"



using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int h, w; cin >> h >> w;
  vector<vector<char>> c(h, vector<char>(w));

  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      cin >> c[i][j];
    }
  }

  vector<vector<int>> g(h*w, vi(h*w, INF));
  for(int i=0;i<h*w;++i) {
    g[i][i] = 0;
  }
  vi dr = {0, 0, -1, 1};
  vi dc = {-1, 1, 0, 0};
  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      if(c[i][j] != '.') continue;
      for(int k=0;k<4;++k) {
        
        int nxti = i + dr[k], nxtj = j + dc[k];
        //cout << i << ":" << j << ":" << nxti << ":" << nxtj << endl;
        if(!(0 <= nxti && nxti < h && 0 <= nxtj && nxtj < w)) continue;
        if(c[nxti][nxtj] != '.') continue;
        g[i*w+j][nxti*w+nxtj] = 1;
      }
    }
  }

  for(int k=0;k<h*w;++k) {
    for(int i=0;i<h*w;++i) {
      for(int j=0;j<h*w;++j) {
        if(g[i][k] != INF && g[k][j] != INF) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }

  int ans = 0;
  for(int i=0;i<h*w;++i) {
    for(int j=i+1;j<h*w;++j) {
      if(g[i][j] != INF) ans = max(ans, g[i][j]);
    }
  }

  cout << ans << endl;


}


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

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 100000000

struct combi{
	deque<mint> kaijou;
	deque<mint> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(kaijou[i-1]*i);
		}
		
		mint b=1/kaijou[n];
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(kaijou_[0]*k);
		}
	}
	
	mint combination(int n,int r){
		if(r>n)return 0;
		mint a = kaijou[n]*kaijou_[r];
		a *= kaijou_[n-r];
		return a;
	}
	
	mint junretsu(int a,int b){
		mint x = kaijou_[a]*kaijou_[b];
		x *= kaijou[a+b];
		return x;
	}
	
	mint catalan(int n){
		return combination(2*n,n)/(n+1);
	}
	
};


int main(){

	int N,K;
	cin>>N>>K;
	
	vector<int> A(N);
	rep(i,N){
		cin>>A[i];
	}
	
	sort(A.begin(),A.end());
	
	combi C(200000);
	
	mint ans = 0;
	
	rep(i,N){
		ans += A[i] * C.combination(i,K-1);
	}
	
	reverse(A.begin(),A.end());
	
	rep(i,N){
		ans -= A[i] * C.combination(i,K-1);
	}
	
	cout<<ans.val()<<endl;
	
    return 0;
}

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

#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	const ll mod = 1e9 + 7;
	ll N, K;
	std::cin >> N >> K;
	vll A(N);
	rep(i, 0, N) {
		std::cin >> A[i];
	}
	sort(A.begin(), A.end());
	ll idx_min = N - K;
	ll idx_max = K - 1;
	ll cnt = 1;
	ll k = K;
	ll max_s = 0;
	ll min_s = 0;
	repeq(i, 1, N - K + 1) {

		max_s += (A[idx_max] * cnt) % mod;
		min_s += (A[idx_min] * cnt) % mod;
		max_s %= mod;
		min_s %= mod;
		idx_max++;
		idx_min--;

		cnt *= k;
		cnt %= mod;
		k++;
		cnt *=modinv(k - K,mod);
		cnt %= mod;

	}
	ll ans=max_s-min_s;
	if (ans < 0) {
		ans += mod;
	}
	std::cout << ans << endl;

	return 0;
}


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

#include <stdio.h>
#include <algorithm>
using namespace std;

const long long mod = 1000000007;
int n,k,a[200200];
long long inv[200200]={0,1},fact[200200]={1,1},ifact[200200]={1,1};

int main()
{
  scanf ("%d %d",&n,&k);
  for (int i=0;i<n;i++) scanf ("%d",&a[i]);
  
  for (int i=2;i<200200;i++){
inv[i] = (mod - mod / i) * inv[mod % i]%mod;
    fact[i] = fact[i-1] * i % mod;
    ifact[i] = ifact[i-1] * inv[i]%mod;
  }
  
  sort(a,a+n);
  long long ans = 0;
  for (int i=k;i<n;i++){
    long long c = fact[i-1] * ifact[k-1] % mod * ifact[i-k]%mod;
ans = (ans + mod + c*(a[i]-a[n-i-1]%mod) % mod;
  }
  printf ("%lld\n",ans);
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:47: error: expected ')' before ';' token
   24 | ans = (ans + mod + c*(a[i]-a[n-i-1]%mod) % mod;
      |       ~                                       ^
      |                                               )
Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;

int n,k,a[200200];
long long inv[200200]={0,1},fact[200200]={1,1},ifact[200200]={1,1};

int main()
{
  scanf ("%d %d",&n,&k);
  for (int i=0;i<n;i++) scanf ("%d",&a[i]);
  
  for (int i=2;i<200200;i++){
inv[i] = (mod - mod / i) * inv[mod % i]%mod;
    fact[i] = fact[i-1] * i % mod;
    ifact[i] = ifact[i-1] * inv[i]%mod;
  }
  
  sort(a,a+n);
  long long ans = 0;
  for (int i=k;i<n;i++){
    long long c = fact[i-1] * ifact[k-1] % mod * ifact[i-k]%mod;
ans = (ans + c*a[i]) % mod;
ans = (ans + mod - c*a[n-i-1]%mod) % mod;
  }
  printf ("%lld\n",ans);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: 'mod' was not declared in this scope
   14 | inv[i] = (mod - mod / i) * inv[mod % i]%mod;
      |           ^~~
a.cc:22:44: error: 'mod' was not declared in this scope
   22 |     long long c = fact[i-1] * ifact[k-1] % mod * ifact[i-k]%mod;
      |                                            ^~~
Language: C++

//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
#define int long long
using ll = long long;
using ull = unsigned long long;
const int maxnfact = 100010;
const ll md = 1e9+7;
int N, K;
int fact[maxnfact], fact_inv[maxnfact];
ll A[maxnfact];

inline void add(int &a, int b) {
 a += b;
 if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int mdpow(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

void pre() {
  fact[0] = 1;
  fact_inv[0] = 1;
  for(int i = 1; i < maxnfact; i++){
    fact[i] = mul(fact[i-1], i);
  }
  fact_inv[maxnfact - 1] = mdpow(fact[maxnfact - 1], md - 2);
  for (int i = maxnfact-1-1; i >= 1; i--) {
    fact_inv[i] = mul(fact_inv[i+1], i+1);
  }
}

inline int nck(int n, int k) {
  return mul(mul(fact[n], fact_inv[n-k]), fact_inv[k]);
}

ll main() {
  fastio;
  cin >> N >> K;
  pre();
  for (int i = 0; i < N; i++) { cin >> A[i]; }
  sort(A, A + N);
  ll res = 0;
  for (int i = K-1; i < N; i++) {
    int choose = nck(i, K-1);
    add(res, mul(A[i], choose));
  }

  for (int i = 0; i + K <= N; i++) {
    int choose = nck(N - i - 1, K-1);
    sub(res, mul(A[i], choose));
  }
  cout << res << endl;

  return 0;
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Compiler output:
a.cc:74:1: error: '::main' must return 'int'
   74 | ll main() {
      | ^~
Language: C++

//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
using ll = long long;
using ull = unsigned long long;
const int maxnfact = 100010;
const ll md = 1e9+7;
int N, K;
int fact[maxnfact], fact_inv[maxnfact];
ll A[maxnfact];

inline void add(int &a, int b) {
 a += b;
 if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int mdpow(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

void pre() {
  fact[0] = 1;
  fact_inv[0] = 1;
  for(int i = 1; i < maxnfact; i++){
    fact[i] = mul(fact[i-1], i);
  }
  fact_inv[maxnfact - 1] = mdpow(fact[maxnfact - 1], md - 2);
  for (int i = maxnfact-1-1; i >= 1; i--) {
    fact_inv[i] = mul(fact_inv[i+1], i+1);
  }
}

inline int nck(int n, int k) {
  return mul(mul(fact[n], fact_inv[n-k]), fact_inv[k]);
}

int main() {
  fastio;
  cin >> N >> K;
  pre();
  for (int i = 0; i < N; i++) { cin >> A[i]; }
  sort(A, A + N);
  ll res = 0;
  for (int i = K-1; i < N; i++) {
    int choose = nck(i, K-1);
    add(res, mul(A[i], choose));
  }

  for (int i = 0; i + K <= N; i++) {
    int choose = nck(N - i - 1, K-1);
    sub(res, mul(A[i], choose));
  }
  cout << res << endl;
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:9: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka 'long long int'}
   82 |     add(res, mul(A[i], choose));
      |         ^~~
a.cc:17:22: note:   initializing argument 1 of 'void add(int&, int)'
   17 | inline void add(int &a, int b) {
      |                 ~~~~~^
a.cc:87:9: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka 'long long int'}
   87 |     sub(res, mul(A[i], choose));
      |         ^~~
a.cc:22:22: note:   initializing argument 1 of 'void sub(int&, int)'
   22 | inline void sub(int &a, int b) {
      |                 ~~~~~^
Language: C++

//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
using ll = long long;
using ull = unsigned long long;
const int maxnfact = 100010;
const int md = 1e9+7;
int N, K;
int fact[maxnfact], fact_inv[maxnfact];
int A[maxnfact];

inline void add(int &a, int b) {
 a += b;
 if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int mdpow(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

void pre() {
  fact[0] = 1;
  fact_inv[0] = 1;
  for(int i = 1; i < maxnfact; i++){
    fact[i] = mul(fact[i-1], i);
  }
  fact_inv[maxnfact - 1] = mdpow(fact[maxnfact - 1], md - 2);
  for (int i = maxnfact-1-1; i >= 1; i--) {
    fact_inv[i] = mul(fact_inv[i+1], i+1);
  }
}

inline int nck(int n, int k) {
  return mul(mul(fact[n], fact_inv[n-k]), fact_inv[k]);
}

int main() {
  fastio;
  cin >> N >> K;
  pre();
  for (int i = 0; i < N; i++) { cin >> A[i]; }
  sort(A, A + N);
  int res = 0;
  for (int i = K-1; i < N; i++) {
    int choose = nck(i, K-1);
    int val = A[i] + md; val %= md;
    add(res, mul(A[i], choose));
  }

  for (int i = 0; i + K <= N; i++) {
    int choose = nck(N - i - 1, K-1);
    sub(res, mul(val, choose));
  }
  cout << res << endl;
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Compiler output:
a.cc: In function 'int main()':
a.cc:88:18: error: 'val' was not declared in this scope
   88 |     sub(res, mul(val, choose));
      |                  ^~~
Language: C++

//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
using ll = long long;
using ull = unsigned long long;
const int maxnfact = 100010;
const int md = 1e9+7;
int N, K;
int fact[maxnfact], fact_inv[maxnfact];
int A[maxnfact];

inline void add(int &a, int b) {
 a += b;
 if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int mdpow(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

void pre() {
  fact[0] = 1;
  fact_inv[0] = 1;
  for(int i = 1; i < maxnfact; i++){
    fact[i] = mul(fact[i-1], i);
  }
  fact_inv[maxnfact - 1] = mdpow(fact[maxnfact - 1], md - 2);
  for (int i = maxnfact-1-1; i >= 1; i--) {
    fact_inv[i] = mul(fact_inv[i+1], i+1);
  }
}

inline int nck(int n, int k) {
  return mul(mul(fact[n], fact_inv[n-k]), fact_inv[k]);
}

int main() {
  fastio;
  cin >> N >> K;
  pre();
  for (int i = 0; i < N; i++) { cin >> A[i]; A[i] += md; A[i] %= md; }
  sort(A, A + N);
  int res = 0;
  for (int i = K-1; i < N; i++) {
    int choose = nck(i, K-1);
    add(res, mul(A[i], choose));
  }

  for (int i = 0; i < N - K + 1; i++) {
    int choose = nck(N - i - 1, K-1);
    sub(res, mul(, choose));
  }
  cout << res << endl;
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:18: error: expected primary-expression before ',' token
   87 |     sub(res, mul(, choose));
      |                  ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

const int MAX_N = 200000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}


int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }

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

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    ll ans = 0;
    REP(i,N){
        ll a = A[i];
        ans += (a * comb(m, K)) % MOD;
        ans %= MOD;
        ans += MOD - (a * comb(N-m-1, K)) % MOD;
        ans %= MOD;
    }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:65:26: error: 'm' was not declared in this scope
   65 |         ans += (a * comb(m, K)) % MOD;
      |                          ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int MOD = 1000000007;
const int MAX = 200000;

ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
// n= 200000までのやつ
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(int n, int k){
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  COMinit();
  rep(i, n) cin >> A[i];
  sort(A.begin(), A.end());
  ll ans = 0;
  ll f_min = 0;
  ll f_max = 0;
  rep(i,n){
    f_min += A[i] * COM(n - i - 1, k - 1);
    f_min %= MOD;
  }
  for (int i = n - 1; i >= 0; i--){
    f_max += A[i] * COM(i, k - 1);
    f_max %= MOD;
  }
  cout(f_max - f_min + 2 * MOD) % MOD << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:7: error: no match for call to '(std::ostream {aka std::basic_ostream<char>}) (ll)'
   51 |   cout(f_max - f_min + 2 * MOD) % MOD << endl;
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
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 P = pair<int,int>;
const int mod = 1000000007;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());

  combination c(n+5);

  mint ans = 0;
  rep(ri,2) {
    rep(i,n) {
      mint now = c(i,k-1);
      if (ri == 1) now = -now;
      ans += now*a[i];
    }
    reverse(a.begin(), a.end());
  }

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


Compiler output:
a.cc:21:11: error: redefinition of 'const int mod'
   21 | const int mod = 1000000007;
      |           ^~~
a.cc:6:11: note: 'const int mod' previously defined here
    6 | const int mod = 1000000007;
      |           ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (((x*f(x,y/2))%mod)*f(x,y/2))%mod;

}
int main(){
int64_t N;
  cin>>N;
  vector<int64_t>A(N);
  for(int64_t i=i;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  int64_t a=1;
  for(int64_t i=K;i<=N-1;i++){
  ans=(ans+(a*(mod+A.at(i)-A.at(N-1-i)))%mod)%mod;
  a=(((a*i)%mod)*f(i-K-1,mod-2))%mod;
  
  }cout<<ans<<endl;
  
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'K' was not declared in this scope
   22 |   for(int64_t i=K;i<=N-1;i++){
      |                 ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

const long long mod = 1e9 + 7;

int main(){
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    vector<long long> fact(n + 1); 
    fact[0] = 1;
    for (int i = 1; i <= n; ++i){
        fact[i] = (fact[i-1]*i) % mod;
        fact[i] %= mod;
    }

    long long sum = 0;
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < n; ++j){
            long long c = 0;
            if(n - j - k >= 0) c = fact[n - j - 1] / (faact[k - 1] * fact[n - j - k]) % mod);
            if(!i) sum -= (a[j] * c) % mod;
            else sum += (a[j] * c) % mod;
            sum %= mod;
        }
        reverse(a.begin(), a.end());
    }
    cout << sum % mod;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:55: error: 'faact' was not declared in this scope; did you mean 'fact'?
   38 |             if(n - j - k >= 0) c = fact[n - j - 1] / (faact[k - 1] * fact[n - j - k]) % mod);
      |                                                       ^~~~~
      |                                                       fact
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define pii pair<int, int>
#define forr(i,a,n) for (int i = (a); i < (n); ++i)
#define rforr(i,a,n) for (int i = (a); i > (n); --i)
#define ALL(x) x.begin(),x.end()
#define LEN(X) ((int)(X).size())
#define CASET int _T; cin >> _T; forr(caset,0,_T)
#define int ll

int mod = 1000000000+7;

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,k; cin >> n >> k;
    vi a(n); forr(i,0,n) cin >> a[i];

    int ans = 0;
    sort(ALL(a));

    vi nck(n,1); nck[1] = k;
    forr(i,2,n) {
        nck[i] = nck[i-1]*(i-1+k)/i;
        sck[i] %= mod;
    }

    forr(i,k-1,n) {
        ans += a[i]*nck[i-k+1];
        ans %= mod;

    }
    rforr(i,n-k,-1) {
        ans += mod - a[i]*nck[n-k-i];
        ans %= mod;
    }
    cout << ans << '\n';

}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'sck' was not declared in this scope; did you mean 'nck'?
   26 |         sck[i] %= mod;
      |         ^~~
      |         nck
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>


typedef long long int ll;


#define MOD 1000000007
#define MAX 100001

using namespace std;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    int N,K;
    cin >> N >> K;
    COMinit();
    vector<int> v;
    for(int i=0;i<N;i++){
      int tmp;
      cin >> tmp;
      v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    ll ans = 0;
    for(int i=K;i<=N;i++){
      ans = (ans + ((v[i-1]%MOD) * COM(i-1,K-1)%MOD)%MOD)%MOD;
    }
    for(int i=0;i<=N-K;i++){
      ans = (ans + v[i]%MOD*((-COM(N-i-1,K-1))%MOD))%MOD)%MOD;
    }
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:57: error: expected ';' before ')' token
   51 |       ans = (ans + v[i]%MOD*((-COM(N-i-1,K-1))%MOD))%MOD)%MOD;
      |                                                         ^
Language: C++

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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976


#define N_MAX 200005
ll f[N_MAX],rf[N_MAX];

ll pow(ll x,ll n){  // xのn乗 (mod m)
    ll res = 1;
    if(n > 0){
        res = pow(x,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }else{
            res = (((res * res) % mod) * x) % mod;
        }
    }
    return res;
}

void init(){
    f[0] = 1;
    for(int i = 1; i < N_MAX; i++){
        f[i] = (i * f[i-1]) % mod;
    }
    for(int i = 0; i < N_MAX; i++){
        rf[i] = pow(f[i],mod-2);
    }
}

ll com(ll n, ll k){
    
    ll a = f[n];
    ll b = rf[k];
    ll c = rf[n-k];

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

int main()
{
    init();
    ;; n,k; cin >> n >> k;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll ans = 0;
    sort(a,a+n);
    rep(i,n-k+1){
        ans += (a[n-1-i] - a[i]) * com((n-1-i),(k-1));
        ans %= mod;
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:8: error: 'n' was not declared in this scope; did you mean 'yn'?
   53 |     ;; n,k; cin >> n >> k;
      |        ^
      |        yn
a.cc:53:10: error: 'k' was not declared in this scope
   53 |     ;; n,k; cin >> n >> k;
      |          ^
a.cc:55:21: error: 'a' was not declared in this scope
   55 |     rep(i,n) cin >> a[i];
      |                     ^
a.cc:57:10: error: 'a' was not declared in this scope
   57 |     sort(a,a+n);
      |          ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std ;
typedef long long ll ;
const ll maxx = 1e5+5,mod=1e9+7 ;
ll fact[maxx];
ll power(ll b,ll p,ll m)
{
    if(p==0){return 1;}
    //if(p==1){return b;}
    ll half = power(b,p/2,m);
    ll ans,full=(half*half)%m;
    if(p%2==0)
    {
        return full;
    }
    else { return  (full*b)%m ;}
}
ll mulv(ll b,ll p)
{
    // since p is prime ;
    // b*x=1 mod p , p is prime so gcd(p,b)=1
    ll x  = power(b,p-2,p);
    return x ;
}
ll ncr(ll n,ll r)
{
    //cout << n << "  " << r << endl;
    if(n<r){return 0;}
    if(r==0 || n==r){return 1;}
    if(r==1 ){return n%mod;}
    ll a,b,c;
    a = fact[n];
    b = mulv(fact[n-r],mod);
    c = mulv(fact[r],mod);
    ll ans = (a*b)%mod;
    ans = (ans*c)%mod;
    return ans ;
}
int main()
{
    fact[0]=1;
    for(int i=1;i<=100002;i++)
    {
       fact[i]=(fact[i-1]*i)%mod;
    }
    ll n , k ;
    cin >> n >> k ;
    vector < ll > arr(n+5);
    for(int i=1;i<=n;i++)
    {
       ll  x ;
       cin >> x ;
       arr[i-1]=x;
    }
    sort(arr.begin(),arr.end(),greater<ll>());
    ll sum=0,sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        sum1+= (arr[i]*ncr(n-i-1,k-1))%mod ;

        sum2+= (arr[i]*ncr(i,k-1))%mod ;
    }
    sum=sum1-sum2;
    cout << sum%mod << endl;
    return 0 ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:5: error: 'vector' was not declared in this scope
   49 |     vector < ll > arr(n+5);
      |     ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include<algorithm>
  +++ |+#include <vector>
    3 | using namespace std ;
a.cc:49:17: error: expected primary-expression before '>' token
   49 |     vector < ll > arr(n+5);
      |                 ^
a.cc:49:19: error: 'arr' was not declared in this scope
   49 |     vector < ll > arr(n+5);
      |                   ^~~
Language: C++

#include <bits\stdc++.h>
#define ll long long
using namespace std;
ll n, k;
ll a[100009], fact[100009],inv[100009], mod = (ll)1e9+7;
ll fp(ll b, ll p)
{
	if (p == 0)
		return 1;
	ll ans = fp(b, p / 2);
	ans = (ans * ans) % mod;
	if (p % 2)
		ans = (ans * (b % mod)) % mod;
	return ans;
}
void pre()
{
	ll e = 100005;
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= e; i++)
	{
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}
ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
ll mx[100009], mn[100009];
int main()
{
	pre();
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		if (i >= k - 1)
			mx[i] = (a[i] * ncr(i, k - 1)) % mod;
		if (n - i - 1 >= k - 1 && n - i > 0)
			mn[i] = (a[i] * ncr(n - i - 1, k - 1)) % mod;
	}
	for (ll i = 0; i < n; i++)
		sum += mx[i] - mn[i];
	cout << sum % mod;
}

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

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int c=1e6;
const ll mod=1e9+7;
ll fact[1e7], inv[1e7];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    calcFacAndInv(c);
    ll n,k;
    cin>>n>>k;
    ll arr[n+6],ar[n+6],mx=0,mn=0;
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    sort(ar,ar+n);
    for(int i=1;i<=n;i++){
        arr[i]=ar[i-1];
    }
    mn=mn+((arr[1]*ncr(n-1, k-1))%mod);
    for(ll i=2;i<n;i++){
    mn=mn+((arr[i]*ncr(n-i, k-1))%mod);
    mx=mx+((arr[i]*ncr(i-1, k-1))%mod);

    }
    mx=mx+((arr[n]*ncr(n-1, k-1))%mod);
    cout<<(mx-mn)%mod;
    //cout<<mn<<" "<<mx;
    return 0;
}


Compiler output:
a.cc:7:9: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    7 | ll fact[1e7], inv[1e7];
      |         ^~~
a.cc:7:9: error: could not convert '1.0e+7' from 'double' to 'long unsigned int'
    7 | ll fact[1e7], inv[1e7];
      |         ^~~
      |         |
      |         double
a.cc:7:9: error: size of array 'fact' has non-integral type 'double'
a.cc:7:19: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    7 | ll fact[1e7], inv[1e7];
      |                   ^~~
a.cc:7:19: error: could not convert '1.0e+7' from 'double' to 'long unsigned int'
    7 | ll fact[1e7], inv[1e7];
      |                   ^~~
      |                   |
      |                   double
a.cc:7:19: error: size of array 'inv' has non-integral type 'double'
Language: C++

// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007ll
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>k;
		// n=s.length();
		vector<ll> a(n);
		rep(i,n)
		{
			cin>>a[i];
		}
		sort(all(a));
		ll C[n+1][k+1];
		rep(i,n+1)
		{
			rep(j,min(k,i+1))
			{
				if (j == 0 || j == i) 
	                C[i][j] = 1; 
				else C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
				// debug3(i,j,C[i][j]);
			}
		}
		repe(i,k-1,n)
		{
			k=(C[i][k-1]*abs(a[i]-a[n-i-1]))%mod
			if(a[i]-a[n-i-1]<0) c=(c-k+mod)%mod;
			else c=(c+k)%mod;
		}
		// reverse(all(a));
		// repe(i,k-1,n)
		// {
		// 	// m=a[n-i-1];
		// 	k=(C[i][k-1]*abs(m))%mod;
		// 	debug3(k,a[n-i-1],n-i-1);
		// 	// if(a[n-i-1]<0) cs=(cs-k+mod)%mod;
		// 	// else cs=(cs+k)%mod;
		// }
		cout<<c-cs;

		
		cout<<"\n";
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:25: error: expected ';' before 'if'
   76 |                         if(a[i]-a[n-i-1]<0) c=(c-k+mod)%mod;
      |                         ^~
a.cc:77:25: error: 'else' without a previous 'if'
   77 |                         else c=(c+k)%mod;
      |                         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int a[maxn];
typedef long long ll;
ll mod = 1e9+7;  // 1e9+9

ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}

ll mpow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll divi(ll x,ll y){return mul(x,mpow(y,mod-2));}

ll fact[10000000]={1}, factc=0;
ll Fact(ll x){
  while( factc < x ){
    factc++;
    fact[factc]=mul( fact[factc-1] , factc );
  }
  return fact[x];
}

ll nCr(ll n,ll r){
    if(n<c)return 0;
  return divi( Fact(n) , mul( Fact(n-r) , Fact(r) )   );
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    debug(nCr(1,2));
    int n,k;cin>>n>>k;
    rep(i,1,n)cin>>a[i];
    sort(a+1,a+1+n);
    ll mx=0,mn=0;;
    rep(i,1,n){
        mx+=a[i]*nCr(i-1,k-1); 
        mn+=a[n-i+1]*nCr(i-1,k-1);
        mx=(mx%mod+mod)%mod;
        mn=(mn%mod+mod)%mod;
        //debug(mx),debug(mn);
    }
    cout<<((mx-mn)%mod+mod)%mod<<endl;
}
/* 

 */

Compiler output:
a.cc: In function 'll nCr(ll, ll)':
a.cc:32:10: error: 'c' was not declared in this scope
   32 |     if(n<c)return 0;
      |          ^
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve2(N, K, A));
    }

    private static long solve2(int N, int K, int[] A) {
        long count = 0;
        Arrays.sort(A);

        for (int i=0; i<N-K+1; i++) {
            long comb = combination(N-i-1, K-1, MOD);
            count -= A[i] * comb % MOD;
            count %= MOD;
            // System.err.println("min:" + A[i] + ", comb:" + comb + ", count:" + count);
        }


        for (int i=N-1; i>=K-1; i--) {
            long comb = combination(i, K-1, MOD);
            count += A[i]*comb%MOD;
            count %= MOD;
            // System.err.println("max:" + A[i] + ", comb:" + comb + ", count:" + count);
        }


        return count;
    }

    public static long combination(int n, int r, int p) {
        if (n == 0 && r == 0) return 1;
        if (n < r || n < 0)   return 0;

        r = Math.min(r, n-r);
        long x = 1;
        long y = 1;
        for (int i=1; i<=r; i++) {
            x = x * (n-i+1) % p;
            y = y * i % p;
        }

Compiler output:
Main.java:55: error: reached end of file while parsing
        }
         ^
1 error
Language: Java

import java.lang.Math;
import java.util.Arrays;

public class Main {
  static long mod = 1000000007;
  static long[] fact;

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    long[] A = new long[N];
    for(int i=0; i<N; i++) {
      A[i] = scan.nextLong();
    }
    scan.close();

    fact = new long[N+1];
    fact[0] = 1;
    for(int i=1; i<=N; i++) {
      fact[i] = (long)i * fact[i-1] % mod;
    }

    Arrays.sort(A);

    long[] nCkArray = new long[N+1];
    long maxSum = 0;
    for(int i=K-1; i<N; i++) {
      if(nCkArray[i] == 0) {
        nCkArray[i] = nCk(i, K-1);
      }

      maxSum += A[i] * nCkArray[i];
      maxSum %= mod;
    }

    long minSum = 0;
    for(int i=0; i<N-K+1; i++) {
      if(nCkArray[N-i-1] == 0) {
        nCkArray[N-i-1] = nCk(N-i-1, K-1);
      }

      minSum += A[i] * nCkArray[N-i-1];
      minSum %= mod;
    }

    System.out.println(maxSum - minSum);
  }

  public static long power(long x, long n) {
    long result = 1;
    while(n > 0) {
      if(n%2 == 1) {
        result *= x;
        result %= mod;
      }
      x = x*x;
      x %= mod;

      n >>= 1;
    }

    return result;
  }

  public static long nCk(long n, long k) {
    return fact[(int)n] * power(fact[(int)k] * fact[(int)(n-k)] % mod, mod-2) % mod;
  }
}

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;

const int mod = 1000000007;
struct mint
{
	ll x; // typedef long long ll;
	mint(ll x = 0) : x((x % mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint &operator+=(const mint a)
	{
		if ((x += a.x) >= mod)
			x -= mod;
		return *this;
	}
	mint &operator-=(const mint a)
	{
		if ((x += mod - a.x) >= mod)
			x -= mod;
		return *this;
	}
	mint &operator*=(const mint a)
	{
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const
	{
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const
	{
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const
	{
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const
	{
		if (!t)
			return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1)
			a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const
	{
		return pow(mod - 2);
	}
	mint &operator/=(const mint a)
	{
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const
	{
		mint res(*this);
		return res /= a;
	}
};

struct combination
{
	vector<mint> fact, ifact;
	combination(int n) : fact(n + 1), ifact(n + 1)
	{
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i)
			fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i)
			ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k)
	{
		if (k < 0 || k > n)
			return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());

	combination c(n+5);
	mint ans = 0;

	rep(ri,2) {
		rep(i,n) {
			mint now = c(i,k-1);
			if (ri == 1) now = -now;
			ans += now*a[i];
		}
		reverse(a.begin(), a.end());
	}
	cout << ans.x << endl;
	return 0;
}

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

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n, k;
    cin >> n >> k;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    init();

    ll ans = 0;
    exrep(i, 0, n-k) {
    }

    ll x = 0;
    exrep(i, 0, n-k) {
        x += (a[(n-1)-i]*Comb((n-1)-i, k-1))%mod;
        x %= mod;
    }

    ll y = 0;
    exrep(i, 0, n-k) {
        y += (a[i]*Comb((n-1)-i, k-1))%mod;
        y %= mod;
    }

    ll ans = (x + mod - y)%mod;

    out(ans);
    re0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:102:8: error: redeclaration of 'll ans'
  102 |     ll ans = (x + mod - y)%mod;
      |        ^~~
a.cc:86:8: note: 'll ans' previously declared here
   86 |     ll ans = 0;
      |        ^~~