Source Code
#include <iostream>
using namespace std;
int main() {
  int c=0;
  string n;
  cin>>n;
  for(int i=0;i<n.size();i++){
    if(n[i]=='1'){
      c++;
      if(n[i+1]=='0' && n[i+2]=='1' && i<=n.size()-2){
        c++;
      }
    }
    
  }
  //1001011100101
  //1001011100101 
  //1 
  cout<<c;
}
Copy
Japanese holidays Hadeel
GNU G++17
6 ms
956 KB
Accepted