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


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <algorithm>
#include <functional>
using namespace std;


int main(){
	

	int i,j;
	int N,K;
	long long diff = LLONG_MAX;
	long long temp;
	
	cin >> N >> K;
	
	vector<long long>H(N);

	for (i = 0; i < N; i++){
		cin >> H.at(i);
	}

	/* 数値を降順にソート */
	sort(H.begin(), H.end(), greater<long long>());

	for (i = 0; i < N-K-1; i++){
		temp = H.at(i) - H.at(i + K - 1);

		if (temp < diff){
			diff = temp;
		}
	}

	cout << diff << endl;

	

	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int  main(void) {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    sort(h.begin(),h.end());
    int ans = 1e7;
    rep(i,n-k+1) ans = min(ans,h[i+k-x1]-h[i]);
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:38: error: 'x1' was not declared in this scope; did you mean 'y1'?
   20 |     rep(i,n-k+1) ans = min(ans,h[i+k-x1]-h[i]);
      |                                      ^~
      |                                      y1
Language: Java

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

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		List<Integer> tree = new ArrayList<>();
		
		// input
		final int NUM = scan.nextInt();
		int light = scan.nextInt();
		for(int i = 0; i < NUM; i++){
			tree.add(scan.nextInt()) ;
		}
		
		// sort
		Collections.sort(tree);
		
		// search
		long answer = Long.MAX_VALUE;
		for(int i = 0; i <= NUM - light; i++){
			if(tree.get(i+light-1) - tree.get(i) < answer){
				answer = tree.get(i+light-1) - tree.get(i);
			}
		}
		
		System.out.println(answer);
	}
}

Compiler output:
Main.java:19: error: cannot find symbol
		Collections.sort(tree);
		^
  symbol:   variable Collections
  location: class Main
1 error
Language: Java

import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		List<Integer> tree = new ArrayList<>();
		
		// input
		final int NUM = scan.nextInt();
		int light = scan.nextInt();
		for(int i = 0; i < NUM; i++){
			tree.add(scan.nextInt()) ;
		}
		
		// sort
		Collections.sort(tree);
		
		// search
		long answer = Long.MAX_VALUE;
		for(int i = 0; i <= NUM - light; i++){
			if(tree.get(i+light-1) - tree.get(i) < answer){
				answer = tree.get(i+light-1) - tree.get(i);
			}
		}
		
		System.out.println(answer);
	}
}

Compiler output:
Main.java:7: error: cannot find symbol
		List<Integer> tree = new ArrayList<>();
		^
  symbol:   class List
  location: class Main
Main.java:7: error: cannot find symbol
		List<Integer> tree = new ArrayList<>();
		                         ^
  symbol:   class ArrayList
  location: class Main
Main.java:17: error: cannot find symbol
		Collections.sort(tree);
		^
  symbol:   variable Collections
  location: class Main
3 errors
Language: C++

#include <bits/stdc++.h>

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, K;
	
	cin >> N >> K;
	
	vector<int> h(N);
	
	rep(i, N)
		cin >> h[i];
		
	sort(h.begin(), h.end());
	
	int ans = 1000000000;
	
	for(int i = 0; i < N - K; i++)
		ans = min(h[i + K] - h[i]);
	
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:26: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   27 |                 ans = min(h[i + K] - h[i]);
      |                       ~~~^~~~~~~~~~~~~~~~~
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:27:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |                 ans = min(h[i + K] - h[i]);
      |                       ~~~^~~~~~~~~~~~~~~~~
/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<iostream>
//#include<vector>
//#include<math.h>
#include<bits/stdc++.h

using namespace std;
#define rep(i,n) for(int i = 0; i<(int)(n);i++)
#define rep2(i,n) for(int i = 2; i<(int)(n); i++)

