Language: C++

#include<bits/stdc++.h>

using namespace std;


struct item{
	
	int val, idx;
	
	
};

struct cmp{
	
	bool operator ()(const item &i1, const item &i2) const{
		
		return i1.val < i2.val;
	}
};
multiset<item, cmp> s;

int main(){
	
	int N,L;
	scanf("%d%d", &N,&L);
	
	int arr[N];
	
	for(int i =0; i < N; i++) {
		
		scanf("%d", &arr[i]);
		if(i < L)
			s.insert({arr[i], i});
	}
	
	
	for(int i = L; i <= N; i++){
		
		printf("%d", *it.begin());
		
		s.erase(s.find(arr[i-L]));
		
		s.insert(arr[i]);
		
		if(i < N) printf(" ");
	}
	
	printf("\n");
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:39:31: error: 'it' was not declared in this scope; did you mean 'i'?
   39 |                 printf("%d", *it.begin());
      |                               ^~
      |                               i
a.cc:41:31: error: no matching function for call to 'std::multiset<item, cmp>::find(int&)'
   41 |                 s.erase(s.find(arr[i-L]));
      |                         ~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/set:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_multiset.h:787:9: note: candidate: 'template<class _Kt> decltype (std::multiset<_Key, _Compare, _Alloc>::iterator{((std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::multiset<_Key, _Compare, _Alloc>::find(const _Kt&) [with _Key = item; _Compare = cmp; _Alloc = std::allocator<item>]'
  787 |         find(const _Kt& __x)
      |         ^~~~
/usr/include/c++/14/bits/stl_multiset.h:787:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_multiset.h: In substitution of 'template<class _Kt> decltype (std::multiset<item, cmp>::iterator{((std::multiset<item, cmp>*)this)->std::multiset<item, cmp>::_M_t.std::_Rb_tree<item, item, std::_Identity<item>, cmp, std::allocator<item> >::_M_find_tr(__x)}) std::multiset<item, cmp>::find(const _Kt&) [with _Kt = int]':
a.cc:41:17:   required from here
   41 |                 s.erase(s.find(arr[i-L]));
      |                         ~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_multiset.h:788:45: error: no matching function for call to 'std::_Rb_tree<item, item, std::_Identity<item>, cmp, std::allocator<item> >::_M_find_tr(const int&)'
  788 |         -> decltype(iterator{_M_t._M_find_tr(__x)})
      |                              ~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) [with _Req = _Kt; _Key = item; _Val = item; _KeyOfValue = std::_Identity<item>; _Compare = cmp; _Alloc = std::allocator<item>]'
 1291 |         _M_find_tr(const _Kt& __k)
      |         ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
                 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/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = cmp; _SfinaeType = int]':
/usr/include/c++/14/bits/stl_tree.h:1289:9:   required by substitution of 'template<class _Kt> decltype (std::multiset<item, cmp>::iterator{((std::multiset<item, cmp>*)this)->std::multiset<item, cmp>::_M_t.std::_Rb_tree<item, item, std::_Identity<item>, cmp, std::allocator<item> >::_M_find_tr(__x)}) std::multiset<item, cmp>::find(const _Kt&) [with _Kt = int]'
 1289 |                typename _Req = __has_is_transparent_t<_Compare, _Kt>>
      |                ^~~~~~~~
a.cc:41:17:   required from here
   41 |                 s.erase(s.find(arr[i-L]));
      |                         ~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<cmp, int, void>'
 1427 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_multiset.h: In substitution of 'template<class _Kt> decltype (std::multiset<item, cmp>::iterator{((std::multiset<item, cmp>*)this)->std::multiset<item, cmp>::_M_t.std::_Rb_tree<item, item, std::_Identity<item>, cmp, std::allocator<item> >::_M_find_tr(__x)}) std::multiset<item, cmp>::find(const _Kt&) [with _Kt = int]':
a.cc:41:17:   required from here
   41 |                 s.erase(s.find(arr[i-L]));
      |                         ~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) const [with _Req = _Kt; _Key = item; _Val = item; _KeyOfValue = std::_Identity<item>; _Compare = cmp; _Alloc = std::allocator<item>]'
 1300 |         _M_find_tr(const _Kt& __k) const
      |         ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_multiset.h:787:9: error: no matching function for call to 'std::_Rb_tree_const_iterator<item>::_Rb_tree_const_iterator(<brace-enclosed initializer list>)'
  787 |         find(const _Kt& __x)
      |         ^~~~
