Source Code
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define IN freopen("input.txt", "r", stdin)
#define OUT freopen("output.txt", "w", stdout)
typedef vector<int> vi;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i <= b; i++)
int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == '1')
         ans++;
         else if(s[i-1] == '1' && s[i+1] == '1')
          ans++;
    }
    cout << ans << '\n';
}
Copy
Japanese holidays monther abu zaina
GNU G++17
2 ms
884 KB
Accepted