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

#include<stdio.h>
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;  
return;  
}

int main(void)
{
int a,b,i,j,c;
long int min=999999999;
  scanf("%d %d",&a,&b);
long int hi[a];
  for(i=0;i<a;++i)
  {
  scanf("%ld",&hi[i]);
  }
c=a;
  for(i=0;i<a-1;i++)
  {
   for(j=0;j<c-1;++j)
   {
   if(hi[j]>hi[j+1]) swap(&hi[j],&hi[j+1]);
   c--;  
   } 
  }

  for(i=0;i<a+1-b;++i)
  {
   if(hi[j+b-1]-hi[j]<min) min=hi[j+b-1]-hi[j];
  }
  printf("%ld",min)
  
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:26:27: error: passing argument 1 of 'swap' from incompatible pointer type [-Wincompatible-pointer-types]
   26 |    if(hi[j]>hi[j+1]) swap(&hi[j],&hi[j+1]);
      |                           ^~~~~~
      |                           |
      |                           long int *
main.c:2:16: note: expected 'int *' but argument is of type 'long int *'
    2 | void swap(int *a,int *b)
      |           ~~~~~^
main.c:26:34: error: passing argument 2 of 'swap' from incompatible pointer type [-Wincompatible-pointer-types]
   26 |    if(hi[j]>hi[j+1]) swap(&hi[j],&hi[j+1]);
      |                                  ^~~~~~~~
      |                                  |
      |                                  long int *
main.c:2:23: note: expected 'int *' but argument is of type 'long int *'
    2 | void swap(int *a,int *b)
      |                  ~~~~~^
main.c:35:20: error: expected ';' before 'return'
   35 |   printf("%ld",min)
      |                    ^
      |                    ;
   36 | 
   37 | return 0;
      | ~~~~~~
Language: C++

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  }
  sort(h.begin(), h.end(), greater<int>());
  int result = 2,147,483,647;
  for(int i = 0; i < (N-K); i++){
    tmp = h.at(i) - h.at(i+K-1);
    if(result > tmp){
      result = tmp;
    }
  }
  cout << tmp << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: expected unqualified-id before numeric constant
   12 |   int result = 2,147,483,647;
      |                  ^~~
a.cc:14:5: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   14 |     tmp = h.at(i) - h.at(i+K-1);
      |     ^~~
      |     tm
a.cc:19:11: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   19 |   cout << tmp << endl;
      |           ^~~
      |           tm
Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long ll;

int	desc(const void *a, const void *b)
{
	long *A = (long *)a;
	long *B = (long *)b;
	if (*B > *A) return 1;
	if (*B < *A) return -1;
	return 0;
}

int asc(const void *a, const void *b) {
	long *A = (long *)a;
	long *B = (long *)b;
	if (*A > *B) return 1;
	if (*A < *B) return -1;
	return 0;
}