/usr/include/c++/14/bits/stl_tree.h:346:7: note: candidate: 'std::_Rb_tree_const_iterator<_Tp>::_Rb_tree_const_iterator(const iterator&) [with _Tp = item; iterator = std::_Rb_tree_const_iterator<item>::iterator]'
  346 |       _Rb_tree_const_iterator(const iterator& __it) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:346:7: note:   conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_tree.h:343:7: note: candidate: 'std::_Rb_tree_const_iterator<_Tp>::_Rb_tree_const_iterator(_Base_ptr) [with _Tp = item; _Base_ptr = const std::_Rb_tree_node_base*]'
  343 |       _Rb_tree_const_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:343:7: note:   conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_tree.h:339:7: note: candidate: 'std::_Rb_tree_const_iterator<_Tp>::_Rb_tree_const_iterator() [with _Tp = item]'
  339 |       _Rb_tree_const_iterator() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:339:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<item>::_Rb_tree_const_iterator(const std::_Rb_tree_const_iterator<item>&)'
  324 |     struct _Rb_tree_const_iterator
      |            ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:324:12: note:   conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<item>::_Rb_tree_const_iterator(std::_Rb_tree_const_iterator<item>&&)'
/usr/include/c++/14/bits/stl_tree.h:324:12: note:   conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_multiset.h:793:9: note: candidate: 'template<class _Kt> decltype (std::multiset<_Key, _Compare, _Alloc>::const_iterator{((const std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::multiset<_Key, _Compare, _Alloc>::find(const _Kt&) const [with _Key = item; _Compare = cmp; _Alloc = std::allocator<item>]'
  793 |         find(const _Kt& __x) const
      |         ^~~~
/usr/include/c++/14/bits/stl_multiset.h:793:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_multiset.h: In substitution of 'template<class _Kt> decltype (std::multiset<item, cmp>::const_iterator{((const std::multiset<item, cmp>*)this)->std::multiset<item, cmp>::_M_t.std::_Rb_tree<item, item, std::_Identity<item>, cmp, std::allocator<item> >::_M_find_tr(__x)}) std::multiset<item, cmp>::find(const _Kt&) const [with _Kt = int]':
a.cc:41:17:   required from here
   41 |                 s.erase(s.find(arr[i-L]));
      |                         ~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_multiset.h:794:51: error: no matching function for call to 'std::_Rb_tree<item, item, std::_Identity<item>, cmp, std::allocator<item> >::_M_find_tr(const int&) const'
  794 |         -> decltype(const_iterator{_M_t._M_find_tr(__x)})
      |                                    ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) [with _Req = _Kt; _Key = item; _Val = item; _KeyOfValue = std::_Identity<item>; _Compare = cmp; _Alloc = std::allocator<item>]'
 1291 |         _M_find_tr(const _Kt& __k)
      |         ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) const [with _Req = _Kt; _Key = item; _Val = item; _KeyOfValue = std::_Identity<item>; _Compare = cmp; _Alloc = std::allocator<item>]'
 1300 |         _M_find_tr(const _Kt& __k) const
      |         ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_multiset.h:793:9: error: no matching function for call to 'std::_Rb_tree_const_iterator<item>::_Rb_tree_const_iterator(<brace-enclosed initializer list>)'
  793 |         find(const _Kt& __x) const
      |         ^~~~
/usr/include/c++/14/bits/stl_tree.h:346:7: note: candidate: 'std::_Rb_tree_const_iterator<_Tp>::_Rb_tree_const_iterator(const iterator&) [with _Tp = item; iterator = std::_Rb_tree_const_iterator<item>::iterator]'
  346 |       _Rb_tree_const_iterator(const iterator& __it) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:346:7: note:   conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_tree.h:343:7: note: candidate: 'std::_Rb_tree_const_iterator<_Tp>::_Rb_tree_const_iterator(_Base_ptr) [with _Tp = item; _Base_ptr = const std::_Rb_tree_node_b