Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>


int main(){
    string s;
    cin >> s;
    int a[4] = {0, 0, 0, 0};
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            if(s[i] == '0'){
                a[0]++;
            }else{
                a[1]++;
            }
        }else{
            if(s[i] == '0'){
                a[2]++;
            }else{
                a[3]++;
            }
        }
    }
    if(a[0] >= a[1] && a[2] <= a[3]){
        cout << s.size() -  a[0] - a[3];
    }
    else if(a[0] >= a[1] && a[2] >= a[3]){
        if(a[0] >= a[2]){
            cout << s.size() - a[0] - a[3];
        }else{
            cout << s.size() - a[1] - a[2];
        }
    }
    else if(a[0] <= a[1] && a[2] <= a[3]){
        if(a[1] >= a[3]){
            cout << s.size() - a[1] - a[2];
        }else{
            cout << s.size() - a[0] - a[3];
        }
    }
    else if(a[0] <= a[1] && a[2] >= a[3]){
        cout << s.size() -  a[1] - a[2];
    }
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'string' was not declared in this scope
   13 |     string s;
      |     ^~~~~~
a.cc:13:5: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included 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:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:14:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   14 |     cin >> s;
      |     ^~~
      |     std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:14:12: error: 's' was not declared in this scope
   14 |     cin >> s;
      |            ^
a.cc:32:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   32 |         cout << s.size() -  a[0] - a[3];
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:36:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   36 |             cout << s.size() - a[0] - a[3];
      |             ^~~~
      |             std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:38:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   38 |             cout << s.size() - a[1] - a[2];
      |             ^~~~
      |             std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:43:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   43 |             cout << s.size() - a[1] - a[2];
      |             ^~~~
      |             std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:45:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   45 |             cout << s.size() - a[0] - a[3];
      |             ^~~~
      |             std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:49:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   49 |         cout << s.size() -  a[1] - a[2];
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~