Source Code
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;


void solve() {
	string s;
	cin >> s;
	int o = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			o++;
		}
	}
	for (int i = 0; i < s.size() - 2; i++) {
		if (s[i] == s[i + 2] && s[i] == '1' && s[i + 1] != '1') {
			o++;
		}
	}
	cout << o;
}

int main() {
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
}
Copy
Japanese holidays lafi-Odeh
GNU G++17
4 ms
1.2 MB
Accepted