Language: C++

#include<bits/stdc++.h>
#define ll long long
#define viit(a) vector<int>::iterator a
#define IT iterater
#define REP(i,a,n) for(ll i=a;i<(n);i++)
#define FOR(i,a,n) for(ll i=a;i<=(n);i++)
#define V vector
#define RE return
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define Fill(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    long long n,k,a[1000001];
    cin>>k>>n;
    REP(i,0,n)
    cin>>a[i];
    int minimum=1000050;
    REP(i,0,n-1){
    	int s=abs(a[i]-a[(i+1)%n]);
    	minimum=min(k-s,minimum);
	}
	minimum=min(a[n-1]-a[0],minimum);
	cout<<minimum;	 
    RE 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:20: error: no matching function for call to 'min(long long int, int&)'
   30 |         minimum=min(k-s,minimum);
      |                 ~~~^~~~~~~~~~~~~
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:30:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   30 |         minimum=min(k-s,minimum);
      |                 ~~~^~~~~~~~~~~~~
/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:30:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |         minimum=min(k-s,minimum);
      |                 ~~~^~~~~~~~~~~~~
a.cc:32:20: error: no matching function for call to 'min(long long int, int&)'
   32 |         minimum=min(a[n-1]-a[0],minimum);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~
/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:32:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |         minimum=min(a[n-1]-a[0],minimum);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~
/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:32:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |         minimum=min(a[n-1]-a[0],minimum);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~