int main (void){

    int N, K;
    cin >> N >> K;
    
    vector <int> a (N);

    rep(i, N) cin >> a[i];

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

    int head,tail, score=100000000, min , max, temp;

    rep(i, N-K+1){
        head = i;
        tail = i + K-1;
        min = a[head];
        max = a[tail];

        temp = max -min;

        if(score>temp) score = temp;


    }

    cout << score;


}


Compiler output:
a.cc:4:23: error: missing terminating > character
    4 | #include<bits/stdc++.h
      |                       ^
Language: Java

import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] h = new long[N];
		for( int i=0; i<N; i++ ){
			h[i] = sc.nextLong();
		}
		Arrays.sort(h);
		long minium = 1000000000L
		for( int i=0; i<=N-K; i++ ){
			long ans = h[i-1+K] - h[i];
			minium = Math.min(ans,minium); 
		}
		System.out.println(minium);
	}
}


Compiler output:
Main.java:14: error: ';' expected
		long minium = 1000000000L
		                         ^
1 error
Language: C++

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    sort(all(h));
    int ans = 1e9;
    repi(i, N - K) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> N >> K;
      |     ^~~
a.cc:4:5: error: 'vector' was not declared in this scope
    4 |     vector<int> h(N);
      |     ^~~~~~
a.cc:4:12: error: expected primary-expression before 'int'
    4 |     vector<int> h(N);
      |            ^~~
a.cc:5:9: error: 'i' was not declared in this scope
    5 |     rep(i, N) cin >> h[i];
      |         ^
a.cc:5:5: error: 'rep' was not declared in this scope
    5 |     rep(i, N) cin >> h[i];
      |     ^~~
a.cc:6:14: error: 'h' was not declared in this scope
    6 |     sort(all(h));
      |              ^
a.cc:6:10: error: 'all' was not declared in this scope
    6 |     sort(all(h));
      |          ^~~
a.cc:6:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    6 |     sort(all(h));
      |     ^~~~
      |     short
a.cc:8:5: error: 'repi' was not declared in this scope
    8 |     repi(i, N - K) {
      |     ^~~~
a.cc:11:5: error: 'cout' was not declared in this scope
   11 |     cout << ans << endl;
      |     ^~~~
a.cc:11:20: error: 'endl' was not declared in this scope
   11 |     cout << ans << endl;
      |                    ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  ll n,k;
  cin>>n>>k;
  ll h[n];
  rep(i,n)cin>>h[i];
  sort(h.begin(),h.end());
  //もし、ｋ個同じ数のやつがあれば０
  ll ans=0;
  rep(i,n-1){
    if(h[i]==h[i+1]){
      ans++;
      if(ans==k){
        cout<<0<<endl;
        return 0;
      }
    }
    else ans=0;
  }
  cout<<h[k-1]-h[0]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:10: error: request for member 'begin' in 'h', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   20 |   sort(h.begin(),h.end());
      |          ^~~~~
a.cc:20:20: error: request for member 'end' in 'h', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   20 |   sort(h.begin(),h.end());
      |                    ^~~
Language: C++

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

typedef long long ll;
typedef long double ld;


#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())

const int MAX = 100000000;

int main() {
	int n, k, tmp;
	cin >> n >> k;
  vector<int> h;
  rep(i,n) {
    cin >> tmp;
    h.push_back(tmp);
  }
  sor(h);

  int min = MAX;
  int diff = 0;
  rep(i, n-k+1) {
    diff = h[i+k-1] - h[i];
    if (min >= diff) min = diff;
  }
	cout << min << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:16: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 | #define sor(v) sort(v.begin(),v.end())
      |                ^~~~
a.cc:26:3: note: in expansion of macro 'sor'
   26 |   sor(h);
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  long h[n];
  int i;
  for(i=0;i<n;i++){
    cin >> h[i];
  }

  sort(h,h+n);
  int distance[100000];
  for(i=1;i<n;i++){
    distance[h[i]-h[i-1]]++;
  }
  ans = 0;
  while(k>0){
    if(k>distance[ans]){
      k-=distance[ans];
      ans++;
    }else{
      break;
    }
  }

cout << ans;
  
}

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

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final int N=sc.nextInt();
    final int K=sc.nextInt();
    int[] h=new int[N];
    for(int i=0;i<N;i++){
      h[0]=sc.nextInt();
    }
    Arrays.sort(h);
    int min=0;
    for(int i=0;i<N-K;i++){
      int dif=h[i+K]-h[i];
      if(min>dif){
        min=dif;
      }
    }
    Sysem.out.println(min);
  }
}

