Language: C++

#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define ull unsigned long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));

ll a[200010];
ll b[200010];
ll mode=1e9+7;
ll Pow(ll a, ll b)
{
    ll sum = 1;
    while (b) {
        if (b & 1) {
            sum = (sum * a) % mode;
            b--;
        }
        b /= 2;
        a = (a * a) % mode;
    }
    return sum;
} 
int main(){
	ll n,k;
	cin>>n>>k;
	//c(n-1,i-1)*c(n,i)
	a[0]=1;
	b[0]=1;
	for(int i=1;i<=n-1;i++){
		a[i]=((a[i-1]*(n-i))%mode)*Pow(i,mode-2);
		a[i]%=mode;
		
	}
	for(int i=1;i<=n;i++){
		b[i]=((b[i-1]*(n+1-i))%mode)*Pow(i,mode-2);
		b[i]%=mode;
	}
	ll sum=0;
//	if(k>=n){
//		if((k-n+1)%2==0){
//			k=n-1;
//		}
//		else{
//			k=n-2;
//		}
//	}
	//最小n-k>0?n-k:(k-(n-1)%2==0?1:2)
	//最大k%2==0?n:n-1

	
	for(int i=max(0,n-k);i<=n;i++){
		sum+=(a[i-1]*b[i])%mode;
		sum%=mode;
	}
	cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:22: error: no matching function for call to 'max(int, long long int)'
   84 |         for(int i=max(0,n-k);i<=n;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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:84:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   84 |         for(int i=max(0,n-k);i<=n;i++){
      |                   ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:84:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   84 |         for(int i=max(0,n-k);i<=n;i++){
      |                   ~~~^~~~~~~