int main()
{
	int n,k;
	scanf("%d%d", &n,&k);
	long h[n];
	long d[n-1];
	long i = 0;
	while (i < n)
	{
		scanf("%ld", &h[i]);
		i++;
	}
	qsort(h, sizeof h / sizeof *h , sizeof *h, desc);
	long j;
	i = 0;
	long min = __LONG_MAX__;
	long sum;
	while (i <= n - k)
	{
		j = i;
		sum = 0;
		// printf("%ld\n", h[i]);
		while (j < (i + k) - 1)
		{
			sum += h[j] - h[j + 1];
			j++;
		}
		// printf("min = %ld\n", sum);
		if (sum <= min)
			min = sum;
		i++;
	}
	printf("%ld", min);

Compiler output:
main.c: In function 'main':
main.c:56:9: error: expected declaration or statement at end of input
   56 |         printf("%ld", min);
      |         ^~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: no matching function for call to 'min(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   13 |     s=min(s,a[i+k]-a[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:13:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   13 |     s=min(s,a[i+k]-a[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:13:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |     s=min(s,a[i+k]-a[i]);
      |       ~~~^~~~~~~~~~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: no matching function for call to 'min(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   13 |     s=min(s,a[i+k]-a[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:13:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   13 |     s=min(s,a[i+k]-a[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:13:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |     s=min(s,a[i+k]-a[i]);
      |       ~~~^~~~~~~~~~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'num' was not declared in this scope; did you mean 'enum'?
   14 |     cout << num << endl;
      |             ^~~
      |             enum
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: request for member 'begin' in 'h', which is of non-class type 'int [n]'
    9 |     sort(h.begin(),h.end());
      |            ^~~~~
a.cc:9:22: error: request for member 'end' in 'h', which is of non-class type 'int [n]'
    9 |     sort(h.begin(),h.end());
      |                      ^~~
a.cc:14:13: error: 'num' was not declared in this scope; did you mean 'enum'?
   14 |     cout << num << endl;
      |             ^~~
      |             enum
Language: C++

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

#define ll long long
#define vecll vector<long long>
#define vecs vector<string>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll n, k, v=0;
  cin >> n >> k;
  vecll h(n);
  forll(i, 0, n)
	cin >> h[i];
  sort(h.begin(), h.end());

  forll(i, 0, n-k){
	v = min(v, h[i + k -1] - h[i])
  }
  cout << v << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:39: error: expected ';' before '}' token
   24 |         v = min(v, h[i + k -1] - h[i])
      |                                       ^
      |                                       ;
   25 |   }
      |   ~
Language: Java

import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line1;
        line1 = sc.nextLine();
        String[] k_n_s = line1.split(" ");
        int N = Integer.parseInt(k_n_s[0]);
        int K = Integer.parseInt(k_n_s[1]);
        int[] kn = new int[N];
        for (int i=0;i<N;i++){
            kn[i] = Integer.parseInt(sc.nextLine());
        }
        // System.out.println("\n");
        Arrays.sort(kn);
        // System.out.println("=======");
        // for (int k:kn){
          // System.out.println(k);
        // }
        // final int INF = (int)Math.pow(10, 9) + 7;
        Long min = 1000000000L;
        int diff = 0L;
        // int min = INF;

        for(int i=0;i<N-K+1;i++){
            diff = kn[K-1+i]-kn[i];
            if (min > diff){
                min = diff;
            }
        }
        // System.out.println("\n");
        // System.out.println("min:");
        System.out.println(min);
    }
}


Compiler output:
Main.java:24: error: incompatible types: possible lossy conversion from long to int
        int diff = 0L;
                   ^
Main.java:30: error: incompatible types: int cannot be converted to Long
                min = diff;
                      ^
2 errors
Language: Java

mport java.util.Arrays;
import java.util.Scanner;
 
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 < h.length; i++) {
            h[i] = sc.nextInt();
        }
        Arrays.sort(h);
        final int INF = (int)Math.pow(10, 9) + 7;
        int dif = INF;
        for (int i = 0; i < h.length - K + 1; i++) {
            dif = Math.min(dif, h[K - 1 + i] - h[i]);
        }
        System.out.println(dif);
        sc.close();
    }
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.Arrays;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.Scanner;
^
2 errors
Language: C++

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