Compiler output:
Main.java:20: error: package Sysem does not exist
    Sysem.out.println(min);
         ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
using ll = long long
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() { ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);}
const int maxn = 100000+5;
int k,n;
int h[maxn];
int main(){
    fastio();
    for(int i=0;i<n;i++) cin >> h[i];
    sort(h,h+n);
    int ans = INF;
    for(int i=0;i<n-k+1;i++)  ans = min(ans,h[i+k-1]-h[i]);
    
    cout << ans << endl;
}

Compiler output:
a.cc:7:10: error: expected ';' before 'INF'
    7 | const int INF = 1e9+7;
      |          ^~~~
      |          ;
a.cc: In function 'int main()':
a.cc:17:15: error: 'INF' was not declared in this scope
   17 |     int ans = INF;
      |               ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
long long int a,b,c[100010],d;

int main(){
  cin >> a >> b;
 for(int i=0;i<a;i++){
   cin >> c[i];
 }
  
  sort(c,c+a);
  d =1000000007
  for(int i=0;i<=a-b;i++){
   d = min(d,(c[i+b-1]-c[i]));
  }
  
  cout << d << endl;
}
    
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: expected ';' before 'for'
   16 |   d =1000000007
      |                ^
      |                ;
   17 |   for(int i=0;i<=a-b;i++){
      |   ~~~           
a.cc:17:15: error: 'i' was not declared in this scope
   17 |   for(int i=0;i<=a-b;i++){
      |               ^
Language: Java

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		int[] heights = new int[n];

		for(int i = 0; i < n; i++) {
			heights[i] = scan.nextInt();
		}

		scan.close();

		Arrays.sort(heights);

		for(int i = 0; i < n; i++) {
			System.out.println(heights[i]);
		}

		int minDiff = Integer.MAX_VALUE;
		for(int i = 0; i < k; i++) {
			int max = heights[i+k -1];
			int min = heights[i];
			int diff = max - min;
			if(minDiff > diff) minDiff = diff;
		}
		System.out.println(minDiff);
	}

}

Compiler output:
Main.java:4: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		                   ^
  symbol:   class Scanner
  location: class Main
Main.java:16: error: cannot find symbol
		Arrays.sort(heights);
		^
  symbol:   variable Arrays
  location: class Main
3 errors
Language: C

#include <stdio.h>
#include <stdlib.h>
int main(){
	int n;
	scanf("%d",&n);
    int k;
    scnaf("%d",&k);
    int tree[100000];
    for(int i = 0;i < n;i++){
    	scanf("%d",&tree[i]);
    }
    int tmp;
    for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (tree[i] > tree[j]) {
        tmp = tree[i];
        tree[i] = tree[j];
        tree[j] = tmp;
      }
    }
    int min = 1000000;
    for (i = 0; i < n - k; i ++){
    	if(abs(tree[i] - tree[i + k]) < min){
        	min = abs(tree[i] - tree[i + k]);
        }
    }
    printf("%d",&min);
}


Compiler output:
main.c: In function 'main':
main.c:7:5: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    7 |     scnaf("%d",&k);
      |     ^~~~~
      |     scanf
