Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            if(N <= K)
            {
                ReadLine();
                WriteLine(N);
                return;
            }

            var s = ReadLine();

            List<int> index = new List<int>();
            index.Add(0);
            int start = int.Parse(s[0].ToString());
            for(int i = 1; i < N; i++)
            {
                if(s[i] != s[i - 1])
                {
                    index.Add(i);
                }
            }
            index.Add(s.Length - 1);
            List<int> num = new List<int>();
            for(int i=0; i < index.Count; i++)
            {
                num.Add(index[Math.Min((i + (2 * K) + ((i + start) % 2) + 1),index.Count - 1)] - index[i]);
            }

            WriteLine(num.Max());
        }
    }
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'static'
    4 | using static System.Console;
      |       ^~~~~~
a.cc:10:26: error: 'string' has not been declared
   10 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:10:35: error: expected ',' or '...' before 'args'
   10 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:43:6: error: expected ';' after class definition
   43 |     }
      |      ^
      |      ;
a.cc: In static member function 'static void D::Program::Main(int*)':
a.cc:12:13: error: 'var' was not declared in this scope
   12 |             var input = ReadLine().Split(' ');
      |             ^~~
a.cc:13:21: error: expected primary-expression before 'int'
   13 |             int N = int.Parse(input[0]);
      |                     ^~~
a.cc:14:21: error: expected primary-expression before 'int'
   14 |             int K = int.Parse(input[1]);
      |                     ^~~
a.cc:17:17: error: 'ReadLine' was not declared in this scope
   17 |                 ReadLine();
      |                 ^~~~~~~~
a.cc:18:17: error: 'WriteLine' was not declared in this scope
   18 |                 WriteLine(N);
      |                 ^~~~~~~~~
a.cc:22:17: error: expected ';' before 's'
   22 |             var s = ReadLine();
      |                 ^
a.cc:24:13: error: 'List' was not declared in this scope
   24 |             List<int> index = new List<int>();
      |             ^~~~
a.cc:24:18: error: expected primary-expression before 'int'
   24 |             List<int> index = new List<int>();
      |                  ^~~
a.cc:25:13: error: 'index' was not declared in this scope
   25 |             index.Add(0);
      |             ^~~~~
a.cc:26:25: error: expected primary-expression before 'int'
   26 |             int start = int.Parse(s[0].ToString());
      |                         ^~~
a.cc:29:20: error: 's' was not declared in this scope
   29 |                 if(s[i] != s[i - 1])
      |                    ^
a.cc:34:23: error: 's' was not declared in this scope
   34 |             index.Add(s.Length - 1);
      |                       ^
a.cc:35:18: error: expected primary-expression before 'int'
   35 |             List<int> num = new List<int>();
      |                  ^~~
a.cc:38:17: error: 'num' was not declared in this scope; did you mean 'enum'?
   38 |                 num.Add(index[Math.Min((i + (2 * K) + ((i + start) % 2) + 1),index.Count - 1)] - index[i]);
      |                 ^~~
      |                 enum
a.cc:38:31: error: 'Math' was not declared in this scope
   38 |                 num.Add(index[Math.Min((i + (2 * K) + ((i + start) % 2) + 1),index.Count - 1)] - index[i]);
      |                               ^~~~
a.cc:41:23: error: 'num' was not declared in this scope; did you mean 'enum'?
   41 |             WriteLine(num.Max());
      |                       ^~~
      |                       enum
a.cc:41:13: error: 'WriteLine' was not declared in this scope
   41 |             WriteLine(num.Max());
      |             ^~~~~~~~~