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

#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
int main() {
	ll n,k;
  	cin >> n >> k;
  	vector<ll> h(n);
  	rep(i,n){
      cin >> h[i];
    }
  	ll ans = INF;
  	sort(all(x));
  	ll temp = h[0];
  	rep(i,n){
      if((i + 1) % k == 0){
        chmin(ans, h[i] - temp);
        if(i != (n-1)) temp = h[i + 1];
      }
    }
    
  	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:18: error: 'x' was not declared in this scope
   29 |         sort(all(x));
      |                  ^
a.cc:2:17: note: in definition of macro 'all'
    2 | #define all(x) (x).begin(),(x).end()
      |                 ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
const int INF = 1000000004
int main () {
  int N, K;
  cin >> N >> K;
  vector<int>hei(N);
  for (int i = 0; i < N; i ++) {
    cin >> hei[i];
  }
  for (int i = 0; i < N; i ++) {
    for (int j = 1; i < N; j ++) {
      if (hei[j - 1] > hei[j]) swap(hei[j - 1], hei[j]);
    }
  }
  int ans = INF;
  for (int i = 0; i < N - K; i ++) {
    int jun = hei[i + K] - hei[i];
    if (ans > jun) ans = jun;
  }
  cout << ans << endl;
}

Compiler output:
a.cc:5:1: error: expected ',' or ';' before 'int'
    5 | int main () {
      | ^~~
Language: Java

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

public class Main

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final int counter = scanner.nextInt();
		final int diff = scanner.nextInt();
		final int[] trees = new int[counter];

		for (int i = 0; i < counter; i++) {
			trees[i] = scanner.nextInt();
		}

		Arrays.sort(trees);

		final int[] diffs = new int[counter - diff + 1];
		for (int i = 0; i < counter - diff + 1; i++) {
			diffs[i] = trees[i + diff - 1] - trees[i];
		}

		System.out.println(min(diffs));
	}

	public static int min(int[] array) {
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] < min) {
				min = array[i];
			}
		}
		return min;
	}

}

Compiler output:
Main.java:4: error: '{' expected
public class Main
                 ^
Main.java:6: error: unnamed classes are a preview feature and are disabled by default.
	public static void main(String[] args) {
	              ^
  (use --enable-preview to enable unnamed classes)
Main.java:36: error: class, interface, enum, or record expected
}
^
3 errors
Language: C++

#include <iostream>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
const int MAX_N = int(1e5) + 10;
const int INF = 1e9;

int K,N;
int h[MAX_N];

int main()
{
  cin >> N >> K;
  REP(i,0,N) cin >> h[i];

  sort(h, h+N);

  int res = INF;
  REP(i,0,N) {
    if (i+K-1 >= N) break;
    chmin(res, h[i+K-1] - h[i]);
  }
  cout << res << endl;

  return 0;
}


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

N, K = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))

h.sort()

ans = 10 ** 9
for i in range(N-K+1):
    print(h[i:i+K])
    ans = min(ans, max(h[i:i+K])-min(h[i:i+K]))

print(ans)

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

#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int n, k, m, s;
	int h[100000];
	int c[]
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	sort(h, h + n);
	m = (1 << 30);
	for (int i = 0; i < n - k+1; i++) {
		s = h[i+k-1]-h[i];
		m = min(m, s);
	}
	cout << m << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: expected initializer before 'cin'
   13 |         cin >> n >> k;
      |         ^~~
Language: C++

#include <iostream>

using namespace std;

long long K, N;

int main(){
    cin >> N >> K;
    long long l[N];

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

    sort(l, l + N); 

    long long min_score = l[N-1];

    for (int i = 0; i < N - K + 1 ; i++ ){
        if (min_score > l[i + K - 1] - l[i]) min_score =  l[i + K - 1] - l[i];
    }

    cout << min_score << endl;

    return 0;
}

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(l, l + N);
      |     ^~~~
      |     short
Language: C++

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

using namespace std;

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

	vector<int> inputs;
	for (int i = 0; i < n; ++i)
	{
		int input;
		cin >> input;
		inputs.push_back(input);
	}

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

	int min = INT_MAX;
	for (int i = 0; i < n - k; ++i)
	{
		int diff = inputs[i+k-1] - inputs[i];
		cout << diff << endl;
		if (min > diff) min = diff;
	}

	cout << min << endl;
}

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