main.c:13:10: error: 'i' undeclared (first use in this function)
   13 |     for (i=0; i<n; ++i) {
      |          ^
main.c:13:10: note: each undeclared identifier is reported only once for each function it appears in
main.c:14:10: error: 'j' undeclared (first use in this function)
   14 |     for (j=i+1; j<n; ++j) {
      |          ^
main.c:28:1: error: expected declaration or statement at end of input
   28 | }
      | ^
Language: C++

#include <iostream>
#include <string>
#include <fstream>
#include<vector>
#include<utility>
#include<algorithm>


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 wk;
	int ans = INT_MAX;
	for (int i = 0; i < n - k + 1; i++) {
		wk = h[i + k - 1] - h[i];

		if (wk < ans)ans = wk;



	}

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



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

#include <bits/stdc++.h>

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

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> h(n);
	rep(i,n) scanf("%d",&h[i];)

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

	int ans=h[n-1]-h[0];
	rep(i,n-k+1) ans=min(ans,h[i+k-1]-h[i]);
	printf("%d\n",ans);

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:34: error: expected ')' before ';' token
   10 |         rep(i,n) scanf("%d",&h[i];)
      |                       ~          ^
      |                                  )
a.cc:10:35: error: expected primary-expression before ')' token
   10 |         rep(i,n) scanf("%d",&h[i];)
      |                                   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
    fastio();
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) { cin >> h[i]; }
    sort(all(h));
    int from_the_left = h[K] - h[0];
    int from_the_right = h[N - 1] - h[N - 1 - K + 1];

    co(((from_the_left <= from_the_right) ? from_the_left : from_the_right));
}#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
    fastio();
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) { cin >> h[i]; }
    sort(all(h));
    int from_the_left = h[K] - h[0];
    int from_the_right = h[N - 1] - h[N - 1 - K + 1];

    co(((from_the_left <= from_the_right) ? from_the_left : from_the_right));
}

Compiler output:
a.cc:24:2: error: stray '#' in program
   24 | }#include <bits/stdc++.h>
      |  ^
a.cc:24:3: error: 'include' does not name a type
   24 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:34:13: error: redefinition of 'void fastio()'
   34 | inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
      |             ^~~~~~
a.cc:11:13: note: 'void fastio()' previously defined here
   11 | inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
      |             ^~~~~~
a.cc:36:5: error: redefinition of 'int main()'
   36 | int main() {
      |     ^~~~
a.cc:13:5: note: 'int main()' previously defined here
   13 | int main() {
      |     ^~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: warning: overflow in conversion from 'long int' to 'int' changes value from '9876543210' to '1286608618' [-Woverflow]
   10 |     int ans  = 9876543210;
      |                ^~~~~~~~~~
a.cc:12:16: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   12 |       ans = min(ans,H[i+K-1]-H[i]);
      |             ~~~^~~~~~~~~~~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:12:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   12 |       ans = min(ans,H[i+K-1]-H[i]);
      |             ~~~^~~~~~~~~~~~~~~~~~~
/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, 2 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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:12:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |       ans = min(ans,H[i+K-1]-H[i]);
      |             ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'd' was not declared in this scope
   15 |                 d = v[K + i - 1] - v[i];
      |                 ^
Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 5min
int main(void){
  long long int h[100001];
  long long int n, k;
  long long int min = 0;
  
  scanf("%lld%lld", &n, &k);
  for(int i = 0; i < n; i++){
    scanf("%lld", &h[i]);
  }

  qsort(h, n, sizeof(long long int), compare_int);

  min = h[0] - h[k - 1];

  for(long long int i = 1; i < n - k + 1; i++){
    //    printf("i = %lld  h[i] = %lld h[i+k-1] = %lld\n", i, h[i], h[i + k - 1]);    if(h[i] - h[i + k - 1] < min){
      min = h[i] - h[i + k - 1];
      //      printf("minmin\n");
    }
  }

  printf("%lld\n", min);
  
  return 0;
}


Compiler output:
main.c:49:10: error: expected declaration specifiers or '...' before string constant
   49 |   printf("%lld\n", min);
      |          ^~~~~~~~
main.c:49:20: error: unknown type name 'min'
   49 |   printf("%lld\n", min);
      |                    ^~~
main.c:51:3: error: expected identifier or '(' before 'return'
   51 |   return 0;
      |   ^~~~~~
main.c:52:1: error: expected identifier or '(' before '}' token
   52 | }
      | ^
