Source Code
#include <iostream>

using namespace std;

int main()
{
    string days;

    cin >> days;

    int counter = 0;
    if (days[0] == '1')
    {
        counter++;
    }

    if (days.length() > 1 && days[1] == '1')
    {
        counter++;
    }

    for (int i = 2; i < days.length(); i++)
    {
        if (days[i] == '1')
        {
            counter++;
            if (days[i - 1] == '0' && days[i - 2] == '1')
            {
                counter++;
            }
        }
    }
    cout << counter << endl;
    return 0;
}
Copy
Japanese holidays DirtyQWERTY
GNU G++17
6 ms
964 KB
Accepted