// https://atcoder.jp/contests/abc115/tasks/abc115_c

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
    int n, k, hmin = INT_MAX;
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    int h[n];

    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h, h + n);

    // 小さい順に並び替えた後、k個の高さの差を計算する
    for (int i = 0; i < n - k + 1; i++) {
        hmin = min(hmin, h[i + k - 1] - h[i]);
    }

    cout << hmin << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: 'INT_MAX' was not declared in this scope
   11 |     int n, k, hmin = INT_MAX;
      |                      ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <iostream>
  +++ |+#include <climits>
    5 | #include <string>
Language: C++

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

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

  ll sum = 0;
  vector<ll> vec(n);
  for (int i = 0 ; i < n; i++) {
    cin >> vec[i];
    sum += vec[i];
  }
  
  ll avg = sum / n;
  for (int i = 0 ; i < n; i++) {
    vec[i] = abs(vec[i] - avg);
  }
  sort(vec.begin(), vec.end());
  
  ll minv = LLONG_MAX;
  ll maxv = 0;
  for (int i = 0; i < k; i++) {
    maxv = max(maxv, vec[i]);
    minv = min(minv, vec[i]);
  }
  cout << maxv - minv << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:13: error: 'LLONG_MAX' was not declared in this scope
   32 |   ll minv = LLONG_MAX;
      |             ^~~~~~~~~
a.cc:10:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <queue>
  +++ |+#include <climits>
   10 | #include <sstream>
Language: C++

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

int main() {
 int n,k;
  cin>>n>>k;
  
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);}
  for(int i=0;i<n-1;i++){
    vec.at(i)=vec.at(i+1)-vec.at(i);}
  vec.at(n-1)=1000000003
  sort(vec.begin(),vec.end());
  int sum=0;
  for(int j=0;j<k-1:j++)
  {sum+=vec.at(j);}
  cout <<sum <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:25: error: expected ';' before 'sort'
   13 |   vec.at(n-1)=1000000003
      |                         ^
      |                         ;
   14 |   sort(vec.begin(),vec.end());
      |   ~~~~                   
a.cc:16:15: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   16 |   for(int j=0;j<k-1:j++)
      |               ^
a.cc:16:20: error: expected ';' before ':' token
   16 |   for(int j=0;j<k-1:j++)
      |                    ^
      |                    ;
a.cc:19:1: error: expected primary-expression before '}' token
   19 | }
      | ^
a.cc:18:21: error: expected ')' before '}' token
   18 |   cout <<sum <<endl;
      |                     ^
      |                     )
   19 | }
      | ~                    
a.cc:16:6: note: to match this '('
   16 |   for(int j=0;j<k-1:j++)
      |      ^
a.cc:19:1: error: expected primary-expression before '}' token
   19 | }
      | ^
Language: C++

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

int main() {
  int N,K;
  cin >> N >> K;
  
  vector<int> tree(N);
  //木の高さ
  
  for(int i=0;i<N;i++){
    cin >>tree.at(i);
  }
  
  sort(tree.begin(),tree.end());
  //小さい方からに並び替え

  vector<int> dif(N-1);
  //n番目に小さいのとn+1番目に小さいのの差

  for(int j=0;j<N-1;j++){
    dif.at(j)=tree.at(j+1)-tree.at(j);
  }
  
  vector<int> hdif(N-K);
  //K個内でのMAX-minの候補
  
  for(int k=0;k<N-K;k++){
    for(int l=0;l<K;l++){
      int a;
      a+=dif.at(i);
    }
    hdif.at(k)=a;
  }
  
  sort(hdif.begin(),hdif.end());
  cout << hdif(0) <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: 'i' was not declared in this scope
   31 |       a+=dif.at(i);
      |                 ^
a.cc:33:16: error: 'a' was not declared in this scope
   33 |     hdif.at(k)=a;
      |                ^
a.cc:37:15: error: no match for call to '(std::vector<int>) (int)'
   37 |   cout << hdif(0) <<endl;
      |           ~~~~^~~
Language: C++

#include <algorithm>
#include <iostream>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  int h[n];
  for (int i = 0; i < n; i++) {
    cin >> n[k];
  }
  sort(h);
  h_diff_min = 1e10
  for (int l = 0; l + k <= n; l++) {
    int h_diff = h[l] - h[l+k-1];
    if (h_diff < h_diff_min) {
      h_diff_min = h_diff;
    }
  }
  cout << h_diff_min << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: invalid types 'int[int]' for array subscript
   10 |     cin >> n[k];
      |             ^
a.cc:12:7: error: no matching function for call to 'sort(int [n])'
   12 |   sort(h);
      |   ~~~~^~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 1 provided
a.cc:13:3: error: 'h_diff_min' was not declared in this scope
   13 |   h_diff_min = 1e10
      |   ^~~~~~~~~~
a.cc:14:19: error: 'l' was not declared in this scope
   14 |   for (int l = 0; l + k <= n; l++) {
      |                   ^
Language: Java

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

public class Christmans {

    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(minimalDistance(A, K));
    }

    private static int minimalDistance(int[] a, int k) {
        Arrays.sort(a);
        int low = Integer.MAX_VALUE;
        for (int i = 0; i <= a.length - k; i++) {
            if (low > (a[i + k - 1] - a[i])) {
                low = a[i + k - 1] - a[i];
            }
        }
        return low;
    }
}

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

#include <bits/stdc++.h>

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000;

int h[MAXN + 2];

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


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

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

int main() {
    int n,k;
    int h[100000];
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h,h+n);
    int min = -1;
    int diff = 0;
    for(int i = 0; i < n - k + 1; i++){
        diff = h[i+k-1] - h[i];
        if(min < 0 || min > diff)
            min = diff;
        diff = 0;
    }
    cout << min << endl;
}



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

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