Language: C++

#include <cstdio>
#include <algorithm>

#define MAX 100000

int main()
{
	int N, K;
	long int h[MAX], ans[MAX];
	scanf("%d %d", &N, &K);
	for(int i=0; i<N; i++){
		scanf("%ld", &h[i]);
	}
	std::sort(h, h+N, std::greater<int>());
	for(int i=0; i<N-K; i++){
		ans[i] = h[i] - h[i+K-1];
	}
	std::sort(ans, ans+(N-K));
	printf("%ld\n", ans[0]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:32: error: 'greater' is not a member of 'std'
   14 |         std::sort(h, h+N, std::greater<int>());
      |                                ^~~~~~~
a.cc:14:40: error: expected primary-expression before 'int'
   14 |         std::sort(h, h+N, std::greater<int>());
      |                                        ^~~
Language: C++

#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n,k;
    cin>>n>>k;
    L h(n,0);
    for(int i=0  ;i<n  ;i++){
        cin>>h[i];
    }
    sorted(h);
    }
    long long ans=1e18;
    for(int i=0  ;i<n-k+1  ;i++){
//        cout<<h[i+k-1]-h[i]<<endl;
        ans=min(h[i+k-1]-h[i],ans);
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc:35:5: error: expected unqualified-id before 'for'
   35 |     for(int i=0  ;i<n-k+1  ;i++){
      |     ^~~
a.cc:35:19: error: 'i' does not name a type
   35 |     for(int i=0  ;i<n-k+1  ;i++){
      |                   ^
a.cc:35:29: error: 'i' does not name a type
   35 |     for(int i=0  ;i<n-k+1  ;i++){
      |                             ^
a.cc:39:5: error: 'cout' does not name a type; did you mean 'vcount'?
   39 |     cout<<ans<<endl;
      |     ^~~~
      |     vcount
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C++

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  ll n,k,ans=1000000000;
  cin>>n>>k;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  rep(i,n-k){
    ans=min(v[i+k-1]-v[i],ans);
  }
  cout<<ans<<endl;
}
///////////////////////////

Compiler output:
a.cc: In function 'int main()':
a.cc:77:12: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type, ll&)'
   77 |     ans=min(v[i+k-1]-v[i],ans);
      |         ~~~^~~~~~~~~~~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:77:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   77 |     ans=min(v[i+k-1]-v[i],ans);
      |         ~~~^~~~~~~~~~~~~~~~~~~
/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, 2 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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:77:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   77 |     ans=min(v[i+k-1]-v[i],ans);
      |         ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  ll n,k,ans=1000000000;
  cin>>n>>k;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  rep(i,n-k){
    ans=min(v[i+k-1]-v[i],ans);
  }
  cout<<ans<<endl;
}
///////////////////////////

Compiler output:
a.cc: In function 'int main()':
a.cc:77:12: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type, ll&)'
   77 |     ans=min(v[i+k-1]-v[i],ans);
      |         ~~~^~~~~~~~~~~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:77:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   77 |     ans=min(v[i+k-1]-v[i],ans);
      |         ~~~^~~~~~~~~~~~~~~~~~~
/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, 2 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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:77:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   77 |     ans=min(v[i+k-1]-v[i],ans);
      |         ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

inline abs(int a, int b)
{
    return ((a - b) >= 0 ? (a - b):-1*(a - b));
}

const int Nmax = 1e5 + 1;
int a[Nmax];
int N,K,Dif_min;

int main()
{
    cin >> N >> K;
    for(int i = 1; i <= N; ++i)
        cin >> a[i];
    sort(a + 1,a + N + 1);
    Dif_min = (1 << 31) - 1;
    for(int i = 1; i <= N - K + 1; ++i)
        Dif_min = min(Dif_min,abs(a[i] - a[i + K - 1]));
    cout << Dif_min;
    return 0;
}


Compiler output:
a.cc:6:8: error: ISO C++ forbids declaration of 'abs' with no type [-fpermissive]
    6 | inline abs(int a, int b)
      |        ^~~
a.cc: In function 'int main()':
a.cc:21:25: warning: integer overflow in expression of type 'int' results in '2147483647' [-Woverflow]
   21 |     Dif_min = (1 << 31) - 1;
      |               ~~~~~~~~~~^~~
Language: C++

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

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

  vector<int> diff(n-1);
  rep(i,n-1) diff[i] = h[i+1] - h[i];

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

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

  vector<int> diff(n-1);
  rep(i,n-1) diff[i] = h[i+1] - h[i];
  //rep(i,n-1) cout << diff[i] <<" ";

  ll ans = 1e18;
  for(int i = 0; i+(k-2) < (n-2); i++){
    ll nowans = 0;
    for(int j = i; j < i+(k-1); j++) {
      nowans += diff[i];
    }
    ans = min(ans , nowans);
  }
  cout << ans << endl;
}

  ll nowans = 0;
  for(int i = 0; i+(k-2) < (n-2); i++){
    for(int j = i; j < i+(k-1); j++) {
      nowans += diff[i];
    }
    ans = min(ans , nowans);
  }
  cout << ans << endl;
}