int main(){
 N, K = map(int, input().split());
 h = [int(input()) for i in range(N)];
 h.sort();
 cout << min(h[i+K-1] - h[i] for i in range(N-K+1)) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:2: error: 'N' was not declared in this scope
    5 |  N, K = map(int, input().split());
      |  ^
a.cc:5:5: error: 'K' was not declared in this scope
    5 |  N, K = map(int, input().split());
      |     ^
a.cc:5:18: error: 'input' was not declared in this scope; did you mean 'int'?
    5 |  N, K = map(int, input().split());
      |                  ^~~~~
      |                  int
a.cc:5:12: error: missing template arguments before '(' token
    5 |  N, K = map(int, input().split());
      |            ^
a.cc:5:13: error: expected primary-expression before 'int'
    5 |  N, K = map(int, input().split());
      |             ^~~
a.cc:6:2: error: 'h' was not declared in this scope
    6 |  h = [int(input()) for i in range(N)];
      |  ^
a.cc:6:7: error: expected identifier before 'int'
    6 |  h = [int(input()) for i in range(N)];
      |       ^~~
a.cc: In lambda function:
a.cc:6:38: error: expected '{' before ';' token
    6 |  h = [int(input()) for i in range(N)];
      |                                      ^
a.cc: In function 'int main()':
a.cc:8:16: error: 'i' was not declared in this scope
    8 |  cout << min(h[i+K-1] - h[i] for i in range(N-K+1)) << endl;
      |                ^
Language: C++

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

int main(){
 N, K = map(int, input().split());
 h = [int(input()) for i in range(N)];
 h.sort();
 cout << min(h[i+K-1] - h[i] for i in range(N-K+1)) << endl;
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: no matching function for call to 'min(long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   11 |     m=min(m,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:11:10: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   11 |     m=min(m,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:11:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   11 |     m=min(m,h[i+K-1]-h[i]);
      |       ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n,k; cin >> n >> k;
  vector<int> H;
  for(int i=0;i<n;i++){
    int h; cin >> h;
    H.push_back(h);
  }
  sort(H.begin(),H.end());
  int ans=2e9;
  for(int i=0;i<=n-k;i++){
    int res = h[i+k-1]-h[i];
    ans = min(ans,res);
  }
  cout << ans << endl;
}

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

#include<algorithm>
#include<stdio.h>
#define min(i, j) (i) < (j) ? (i) : (j)
int main() {
    int n, k, h[100010], i, minn = 1000000010;
    scanf("%d%d", &n, &k);
    for(i = 1; i <= n; ++i) scanf("%d", &h[i]);
    std::sort(h + 1, h + 1 + n);
    for(i = 1; i <= n - k + 1; ++i) minn = min(minn, h[i + k - 1] - h[i]);
    printf("%d\n", minn);
    return 0;
}

Compiler output:
main.c:1:9: fatal error: algorithm: No such file or directory
    1 | #include<algorithm>
      |         ^~~~~~~~~~~
compilation terminated.
Language: Java

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());

    int[] h = new int[N];

    for (int i = 0; i < N; i++) {
      h[i] = Integer.parseInt(sc.next());
    }
    int ans = (int) 10e9;
    Arrays.sort(h);
    for (int j = 0; j <= N - K; j++) {
      if (h[j + K - 1] - h[j] < ans)
        ans = h[j + K - 1] - h[j];
    }

    System.out.println(ans);
  }
}

Compiler output:
Main.java:8: error: cannot find symbol
    FastScanner sc = new FastScanner();
    ^
  symbol:   class FastScanner
  location: class Main
Main.java:8: error: cannot find symbol
    FastScanner sc = new FastScanner();
                         ^
  symbol:   class FastScanner
  location: class Main
