Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 300002;




ll n,k,q,ans=INF;
vector<ll> a;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k>>q;
	FOR(i,0,n){
		ll ooo;cin>>ooo;
		a.pb(ooo);
	}


	FOR(i,0,n){
		ll minl=a[i],maxl;
		vector<ll> w;
		vector<ll> toru;
		FOR(j,0,n){
			if(a[j]<minl){
				SORT(w);
				FOR(dd,0,min(q,w.size()-k+1)){
					toru.pb(w[dd]);
				}
				w.clear();
			}else{
				w.pb(a[j]);
			}
		}
		SORT(w);
		FOR(dd,0,min(q,w.size()-k+1)){
			toru.pb(w[dd]);
		}
		SORT(toru);
		if(toru.size()<q)continue;
		maxl=toru[q-1];
		ans=min(ans,maxl-minl);
	}
	pri(ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:45: error: no matching function for call to 'min(ll&, long long unsigned int)'
   45 |                                 FOR(dd,0,min(q,w.size()-k+1)){
      |                                          ~~~^~~~~~~~~~~~~~~~
a.cc:4:41: note: in definition of macro 'FOR'
    4 | #define FOR(I,A,B) for(ll I = (A); I < (B); ++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:45:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   45 |                                 FOR(dd,0,min(q,w.size()-k+1)){
      |                                          ~~~^~~~~~~~~~~~~~~~
a.cc:4:41: note: in definition of macro 'FOR'
    4 | #define FOR(I,A,B) for(ll I = (A); I < (B); ++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:45:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |                                 FOR(dd,0,min(q,w.size()-k+1)){
      |                                          ~~~^~~~~~~~~~~~~~~~
a.cc:4:41: note: in definition of macro 'FOR'
    4 | #define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
      |                                         ^
a.cc:54:29: error: no matching function for call to 'min(ll&, long long unsigned int)'
   54 |                 FOR(dd,0,min(q,w.size()-k+1)){
      |                          ~~~^~~~~~~~~~~~~~~~
a.cc:4:41: note: in definition of macro 'FOR'
    4 | #define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
      |                                         ^
/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:54:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   54 |                 FOR(dd,0,min(q,w.size()-k+1)){
      |                          ~~~^~~~~~~~~~~~~~~~
a.cc:4:41: note: in definition of macro 'FOR'
    4 | #define FOR(I,A,B) for(ll I = (A); I < (B); ++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
/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:54:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 |                 FOR(dd,0,min(q,w.size()-k+1)){
      |                          ~~~^~~~~~~~~~~~~~~~
a.cc:4:41: note: in definition of macro 'FOR'
    4 | #define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
      |                                         ^