Compiler output:
a.cc:15:17: error: stray '#' in program
   15 |   ll ans = 1e18;#include <bits/stdc++.h>
      |                 ^
a.cc: In function 'int main()':
a.cc:15:18: error: 'include' was not declared in this scope
   15 |   ll ans = 1e18;#include <bits/stdc++.h>
      |                  ^~~~~~~
a.cc:15:27: error: 'bits' was not declared in this scope
   15 |   ll ans = 1e18;#include <bits/stdc++.h>
      |                           ^~~~
a.cc:15:32: error: 'stdc' was not declared in this scope; did you mean 'std'?
   15 |   ll ans = 1e18;#include <bits/stdc++.h>
      |                                ^~~~
      |                                std
a.cc:17:1: error: expected primary-expression before 'using'
   17 | using namespace std;
      | ^~~~~
a.cc:20:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   20 | int main() {
      |         ^~
a.cc:20:9: note: remove parentheses to default-initialize a variable
   20 | int main() {
      |         ^~
      |         --
a.cc:20:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:20:12: error: a function-definition is not allowed here before '{' token
   20 | int main() {
      |            ^
Language: C++

#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	ll n, k,diff=LLONG_MAX;
	in(n);
	in(k);

	vll h(n);
	rep(i, 0, n) {
		in(h[i]);
	}

	sort(h.begin(), h.end());
	repeq(i, 0, n - k) {
		diff = min(h[i + k - 1] - h[i], diff);
	}
	outn(diff);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:22: error: 'LLONG_MAX' was not declared in this scope
   27 |         ll n, k,diff=LLONG_MAX;
      |                      ^~~~~~~~~
a.cc:9:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include<map>
  +++ |+#include <climits>
    9 | #include<string>
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <array>
#include <map>
#include <string>

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

using namespace std;
using ll = long long;

void main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(3, 0);
	for (int i = 0; i < n; i++) cin >> h[i];

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

	int ans = h[n - 1];
	for (int i = 0; i < n - k; i++)
	{
		ans = min(h[i + k - 1] - h[i], ans);
	}

	cout << ans << endl;
}

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  int ans = mod;
  rep(i, n+1-k) {
    int cans = c[k-1-i] - c[i];
    ans = min(ans, cans);
  }
  cout << ans << endl;
}

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

#include<iostream>
#include<vector>
#include<deque>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    deque<int> h(N);
    for(int i=0; i<N; i++){
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());
    int m = 1000*1000;
    for(int i=0; i<N-K+1; i++){
        if(m>h.at(i+K-1)-h.at(i)){
            m = h.at(i+K-1)-h.at(i);
        }
    }
    cout << m << 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: Java

import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] h = sc.nextInt();
      int min = 1000000000;
      for(int i = 0;i < n;i++)h[i] = sc.nextInt();
      Arrays.sort(h);
      for(int i = 0;i <= n-k;i++){
      	min = Math.min(min,h[i+k-1]-h[i]);
      }
      System.out.println(min);
    }
}

