Language: C++

#include <iostream>
#include <string>
using namespace std;
int cnt, a[1000000];
long long max, t;
int main()
{
	int n, k;
	int jud=0, j;
	string s;
	cin>>n>>k>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]-48==1)
		{
			for( j=i+1;j<n;j++)
			{
				if(s[j]-48==0)break;
			}
			a[cnt++]=j-i;
			i=j;
		}
		else
		{
		    for(j=i+1;j<n;j++)
			{
				if(s[j]-48==1)break;
			}
			a[cnt++]=j-i;
			i=j;
		}
	}
	if(s[0]-48==0)jud=0;
	else jud=1;
	for(int i=0;i<cnt;i++)
	{
		int jud=(i+jud)%2;
		if(jud==1)
		{
			for(int j=i;j<=i+2*k;j++)
			{
				t+=a[j];
			}
			if(max<t)
			{
			  max=t;
			}
			t=0;
		}
		else
		{
						for(int j=i;j<=i+2*k-1;j++)
			{
				t+=a[j];
			}
			if(max<t)
			{
				max=t;
			}
			t=0;
		}
	}
	
	cout<<max<<endl;
	
	return 0;
	
		
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:28: error: reference to 'max' is ambiguous
   44 |                         if(max<t)
      |                            ^~~
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:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:11: note:                 'long long int max'
    5 | long long max, t;
      |           ^~~
a.cc:46:27: error: reference to 'max' is ambiguous
   46 |                           max=t;
      |                           ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:11: note:                 'long long int max'
    5 | long long max, t;
      |           ^~~
a.cc:56:28: error: reference to 'max' is ambiguous
   56 |                         if(max<t)
      |                            ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:11: note:                 'long long int max'
    5 | long long max, t;
      |           ^~~
a.cc:58:33: error: reference to 'max' is ambiguous
   58 |                                 max=t;
      |                                 ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:11: note:                 'long long int max'
    5 | long long max, t;
      |           ^~~
a.cc:64:15: error: reference to 'max' is ambiguous
   64 |         cout<<max<<endl;
      |               ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:11: note:                 'long long int max'
    5 | long long max, t;
      |           ^~~