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

#include <iostream>
#include <algorithm>
#include <cassert>
#include <functional>
#include <vector>


using namespace std;

int main(void) {
	int N, K;
	cin >> N >> K;
	vector<int> vs;
	for(int i = 0; i < N; i++) {
		long long int h;
		cin >> h;
		vs.push_back(h);
	}
	sort(vs.begin(), vs.end());
	//for(auto v:vs) cout << "::" <<  v << endl;
	long long int ans = 100000000;
	for (int i = 0; i <= N-K; i++) {
//		cout << i+K-1 << ":" << i << endl;
		int score = vs.at(i+K-1) - vs.at(i);
//		cout << score << endl;
		ans = min(ans, score);
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:26: error: no matching function for call to 'min(long long int&, int&)'
   26 |                 ans = min(ans, score);
      |                       ~~~^~~~~~~~~~~~
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:26:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   26 |                 ans = min(ans, score);
      |                       ~~~^~~~~~~~~~~~
/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:2:
/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:26:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |                 ans = min(ans, score);
      |                       ~~~^~~~~~~~~~~~
Language: C++

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

using namespace std;

int main(int, char**)
{
	unsigned int n, k, a = 109;
	cin >> n >> k;
	vector<unsigned int int> t;
	t.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	sort(t.begin(), t.end());

	for (int i = 0; i <= n - k; i++) {
		int x = t[i+k-1] - t[i];
		if (a > x)
			a = x;
	}

	cout << a << endl;
	return 0;

}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:11:25: error: two or more data types in declaration of 'type name'
   11 |         vector<unsigned int int> t;
      |                         ^~~
a.cc:11:32: error: template argument 1 is invalid
   11 |         vector<unsigned int int> t;
      |                                ^
a.cc:11:32: error: template argument 2 is invalid
a.cc:12:11: error: request for member 'resize' in 't', which is of non-class type 'int'
   12 |         t.resize(n);
      |           ^~~~~~
a.cc:14:25: error: invalid types 'int[int]' for array subscript
   14 |                 cin >> t[i];
      |                         ^
a.cc:16:16: error: request for member 'begin' in 't', which is of non-class type 'int'
   16 |         sort(t.begin(), t.end());
      |                ^~~~~
a.cc:16:27: error: request for member 'end' in 't', which is of non-class type 'int'
   16 |         sort(t.begin(), t.end());
      |                           ^~~
a.cc:19:26: error: invalid types 'int[unsigned int]' for array subscript
   19 |                 int x = t[i+k-1] - t[i];
      |                          ^
a.cc:19:37: error: invalid types 'int[int]' for array subscript
   19 |                 int x = t[i+k-1] - t[i];
      |                                     ^
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
using lli = long long int;
typedef pair<ll, ll> pii;
const ll MM = 1000000000;
const ll mod = MM + 7;
int main(){
    ll n, k; cin >> n >> k;
    ll h[10001];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    }
    cout << 0 << endl;
}

Compiler output:
a.cc:19:5: error: 'cout' does not name a type
   19 |     cout << 0 << endl;
      |     ^~~~
a.cc:20:1: error: expected declaration before '}' token
   20 | }
      | ^
Language: C++

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

  int main(){
  int n,k,tmp,h[110000];
  cin >> n >> k;
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  
  int res = -INF;                    
  for (int i = 0; i < n; ++i) {
        if (res < h[i]) res = h[i]; 
  }

  for (int i=0; i<n; ++i) {
    for (int j=i+1; j<n; ++j) {
      if (h[i] < h[j]) {
        tmp =  h[i];
        h[i] = h[j];
        h[j] = tmp;
      }
    }
  }
  int rs = n-k+1;
  int sa=h[0]-h[k-1];
  for(int i = 0; i<rs; i++){
    sa=min(sa,h[i]-h[i+k-1]);
  }
  cout << sa << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: 'INF' was not declared in this scope
   11 |   int res = -INF;
      |              ^~~
Language: C

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n;
    cin>>k;
    vector<int> trees(n);
    for(int i=0;i<n;i++)
	cin>>trees[i];
    sort(trees.begin(),trees.end());
    int hmin=trees.back()-trees.front();
    for(int i=0;i<=n-k;i++){
	int h=trees[i+k-1]-trees[i];
	if(h<hmin)
	    hmin=h;
    }
    cout<<hmin<<endl;
    return 0;
}


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