int N, K, H[101010];

void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> H[i];
    sort(H, H + N);
 
    int ans = inf;
    rep(L, 0, N - K + 1) {
        int R = L + K - 1;
        chmin(ans, H[R] - H[L]);
    }
    cout << ans << endl;
}

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

int N, K, H[101010];

void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> H[i];
    sort(H, H + N);
 
    int ans = inf;
    rep(L, 0, N - K + 1) {
        int R = L + K - 1;
        chmin(ans, H[R] - H[L]);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'void _main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> N >> K;
      |     ^~~
a.cc:5:9: error: 'i' was not declared in this scope
    5 |     rep(i, 0, N) cin >> H[i];
      |         ^
a.cc:5:5: error: 'rep' was not declared in this scope
    5 |     rep(i, 0, N) cin >> H[i];
      |     ^~~
a.cc:6:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    6 |     sort(H, H + N);
      |     ^~~~
      |     short
a.cc:8:15: error: 'inf' was not declared in this scope; did you mean 'int'?
    8 |     int ans = inf;
      |               ^~~
      |               int
a.cc:9:9: error: 'L' was not declared in this scope
    9 |     rep(L, 0, N - K + 1) {
      |         ^
a.cc:13:5: error: 'cout' was not declared in this scope
   13 |     cout << ans << endl;
      |     ^~~~
a.cc:13:20: error: 'endl' was not declared in this scope
   13 |     cout << ans << endl;
      |                    ^~~~
Language: C++

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    vec.push_back(tmp);
  }
  sort(vec.begin(), vec.end());

  int ans = INT_MAX;
  for (int i = K - 1; i < N; i++) {
    int hmin = vec[i - K + 1];
    int hmax = vec[i];
    int diff = hmax - hmin;
    ans = min(ans, diff);
  }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: 'INT_MAX' was not declared in this scope
   18 |   int ans = INT_MAX;
      |             ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <vector>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

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

int main() {
    int N,K;
    cin >> N >> K;
  	long long h[1100] = {0};
    for(int i = 0; i < N; ++i) cin >> h[i];
    ans = 0;
    sort(h,h+N);
    ans = h[K] - h[0];
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 |     ans = 0;
      |     ^~~
      |     abs
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N,K,Min = 1000000000;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++)cin >> h[i];
  
  sort(h.begin(),h.end());
  for(int i=0;i<=N-K;i++){
    Min=min(Min,h[i+k-1]-h[i]);
  }
  
  cout << Min << endl;
  
  return 0;
}


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

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N,K,Min = 1000000000;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++)cin >> h[i];
  
  sort(h.begin(),h.end());
  for(int i=0;i<=N-K;i++){
    Min=min(Min,h[i+k]-h[i]);
  }
  
  cout << Min << endl;
  
  return 0;
}


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

l = map(long, raw_input().split())

height = []
for i in range(l[0]):
    height.append(long(input()))
    
height.sort()
print height

diff = 1000000000000L
for x in range(len(height)-l[1]+1):
  print height[x+l[1]-1] - height[x]
  if diff > height[x+l[1]-1] - height[x]:
    diff = height[x+l[1]-1] - height[x]
    
print diff

Compiler output:
a.cc:1:1: error: 'l' does not name a type
    1 | l = map(long, raw_input().split())
      | ^
Language: C

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

