Problem - 1186C - Codeforces
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define syncfalse ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int N = 1e6+5;
char a[N], b[N];
int pre[N][2];
int main(){
syncfalse
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
cin>>a+1>>b+1;
int n = strlen(a+1), m = strlen(b+1);
int num0 = 0, num1 = 0;
for (int i = 1; i <= m; ++i){
if (b[i]=='0')num0++;
else num1++;
}
for (int i = 1; i <= n; ++i){
pre[i][0]+=pre[i-1][0];
pre[i][1]+=pre[i-1][1];
if (a[i]=='1')pre[i][1]++;
else pre[i][0]++;
}
int l = 1;
int ans = 0;
for (int r = m; r <= n; ++r, ++l){
int now1 = pre[r][1]-pre[l-1][1];
int tem = abs(now1-num1);
if (tem%2==0)ans++;
}
cout << ans << "\n";
return 0;
}