2 errors
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,k;
    cin>>n>>k;
    vector<int64_t> h(n);
    rep(i,n) cin>>h.at(i);
    sort(h.begin(),h.end());
    long long sa=INF;
    rep(i,n-k+1){
        sa=min(sa,h.at(i+k-1)-h.at(i));
    }
    cout<<sa<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:15: error: no matching function for call to 'min(long long int&, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   22 |         sa=min(sa,h.at(i+k-1)-h.at(i));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
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: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:22:15: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   22 |         sa=min(sa,h.at(i+k-1)-h.at(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,
                 from a.cc:4:
/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:22:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 |         sa=min(sa,h.at(i+k-1)-h.at(i));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

N,K = map(int, input().split())
A = [list(map(int,input().split())) for i in range(N)]

def bubble_sort(arr):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i] > arr[i + 1]:
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
    return arr

B=[]
for i in range(N):
    B.append(A[i][0])
    
C=bubble_sort(B)

ans = C[K-1] - C[0]
for i in range(N-K+1):
    if ans > C[i+K-1] -C[i]:
        ans = C[i+K-1] -C[i]
        
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 <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int n,k;
llint p[15];

void solve(){
	cin >> n >> k;
	llint h[n];
	for(int i=0;i<n;i++)cin >> h[i];
	sort(h,h+n);
	llint x=h[k-1]-h[0];
	for(int i=0;i<n-k+1<i++){
		if(x>h[k+i-1]-h[i])x=h[k+i-1]-h[i];
	}
	cout << x << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:29:32: error: expected ';' before ')' token
   29 |         for(int i=0;i<n-k+1<i++){
      |                                ^
      |                                ;
Language: C++

#include <bits\stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main()
{
	int n, k; cin >> n >> k;
	int a[100005];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 1e9;
	sort(a, a + n, greater<int>());
	for (int i = k-1; i < n; i++)
		ans = min(ans, a[i - k+1] - a[i]);
	cout << ans;
}

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

#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<map>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define LSTAGE 1
#define max 10000007


bool binary(ll r[], ll st, ll ed,const ll& key, ll& m)
{
    ll mid;
    while(st<=ed)
    {
        mid = (st+ed)/2;
        if(r[mid]==key)
        {
            m = mid;

            return true;
        }
        else if(r[mid]< key)
        {
            ed = mid - 1;
        }
        else
            st = mid + 1;
    }
    m = 0;
//    cout <<"False\n";
    return false;
}

int main()
{
    int n , k;
    cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr+n);

    int m = INT_MAX;
    for(int  i= n - 1; i >= k-1; i--) m = min(m,arr[i]-arr[i-k+1]);
    cout << m;



}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:13: error: 'INT_MAX' was not declared in this scope
   57 |     int m = INT_MAX;
      |             ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include<utility>
  +++ |+#include <climits>
   12 | #define ul unsigned long long int
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

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 = INT_MAX;
    rep(i,n-k+1) {
        ans = min(ans, h[i+k-1]-h[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;int main(){int n, k, ans=INT_MAX;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+1;i++)ans=min(ans, h[i+k-1]-h[i]);cout<<ans<<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:2:205: error: expected '}' at end of input
    2 | using namespace std;int main(){int n, k, ans=INT_MAX;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+1;i++)ans=min(ans, h[i+k-1]-h[i]);cout<<ans<<endl;
      |                               ~                                                                                                                                                                             ^
Language: Java

import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt(),i=0;
        int[]a=new int[n];
        for(;i<n;){
            a[i++]=sc.nextInt();
        }
        Arrays.sort(num);
        int sum=1000000000;
        for(i=0;i+m-1<n;i++){
            sum=Math.min(sum,a[i+m-1]-a[i]);
        }
        System.out.print(sum);
    }
}


Compiler output:
Main.java:16: error: cannot find symbol
        Arrays.sort(num);
                    ^
  symbol:   variable num
  location: class Main
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k,a[100001],ans=-99999,sum;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
for(int i=1;i<=n-K+1;i++)
{
sum=a[i+k-1]-a[i];
ans=max(sum,ans);
}
cout<<ans<<endl;
return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define fin(ans) cout << (ans) << endl;
#define all(a) a.begin(), a.end()
template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}
template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}
void Main()
{
  ll n, k; cin >> n >> k;
  vll h(n); V(h);
  Sort(h);
  ll ans = MAX;
  for(ll i = 0;i < n - k + 1;i++)
  {
    ll a = abs(h[i] - h[i + k - 1]);
    ans = min(ans, a);
  }
  fin(ans);
  return;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  Main();
  return 0;
}

Compiler output:
a.cc: In function 'void Main()':
a.cc:32:12: error: 'MAX' was not declared in this scope
   32 |   ll ans = MAX;
      |            ^~~
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 = 1001001001;
    for(int i = 0; i <= n - k; i++){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << 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.begin(), h.end());
      |     ^~~~
      |     short
Language: C++

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

int main() {

  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<int> tree(n);
  for(int i=0; i<n; i++) cin >> tree(i);
  
  sort(tree.begin(),tree.end());
  
  int ans=1000000001;
  for(int i=0; i<n-k+1; i++) {
    ans=min(ans, tree.at(k-1+i)-tree.at(i));
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:37: error: no match for call to '(std::vector<int>) (int&)'
   11 |   for(int i=0; i<n; i++) cin >> tree(i);
      |                                 ~~~~^~~
Language: C

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

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


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
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 = 1000000000;
    for(int i = k-1; i < n; i++){
        if (ans > h[i] - h[i-k+1]) {
            ans = h[i] - h[i-k+1];
        }
    }
    cout << ans << '\n';
}

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>
#include <algorithm>
#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<int> h(n);
    rep(i,n)  cin>>h[i];

    sort(h.begin,h.end);
    int ans=1000000009;
    rep(i,n-k) {
          ans=min(ans,h[i+k-1]-h[i]);
    }

    cout<<ans<<endl;

 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: no matching function for call to 'sort(<unresolved overloaded function type>, <unresolved overloaded function type>)'
   14 |     sort(h.begin,h.end);
      |     ~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/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:   template argument deduction/substitution failed:
a.cc:14:9: note:   couldn't deduce template parameter '_RAIter'
   14 |     sort(h.begin,h.end);
      |     ~~~~^~~~~~~~~~~~~~~
/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, 2 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, 2 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, 2 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k,a[100001],ans=-99999;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
for(int i=1;i<=n-k+1;i++)
{
sum=a[i+k-1]-a[i];
ans=max(sum,ans);
}
cout<<ans<<endl;
return 0;
}

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

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int a[100008];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int min=999999999;
	int cha=0;
	for(int i=0;i<=n-k;i++)
	{
		cha=a[i+k-1]-a[i];
		if(cha<min)
		min=cha;
	}
	printf("%d\n",min);
	return 0;
}





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

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