int main(void){
  int n, k;
  int h[100000];
  int min = 1000000;
  scanf("%d %d", &n, &k);
  int i;
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &h[i]);
  }
  qsort(h, n, sizeof(int), compare_int);
  for ( i = 0; i < n - k; i++ ) {
    if ( h[i+k-1] - h[i] < min ) {
      min = h[i+k-1] - h[i];
    }
  }
  printf("%d\n", min);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:13:28: error: 'compare_int' undeclared (first use in this function)
   13 |   qsort(h, n, sizeof(int), compare_int);
      |                            ^~~~~~~~~~~
main.c:13:28: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main(){
    int N,K,M;
    M=10000000;
    cin >> N >> K;
    int h[N];
    for (int i=0; i<N; ++i) cin >> h[i];
    sort (h,h+N);
    for (int i=0; i<=N-K; ++i){
        M=min(M,h[i+k-1]-h[i]);
    }
    cout << M << endl;
}


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

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

int main(){
    int N,K,M;
    cin >> N >> K;
    int h[N];
    for (int i=0; i<N; ++i) cin >> h[i];
    sort (h,h+N,grater<int>());
    int s[N-K];
    for (int i=0; i<N-K; ++i){
        s[i]=h[i]-h[i+K];
        M=min(M,s[i]);
    }
    cout << M << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'grater' was not declared in this scope
   11 |     sort (h,h+N,grater<int>());
      |                 ^~~~~~
a.cc:11:24: error: expected primary-expression before 'int'
   11 |     sort (h,h+N,grater<int>());
      |                        ^~~
Language: C++

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

int main(){
    int N,K,M;
    cin >> N >> K;
    int h[N];
    for (int i=0; i<N; ++i) cin >> h[i];
    sort (h,h+N,grater<int>());
    int s[N-K];
    for (int i=0; i<N-K; ++i){
        s[i]=h[i]-h[i+K];
        M=min(M,s[i]);
    }
    cout << M << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: 'grater' was not declared in this scope
   10 |     sort (h,h+N,grater<int>());
      |                 ^~~~~~
a.cc:10:24: error: expected primary-expression before 'int'
   10 |     sort (h,h+N,grater<int>());
      |                        ^~~
Language: C++

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

int main(){
    int N,K,M;
    cin >> N >> K;
    int h[N];
    for (int i=0; i<N: ++i) cin >> h[i];
    sort (h,h+N,grater<int>());
    int s[N-K];
    for (int i=0; i<N-K; ++i){
        s[i]=h[i]-h[i+K];
        M=min(M,s[i]);
    }
    cout << M << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
    9 |     for (int i=0; i<N: ++i) cin >> h[i];
      |                   ^
a.cc:9:22: error: expected ';' before ':' token
    9 |     for (int i=0; i<N: ++i) cin >> h[i];
      |                      ^
      |                      ;
a.cc:10:17: error: 'grater' was not declared in this scope
   10 |     sort (h,h+N,grater<int>());
      |                 ^~~~~~
a.cc:10:24: error: expected primary-expression before 'int'
   10 |     sort (h,h+N,grater<int>());
      |                        ^~~
a.cc:11:5: error: expected primary-expression before 'int'
   11 |     int s[N-K];
      |     ^~~
a.cc:10:32: error: expected ')' before 'int'
   10 |     sort (h,h+N,grater<int>());
      |                                ^
      |                                )
   11 |     int s[N-K];
      |     ~~~                         
a.cc:9:9: note: to match this '('
    9 |     for (int i=0; i<N: ++i) cin >> h[i];
      |         ^
a.cc:13:9: error: 's' was not declared in this scope
   13 |         s[i]=h[i]-h[i+K];
      |         ^
Language: C++

#include <bits/stdc++.h>

#define MAXN (100010)

int h[MAXN];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &h[i]);
    }
    std::sort(h + 1, h + n + 1);
    int hmin = INT32_MAX;
    for (int i = 1; i + k - 1 <= n ; ++i) {
        hmin = std::min(hmin, h[i+k-1] - h[i]);
    }
    printf("%d", hmin);


Compiler output:
a.cc: In function 'int main()':
a.cc:18:24: error: expected '}' at end of input
   18 |     printf("%d", hmin);
      |                        ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C

#include<stdio.h>

void swap(int *x,int *y){
  int tmp;
  tmp = *x;*x = *y;*y = tmp;
}

void sort(int *tree,int size){
  for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){
      if(*(tree+i)<*(tree+j)) swap(tree+i,tree+j);
    }
  }
}



