Language: C++

#include <iostream>                                                                                     #include <vector>
#include <algorithm>
#include <map>
#include <string.h>                                                                                                                                                                                             using namespace std;

int main() {
    string s;
    cin >> s;
    int pos = 0;
    int pos_pre = 0;
    int count=0;
    int zero= 0;                                                                                            int one= 0;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == '0') {
            pos = 0;
        } else {
            pos = 1;
        }
        if (i != 0 ) {
            if (pos_pre == pos) {
                count++;
                if (pos == 0) {
                    pos = 1;
                } else {
                    pos = 0;
                }
            }
        }
        pos_pre = pos;
    }
    cout << count;
}


Compiler output:
a.cc:1:105: warning: extra tokens at end of #include directive
    1 | #include <iostream>                                                                                     #include <vector>
      |                                                                                                         ^
a.cc:4:209: warning: extra tokens at end of #include directive
    4 | #include <string.h>                                                                                                                                                                                             using namespace std;
      |                                                                                                                                                                                                                 ^~~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'string' was not declared in this scope
    7 |     string s;
      |     ^~~~~~
a.cc:7: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:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |     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:8:12: error: 's' was not declared in this scope
    8 |     cin >> s;
      |            ^
a.cc:31:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |     cout << count;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~