H.sort()
ans = 100007
print(H)
for i in range(0,len(H)-K+1):
	# print(H[i],H[i+K-1],len(H)-K-1)
	if ans >= H[i+K-1] - H[i]:
		ans =  H[i+K-1] - H[i]
		# print(ans)
print(ans)



Compiler output:
a.cc:10:11: error: invalid preprocessing directive #print
   10 |         # print(H[i],H[i+K-1],len(H)-K-1)
      |           ^~~~~
a.cc:13:19: error: invalid preprocessing directive #print
   13 |                 # print(ans)
      |                   ^~~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N,K = map(int,input().split())
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll lonog long
int main()
{
    ll i,a,b,d,ar[100005],mn=1000000000;

    cin>>a>>b;
    for(i=0;i<a;i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+a);

    for(i=0;i<a;i++)
    {
        d=abs(ar[i]-ar[i+b-1]);
        if(d<mn)
        mn=d;

    }

    cout<<mn<<endl;





    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:12: error: 'lonog' was not declared in this scope; did you mean 'long'?
    3 | #define ll lonog long
      |            ^~~~~
a.cc:6:5: note: in expansion of macro 'll'
    6 |     ll i,a,b,d,ar[100005],mn=1000000000;
      |     ^~
a.cc:8:10: error: 'a' was not declared in this scope
    8 |     cin>>a>>b;
      |          ^
a.cc:8:13: error: 'b' was not declared in this scope
    8 |     cin>>a>>b;
      |             ^
a.cc:9:9: error: 'i' was not declared in this scope
    9 |     for(i=0;i<a;i++)
      |         ^
a.cc:11:14: error: 'ar' was not declared in this scope
   11 |         cin>>ar[i];
      |              ^~
a.cc:13:10: error: 'ar' was not declared in this scope
   13 |     sort(ar,ar+a);
      |          ^~
a.cc:15:9: error: 'i' was not declared in this scope
   15 |     for(i=0;i<a;i++)
      |         ^
a.cc:17:9: error: 'd' was not declared in this scope
   17 |         d=abs(ar[i]-ar[i+b-1]);
      |         ^
a.cc:18:14: error: 'mn' was not declared in this scope; did you mean 'yn'?
   18 |         if(d<mn)
      |              ^~
      |              yn
a.cc:23:11: error: 'mn' was not declared in this scope; did you mean 'yn'?
   23 |     cout<<mn<<endl;
      |           ^~
      |           yn
Language: C++

#include <bits/stdc++.h>

using namespace std;
int n,p[12345];
signed main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>p[i];
	sort(p,p+n);
	
	for(int i=0;i<n-1;i++){
		a+=p[i];
	}
	a+=p[n-1]/2;
	cout<<a<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'a' was not declared in this scope
   11 |                 a+=p[i];
      |                 ^
a.cc:13:9: error: 'a' was not declared in this scope
   13 |         a+=p[n-1]/2;
      |         ^
Language: C

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,i,l,sum,sum1,j;
    scanf("%d%d",&n,&k);
    int a[n+5];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
   sum=a[k-1]-a[0];
   sum1=a[n-1]-a[n-k];
   if(sum1<sum)
    sum=sum1;
   printf("%d\n",sum);
   return 0;
}



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