int main(){
  int n,k,tree_height[100000];
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++) scanf("%d",&tree_height[i]);
  sort(&tree_height[0],n);
  for(int i=0;i<n-k;i++){
      if(tree_height[i+K-1]-tree_height[i]<tmp) tmp=tree_height[i+K-1]-tree_height[i];
  }  
  printf("%d",tmp);
  return 0;
}



Compiler output:
main.c: In function 'main':
main.c:24:24: error: 'K' undeclared (first use in this function)
   24 |       if(tree_height[i+K-1]-tree_height[i]<tmp) tmp=tree_height[i+K-1]-tree_height[i];
      |                        ^
main.c:24:24: note: each undeclared identifier is reported only once for each function it appears in
main.c:24:44: error: 'tmp' undeclared (first use in this function)
   24 |       if(tree_height[i+K-1]-tree_height[i]<tmp) tmp=tree_height[i+K-1]-tree_height[i];
      |                                            ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <limits.h>
#include <conio.h>
using namespace std;

#define Rep(i,n) for(int i = 0; i < n; ++i )

long N, K;
long H[100001];

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

	cin >> N >> K;
	Rep(i,N)
		cin >> H[i];
	sort(H,H+N);
	long v,minV = LONG_MAX;
	Rep(i,N-K+1){
		v = H[i+K-1]-H[i];
		if( v < minV )
			minV = v;
	}
	cout << minV;
}

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

#include <stdlib.h>
#include <stdio.h>
#define MAX 10000
int compare ( const void * a , const void * b ) {
    // Visual C++ ではキャストが必要。
    const int * pa = a;
    const int * pb = b;
    // printf("%d - %d = %d\n", *pa, *pb, *pa - *pb);
    return *pa - *pb;
}
int main ( void ) {
    // 整列前のデータ
    int i;
    int amo=0;
    int num=0;
    int data[MAX];
    int min = 10000;
    
    scanf("%d",&amo);
    scanf("%d",&num);
    
    for(i = 0;i < amo; i++){
    	scanf("%d",&data[i]);
    }
    for(i = amo;i < MAX;i++){
    	data[i] = 0;
    }
    
    qsort(data,
          sizeof(data) / sizeof(data[0]),
          sizeof(data[0]),
          compare);
    // 整列後のデータ （ 1 2 3 4 5 ）
    for (i = 0; i < sizeof(data) / sizeof(data[0]); i++) {
    	if(data[i] != 0){
    		if(min > data[i+num-1] - data[i] && data[i+num-1] - data[i] >= 0){
    		    //printf("%d ", data[i]);
    			min = data[i+num-1] - data[i];
    		}
    	}
    }
    printf("%d",min);
    //printf("\n");
    
        return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int compare(const void*, const void*)':
a.cc:6:22: error: invalid conversion from 'const void*' to 'const int*' [-fpermissive]
    6 |     const int * pa = a;
      |                      ^
      |                      |
      |                      const void*
a.cc:7:22: error: invalid conversion from 'const void*' to 'const int*' [-fpermissive]
    7 |     const int * pb = b;
      |                      ^
      |                      |
      |                      const void*
Language: C++

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

vector<int> hs;
int n, k;
int main() {
 	cin >> n >> k;
  	hs.resize(n, 0);
  	for (int i = 0; i < n; i++) cin >> hs[i];
  	sort(hs.begin(), hs.end());
  	int ans = hs[k - 1] - hs[0];
  	for (int i = k - 1; i < n; i++) ans = min(ans, hs[i] - hs[i - k + 1]);
  	cout << ans << endl;
}

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

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

vector<int> hs;
int main() {
 	cin >> n >> k;
  	hs.resize(n, 0);
  	for (int i = 0; i < n; i++) cin >> hs[i];
  	int ans = hs[k - 1] - hs[0];
  	for (int i = k - 1; i < n; i++) ans = min(ans, hs[i] - hs[i - k + 1]);
  	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:16: error: 'n' was not declared in this scope
    7 |         cin >> n >> k;
      |                ^
a.cc:7:21: error: 'k' was not declared in this scope
    7 |         cin >> n >> k;
      |                     ^
Language: Java

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

public class Christmas_Eve_solution {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] nums = new int[n];
		for(int i=0; i<n; i++) {
			nums[i] = sc.nextInt();
		}
		
		Arrays.sort(nums);
		int min = Integer.MAX_VALUE;
		
		for(int i=0; i<=nums.length-k; i++) {
			min = Math.min(nums[nums.length-k+i]-nums[i], min);
		}
		System.out.println(min);
	}
}


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

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Christmas_Eve {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] nums = new int[n];
		for(int i=0; i<n; i++) {
			nums[i] = sc.nextInt();
		}
		
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		List<Integer> list = new ArrayList<Integer>();
		boolean[] used = new boolean[n];
		int res = Integer.MAX_VALUE;
		dfs(lists, list, k, nums, used);
		
		for(int i=0; i<lists.size(); i++) {
			List<Integer> tmpList = lists.get(i);
			int tmpvalue = 0;
			for(int j=0; j<tmpList.size(); j++) {
				tmpvalue = Collections.max(tmpList) -Collections.min(tmpList);
			}
			res = Math.min(tmpvalue, res);
		}
		System.out.println(res);
		
	}

	private static void dfs(List<List<Integer>> lists, List<Integer> list, 
			int k, int[] nums, boolean[] used) {
		if(k<0) {
			return;
		}else if(k==0) {
			lists.add(new ArrayList<Integer>(list));
		}else {
			for(int i=0; i<nums.length; i++) {
				if(used[i] || (i>0 && used[i-1]==false && nums[i]==nums[i-1])) {
					continue;
				}
				used[i] = true;
				list.add(nums[i]);
				dfs(lists, list, k-1, nums, used);
				list.remove(list.size()-1);
				used[i] = false;
			}
		}
	}
}


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

