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

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

int main(){
  int n,k;
  int a[100001],b[100001];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n-1);
  for(int i=0;i<n-k;i++){
	b[i]=a[i+k]-a[i];
  }
  sort(b,a+n-1);
  cout<<b[0]<<endl;
}

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

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int N,K;
  cin>>N>>K;
  
  vector<long long int>h(N);
  
  for(long long int i=0;i,N;i++){
    cin>>h[i];
  }
      sort(h.begin(),h.end());
      
      long long int min=1000000000;
      
      for(long long int i=0;i<N-K+1;i++){
        if(min>h[i+K-1]-h[i]){
min=h[i+k-1]-h[i];
        }
      }

      cout<<min<<endl;
      }

        
        

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'k' was not declared in this scope
   18 | min=h[i+k-1]-h[i];
      |         ^
Language: C++

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

int main(void){
  int N, K;
  cin >> N >> K;
  int h[N];
  for(int i=0; i<N; i++) cin >> h[i];
  sort(h[i], h[i]+N);
  int ans=1e9;
  for(int i=0; i<N-K; i++){
    ans = min(h[i+K]-h[i], ans);
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: 'i' was not declared in this scope
    9 |   sort(h[i], h[i]+N);
      |          ^
Language: C++

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

int main(){
	int n,k;cin>>n>>k;
	vector<int> h(n);
	for(auto&& u:h)cin>>u;
	sort(begin(h),end(h));
	int mn=1e9;
	for(int i=0;i+k-1<n;i++)mn=min(mn,h[i+k-1]-h[i]);
	cout<<mn<<endl;	
}

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

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

int main {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
  
    sort(h.begin(), h.end());
    int ans = 1000000000;
    int i = 0;
    while (true) {
        if (i + k == n) break;
        for (int j = i; j < k+i; i++) {
            ans = min(ans, h[i+1]-h[i]);
        }
        i++;
    }
    cout << ans << endl;
}


Compiler output:
a.cc:4:5: error: cannot declare '::main' to be a global variable
    4 | int main {
      |     ^~~~
a.cc:5:5: error: expected primary-expression before 'int'
    5 |     int n, k; cin >> n >> k;
      |     ^~~
a.cc:5:5: error: expected '}' before 'int'
a.cc:4:10: note: to match this '{'
    4 | int main {
      |          ^
a.cc:5:15: error: 'cin' does not name a type
    5 |     int n, k; cin >> n >> k;
      |               ^~~
a.cc:6:19: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 |     vector<int> h(n);
      |                   ^
      |                   yn
a.cc:7:5: error: expected unqualified-id before 'for'
    7 |     for (int i = 0; i < n; i++) cin >> h[i];
      |     ^~~
a.cc:7:21: error: 'i' does not name a type
    7 |     for (int i = 0; i < n; i++) cin >> h[i];
      |                     ^
a.cc:7:28: error: 'i' does not name a type
    7 |     for (int i = 0; i < n; i++) cin >> h[i];
      |                            ^
a.cc:9:9: error: expected constructor, destructor, or type conversion before '(' token
    9 |     sort(h.begin(), h.end());
      |         ^
a.cc:12:5: error: expected unqualified-id before 'while'
   12 |     while (true) {
      |     ^~~~~
a.cc:19:5: error: 'cout' does not name a type
   19 |     cout << ans << endl;
      |     ^~~~
a.cc:20:1: error: expected declaration before '}' token
   20 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

#define int long long int

constexpr int INF = std::numeric_limits<int>::max();

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K; cin >> N >> K;
    vector<int> h(N);
    for (int &h : h) {
        cin >> h;
    }

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

    int ans = INF;
    for (int i = 0; i < h.size() - K + 1; i++) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }

    cout << ans << endl;
}

Compiler output:
a.cc:12:26: error: 'numeric_limits' is not a member of 'std'
   12 | constexpr int INF = std::numeric_limits<int>::max();
      |                          ^~~~~~~~~~~~~~
a.cc:10:13: error: expected primary-expression before 'long'
   10 | #define int long long int
      |             ^~~~
a.cc:12:41: note: in expansion of macro 'int'
   12 | constexpr int INF = std::numeric_limits<int>::max();
      |                                         ^~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 10;

int main(void){
    ll N;#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N, K;
    ll h[MAX_N];
    ll answer = 0;
    cin >> N >> K;
    rep(i, N) cin >> h[i];

    sort(h, h + N);
    rep(i, N - K + 1) answer = min(h[i + K - 1] - h[i], answer);

    cout << answer << endl;

    return 0;
}

Compiler output:
a.cc:33:10: error: stray '#' in program
   33 |     ll N;#include <stdio.h>
      |          ^
a.cc: In function 'int main()':
a.cc:33:11: error: 'include' was not declared in this scope
   33 |     ll N;#include <stdio.h>
      |           ^~~~~~~
a.cc:33:20: error: 'stdio' was not declared in this scope; did you mean 'stdin'?
   33 |     ll N;#include <stdio.h>
      |                    ^~~~~
      |                    stdin
a.cc:51:1: error: expected primary-expression before 'using'
   51 | using namespace std;
      | ^~~~~
a.cc:64:15: error: a function-definition is not allowed here before '{' token
   64 | int main(void){
      |               ^
a.cc:77:2: error: expected '}' at end of input
   77 | }
      |  ^
a.cc:32:15: note: to match this '{'
   32 | int main(void){
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define INF 100000000
typedef long long int LL;


int main(){
    int N,K; cin >> N >> K;

    rep(i,N){
        vector<LL> h(N);
        cin >> h[i];
    }

    sort(all(h));

    LL temp = INF;
    rep(j,N-K){
        temp = min(temp,h[j+K] - h[j]);
    }

    cout << temp << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:14: error: 'h' was not declared in this scope
   18 |     sort(all(h));
      |              ^
a.cc:4:18: note: in definition of macro 'all'
    4 | #define  all(x) (x).begin(),(x).end()     // 昇順ソート
      |                  ^
Language: C++

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n,m;
  	ci(n>>m);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  SORT(A);
  ll ans=A[n-1];
  
  FOR(i,0,n-m+1){
    ans=min(ans,A[m+i-1]-A[i])
  }
  co(ans)
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:48:31: error: expected ';' before '}' token
   48 |     ans=min(ans,A[m+i-1]-A[i])
      |                               ^
      |                               ;
   49 |   }
      |   ~
Language: C++

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i;i < N;i++) {
    cin >> vec.at(i);
  }
  int answer = 100000;
  int count = 0;
  sort(vec.begin(),vec.end());
  for(int j =0;j < N - K + 1;j++) {
    count = vec.at(j + K - 1) - vec.at(j)
    if(answer > count) {
      answer = count;
    }
  }
  cout << answer << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:42: error: expected ';' before 'if'
   17 |     count = vec.at(j + K - 1) - vec.at(j)
      |                                          ^
      |                                          ;
   18 |     if(answer > count) {
      |     ~~
Language: C++

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i;i < N;i++) {
    cin >> vec,at(i);
  }
  int answer = 100000;
  int count = 0;
  sort(vec.begin(),vec.end());
  for(int j =0;j < N - K + 1;j++) {
    count = vec.at(j + K - 1) - vec.at(j)
    if(answer > count) {
      answer = count;
    }
  }
  cout << answer << endl;
}

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

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


int main() {
    int n, k; cin >> n >> k;
    vector<int> l;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    // rep(i,n) cout << v[i];
    // cout << endl;
    rep(i, n-k+1){
        // cout << v[i] << v[i+k-1] << endl;
        l.push_back(v[i+k-1] - v[i])
    }
    cout << *min_element(l.begin(), l.end()) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:37: error: expected ';' before '}' token
   19 |         l.push_back(v[i+k-1] - v[i])
      |                                     ^
      |                                     ;
   20 |     }
      |     ~
Language: Java

import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n= scan.nextInt();
      	int k = scan.nextInt();
      	int[] h = new int[];
     	for(int i = o; i < n; i++){
        	h[i] = scan.nextInt();
        }
      	Arrays.sort(h);
      	int ans = Integer.MAX_VALUE;
      	for(int j = 0; j < n; j++){
        	ans = Math.min(ans, h[j + k] - h[j]);
        }
      	System.out.print(ans);
    }
 
}

