Source Code
#include <iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	int count = 0;
	if(s[0]=='1')count++;
	if(s[1]=='1')count++;
	for(int i=2;i<s.size(); i++){
	    if(s[i]=='1'&&s[i-1]=='0'&&s[i-2]=='1'){
	        count++;
	    }
	    if(s[i]=='1'){
	        count++;
	    }
	}
	cout<<count;
	return 0;
}
Copy
Japanese holidays Alazzam
GNU G++17
3 ms
508 KB
Accepted