#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

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

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

print(ans)

Compiler output:
main.c:1:2: error: invalid preprocessing directive #coding
    1 | #coding: utf-8
      |  ^~~~~~
main.c:2:1: error: unknown type name 'import'
    2 | import math
      | ^~~~~~
main.c:3:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'import'
    3 | import heapq
      | ^~~~~~
main.c:3:1: error: unknown type name 'import'
main.c:6:2: error: invalid preprocessing directive #from
    6 | #from scipy.misc import comb
      |  ^~~~
Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k;
  cin>>n>>k;
  vll x(n);
  rep(i,n) cin>>x[i];
  sort(all(x));
  ll k=INF;
  for(int i=0;i<=n-k;i++){
    k=min(k,x[i+k-1]-x[i]);
  }
  COUT(k);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:6: error: redeclaration of 'long long int k'
   44 |   ll k=INF;
      |      ^
a.cc:39:8: note: 'long long int k' previously declared here
   39 |   ll n,k;
      |        ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  long long dif=(1 << 33);
  for (int i=0; i <= n-k; i++){
    if (dif > v[i+k-1]-v[i]) dif=v[i+k-1]-v[i];
  }
  cout << dif << endl;
  return 0;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |   sort(v.begin(),v.end());
      |   ^~~~
      |   short
a.cc:12:20: warning: left shift count >= width of type [-Wshift-count-overflow]
   12 |   long long dif=(1 << 33);
      |                  ~~^~~~~
Language: C++

N, K = [int(i) for i in input().split()]
h = sorted([int(input()) for _ in range(N)])

ans = float("inf")
for i, h_i in enumerate(h):
    if i + K - 1 == N:
        break
    ans = min(ans, h[i + K - 1] - h_i)
print(ans)

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

// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
//#include<bits/stdc++.h>
#include<iostream>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n,k;
    cin >> n >> k;
    
    ll * arr = new ll[n];
    
    for(int i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    ll val = INT_MAX;
    for(int i=0;i<n-k+1;i++)
        val = min(val,arr[i+k-1]-arr[i]);
    cout<<val;
    delete[] arr;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   22 |     sort(arr,arr+n);
      |     ^~~~
      |     short
a.cc:23:14: error: 'INT_MAX' was not declared in this scope
   23 |     ll val = 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 | #define ll long long
Language: C++

// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
//#include<bits/stdc++.h>
#include<iostream>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n,k;
    cin >> n >> k;
    
    ll * arr = new ll[n+1];
    
    for(int i=1;i<=n;i++)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    ll val = INT_MAX;
    for(int i=1;i<=n+k;i++)
        val = min(val,arr[i+k]-arr[i]);
    cout<<val;
    delete[] arr;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   22 |     sort(arr,arr+n);
      |     ^~~~
      |     short
a.cc:23:14: error: 'INT_MAX' was not declared in this scope
   23 |     ll val = 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 | #define ll long long
Language: C++

// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
//#include<bits/stdc++.h>
#include<iostream>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n,k;
    cin >> n >> k;
    
    ll * arr = new ll[n+1];
    
    for(int i=1;i<=n;i++)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    ll val = INT_MAX;
    ll l=1, r=k;
    while(r<=n)
    {
        val = min(abs(arr[r]-arr[l]),val);
        ++l;++r;
    }
    cout<<val<<endl;
    delete[] arr;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   22 |     sort(arr,arr+n);
      |     ^~~~
      |     short
a.cc:23:14: error: 'INT_MAX' was not declared in this scope
   23 |     ll val = 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 | #define ll long long
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
        long k = sc.nextLong();
        long[] h = new long[n];
        for (long i = 0; i < n; i++ ) {
          h[i] = sc.nextLong();
        }
        Arrays.sort(h);
		long f = 1000000000;
		//
		for ( long m = 0; m < n - k + 1; m++ ) {
          long t = h[m+k-1] - h[m];
          if (t<f) {
             f = t;
          }
        }
        System.out.println(f);
	}
}


Compiler output:
Main.java:7: error: incompatible types: possible lossy conversion from long to int
        long[] h = new long[n];
                            ^
Main.java:9: error: incompatible types: possible lossy conversion from long to int
          h[i] = sc.nextLong();
            ^
Main.java:15: error: incompatible types: possible lossy conversion from long to int
          long t = h[m+k-1] - h[m];
                        ^
Main.java:15: error: incompatible types: possible lossy conversion from long to int
          long t = h[m+k-1] - h[m];
                                ^
4 errors
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
        long k = sc.nextLong();
        long[] h = new long[n];
        for (long i = 0; i < n; i++ ) {
          h[i] = sc.nextLong();
        }
        Arrays.sort(h)
		long f = 1000000000;
		//
		for ( long m = 0; m < n - k + 1; m++ ) {
          long t = h[m+k-1] - h[m];
          if (t<f) {
             f = t;
          }
        }
        System.out.println(f);
	}
}


Compiler output:
Main.java:11: error: ';' expected
        Arrays.sort(h)
                      ^
1 error
Language: C++

#include<bits/stdc++.h>
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 l=0,r= k-1,df = MAX_INT;
    while(r < n){
    	df = min(df,(A[r]-A[l]));
        l++;
        r++;
    }
    cout<<df<<endl;
    
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:16: error: expected ';' before 'int'
    9 |     sort(A,A+n)
      |                ^
      |                ;
   10 |     int l=0,r= k-1,df = MAX_INT;
      |     ~~~         
a.cc:11:11: error: 'r' was not declared in this scope
   11 |     while(r < n){
      |           ^
a.cc:12:9: error: 'df' was not declared in this scope
   12 |         df = min(df,(A[r]-A[l]));
      |         ^~
a.cc:12:29: error: 'l' was not declared in this scope
   12 |         df = min(df,(A[r]-A[l]));
      |                             ^
a.cc:16:11: error: 'df' was not declared in this scope
   16 |     cout<<df<<endl;
      |           ^~
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 l=0,r= k-1,df = MAX_INT;
    while(r < n){
    	df = min(df,(A[r]-A[l]));
        l++;
        r++;
    }
    cout<<df<<endl;
    
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    9 |     sort(A,A+n)
      |     ^~~~
      |     short
a.cc:11:11: error: 'r' was not declared in this scope
   11 |     while(r < n){
      |           ^
a.cc:12:9: error: 'df' was not declared in this scope
   12 |         df = min(df,(A[r]-A[l]));
      |         ^~
a.cc:12:29: error: 'l' was not declared in this scope
   12 |         df = min(df,(A[r]-A[l]));
      |                             ^
a.cc:16:11: error: 'df' was not declared in this scope
   16 |     cout<<df<<endl;
      |           ^~