Language: C++

#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=500005;
int n,ans;
char c[maxn];
string s;
int dp[maxn],pre[maxn];

int main(){
	scanf("%d%s",&n,c);
	s=c;
	pre[0]=s[0]=='1';
	REP(i,n-1){
		if(s[i]=='0')pre[i]=0;
		else pre[i]=pre[i-1]+1;
//		cout<<pre[i]<<endl;
	}
	dp[0]=0;
	REP(i,n-1){
		if(i<2)continue;
		dp[i]=dp[i-1];
		if(s[i]=='1'&&s[i-1]=='0'&&s[i-2]=='1')
		dp[i]=max(dp[i],(i-pre[i-2]-2<0?0:dp[i-pre[i-2]-2])+pre[i-2]);
		if(pre[i]&&i-pre[i]>=1&&s[i-pre[i]]=='0'&&s[i-pre[i]-1]=='1')
		dp[i]=max(dp[i],(i-pre[i]-2<0?0:dp[i-pre[i]-2])+pre[i]); 
		ans=max(ans,dp[i]);
	}
	printf("%d",ans);
	return 0;
}#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=500005;
int n,ans;
char c[maxn];
string s;
int dp[maxn],pre[maxn];

int main(){
	scanf("%d%s",&n,c);
	s=c;
	pre[0]=s[0]=='1';
	REP(i,n-1){
		if(s[i]=='0')pre[i]=0;
		else pre[i]=pre[i-1]+1;
//		cout<<pre[i]<<endl;
	}
	dp[0]=0;
	REP(i,n-1){
		if(i<2)continue;
		dp[i]=dp[i-1];
		if(s[i]=='1'&&s[i-1]=='0'&&s[i-2]=='1')
		dp[i]=max(dp[i],(i-pre[i-2]-2<0?0:dp[i-pre[i-2]-2])+pre[i-2]);
		if(pre[i]&&i-pre[i]>=1&&s[i-pre[i]]=='0'&&s[i-pre[i]-1]=='1')
		dp[i]=max(dp[i],(i-pre[i]-2<0?0:dp[i-pre[i]-2])+pre[i]); 
		ans=max(ans,dp[i]);
	}
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc:83:2: error: stray '#' in program
   83 | }#include<ctime>
      |  ^
a.cc:83:3: error: 'include' does not name a type
   83 | }#include<ctime>
      |   ^~~~~~~
a.cc:133:13: error: redefinition of 'void Fail()'
  133 | inline void Fail(){
      |             ^~~~
a.cc:51:13: note: 'void Fail()' previously defined here
   51 | inline void Fail(){
      |             ^~~~
a.cc:138:11: error: redefinition of 'const int maxn'
  138 | const int maxn=500005;
      |           ^~~~
a.cc:56:11: note: 'const int maxn' previously defined here
   56 | const int maxn=500005;
      |           ^~~~
a.cc:139:5: error: redefinition of 'int n'
  139 | int n,ans;
      |     ^
a.cc:57:5: note: 'int n' previously declared here
   57 | int n,ans;
      |     ^
a.cc:139:7: error: redefinition of 'int ans'
  139 | int n,ans;
      |       ^~~
a.cc:57:7: note: 'int ans' previously declared here
   57 | int n,ans;
      |       ^~~
a.cc:140:6: error: redefinition of 'char c [500005]'
  140 | char c[maxn];
      |      ^
a.cc:58:6: note: 'char c [500005]' previously declared here
   58 | char c[maxn];
      |      ^
a.cc:141:8: error: redefinition of 'std::string s'
  141 | string s;
      |        ^
a.cc:59:8: note: 'std::string s' previously declared here
   59 | string s;
      |        ^
a.cc:142:5: error: redefinition of 'int dp [500005]'
  142 | int dp[maxn],pre[maxn];
      |     ^~
a.cc:60:5: note: 'int dp [500005]' previously declared here
   60 | int dp[maxn],pre[maxn];
      |     ^~
a.cc:142:14: error: redefinition of 'int pre [500005]'
  142 | int dp[maxn],pre[maxn];
      |              ^~~
a.cc:60:14: note: 'int pre [500005]' previously declared here
   60 | int dp[maxn],pre[maxn];
      |              ^~~
a.cc:144:5: error: redefinition of 'int main()'
  144 | int main(){
      |     ^~~~
a.cc:62:5: note: 'int main()' previously defined here
   62 | int main(){
      |     ^~~~