Compiler output:
Main.java:8: error: array dimension missing
      	int[] h = new int[];
      	                   ^
1 error
Language: Java

import java.util.*;
 
public class Main{
	public static void main(String[[] args){
    	Scanner scan = new Scanner(System.in);
      	int n= scan.nextInt();
      	int k = scan.nextInt();
      	int[] h = new int[n];
     	for(int i = o; i < n; i++){
        	h[i] = scan.nextInt();
        }
      	Arrays.sort(h);
      	int ans = Integer.MAX_VALUE;
      	for(int j = 0; j < n; j++){
        	ans = Math.min(ans, h[j + k] - h[j]);
        }
      	System.out.print(ans);
    }
 
}

Compiler output:
Main.java:4: error: ']' expected
	public static void main(String[[] args){
	                               ^
1 error
Language: Java

import java.util.*;

public class Main{
	public static void main(String[[] args){
    	Scanner scan = new Scanner(System.in);
      	int n= scan.nextInt();
      	int k = scan.nextInt();
      	int[] h = new int[];
     	for(int i = o; i < n; i++){
        	h[i] = scan.nextInt();
        }
      	Arrays.sort(h);
      	int ans = Integer.MAX_VALUE;
      	for(int j = 0; j < n; j++){
        	ans = Math.min(ans, h[j + k] - h[j]);
        }
      	System.out.print(ans);
    }

}

Compiler output:
Main.java:4: error: ']' expected
	public static void main(String[[] args){
	                               ^
Main.java:8: error: array dimension missing
      	int[] h = new int[];
      	                   ^
2 errors
Language: C++

#include <iostream>
#include <vector>

int main(void)
{
	int N = 0, K = 0;
	std::cin >> N;
	std::cin >> K;

	std::vector<int> h;
	for (int i = 0; i < N; i++)
	{
		int a = 0;
		std::cin >> a;
		h.push_back(a);
	}

	for (int i = 1; i < N; i++)
	{
		for (int j = i; j >= 1 && h[j] < h[j - 1]; j--)
		{
			int tmp = 0;
			tmp = h[j - 1];
			h[j - 1] = h[j];
			h[j] = tmp;
		}
	}

	int min = INT_MAX;
	for (int i = 0; i + K < N; i++)
	{
		if (min > (h[i + K] - h[i]))
		{
			min = h[i + K] - h[i];
		}
	}

	std::cout << min << std::endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:19: error: 'INT_MAX' was not declared in this scope
   29 |         int min = INT_MAX;
      |                   ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 |
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n>>k;
    vl v(n);
    fo(i,n)cin>>v[i];
    sort(all(v));
    for(int i=0;i<n-k+1;i++)h=min(h,a[i+k-1]-a[i]);
    cout<<h;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:126:37: error: 'a' was not declared in this scope
  126 |     for(int i=0;i<n-k+1;i++)h=min(h,a[i+k-1]-a[i]);
      |                                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  vector<int> ki(n);
  vector<int> sa(n-k);
  cin>>n>>k;
  for(int i=0;i<n;i++){cin>>ki[i];}
  sort(ki.begin(),ki.end());
  for(int j=0;j<n-k;j++){sa[j]=ki[k+j-1]-ki[i];}
  cout<<min(sa)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:45: error: 'i' was not declared in this scope
   10 |   for(int j=0;j<n-k;j++){sa[j]=ki[k+j-1]-ki[i];}
      |                                             ^
a.cc:11:12: error: no matching function for call to 'min(std::vector<int>&)'
   11 |   cout<<min(sa)<<endl;
      |         ~~~^~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/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:   template argument deduction/substitution failed:
a.cc:11:12: note:   'std::vector<int>' is not derived from 'std::initializer_list<_Tp>'
   11 |   cout<<min(sa)<<endl;
      |         ~~~^~~~
/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:   candidate expects 2 arguments, 1 provided
Language: C

#include<stdio.h>
int main(void){
  int N,K,i,j,flag;
  int h[100000];
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++){
	scanf("%d",&h[i]);
  }
  for(i=1;i<n;i++){
    flag=h[i];
    if (h[i-1]>flag){
      j=i;
      do{
        h[j]=h[j-1];
        j--;
      }while(j>0 && h[j-1]>flag);
      h[j]=flag;
    }
  }
  if(h[K-1]-h[0]>h[N-1]-h[N-K]){
    printf("%d\n",h[N-1]-h[N-K]);
  }else{
    printf("%d\n",h[K-1]-h[0]);
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:13: error: 'n' undeclared (first use in this function)
    9 |   for(i=1;i<n;i++){
      |             ^
main.c:9:13: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort
print(min(h[i+K-1]-h[i] for i in range(N-K+1)))

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

ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long 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;
    }
}
//組み合わせ
long long 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 args, char* argv[]) {
    solve();
}

Compiler output:
a.cc:1:1: error: 'ans' does not name a type
    1 | ans = min(ans, h[i + K - 1] - h[i]);
      | ^~~
a.cc:2:5: error: expected declaration before '}' token
    2 |     }
      |     ^
a.cc:3:5: error: 'cout' does not name a type
    3 |     cout << ans << endl;
      |     ^~~~
a.cc:4:5: error: expected unqualified-id before 'return'
    4 |     return;
      |     ^~~~~~
a.cc:5:1: error: expected declaration before '}' token
    5 | }
      | ^
a.cc:7:15: error: 'MAX' was not declared in this scope
    7 | long long fac[MAX], finv[MAX], inv[MAX];
      |               ^~~
a.cc:7:26: error: 'MAX' was not declared in this scope
    7 | long long fac[MAX], finv[MAX], inv[MAX];
      |                          ^~~
a.cc:7:36: error: 'MAX' was not declared in this scope
    7 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                    ^~~
a.cc: In function 'void COMinit()':
a.cc:9:5: error: 'fac' was not declared in this scope
    9 |     fac[0] = fac[1] = 1;
      |     ^~~
a.cc:10:5: error: 'finv' was not declared in this scope
   10 |     finv[0] = finv[1] = 1;
      |     ^~~~
a.cc:11:5: error: 'inv' was not declared in this scope; did you mean 'int'?
   11 |     inv[1] = 1;
      |     ^~~
      |     int
a.cc:12:25: error: 'MAX' was not declared in this scope
   12 |     for (int i = 2; i < MAX; i++) {
      |                         ^~~
a.cc:13:31: error: 'MOD' was not declared in this scope
   13 |       fac[i] = fac[i-1] * i % MOD;
      |                               ^~~
a.cc: In function 'long long int COM(int, int)':
a.cc:22:12: error: 'fac' was not declared in this scope
   22 |     return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
      |            ^~~
a.cc:22:22: error: 'finv' was not declared in this scope
   22 |     return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
      |                      ^~~~
a.cc:22:44: error: 'MOD' was not declared in this scope
   22 |     return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
      |                                            ^~~
a.cc: In function 'int main(int, char**)':
a.cc:25:5: error: 'solve' was not declared in this scope
   25 |     solve();
      |     ^~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N , K;
  cin >> N >> K;
  vector<long long int> A(N);
  for(int  i = 0; i < N; i++) cin >> A[i];
  
  sort(A.begin(), A.end());
  
  long long int mind = 100000000LL;
  for(int i = 0; i + K - 1 <N; i++){
    long long int maxh,minh,d;
    minh = A[i];
    maxh = A[i + K - 1];
    d = maxh - minh;
    mind = min(d, mind);
  }
  cout << mind;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |   sort(A.begin(), A.end());
      |   ^~~~
      |   short
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>

int main()
{
    int N, K;
    std::cin >> N >> K;

    std::vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> H[i];
    }
    std::sort(H.begin(), H.end());

    int min = INT_MAX;

    for (int i = 0; i < N - K + 1; i++)
    {
        int r = H[i + K - 1];
        int l = H[i];
        min = std::min(min, r - l);
    }
    std::cout << min << std::endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: 'INT_MAX' was not declared in this scope
   20 |     int min = INT_MAX;
      |               ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <numeric>
  +++ |+#include <climits>
    7 |
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>

int main()
{
    int N, K;
    std::cin >> N >> K;

    std::vector<long long> H(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> H[i];
    }
    std::sort(H.begin(), H.end());

    long long min = LLONG_MAX;

    for (int i = 0; i < N - K + 1; i++)
    {
        long long r = H[i + K - 1];
        long long l = H[i];
        min = std::min(min, r - l);
    }
    std::cout << min << std::endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: error: 'LLONG_MAX' was not declared in this scope
   20 |     long long min = LLONG_MAX;
      |                     ^~~~~~~~~
a.cc:7:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <numeric>
  +++ |+#include <climits>
    7 |
Language: C++

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

int main(){
 int a,b,c;
  cin>>a>>b;
  vector<int> n(a);
 c=1000000000;
  for(int i=0;i<a;i++){
 cin>>n[i];
    }
  sort(n.bigin(),n.end())
  for(int i=0;i<a-b;i++){
c=min(c,abs(n[i]-n[i+b]));

  }
  cout<<<<endc

}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:10: error: 'class std::vector<int>' has no member named 'bigin'; did you mean 'begin'?
   12 |   sort(n.bigin(),n.end())
      |          ^~~~~
      |          begin
a.cc:13:15: error: 'i' was not declared in this scope
   13 |   for(int i=0;i<a-b;i++){
      |               ^
a.cc:17:9: error: expected primary-expression before '<<' token
   17 |   cout<<<<endc
      |         ^~
a.cc:17:11: error: 'endc' was not declared in this scope
   17 |   cout<<<<endc
      |           ^~~~
Language: C++

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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (auto& i : h)
        cin >> i;

    sort(h.begin(), h.end(), greater<int>());
    int minimum = pow(10, 9);
    for (int i = 0; i < N-K+1; i++) {
        minimum = min(minimum, h[i] - h[i + K - 1]);
    }

    cout << minimum << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:19: error: 'pow' was not declared in this scope
   15 |     int minimum = pow(10, 9);
      |                   ^~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    long long tmp;
    vector<long long> h;
    for(int i = 0; i< n; i++){
        cin >> tmp;
        h.push_back(tmp);
    }
    sort(h.begin(), h.end());
    vector<long long> diff(n-k+1);
    for(int i = 0; i<n-k+1;i++){
        diff[i] = h[i+2] - h[i];
    }
    sort(diff.begin(), diff.end());
    cout << diff[0] << endl;
}


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

#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int n,k;
int a[100005];
scanf("%d %d",&n,&k);
for(int i=0;i<n;i++)
{
scanf("%d",&h[i]);
}
sort(a,a+n);
int min=1000000005;
for(int i=0;i<n-k+1;i++)
{
if(a[i+k-1]-a[i]<min){min=a[i+k-1]-a[i];}
}
printf("%d\n",min);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: 'h' was not declared in this scope
   12 | scanf("%d",&h[i]);
      |             ^
Language: C++

#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int n,k;
int a[100005];
scanf("%d %d",&n,&k);
for(int i=0;i<n;i++)
{
scanf("%d",&h[i]);
}
sort(a,a+n);
int min=1000000005;
for(int i=0;i=n-k+;i++)
{
if(a[i+k-1]-a[i]<min){min=a[i+k-1]-a[i];}
}
printf("%d\n",min);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: 'h' was not declared in this scope
   12 | scanf("%d",&h[i]);
      |             ^
a.cc:16:19: error: expected primary-expression before ';' token
   16 | for(int i=0;i=n-k+;i++)
      |                   ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0); }

int main() {
  ull n, k;
  cin >> n >> k;

  vector<ull> h;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    h.push(tmp);
  }

  ull result = INF;
  sort_asc(h);
  for (auto i=(k-1); i < n; i++) {
    vector<ull> hh;
    each(j, k) {
      hh.push(h[i-j]);
    }
    auto current = max_value(hh) - min_value(hh);
    result = min({result, current});
  }

  cout << result << endl;

  return 0;
}


Compiler output:
a.cc:18:22: error: 'ULLONG_MAX' was not declared in this scope
   18 | constexpr auto INF = ULLONG_MAX;
      |                      ^~~~~~~~~~
a.cc:13:1: note: 'ULLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <utility>
  +++ |+#include <climits>
   13 |
Language: C++


using namespace std;
typedef long long ll;

int main()
{
  int n, k;
  vector<ll> h;
  cin >> n >> k;

  int a;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    h.push_back(a);
  }

  ll res = 1e+10;
  sort(h.begin(), h.end());
  for (int i = 0; i < n - k + 1; i++)
  {
    ll tmp = h[i + k - 1] - h[i];
    if (tmp < res)
    {
      res = tmp;
    }
  }

  cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<ll> h;
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | 
a.cc:8:12: error: expected primary-expression before '>' token
    8 |   vector<ll> h;
      |            ^
a.cc:8:14: error: 'h' was not declared in this scope
    8 |   vector<ll> h;
      |              ^
a.cc:9:3: error: 'cin' was not declared in this scope
    9 |   cin >> n >> k;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:19:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |   sort(h.begin(), h.end());
      |   ^~~~
      |   short
a.cc:29:3: error: 'cout' was not declared in this scope
   29 |   cout << res << endl;
      |   ^~~~
a.cc:29:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:29:18: error: 'endl' was not declared in this scope
   29 |   cout << res << endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 |
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, k; cin >> n >> k;
  vector<long> hs(n);
  for (int i = 0; i < n; ++i) {
    cin >> hs[i];
  }

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

  long min = 1000000000;
  for (int i = k - 1; i < n; ++i) {
    long sub = hs[i] - hs[i - k + 1];
    if (sub < min) min = sub;
  }

  cout << min << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |   sort(hs.begin(), hs.end());
      |   ^~~~
      |   short
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <stdlib.h>
int asc(const void *a, const void *b) {
   return *(int *)a - *(int *)b;
}
#define MIN(a,b) ((a)<(b)?(a):(b))
int main(void) {
   int N, K;
   int ans = 1000000010;
   int L[1000000];
   cin >> N;
   cin >> K;
   for (int i = 0; i < N; i++) {
      cin >> L[i];
   }
   qsort(L,N,sizeof (int), asc);
   for (int i = 0; i < N - K + 1; i++) {
      ans = MIN(ans, L[i+2] - L[i]);
   }
   cout << ans << endl;
}
　

Compiler output:
a.cc:23:1: error: extended character 　 is not valid in an identifier
   23 | 　
      | ^
a.cc:23:1: error: '\U00003000' does not name a type
   23 | 　
      | ^~
Language: C++

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

int main(){
    int n, k;
    cin >> n >> k;
    
    long long int trees[n];
    for(int i = 0; i < n; i++){
        cin >> trees[i];
    }
    sort(trees, trees+n);
    long long int ans = 0;
    for(int i = 0; i < n - k + 1; i++){
        if(i == 0){
            ans = trees[i + 2] - trees[i];
        }else{
            if(ans >= trees[i + 2] - trees[i]){
                ans = trees[i + 2] - trees[i];
            }
        }
    }
    cout << ans;
}

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

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

int main() {
  int n,k,min=1e9;
  cin >> n >> k;
  int a[n];
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  for(int i=0; i<n-k; i++) {
    min=min(min,a[n-k-1]-a[i]);
  cout << min << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: 'min' cannot be used as a function
   13 |     min=min(min,a[n-k-1]-a[i]);
      |         ~~~^~~~~~~~~~~~~~~~~~~
a.cc:15:2: error: expected '}' at end of input
   15 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;

  vector<int> h;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    h.push_back(tmp);
  }

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

  int diff = h[N - 1] - h[0];
  for (int i = 0; i <= N - K; i++) {
    int min = h[i];
    int max = h[i + K - 1];
    if (diff > max - min)
      diff = max - min;
  }

  cout << diff << endl;

  return 0;
}

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

#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}


int main() {
	int n, k;
	cin >> n >> k;
	int *h = new int[n];
	int *sum = new int[n+1];
	sum[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		sum[i + 1] = sum[i] + h[i];
	}
	sort(h, h + n);
	int min = INT_MAX;
	for (int i = 0; i <= n-k; i++) {
		int temp = h[i + k-1] - h[i];
		if (min > temp)min = temp;
	}
	cout << min;
	

	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:19: error: 'INT_MAX' was not declared in this scope
   66 |         int min = INT_MAX;
      |                   ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include<cmath>
  +++ |+#include <climits>
    9 | using namespace std;
a.cc: In function 'int find(std::vector<long long int>&, long long int)':
a.cc:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;

	vector<long long> list(N);
	for (int i = 0; i < N; i++)
	{
		cin >> list[i];
	}

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

	long long ans = LLONG_MAX;
	for (int i = 0; i < N - K + 1; i++)
	{
		ans = min(ans, list[i + K - 1] - list[i]);
	}

	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:25: error: 'LLONG_MAX' was not declared in this scope
   22 |         long long ans = LLONG_MAX;
      |                         ^~~~~~~~~
a.cc:6:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <cmath>
  +++ |+#include <climits>
    6 |
Language: C++

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;

  vector<ll> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());

  vector<ll> difs(N - K + 1, 0);

  for (int i = 0; i < N - K + 1; i++) {
    difs[i] = h[i + K - 1] - h[i];
  }

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

  cout << difs[0] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |   sort(h.begin(), h.end());
      |   ^~~~
      |   short
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
cin>>N>>K;
vector<int>h(N);
sort(begin.(),end());
cout<<h.at(N)-h.at(N-K)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:12: error: expected unqualified-id before '(' token
    7 | sort(begin.(),end());
      |            ^
a.cc:7:18: error: no matching function for call to 'end()'
    7 | sort(begin.(),end());
      |               ~~~^~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
                 from /usr/include/c++/14/bits/stl_algo.h:59,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:74:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:85:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:106:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1249:5: note: candidate: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/valarray:1265:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1265:5: note:   candidate expects 1 argument, 0 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; }


int main(){
    int N, K; cin >> N >> K;
    vi h(100005);
    rep(i, N) cin >> h[i];
    sort(ALL(h));
    int ans = INF;
    REP(i, k - 1, N){
        ans = min(ans, h[i] - h[i - k + 1]);
    }
    COUT(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:12: error: 'k' was not declared in this scope
   47 |     REP(i, k - 1, N){
      |            ^
a.cc:23:34: note: in definition of macro 'REP'
   23 | #define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
      |                                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; }


int main(){
    int N, K; cin >> N >> K;
    vi h(100001);
    REP(i, 1, N + 1) cin >> h[i];
    sort(h.begin() + 1, h.end() + 1);
    int ans = INF;
    REP(i, M, N + 1){
        ans = min(ans, a[i] - a[i - m + 1]);
    }
    COUT(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:12: error: 'M' was not declared in this scope
   47 |     REP(i, M, N + 1){
      |            ^
a.cc:23:34: note: in definition of macro 'REP'
   23 | #define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
      |                                  ^
a.cc:48:24: error: 'a' was not declared in this scope
   48 |         ans = min(ans, a[i] - a[i - m + 1]);
      |                        ^
a.cc:48:37: error: 'm' was not declared in this scope
   48 |         ans = min(ans, a[i] - a[i - m + 1]);
      |                                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    ll N = read(), K = read();
    vector<int> H(N);
    for(auto &h;H) h = read();
    sort(all(H));
    int ans=0;
    for(int i=0;i+K<=N;i++){
        ans = max(ans,H[i+K-1]-H[i]);
    }
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Compiler output:
a.cc: In function 'void Main()':
a.cc:8:9: error: declaration of 'auto& h' has no initializer
    8 |     for(auto &h;H) h = read();
      |         ^~~~
a.cc:8:17: error: could not convert 'H' from 'std::vector<int>' to 'bool'
    8 |     for(auto &h;H) h = read();
      |                 ^
      |                 |
      |                 std::vector<int>
a.cc:8:18: error: expected ';' before ')' token
    8 |     for(auto &h;H) h = read();
      |                  ^
      |                  ;