Compiler output:
Main.java:7: error: incompatible types: int cannot be converted to int[]
      int[] h = sc.nextInt();
                          ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
//char型から数値型に変換する関数（z.at(i)などに使用）
int ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  int64_t n,k;
  cin>>n>>k;
  vector<int64_t> h(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
  }
  sort(h.begin(),h.end());
  vector<int64> sa(n-k+1);
  for(int i=0;i<(n-k+1);i++){
    sa.at(i)=h.at(k-1+i)-h.at(0+i);
  }
  sort(sa.begin(),sa.end());
  cout<<sa.at(0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:10: error: 'int64' was not declared in this scope
   18 |   vector<int64> sa(n-k+1);
      |          ^~~~~
a.cc:18:15: error: template argument 1 is invalid
   18 |   vector<int64> sa(n-k+1);
      |               ^
a.cc:18:15: error: template argument 2 is invalid
a.cc:20:8: error: request for member 'at' in 'sa', which is of non-class type 'int'
   20 |     sa.at(i)=h.at(k-1+i)-h.at(0+i);
      |        ^~
a.cc:22:11: error: request for member 'begin' in 'sa', which is of non-class type 'int'
   22 |   sort(sa.begin(),sa.end());
      |           ^~~~~
a.cc:22:22: error: request for member 'end' in 'sa', which is of non-class type 'int'
   22 |   sort(sa.begin(),sa.end());
      |                      ^~~
a.cc:23:12: error: request for member 'at' in 'sa', which is of non-class type 'int'
   23 |   cout<<sa.at(0);
      |            ^~
Language: Java

import java.util.*;

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

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

package newbie;

import java.util.*;

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

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

n,k = map(int,input().split())
H = [int(input()) for i in range(n)]
H.sort()
D = []
for i in range(n-k+1):
    D += [H[i+k-1]-H[i]]
print(min(D))

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

import java.util.*;

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


Compiler output:
Main.java:9: error: illegal start of expression
		for (int i = 0; i < ; i++) {
		                    ^
1 error
Language: C++

/******************************************************************************
 
                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
 
*******************************************************************************/
 
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int n, k;
int a[100005];
long long ans=1e9;
 
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort (a+1, a+n+1);
    for (int i = k+1; i <= n; i++) ans=min(ans, a[i]-a[i-k]);
    cout << ans;
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:43: error: no matching function for call to 'min(long long int&, int)'
   23 |     for (int i = k+1; i <= n; i++) ans=min(ans, a[i]-a[i-k]);
      |                                        ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:9:
/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:   template argument deduction/substitution failed:
a.cc:23:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   23 |     for (int i = k+1; i <= n; i++) ans=min(ans, a[i]-a[i-k]);
      |                                        ~~~^~~~~~~~~~~~~~~~~~
/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, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:10:
/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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:23:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   23 |     for (int i = k+1; i <= n; i++) ans=min(ans, a[i]-a[i-k]);
      |                                        ~~~^~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
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;
  for (int i = 0; i < N-K+1; i++) {
    ans = min(ans, h[K-1+i]-h[i]);
  }

  cout << ans << endl;

  return 0;
}


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>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'a' was not declared in this scope
   15 |         m=min(m,a[i+k-1]-a[i]);
      |                 ^