#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<cmath>
using namespace std;

int main(void)
{
	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 ret = INT_MAX;
	for(int i=0; i<=N-K; i++)
		ret = min(ret, h[i+K-1]-h[i]);

	cout << ret << endl;

	return 0;
}


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

#include<iostream>
#include<algorithm>
#include<vector>
int main()
{
  int N,K;std::cin>>N>>K;
  std::vector<int>h(N);
  for(auto& e:h)std::cin>>e;
  int ans =1e10;
  for(int i=0;i+K<=N;i++)ans=std::min(ans,h[i+K-1]-h[i];
                                 std::cout<<ans<<std::endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
    9 |   int ans =1e10;
      |            ^~~~
a.cc:10:56: error: expected ')' before ';' token
   10 |   for(int i=0;i+K<=N;i++)ans=std::min(ans,h[i+K-1]-h[i];
      |                                      ~                 ^
      |                                                        )
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#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--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  
  long N, K
  long long ans = 0;

  cin >> N >> K;

  vector<long> h(N), diff(N-1);

  REP(i,N){
    cin >> h[i];
  }

  VSORT(h);

  REP(i,N-1){
    diff[i] = h[i+1] - h[i];
  }

  VSORT(diff);

  REP(i,K-1) {
    ans += diff[i];
  }
  

  cout << ans << endl;

  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:3: error: expected initializer before 'long'
   25 |   long long ans = 0;
      |   ^~~~
a.cc:27:15: error: 'K' was not declared in this scope
   27 |   cin >> N >> K;
      |               ^
a.cc:44:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |     ans += diff[i];
      |     ^~~
      |     abs
a.cc:48:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   48 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
using namespace std;
int normalsort(const void* a, const void* b)
{
	long* pa = (long*)a;
	long* pb = (long*)b;
	return *pa - *pb;
}

int main()
{
	int nN,nK;
	cin >> nN >> nK;

	long lnHigh[100000];
	memset(lnHigh, 0, sizeof(lnHigh));
	for (int i = 0; i < nN; i++)
	{
		cin >> lnHigh[i];
	}
	qsort(lnHigh, nN, sizeof(long), normalsort);

	long lnMinDiff = LONG_MAX;
	long lnRet[100000];
	memset(lnRet, 0, sizeof(lnRet));
	for (int i = 0; i < nN - nK+1; i++)
	{
		long lnDiff = lnHigh[i + nK - 1] - lnHigh[i];
		if (lnMinDiff > lnDiff)
			lnMinDiff = lnDiff;
	}

	cout << lnMinDiff;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:26: error: 'LONG_MAX' was not declared in this scope
   28 |         long lnMinDiff = LONG_MAX;
      |                          ^~~~~~~~
a.cc:7:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <map>
  +++ |+#include <climits>
    7 | using namespace std;
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: expected ';' before 'int'
   13 | sort(a,a+n)
      |            ^
      |            ;
   14 | int b[100000];
      | ~~~         
a.cc:16:1: error: 'b' was not declared in this scope
   16 | b[i]=a[i+k-1]-a[i];
      | ^
a.cc:20:9: error: 'b' was not declared in this scope
   20 | ans=min(b[i],ans);
      |         ^
Language: C++

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


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

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


Compiler output:
main.c: In function 'main':
main.c:13:33: error: expected expression before '[' token
   13 |                         if(h[i]<[j]){
      |                                 ^
Language: C

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

Compiler output:
main.c: In function 'main':
main.c:13:33: error: expected expression before '[' token
   13 |                         if(h[i]<[j]){
      |                                 ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

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

  sort(hs.begin(), hs.end());
  int ans = 1e+9+1;;
  for (int i = 0; i <= N - K; i++){
    ans = min(ans, hs[i + 2] - hs[i]);
  }
  cout << ans << endl;
  return 0;
}

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

#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(){
  int N,K,h[100000],min=1000000000;
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  qsort(h, N, sizeof(int), compare_int);
  for(i=0;i<N-K;i++){
    if(h[i+K]-h[i]<min){
      min=h[i+K]-h[i];
    }
  }
  printf("%d",min);
}


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

#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(){
  int N,K,h[100000],min=1000000000;
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  qsort(h, N, sizeof(int), compare_int);
  for(i=0;i<N-K;i++){
    if(h[i+K]-h[i])<min{
      min=h[i+K]-h[i];
    }
  }
  printf("%d",min);
}


Compiler output:
main.c: In function 'main':
main.c:10:7: error: 'i' undeclared (first use in this function)
   10 |   for(i=0;i<N;i++){
      |       ^
main.c:10:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:15:20: error: expected expression before '<' token
   15 |     if(h[i+K]-h[i])<min{
      |                    ^
Language: C

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

int comparator(const void *a, const void *b);
long long int TREES[100001];

int main(void) {
  long K,N;
  scanf("%ld %ld", &N, &K);
  for(long i=0;i<N;i++) {
    scanf("%lld", &TREES[i]);
  }

  qsort(TREES, N, sizeof(long long int), comparator);


  long long int minDist = TREES[K - 1] - TREES[0];
  long long int beg, end;
  for(long i=1;i<=N - K;i++) {
    long long int dist = TREES[i + K - 1] - TREES[i];
    if(dist < minDist) {
      minDist = dist;
    }
  }
  printf("%lld\n", minDist);
  return 0;
}

int comparator(const long long int *a, const long long int *b) {
  if(*a > *b) return 1;
  else if(*a == *b) return 0;
  else return -1;
}

Compiler output:
main.c:29:5: error: conflicting types for 'comparator'; have 'int(const long long int *, const long long int *)'
   29 | int comparator(const long long int *a, const long long int *b) {
      |     ^~~~~~~~~~
main.c:4:5: note: previous declaration of 'comparator' with type 'int(const void *, const void *)'
    4 | int comparator(const void *a, const void *b);
      |     ^~~~~~~~~~
Language: C++

#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

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

  long diff = labs(h[0] - h[1] - h[2]);
  int index = 0;
  for (int i = 1; i < N - 2; ++i) {
    if (abs(h[i] - h[i + 1] - h[i + 2]) < diff) {
      diff = labs(h[i] - h[i + 1] - h[i + 2]);
      index = i;
    }
  }

  cout << h[index + 2] - h[index] << 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 <iostream>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main(){
int n,k;
cin >> n >> k;
vector<int> vec(n);
for (int i=0;i<n;i++){
cin >> vec.at(i);
}
sort (vec.begin(),vec.end());
int b[100000];
for (int i=0;i<n;i++){
b[i]=vec.at(i+k-1)-yec.at(i);
}
int ans=1000000000;
for (int i=0;i<n;i++){
ans=min(b[i],ans);
}
cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:20: error: 'yec' was not declared in this scope; did you mean 'vec'?
   16 | b[i]=vec.at(i+k-1)-yec.at(i);
      |                    ^~~
      |                    vec
Language: C

#include<stdio.h>
#include<stdlib.h>
int main(){
  int N,K,h[100000],min=1000000000;
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  qsort(h, N, sizeof(int), compare_int);
  for(i=0;i<N-K;i++){
    if(h[i+K]-h[i])<min{
      min=h[i+K]-h[i];
    }
  }
  printf("%d",min);
}


Compiler output:
main.c: In function 'main':
main.c:6:7: error: 'i' undeclared (first use in this function)
    6 |   for(i=0;i<N;i++){
      |       ^
main.c:6:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:28: error: 'compare_int' undeclared (first use in this function)
    9 |   qsort(h, N, sizeof(int), compare_int);
      |                            ^~~~~~~~~~~
main.c:11:20: error: expected expression before '<' token
   11 |     if(h[i+K]-h[i])<min{
      |                    ^
Language: C++

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

int main()
{
	int n, m;
	
	scanf("%d %d", &n, &m)；
	
		int i;
		int min;
		int a[100000];

		for(i = 0; i < n; i++)
		{
			scanf("%d", &a[i]);
		}

		sort(a, a + n);
		/*for(i = 0; i < n; i++)
			printf("%d\n", a[i]);*/

		min = 100000;
		for(i = 0; i < (n - m + 1); i++)
		{
			if(a[i + m - 1] - a[i] <= min)
				min = a[i + m - 1] - a[i];
			//printf("%d\n", min);
		}
		printf("%d\n", min);
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:31: error: expected ';' before '\U0000ff1b'
    9 |         scanf("%d %d", &n, &m)；
      |                               ^~
      |                               ;
a.cc:15:21: error: 'i' was not declared in this scope
   15 |                 for(i = 0; i < n; i++)
      |                     ^
a.cc:25:21: error: 'i' was not declared in this scope
   25 |                 for(i = 0; i < (n - m + 1); i++)
      |                     ^
Language: C

#include "stdio.h"

int main(void){
  int N, K;

  if(scanf("%d %d", &N, &K)==EOF) return 0;
  
  int h[N];
    
  for(int i=0; i < N; i++){
  	if(scanf("%d", &h[i])==EOF) return 0;
  }
  int temp;
  for (int i=0; i<N-1; i++){
        for (int j=N-1; j>i; j--){
            if (h[j - 1] > h[j]){  
                temp = h[j];        
                h[j] = h[j - 1];
                h[j - 1]= temp;
            }
        }	
    }
  int min;
  for(int i=N-1; i > 0; i--){
    if(h[i]-h[i-1] <= min)
      min =h[i]-h[a-1];
  }
  printf("%d", min);

}


Compiler output:
main.c: In function 'main':
main.c:26:19: error: 'a' undeclared (first use in this function)
   26 |       min =h[i]-h[a-1];
      |                   ^
main.c:26:19: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
int main(){
  int N,K,h[100000],min=1000000000;
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  qsort(h, N, sizeof(int), compare_int);
  for(i=0;i<N-K;i++){
    if(h[i+K]-h[i])<min{
      min=h[i+K]-h[i];
    }
  }
  printf("%d",min);
}


Compiler output:
main.c: In function 'main':
main.c:5:7: error: 'i' undeclared (first use in this function)
    5 |   for(i=0;i<N;i++){
      |       ^
main.c:5:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:8:3: error: implicit declaration of function 'qsort' [-Wimplicit-function-declaration]
    8 |   qsort(h, N, sizeof(int), compare_int);
      |   ^~~~~
main.c:8:28: error: 'compare_int' undeclared (first use in this function)
    8 |   qsort(h, N, sizeof(int), compare_int);
      |                            ^~~~~~~~~~~
main.c:10:20: error: expected expression before '<' token
   10 |     if(h[i+K]-h[i])<min{
      |                    ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    long N,K;
    int flag = 0;
    cin >> N >> K;
    vector<long> V(N);
    cin >> V[0];
    for(int i=1;i<N;i++) {
        cin >> V[i];
        if(V[i-1] == V[i]) flag = 1;
    }
    sort(V.begin(),V.end());
    if(flag) cout<<
    else cout << V[K-1]-V[0];
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: expected primary-expression before 'else'
   17 |     else cout << V[K-1]-V[0];
      |     ^~~~
Language: C

#include "stdio.h"

int main(void){
  int N, K;

  if(scanf("%d %d", &N, &K)==EOF) return 0;
  
  int h[N];
    
  for(int i=0; i < N; i++){
  	if(scanf("%d", h[i])==EOF) return 0;
  }
  int temp;
  for (int i=0; i<N-1; i++){
        for (int j=N-1; j>i; j--){
            if (h[j - 1] > h[j]){  
                temp = h[j];        
                h[j] = h[j - 1];
                h[j - 1]= temp;
            }
        }	
    }
  int min;
  for(int i=N-1; i > 0; i--){
    if(h[i]-h[a-1] <= min)
      min =h[i]-h[a-1];
  }
  printf("%d", min);

}


Compiler output:
main.c: In function 'main':
main.c:25:15: error: 'a' undeclared (first use in this function)
   25 |     if(h[i]-h[a-1] <= min)
      |               ^
main.c:25:15: note: each undeclared identifier is reported only once for each function it appears in
Language: Java

import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		List<Long> list = new ArrayList<>();
		for(int i=0;i<n;i++){
			list.add( sc.nextLong());
		}
		Collections.sort(list);

		long diff = list.get(k-1) - list.get(0);
		// System.out.println("first diff"+diff);
		for(int i=0;i<n;i++){
			if(i<k){
				continue;
			}
			if(diff=0){
				break;
			}
			long curDiff =(list.get(i)-list.get(i-1)) - (list.get(i-k+1)-list.get(i-k));
			
			// System.out.print("diff");
			// System.out.println(curDiff);
			if(curDiff<0){
				diff += curDiff;
			}
			
			
		}

		System.out.println(diff);


	}

}



Compiler output:
Main.java:22: error: incompatible types: long cannot be converted to boolean
			if(diff=0){
			       ^
1 error
Language: C

#include "stdio.h"

int main(void){
  int N, K;

  if(scanf("%d %d", &N, &K)==EOF) return 0;
  
  int h[N];
    
  for(int i=0; i < N; i++){
  	if(scanf("%d", h[i])==EOF) return 0;
  }
  int temp;
  for (int i=0; i<N-1; i++){
        for (int j=N-1; j>i; j--){
            if (h[j - 1] > h[j]){  
                temp = h[j];        
                h[j] = h[j - 1];
                h[j - 1]= temp;
            }
        }	
    }
  int min;
  for(int i=N-1; i > 0; i--){
    if(a[i]-a[a-1] <= min)
      min =a[i]-a[a-1];
  }
  printf("%d", min);

}

Compiler output:
main.c: In function 'main':
main.c:25:8: error: 'a' undeclared (first use in this function)
   25 |     if(a[i]-a[a-1] <= min)
      |        ^
main.c:25:8: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

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

  long diff = abs(h[0] - h[1] - h[2]);
  int index = 0;
  for (int i = 1; i < N - 2; ++i) {
    if (abs(h[i] - h[i + 1] - h[i + 2]) < diff) {
      diff = abs(h[i] - h[i + 1] - h[i + 2]);
      index = i;
    }
  }

  cout << h[index + 2] - h[index] << endl;

  return 0;
}


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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: request for member 'begin' in 'a', which is of non-class type 'int [100000]'
   13 | sort (a.begin(),a.end());
      |         ^~~~~
a.cc:13:19: error: request for member 'end' in 'a', which is of non-class type 'int [100000]'
   13 | sort (a.begin(),a.end());
      |                   ^~~
Language: C++

#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

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

  long diff = abs(h[0] - h[1] - h[2]);
  int index = 0;
  for (int i = 1; i < N - 2; ++i) {
    if (abs(h[i] - h[i + 1] - h[i + 2]) < diff) {
      diff = abs(h[i] - h[i + 1] - h[i + 2]);
      index = i;
    }
  }
  long max = *max_element(&h[index], &h[index + 3]);
  long min = *min_element(&h[index], &h[index + 3]);

  cout << max - min << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |   sort(h.begin(), h.end());
      |   ^~~~
      |   short
a.cc:26:15: error: 'max_element' was not declared in this scope
   26 |   long max = *max_element(&h[index], &h[index + 3]);
      |               ^~~~~~~~~~~
a.cc:27:15: error: 'min_element' was not declared in this scope
   27 |   long min = *min_element(&h[index], &h[index + 3]);
      |               ^~~~~~~~~~~
Language: Java

import java.util.*;

public class Main{
  public static void (String[] args){
    Scanner scan = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<Integer>();
	int all = scan.nextInt();
    int extraction  = scan.nextInt();
    int b=0;
    for(int i = 0; i<all;i++){
      b=scan.nextInt();
      list.add(b);
    }
    Collections.sort(list);
    int ans=214748364;
    for(int i = 0;i<(all-extraction);i++){
      if(ans>list.get(i+extraction-1)-list.get(i)) ans = list.get(i+extraction-1)-list.get(i);
    }
    System.out.println(ans);

Compiler output:
Main.java:4: error: <identifier> expected
  public static void (String[] args){
                    ^
Main.java:19: error: reached end of file while parsing
    System.out.println(ans);
                            ^
2 errors
Language: C++

#include <iostream>
using namespace std;

int main(){
  int N, K, i, min, max, count=0, ans=0;
  cin >> N >> K;
  int h[N];
  for(i=0; i<N; i++){
    cin >> h[i];
  }
  sort(h, h+N);
  min = h[0]; max = h[K-1];
  ans = max - min;
  for(i=K-1; i<N; i++){
    if(i+K-1 <= N-1){
      min = h[i]; max = h[i+K-1];
      if(ans > max-min) ans = max - min;
    }
  }
  cout << ans << "\n";
  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(h, h+N);
      |   ^~~~
      |   short
Language: C++

#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
typedef long long int ll;
using namespace std;
int main(){
	ll N;
	ll K;
	ll x;
	vector<ll> h;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>x;zza
		h.push_back(x);
	}
	sort(h.begin(),h.end());
	x=100000000;
	for(int i=0;i<N-K+1;i++){
		if(h[i+K-1]-h[i]<x){
			x=h[i+K-1]-h[i];
		}
	}
	cout << x << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:24: error: 'zza' was not declared in this scope
   16 |                 cin>>x;zza
      |                        ^~~
Language: Java

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<Long> c = new ArrayList<Long>();
		long mini = 1000000000;
		long a = sc.nextInt();
		long b = sc.nextInt();
		for(int i = 0; i < a; i++){
			long d = sc.nextInt();
			c.add(d);
		}
		Collections.sort(c);
		for(int i = 0; i < a; i+=b-1){
			if(i > a-b+1){
				break;
			}
			long f = c.get(i+b-1)-c.get(i);
			if(mini>f){
				mini = f;
			}
		}
		System.out.println(mini);
	}
}

Compiler output:
Main.java:20: error: incompatible types: possible lossy conversion from long to int
			long f = c.get(i+b-1)-c.get(i);
			                  ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: Java



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

import javafx.util.Pair;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        Map<Long, Long> map = new TreeMap<>();
        Pair<Long, Long> max = new Pair<Long, Long>(0L, 0L);
        for (int i = 0; i < n; i++) {
            long num = sc.nextLong();
            long time = 1;
            if (map.containsKey(num)) {
                long tmp = map.get(num);
                map.put(num, tmp + 1);
                time = tmp + 1;
            } else {
                map.put(num, 1L);
            }
            if (time == k) {
                System.out.println(0);
                return;
            } else {
                if (time > max.getValue()) {
                    max = new Pair<Long, Long>(num, time);
                }
            }
        }
        List<Long> keys = new ArrayList<>(map.keySet());
        int index = keys.indexOf(max.getKey());
        int diffUp = 0;
        Long treeValueUp = k - max.getValue();
        while (treeValueUp > 0) {
            diffUp++;
            if (index + diffUp >= keys.size()) {
                diffUp = Integer.MAX_VALUE;
                break;
            }
            treeValueUp = treeValueUp - map.get(keys.get(index + diffUp));
        }
        int diffDown = 0;
        Long treeValueDown = k - max.getValue();
        while (treeValueDown > 0) {
            diffDown++;
            if (index - diffDown < 0) {
                diffDown = Integer.MAX_VALUE;
                break;
            }
            treeValueDown = treeValueDown - map.get(keys.get(index - diffDown));
        }
        System.out.println(Math.min(diffDown, diffUp));
    }
}


Compiler output:
Main.java:9: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
Main.java:20: error: cannot find symbol
        Pair<Long, Long> max = new Pair<Long, Long>(0L, 0L);
        ^
  symbol:   class Pair
  location: class Main
Main.java:20: error: cannot find symbol
        Pair<Long, Long> max = new Pair<Long, Long>(0L, 0L);
                                   ^
  symbol:   class Pair
  location: class Main
Main.java:36: error: cannot find symbol
                    max = new Pair<Long, Long>(num, time);
                              ^
  symbol:   class Pair
  location: class Main
4 errors
Language: C++

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

int main() {
	int N,K;
	cin >> N >> K;
	vector<int> h;
	for (int i=0; i<N;i++) {
		int tmp;
		cin >> tmp ;
		h.push_back(tmp);
	}
	sort(h.begin(), h.end());
	int dh = h[N-1]-h[0]; 
	for (int i=0; i<N-K+1; i++) {
		if (dh>(h[i+K-1]-h[i])) dh = h[i+K-1]-h[i];
	}
	cout << dh << endl;

	return 0;
}


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

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

int main(){
int n,k;
cin >> n >> k;
int a[100000];
for (int i=0;i<n;i++){
cin >> a[i];
}
vector<int> vec(100000);
for (int i=0;i<n;i++){
int vec.at(i)=a[i]
}
sort(vec.begin(),vec.end());
int x[100000];
for (int i=0;i<n;i++){
int x[i]=vec.at(i);
}
int b[100000];
for (int i=0;i<n;i++){
b[i]=x[i+k-1]-x[i];
}
int ans=1000000000;
for (int i=0;i<n;i++);{
ans = min(ans,b[i]);
}
cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: expected initializer before '.' token
   15 | int vec.at(i)=a[i]
      |        ^
a.cc:20:16: error: array must be initialized with a brace-enclosed initializer
   20 | int x[i]=vec.at(i);
      |          ~~~~~~^~~
a.cc:28:17: error: 'i' was not declared in this scope
   28 | ans = min(ans,b[i]);
      |                 ^
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		List<Integer> l = new ArrayList<Integer>();
		int n = sc.nextInt();
		int k = sc.nextInt();
		while (sc.hasNext()) {
			int a = sc.nextInt();
			l.add(a);
		}
		Collections.sort(a);
		int min = 1000000000;
		for (int i=0 ; i < l.size() - k; i++ ) {
			int sabun = l.get(i+k) - l.get(i);
			if (sabun < min) min = sabun;
		}
		// 出力
		System.out.println(min);
	}
}


Compiler output:
Main.java:12: error: cannot find symbol
		Collections.sort(a);
		                 ^
  symbol:   variable a
  location: class Main
1 error
Language: C

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

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

int main(void){
	int N=0,K=0,min=0;
	scanf("%d %d",&N,&K);
  int h[N];
  for(int i=0;i<N;i++){
  	scanf("%d",&h[N]);
  }
	qsort(h,N,sizeof(int),comp);
	for(int i=0;i<N-K+1;i++){
    	if(min>h[i+K-1]-h[i]) min=h[i+K-1]-h[i];
    }
  printf("%d",min);
	return 0;
}

Compiler output:
main.c: In function 'comp':
main.c:5:19: error: expected expression before 'int'
    5 |         return *(*int)a-*(*int)b;
      |                   ^~~
main.c:5:23: error: expected ';' before 'a'
    5 |         return *(*int)a-*(*int)b;
      |                       ^
      |                       ;
Language: C++

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

int main(){
    int n,k;
    int tmp;
    int min = 1000000000;
    cin >> n >> k;
    vector<int> data;
    for (int i = 0; i < n; i++){
        cin >> tmp;
        data.push_back(tmp);
    }
    sort(data.begin(),data.end(),greater<int>());
    for (int i = 0; i < data.size() - k + 1; i++){
        if (min > data[i]-data[i+k-1]){
            min = data[i]-data[i+k-1];
        }
    }
    cout << min << 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(data.begin(),data.end(),greater<int>());
      |     ^~~~
      |     short
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		List<Integer> l = new ArrayList<Integer>;
		int n = sc.nextInt();
		int k = sc.nextInt();
		while (sc.hasNext()) {
			int a = sc.nextInt();
			l.add(a);
		}
		Collections.sort(a);
		int min = 1000000000;
		for (int i=0 ; i++ ; i < l.size() - k) {
			int sabun = l.get(i+k) - l.get(i);
			if (sabun < min) min = sabun;
		}
		// 出力
		System.out.println(min);
	}
}


Compiler output:
Main.java:5: error: '(' or '[' expected
		List<Integer> l = new ArrayList<Integer>;
		                                        ^
Main.java:14: error: not a statement
		for (int i=0 ; i++ ; i < l.size() - k) {
		                       ^
2 errors
Language: C++

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

int n,m,mx =0,tp;
long long int ans=0;
vector<int> v;

int main(){
    cin >> n>>m;
  REP(i,n){
    cin>>tp;
v.push_back(tp);
  }
sort(v.end(),v,begin());
 
  cout<< v[0] - v[m]<<endl;
} 


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

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef unsigned long long ull;
#define MAX 1000000000

int main() {
  int n,k;
  cin >> n >> k;
  vector<ull> h(n);
  for(int i = 0; i < n; i++)
    cin >> h[i];
  sort(h.begin(), h.end());
  ull hmax,hmin,hsa, sa = MAX;
  for(int i = 0; i < n-k+1; i++) {
    hmin = h[i];
    hmax = h[i+k-1];
    hsa = hmax-hmin;
    if(sa > hsa)
      sa = hsa;
  }
  cout << sa << endl;

  return 0;
}

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

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin>>p.at(i);
  sort(p.begin(),p.end());
  int def=1000000000;
  for(int i=0;i<=n-k;i++){
    def = min(def,p.at(i+k-1)-p.at(i));   
  }
  cout<<def<<endl;
  return 0;
}/

Compiler output:
a.cc:16:2: error: expected unqualified-id before '/' token
   16 | }/
      |  ^
Language: C++

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstring>
typedef long long ll;
using namespace std;
int a[10005];
int main(){
	long long m,n;
	cin>>m>>n;
	for(ll i=0;i<m;i++){
		cin>>a[i];
	}
	sort(a,a+m);
	long long ans=99999999;
	for(ll i=0;i+n-1<m;i++){
		ans=min(ans,a[i+n-1]-a[i]);
	}
	printf("%lld",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:24: error: no matching function for call to 'min(long long int&, int)'
   18 |                 ans=min(ans,a[i+n-1]-a[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:2:
/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:18:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |                 ans=min(ans,a[i+n-1]-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,
                 from a.cc:3:
/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:18:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |                 ans=min(ans,a[i+n-1]-a[i]);
      |                     ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[]) {
        int N, K;
        cin >> N >> K;

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

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

        vector<int> sub_arr;  // 前後の差を格納する配列
        for (int j = 0; j < N; j++) {
                sub_arr.push_back(arr[j + 1] - arr[j]);
                if ((j + 1) == (N - 1)) {
                        break;
                }
        }

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

        int ans = 0;
        for (int l = 0; l < K - 1; l++) {
                ans += sub_arr[l];
        }

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


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main(int, char**)':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin >> N >> K;
      |         ^~~
a.cc:10:9: error: 'vector' was not declared in this scope
   10 |         vector<int> arr;
      |         ^~~~~~
a.cc:10:16: error: expected primary-expression before 'int'
   10 |         vector<int> arr;
      |                ^~~
a.cc:13:17: error: 'arr' was not declared in this scope
   13 |                 arr.push_back(cur);
      |                 ^~~
a.cc:16:14: error: 'arr' was not declared in this scope
   16 |         sort(arr.begin(), arr.end());
      |              ^~~
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |         sort(arr.begin(), arr.end());
      |         ^~~~
      |         short
a.cc:18:16: error: expected primary-expression before 'int'
   18 |         vector<int> sub_arr;  // 前後の差を格納する配列
      |                ^~~
a.cc:20:17: error: 'sub_arr' was not declared in this scope
   20 |                 sub_arr.push_back(arr[j + 1] - arr[j]);
      |                 ^~~~~~~
a.cc:26:14: error: 'sub_arr' was not declared in this scope
   26 |         sort(sub_arr.begin(), sub_arr.end());
      |              ^~~~~~~
a.cc:33:9: error: 'cout' was not declared in this scope
   33 |         cout << ans << endl;
      |         ^~~~
a.cc:33:24: error: 'endl' was not declared in this scope
   33 |         cout << ans << endl;
      |                        ^~~~
Language: C++

#include<iostream>
using namespace std;
	int a[500000];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int min=10000000;
	for(int i=0;i<n-m+1;i++){
		if((a[i+m-1]-a[i])<min)
		{
			min=a[i+m-1]-a[i];
			
		}
	}
cout<<min;
} 

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