#include<iostream>
using namespace std;
void swap (int& a, int& b) {
  int t = a;
  a = b;
  b = t;
}
const int p = 100000;
int main () {
  int N, K;
  cin >> N >> K;
  int h[p];
  int k[p];
  for (int i = 0; i < N; i ++) {
    cin >> h[i];
  }
  for(int i = 0; i < N; i ++) {
    for(int j = 1; j < N; j ++) {
      if (a[j - 1] > a[j]) swap(a[j - 1], a[j]);
    }
  }
  int min = a[N - 1] - a[0];
  for (int i = 0; i < N - K; i ++) {
    int sa = a[i + K] - a[i];
    if (min > sa) min = sa;
  }
  cout << min << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:11: error: 'a' was not declared in this scope
   19 |       if (a[j - 1] > a[j]) swap(a[j - 1], a[j]);
      |           ^
a.cc:22:13: error: 'a' was not declared in this scope
   22 |   int min = a[N - 1] - a[0];
      |             ^
Language: C

#include <stdio.h>

int main(){
  int num,t;
  scanf("%d %d",&num,&t);
  
  int p[num],i,j,tmp,sa;
  
    for(i=0;i<num;i++){
    scanf("%d",&p[i]);
  }
  
  for(i=0;i<num-1;i++){
    for(j=i+1;j<num;j++){
      if(p[j]>p[i]){
        tmp = p[j];
        p[j]=p[i];
        p[i]=tmp;
      }
    }
  }
  ans = p[0]-p[t];
  for(i=1;i<num-t;i++){
    sa = p[i]-p[i+t];
    if(ans > sa) ans = sa;
  }
  
  printf("%d\n",ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:22:3: error: 'ans' undeclared (first use in this function)
   22 |   ans = p[0]-p[t];
      |   ^~~
main.c:22:3: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

int main(){
  int num,t;
  scanf("%d %d",&num,&t);
  
  int p[num],i,j,tmp,sa,t;
  
    for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  
  for(i=0;i<num-1;i++){
    for(j=i+1;j<num;j++){
      if(p[j]>p[i]){
        tmp = p[j];
        p[j]=p[i];
        p[i]=tmp;
      }
    }
  }
  ans = p[0]-p[t];
  for(i=1;i<num-t;i++){
    sa = p[i]-p[i+t];
    if(ans > sa) ans = sa;
  }
  
  printf("%d\n",ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:7:25: error: redeclaration of 't' with no linkage
    7 |   int p[num],i,j,tmp,sa,t;
      |                         ^
main.c:4:11: note: previous declaration of 't' with type 'int'
    4 |   int num,t;
      |           ^
main.c:9:15: error: 'n' undeclared (first use in this function)
    9 |     for(i=0;i<n;i++){
      |               ^
main.c:9:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:22:3: error: 'ans' undeclared (first use in this function)
   22 |   ans = p[0]-p[t];
      |   ^~~
Language: C++

#include<iostream>

using namespace std;

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

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

  sort(h, h + N);

  int ans = 1e9;
  for (int i = K -1; i < N; i++) {
    ans = min(ans, h[i] - h[i - 2]);
  }

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

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

#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <string>
using namespace std;
#define ll long long int
#define mp  std::make_pair
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << v << endl;

int main(int argc, const char * argv[]) {
	int K,N,h;
	cin >> N >> K;
	map<int,int> hmap;
	for (int i = 0; i < N; ++i) {
		cin >> h;
		map<int,int>::iterator itr= hmap.find(h);
		if(itr==hmap.end()){
			hmap.insert(mp(h,1));
		}else{
			int v = itr->second;
			hmap.erase(itr);
			hmap.insert(mp(h,v+1));
		}
	}
	
//	int ret_hmin,ret_hmax,ret_diff=1000000000,sum=0;
//	map<int,int>::iterator hmin_itr,hmax_itr,hend_itr;
//	hend_itr = hmap.end();hend_itr--;
//	hmin_itr = hmap.begin();
//	while(true){
//		sum=0;
//		for(hmax_itr = hmin_itr;
//				hmax_itr != hmap.end() && sum < K;hmax_itr++){
//			sum += hmax_itr->second;
//		}
//		hmax_itr--;
//		if(sum < K) break;
//		for(; sum - hmin_itr->second >= K;hmin_itr++){
//			sum -= hmin_itr->second;
//			if(distance(hmin_itr,hmax_itr)==0) break;
//		}
//
//		int diff = hmax_itr->first - hmin_itr-> first;
//		if(diff < ret_diff){
//			ret_hmin = hmin_itr->first;
//			ret_hmax = hmax_itr->first;
//			ret_diff = diff;
//		}
//		if(hmax_itr == hend_itr) break;
//		hmin_itr++;
//	}

	cout << ret_diff << endl;

}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:57:17: error: 'ret_diff' was not declared in this scope
   57 |         cout << ret_diff << endl;
      |                 ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int arr[N];

int main(){
	int n,k;
  	cin>>n>>k;
  	for(int i=0;i<n;i++)
      cin>>arr[i];
  	int ans = INT_MAX;
  	for(int i=0;i<n-k+1;i++)
      if(arr[i+k-1]-arr[i] < ans)
        ans = arr[i+k-1] - arr[i];
  
  	cout<<ans<<endl;
  	return 0
      
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: expected ';' before '}' token
   17 |         return 0
      |                 ^
      |                 ;
   18 | 
   19 | }
      | ~
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: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;


public class A {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), k = sc.nextInt();
		Integer [] a = new Integer[n];
		for (int i = 0; i < a.length; ++i) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int min = a[k-1] - a[0];
		for (int i = 1; i+k-1 < n; ++i) {
			min = Math.min(min, a[i+k-1] - a[i]);
		}
		out.println(min);
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}

}


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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;


public class A {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), k = sc.nextInt();
		Integer [] a = new Integer[n];
		for (int i = 0; i < a.length; ++i) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int min = a[k-1] - a[0];
		for (int i = 1; i < n; ++i) {
			min = Math.min(min, a[i+k-1] - a[i]);
		}
		out.println(min);
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}

}


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

n, x = map(int, input().split(' '))
lst = []
for i in range(n):
	lst.append(int(input()))
lst.sort()
minn = 999999999999
for i in range(0, n-x+1):
	if lst[i+x]-lst[i] < minn:
		minn = lst[i+x] - lst[i]
print(minn)

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

#include <iostream>
using namespace std;
int main(){
    int n,k;
    long h[100000];
    cin>>n>>k;
    for (size_t i = 0; i < n; i++) {
        cin>>h[i];
    }
    sort(h, h+n);
    int min;
    int sub;
for (size_t i = 0; i < n-k; i++) {
    sub = h[i+k] - h[i];
    if(min>sub)min=sub;
}
cout<<sub;
}


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

#include<bits/stdc++.h>

using namespace std;

void solve(int n,int k, vector<int> arr)
{
	sort(arr.begin(),arr.end());
  	int ans=1e9+9;
  	for (int i=0;i<(n-k);i++)
    {
    	ans=min(ans,arr[i+k]-arr[i]);
    }
    cout<<ans;
}
void input()
{
	int n,k;
  	cin>>n>>k;
  	vector<int> arr(n);
  	for (int i=0;<n;i++)
      cin>>arr[i];
  	solve(n,k,arr);
}
int main()
{
	input();
}

Compiler output:
a.cc: In function 'void input()':
a.cc:20:22: error: expected primary-expression before '<' token
   20 |         for (int i=0;<n;i++)
      |                      ^
Language: C

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

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

int main(){
	int N,K,i,min;
	int h[100000]={'0'};
	unsinged int res= 1000000001;
	scanf("%d %d\n",&N,&K);
	for(i = 0; i < N; i++) scanf("%d\n",&h[i]);

	qsort(h,N,sizeof(h[0]),com);

	for(i = 0;i+K-1<N;i++){
		min = h[i+K-1]-h[i];
		res = min < res ? min : res;
	}
	printf("%d\n",res);

	return 0;

}

Compiler output:
main.c: In function 'main':
main.c:12:9: error: 'unsinged' undeclared (first use in this function)
   12 |         unsinged int res= 1000000001;
      |         ^~~~~~~~
main.c:12:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:12:17: error: expected ';' before 'int'
   12 |         unsinged int res= 1000000001;
      |                 ^~~~
      |                 ;
main.c:20:17: error: 'res' undeclared (first use in this function)
   20 |                 res = min < res ? min : res;
      |                 ^~~
Language: C++

#include <iostream>
2.#include <algorithm>
3.using namespace std;
4. 
5.int main(){
6.  int N,K;
7.  cin >> N;
8.  cin >> K;
9.  
10.  int a[N];
11.  int m=0;
12.  
13.  for(int i=0;i<N;i++){
14.    cin >> a[i];
15.  }
16.  sort(a,a+N);
17.  
18.  int h;
19.  h= a[K-1]-a[0];
20.  
21.  for(int x=0;x<N-K+1;x++){
22.    if(a[x-1+K]-a[x]>a[x+K]-a[x+1]){
23.      h=a[x+K]-a[x+1];
24.    }
25.  }
26.  
27.  cout << h;
28.  
29.  return 0;
30.}
31.  


Compiler output:
a.cc:2:3: error: stray '#' in program
    2 | 2.#include <algorithm>
      |   ^
a.cc:2:1: error: expected unqualified-id before numeric constant
    2 | 2.#include <algorithm>
      | ^~
a.cc:4:1: error: expected unqualified-id before numeric constant
    4 | 4.
      | ^~
a.cc:31:1: error: expected unqualified-id before numeric constant
   31 | 31.
      | ^~~
Language: C++

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

#define INF 1000000000
int main()
{
  int N, K;
  long min;
  cin >> N >> K;
  vector<long> h(N);
  for(int i = 0; i < N; i++)
    cin >> h[i];
  sort(h.begin(), h.end());
  min = INF;
  for(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;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |   cin >> N >> K;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:3: error: 'vector' was not declared in this scope
   11 |   vector<long> h(N);
      |   ^~~~~~
a.cc:11:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:11:10: error: expected primary-expression before 'long'
   11 |   vector<long> h(N);
      |          ^~~~
a.cc:13:12: error: 'h' was not declared in this scope
   13 |     cin >> h[i];
      |            ^
a.cc:14:8: error: 'h' was not declared in this scope
   14 |   sort(h.begin(), h.end());
      |        ^
a.cc:14:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   14 |   sort(h.begin(), h.end());
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:20:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |   cout << min;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <iosteam>
#include <vector>
#include <algorithm>

#define INF 1000000000
int main()
{
  int N, K;
  long min;
  cin >> N >> K;
  vector<long> h(N);
  for(int i = 0; i < N; i++)
    cin >> h[i];
  sort(h.begin(), h.end());
  min = INF;
  for(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;
}
    

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

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

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


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

#include <stdio.h>
#include <string.h>
#include <algorithm>

int main(int argc, char* argv[])
{
    long n, k;
    scanf("%ld %ld", &n, &k);

    long h[100000];

    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &(h[i]));
    }
    std::sort(h, h+n);

    long min = LONG_MAX;
    for(i=k-1; i<n; i++) {
        long value = h[i]-h[i-(k-1)];
        if(min > value) {
            min = value;
        }
    }

    printf("%d\n", min);

    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:18:16: error: 'LONG_MAX' was not declared in this scope
   18 |     long min = LONG_MAX;
      |                ^~~~~~~~
a.cc:4:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 |
Language: C++

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

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

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

#include <iostream>

using namespace std;
int main() {
    int n, k;
    cin >> n >> k;

    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a, a + n);

    int ans = 9999;
    for (int i = 0; i < n - k + 1; i++)
        ans = min(ans, a[i + k - 1] - a[i]);

    cout << ans << endl;

    return 0;
}

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