stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



string kata;

int len;

int prefixsum[100005];

int tmp;



int main(){

	cin>>kata;

	int r = kata.length();

	len = r;

	int l = 1;

	while(l<r){

		int mid = (l+r+1)>>1;

		

		memset(prefixsum, 0, sizeof(prefixsum));

		tmp =0;

		for(int i=0; i+mid <= len; i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos){

				prefixsum[i+1] ++;

				prefixsum[i+mid] --;

			}

		}

		int sisa  = len - mid;

		for(int i=len-mid+1;i<len;i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos == 0) sisa = i;else break;

		}

		if(sisa+1 >= mid){

			l = mid;

		}else{

			r = mid -1;

		}

	}	

	cout<<l<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 1.4758885710213419x):
#include <iostream>



using namespace std;



int main(){

    string s;

    cin>>s;

    bool ok = true;

    int ans = 1e9;

    

  

    for(int i=1;i<(int)s.length();i++){

        if(s[i]!=s[i-1]){

            ans = min(ans,max(i,(int)s.length()-i));

        }

    }

    if(ans == 1e9){

        cout<<s.length()<<endl;

        return 0;

    }

    cout<<ans<<endl;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



string kata;

int len;

int prefixsum[100005];

int tmp;



int main(){

	cin>>kata;

	int r = kata.length();

	len = r;

	int l = 1;

	while(l<r){

		int mid = (l+r+1)>>1;

		

		memset(prefixsum, 0, sizeof(prefixsum));

		tmp =0;

		for(int i=0; i+mid <= len; i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos){

				prefixsum[i+1] ++;

				prefixsum[i+mid] --;

			}

		}

		int sisa  = len - mid;

		for(int i=len-mid+1;i<len;i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos == 0) sisa = i;else break;

		}

		if(sisa+1 >= mid){

			l = mid;

		}else{

			r = mid -1;

		}

	}	

	cout<<l<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 1.46681112892887x):
#include <bits/stdc++.h>

#define ll long long



using namespace std;



int n;

string s;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);



	cin>>s;

	int n=s.size();

	bool isti=true;

	for(int i=1;i<n;i++)

        if(s[i]!=s[i-1])

            isti=false;

    if(isti)

    {

        cout<<n;

        return 0;

    }

	int k=n;

	for(int i=0;i<n/2;i++)

        if(s[i]!=s[i+1])

            k=min(k,n-i-1);

    for(int i=(n+1)/2;i<n;i++)

        if(s[i]!=s[i-1])

            k=min(k,i);

    cout<<k;

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



string kata;

int len;

int prefixsum[100005];

int tmp;



int main(){

	cin>>kata;

	int r = kata.length();

	len = r;

	int l = 1;

	while(l<r){

		int mid = (l+r+1)>>1;

		

		memset(prefixsum, 0, sizeof(prefixsum));

		tmp =0;

		for(int i=0; i+mid <= len; i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos){

				prefixsum[i+1] ++;

				prefixsum[i+mid] --;

			}

		}

		int sisa  = len - mid;

		for(int i=len-mid+1;i<len;i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos == 0) sisa = i;else break;

		}

		if(sisa+1 >= mid){

			l = mid;

		}else{

			r = mid -1;

		}

	}	

	cout<<l<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 1.490222186768017x):
#include<iostream>

#include<cstdio>

#include<queue>

#include<string>

#include<stack>

#include<algorithm>

#include<cstring>

#include<map>

using namespace std;

string s; 

int main()

{

	cin>>s;

	int ans=s.length();

	int l=s.length();

	for(int i=1;i<l;i++)

	{

		if(s[i]!=s[i-1])

		{

			ans=min(ans,max(i,l-i));

		}

	}

	cout<<ans;

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



string kata;

int len;

int prefixsum[100005];

int tmp;



int main(){

	cin>>kata;

	int r = kata.length();

	len = r;

	int l = 1;

	while(l<r){

		int mid = (l+r+1)>>1;

		

		memset(prefixsum, 0, sizeof(prefixsum));

		tmp =0;

		for(int i=0; i+mid <= len; i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos){

				prefixsum[i+1] ++;

				prefixsum[i+mid] --;

			}

		}

		int sisa  = len - mid;

		for(int i=len-mid+1;i<len;i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos == 0) sisa = i;else break;

		}

		if(sisa+1 >= mid){

			l = mid;

		}else{

			r = mid -1;

		}

	}	

	cout<<l<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 1.5052734132016354x):
#include<cstdio>

#include<cstring>

#include<iostream>

const int M=120000;

using namespace std;

int a[M],ans;char s[M];

int main(){

    

    scanf("%s",s+1);

    int n=strlen(s+1);

    ans=n;

    for(int i=2;i<=n;i++)

    if(s[i]!=s[i-1])

    ans=min(ans,max(i-1,n-i+1));

    printf("%d",ans);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



string kata;

int len;

int prefixsum[100005];

int tmp;



int main(){

	cin>>kata;

	int r = kata.length();

	len = r;

	int l = 1;

	while(l<r){

		int mid = (l+r+1)>>1;

		

		memset(prefixsum, 0, sizeof(prefixsum));

		tmp =0;

		for(int i=0; i+mid <= len; i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos){

				prefixsum[i+1] ++;

				prefixsum[i+mid] --;

			}

		}

		int sisa  = len - mid;

		for(int i=len-mid+1;i<len;i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos == 0) sisa = i;else break;

		}

		if(sisa+1 >= mid){

			l = mid;

		}else{

			r = mid -1;

		}

	}	

	cout<<l<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 1.4557498200529266x):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cstdlib>

#include<vector>

#include<string>



typedef long long ll;



using namespace std;



int main(){

    ios::sync_with_stdio(0);

    string s;

    cin >> s;

    int ans = 1e9;

    int len = s.length();

    for (int i = 0; i <= len-2; i++){

        if(s[i]!=s[i+1]){

            ans = min(ans, max(i + 1, len -1 - i));

        }

    }

    //易错!!!如果ans还是1e9的话,答案应该是s.length()!!!我只想着"因为要去最小值所以一开始要初始化一个很大的值"了...

    //其实一开始给ans初始化s.length()就行啦~~

    if(ans==(int)1e9){

        ans = len;

    }

    cout << ans << endl;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



string kata;

int len;

int prefixsum[100005];

int tmp;



int main(){

	cin>>kata;

	int r = kata.length();

	len = r;

	int l = 1;

	while(l<r){

		int mid = (l+r+1)>>1;

		

		memset(prefixsum, 0, sizeof(prefixsum));

		tmp =0;

		for(int i=0; i+mid <= len; i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos){

				prefixsum[i+1] ++;

				prefixsum[i+mid] --;

			}

		}

		int sisa  = len - mid;

		for(int i=len-mid+1;i<len;i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos == 0) sisa = i;else break;

		}

		if(sisa+1 >= mid){

			l = mid;

		}else{

			r = mid -1;

		}

	}	

	cout<<l<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 1.505499178708506x):
//C

#include<cstdio> 

#include<iostream>

#include<cstring>

using namespace std;

char s[100010];

int main()

{

	int k=100010,len;

	scanf("%s",s);

	len=strlen(s);

	for(int i=0;i<len;i++)

	{

		if(s[i]!=s[i+1])

		{

			k=min(k,max(i+1,len-1-i));

		}

	}

	printf("%d",k);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



string kata;

int len;

int prefixsum[100005];

int tmp;



int main(){

	cin>>kata;

	int r = kata.length();

	len = r;

	int l = 1;

	while(l<r){

		int mid = (l+r+1)>>1;

		

		memset(prefixsum, 0, sizeof(prefixsum));

		tmp =0;

		for(int i=0; i+mid <= len; i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos){

				prefixsum[i+1] ++;

				prefixsum[i+mid] --;

			}

		}

		int sisa  = len - mid;

		for(int i=len-mid+1;i<len;i++){

			tmp += prefixsum[i];

			int nilpos = (kata[i] - '0') ^ (tmp & 1);

			if(nilpos == 0) sisa = i;else break;

		}

		if(sisa+1 >= mid){

			l = mid;

		}else{

			r = mid -1;

		}

	}	

	cout<<l<<"\n";

}

// Faster C++ solution for the same problem (measured speedup: 1.475925624009315x):
#include <iostream>

#include <stdio.h>



using namespace std;



int main()

{

    string s;

    cin>>s;

    int le=s.size();

    int n=le;

    for(int i=1;i<n;i++)

        if(s[i]!=s[i-1])

            le=min(le,max(n-i,i));

    cout<<le<<endl;

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

string s;

int ans=1<<30;

int main()

{

	cin>>s;

	for(int i=1;i<s.length();i++)

		if(s[i]!=s[i-1])

			ans=min(ans,max(i,int(s.length())-i));

	cout<<min(ans,int(s.length()))<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.278297406691189x):
/*

#pragma GCC optimize(2)

#pragma GCC optimize(3)

#pragma GCC optimize("Ofast")

#pragma GCC optimize("inline")

#pragma GCC optimize("-fgcse")

#pragma GCC optimize("-fgcse-lm")

#pragma GCC optimize("-fipa-sra")

#pragma GCC optimize("-ftree-pre")

#pragma GCC optimize("-ftree-vrp")

#pragma GCC optimize("-fpeephole2")

#pragma GCC optimize("-ffast-math")

#pragma GCC optimize("-fsched-spec")

#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("-falign-jumps")

#pragma GCC optimize("-falign-loops")

#pragma GCC optimize("-falign-labels")

#pragma GCC optimize("-fdevirtualize")

#pragma GCC optimize("-fcaller-saves")

#pragma GCC optimize("-fcrossjumping")

#pragma GCC optimize("-fthread-jumps")

#pragma GCC optimize("-funroll-loops")

#pragma GCC optimize("-fwhole-program")

#pragma GCC optimize("-freorder-blocks")

#pragma GCC optimize("-fschedule-insns")

#pragma GCC optimize("inline-functions")

#pragma GCC optimize("-ftree-tail-merge")

#pragma GCC optimize("-fschedule-insns2")

#pragma GCC optimize("-fstrict-aliasing")

#pragma GCC optimize("-fstrict-overflow")

#pragma GCC optimize("-falign-functions")

#pragma GCC optimize("-fcse-skip-blocks")

#pragma GCC optimize("-fcse-follow-jumps")

#pragma GCC optimize("-fsched-interblock")

#pragma GCC optimize("-fpartial-inlining")

#pragma GCC optimize("no-stack-protector")

#pragma GCC optimize("-freorder-functions")

#pragma GCC optimize("-findirect-inlining")

#pragma GCC optimize("-frerun-cse-after-loop")

#pragma GCC optimize("inline-small-functions")

#pragma GCC optimize("-finline-small-functions")

#pragma GCC optimize("-ftree-switch-conversion")

#pragma GCC optimize("-foptimize-sibling-calls")

#pragma GCC optimize("-fexpensive-optimizations")

#pragma GCC optimize("-funsafe-loop-optimizations")

#pragma GCC optimize("inline-functions-called-once")

#pragma GCC optimize("-fdelete-null-pointer-checks")

*/

#include <stdio.h>

#include <string.h> 

int ans = 1 << 25;

char str[100010];

int main()

{

	scanf("%s", str);

	int len = strlen(str);

	for (int _ = 1; _ < len; ++ _)

	{

		if (str[_] != str[_ - 1])

		{

			ans = ans > (_ > len - _? _: len - _)? (_ > len - _? _: len - _): ans;

		}

	 } 

	 return !printf("%d\n", ans > len? len: ans);

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

using namespace std;

bool a[100005], c[100005];

int n;

int getans(int k){

	int i;

	memset(c, 0, sizeof(c));

	for(i=2; i<=k; i++){

		c[i]=c[i]^c[i-1];

		if((a[i]^c[i])^(a[i-1]^c[i-1])){

			if(i+k-1>n)

				return false;

			c[i]=!c[i];

			c[i+k-1]=!c[i+k-1];

		}

	}

	return true;

}

int main(){

	int i, l, r, mid;

	char ch;

	

	n=0;

	ch=getchar();

	while(~ch and ch>>5){

		a[++n]=ch&1; 

		ch=getchar();

	}

	l=1;

	r=n;

	while(l<r){

		mid=(l+r+1)>>1;

		if(getans(mid))

			l=mid;

		else

			r=mid-1;

	}

	printf("%d", l);

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.6296549894529215x):


#pragma GCC optimize(2)

#pragma GCC optimize(3)

#pragma GCC optimize("Ofast")

#pragma GCC optimize("inline")

#pragma GCC optimize("-fgcse")

#pragma GCC optimize("-fgcse-lm")

#pragma GCC optimize("-fipa-sra")

#pragma GCC optimize("-ftree-pre")

#pragma GCC optimize("-ftree-vrp")

#pragma GCC optimize("-fpeephole2")

#pragma GCC optimize("-ffast-math")

#pragma GCC optimize("-fsched-spec")

#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("-falign-jumps")

#pragma GCC optimize("-falign-loops")

#pragma GCC optimize("-falign-labels")

#pragma GCC optimize("-fdevirtualize")

#pragma GCC optimize("-fcaller-saves")

#pragma GCC optimize("-fcrossjumping")

#pragma GCC optimize("-fthread-jumps")

#pragma GCC optimize("-funroll-loops")

#pragma GCC optimize("-fwhole-program")

#pragma GCC optimize("-freorder-blocks")

#pragma GCC optimize("-fschedule-insns")

#pragma GCC optimize("inline-functions")

#pragma GCC optimize("-ftree-tail-merge")

#pragma GCC optimize("-fschedule-insns2")

#pragma GCC optimize("-fstrict-aliasing")

#pragma GCC optimize("-fstrict-overflow")

#pragma GCC optimize("-falign-functions")

#pragma GCC optimize("-fcse-skip-blocks")

#pragma GCC optimize("-fcse-follow-jumps")

#pragma GCC optimize("-fsched-interblock")

#pragma GCC optimize("-fpartial-inlining")

#pragma GCC optimize("no-stack-protector")

#pragma GCC optimize("-freorder-functions")

#pragma GCC optimize("-findirect-inlining")

#pragma GCC optimize("-frerun-cse-after-loop")

#pragma GCC optimize("inline-small-functions")

#pragma GCC optimize("-finline-small-functions")

#pragma GCC optimize("-ftree-switch-conversion")

#pragma GCC optimize("-foptimize-sibling-calls")

#pragma GCC optimize("-fexpensive-optimizations")

#pragma GCC optimize("-funsafe-loop-optimizations")

#pragma GCC optimize("inline-functions-called-once")

#pragma GCC optimize("-fdelete-null-pointer-checks")



#include <stdio.h>

#include <string.h> 

int ans = 1 << 25;

char str[100010];

int main()

{

	scanf("%s", str);

	int len = strlen(str);

	for (int _ = 1; _ < len; ++ _)

	{

		if (str[_] != str[_ - 1])

		{

			ans = ans > (_ > len - _? _: len - _)? (_ > len - _? _: len - _): ans;

		}

	 } 

	 return !printf("%d\n", ans > len? len: ans);

}
// Slower C++ solution:
    #include<iostream>

    #include<string>

    #include<algorithm>

    using namespace std;

    int main(){

        string S;

        cin>>S;

        int res=S.size();

        int a=S.size();

        for(int i=1;i<S.size();i++){

            if(S[i]!=S[i-1])

                res=min(res,max(i,a-i));

        }

        cout<<res<<endl;

        return 0;

    }




// Faster C++ solution for the same problem (measured speedup: 5.307940401543944x):


#pragma GCC optimize(2)

#pragma GCC optimize(3)

#pragma GCC optimize("Ofast")

#pragma GCC optimize("inline")

#pragma GCC optimize("-fgcse")

#pragma GCC optimize("-fgcse-lm")

#pragma GCC optimize("-fipa-sra")

#pragma GCC optimize("-ftree-pre")

#pragma GCC optimize("-ftree-vrp")

#pragma GCC optimize("-fpeephole2")

#pragma GCC optimize("-ffast-math")

#pragma GCC optimize("-fsched-spec")

#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("-falign-jumps")

#pragma GCC optimize("-falign-loops")

#pragma GCC optimize("-falign-labels")

#pragma GCC optimize("-fdevirtualize")

#pragma GCC optimize("-fcaller-saves")

#pragma GCC optimize("-fcrossjumping")

#pragma GCC optimize("-fthread-jumps")

#pragma GCC optimize("-funroll-loops")

#pragma GCC optimize("-fwhole-program")

#pragma GCC optimize("-freorder-blocks")

#pragma GCC optimize("-fschedule-insns")

#pragma GCC optimize("inline-functions")

#pragma GCC optimize("-ftree-tail-merge")

#pragma GCC optimize("-fschedule-insns2")

#pragma GCC optimize("-fstrict-aliasing")

#pragma GCC optimize("-fstrict-overflow")

#pragma GCC optimize("-falign-functions")

#pragma GCC optimize("-fcse-skip-blocks")

#pragma GCC optimize("-fcse-follow-jumps")

#pragma GCC optimize("-fsched-interblock")

#pragma GCC optimize("-fpartial-inlining")

#pragma GCC optimize("no-stack-protector")

#pragma GCC optimize("-freorder-functions")

#pragma GCC optimize("-findirect-inlining")

#pragma GCC optimize("-frerun-cse-after-loop")

#pragma GCC optimize("inline-small-functions")

#pragma GCC optimize("-finline-small-functions")

#pragma GCC optimize("-ftree-switch-conversion")

#pragma GCC optimize("-foptimize-sibling-calls")

#pragma GCC optimize("-fexpensive-optimizations")

#pragma GCC optimize("-funsafe-loop-optimizations")

#pragma GCC optimize("inline-functions-called-once")

#pragma GCC optimize("-fdelete-null-pointer-checks")



#include <stdio.h>

#include <string.h> 

int ans = 1 << 25;

char str[100010];

int main()

{

	scanf("%s", str);

	int len = strlen(str);

	for (int _ = 1; _ < len; ++ _)

	{

		if (str[_] != str[_ - 1])

		{

			ans = ans > (_ > len - _? _: len - _)? (_ > len - _? _: len - _): ans;

		}

	 } 

	 return !printf("%d\n", ans > len? len: ans);

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

using namespace std;

bool a[100005], c[100005];

int n;

int getans(int k){

	int i;

	memset(c, 0, sizeof(c));

	for(i=2; i<=k; i++){

		c[i]=c[i]^c[i-1];

		if((a[i]^c[i])^(a[i-1]^c[i-1])){

			if(i+k-1>n)

				return false;

			c[i]=!c[i];

			c[i+k-1]=!c[i+k-1];

		}

	}

	return true;

}

int main(){

	int i, l, r, mid;

	char ch;

	

	n=0;

	ch=getchar();

	while(~ch and ch>>5){

		a[++n]=ch&1; 

		ch=getchar();

	}

	l=1;

	r=n;

	while(l<r){

		mid=(l+r+1)>>1;

		if(getans(mid))

			l=mid;

		else

			r=mid-1;

	}

	printf("%d", l);

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 1.6323746984914267x):
#include "cstdio"

#include "cstring"

int max(int x,int y){

	return x>y?x:y;

}

int min(int x,int y){

	return x<y?x:y;

}

char s[100005];int ss=1e9;

int main(){

	scanf("%s",s);int x=strlen(s);

	for(int i=1;i<x;i++){

		if(s[i]!=s[i-1])ss=min(ss,max(i,x-i));

	}

	printf("%d\n",min(ss,x));

}
// Slower C++ solution:
    #include<iostream>

    #include<string>

    #include<algorithm>

    using namespace std;

    int main(){

        string S;

        cin>>S;

        int res=S.size();

        int a=S.size();

        for(int i=1;i<S.size();i++){

            if(S[i]!=S[i-1])

                res=min(res,max(i,a-i));

        }

        cout<<res<<endl;

        return 0;

    }




// Faster C++ solution for the same problem (measured speedup: 5.316798751059244x):
#include "cstdio"

#include "cstring"

int max(int x,int y){

	return x>y?x:y;

}

int min(int x,int y){

	return x<y?x:y;

}

char s[100005];int ss=1e9;

int main(){

	scanf("%s",s);int x=strlen(s);

	for(int i=1;i<x;i++){

		if(s[i]!=s[i-1])ss=min(ss,max(i,x-i));

	}

	printf("%d\n",min(ss,x));

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main() {

    string a; 

    int minn = 214748364; 

    cin >> a;

    for (int i = 1; i < a.size(); i++) 

        if (a[i] != a[i - 1]) 

            minn = min(max(int(a.size()) - i, i), minn);

    if (minn < a.size()) printf("%d\n", minn); else printf("%d\n", a.size());

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2518088168537505x):
#include "cstdio"

#include "cstring"

int max(int x,int y){

	return x>y?x:y;

}

int min(int x,int y){

	return x<y?x:y;

}

char s[100005];int ss=1e9;

int main(){

	scanf("%s",s);int x=strlen(s);

	for(int i=1;i<x;i++){

		if(s[i]!=s[i-1])ss=min(ss,max(i,x-i));

	}

	printf("%d\n",min(ss,x));

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int main()

{

    string s;

    while(cin>>s)

    {



    int res=s.size();

    int a=s.size();

    for(int i=1; i<s.size(); i++)

    {

        if(s[i]!=s[i-1])

            res=min(res,max(i,a-i));

    }

    cout<<res<<endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.320665361487578x):
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include<algorithm>

using namespace std;

char s[210000];

int n,ans;

int main()

{

    scanf("%s",s+1);

    n=strlen(s+1);

    ans=n;

    for(int i=1;i<n;i++)

    {

        if(s[i]!=s[i+1])

            ans=min(ans,max(i,n-i));

    }

    printf("%d\n",ans);

    //system("pause");

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string.h>

#include <stdio.h>

#include <algorithm>

using namespace std;

char t[100001];

int main()

{

    while(scanf("%s",t)!=EOF)

    {

    int y=strlen(t);

    int max1=y;

    int h=0;

    for(int i=0;i<y;i++)

    {

        if(t[i]!=t[i+1])

        {

            int u;

            if(y-i-1>i+1)

                u=y-i-1;

            else

                u=i+1;

            if(max1>u)

                max1=u;

        }

    }

    cout<<max1<<endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.279729599329321x):
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include<algorithm>

using namespace std;

char s[210000];

int n,ans;

int main()

{

    scanf("%s",s+1);

    n=strlen(s+1);

    ans=n;

    for(int i=1;i<n;i++)

    {

        if(s[i]!=s[i+1])

            ans=min(ans,max(i,n-i));

    }

    printf("%d\n",ans);

    //system("pause");

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string.h>

#define MAXN 100005

using namespace std;



int n, ps[MAXN];

string s;

bool valid(int k){

	memset(ps, 0, sizeof ps);

	int tmp = 0;

	for(int i = 0; i <= n - k; i++){

		tmp += ps[i];

		int now = (s[i]	- '0') ^ (tmp % 2);

//		cout << i << " # " << tmp << " \n";

		if(!now) continue;

		ps[i+1]++;

		ps[min(i+k, n)]--;

	}

	int r = n - k;

	for(int i = n - k + 1; i < n; i++){

		tmp += ps[i];

		int now = (s[i]	- '0') ^ (tmp % 2);

		if(now) break;

		r = i;

	}

//	cout << k << " -> " << r << "\n";

	return r + 1 >= k;

}

int main(){

	ios_base::sync_with_stdio(0);

	cin.tie();

	

	cin >> s;

	n = s.length();

	int l = 1;

	int r = s.length();

	int k = (l + r + 1) / 2;

	while(l < r){

		if(valid(k)) l = k;

		else r = k - 1;

		k = (l + r + 1) / 2;

	}

	cout << l << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4808879538493112x):
#include <bits/stdc++.h>



using namespace std;



void FAST_IO() {

	ios_base::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

}



#define REP(_i, _a) for(int _i = 0; _i < _a; ++_i)

#define FOR(_i, _a, _b) for(int _i = _a; _i <= _b; ++_i)

#define FORD(_i, _a, _b) for(int _i = _a; _i >= _b; --_i)

#define RESET(_a, _value) memset(_a, _value, sizeof(_a))

#define ALL(_a) _a.begin(), _a.end()

#define SIZE(_a) _a.size()

#define pb push_back

#define eb emplace_back

#define mp make_pair

#define fi first

#define se second

#define newline '\n';



typedef long long ll;

typedef pair<int, int> ii;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef pair<double, double> pdd;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef vector<ii> vii;



const double PI = acos(-1.0);

const int MOD = 1e9 + 7;

const int INF = 2e9;



const int MAX_N = 1e5 + 5;



int suffix_count[MAX_N + 5];



string s;

int n;



int main() {

	FAST_IO();

	

	cin >> s;

	n = s.length();

	

	int ans = n;



	REP(i, n-1) {

		if (s[i] != s[i+1]) {

			ans = min(ans, max(n - i - 1, i + 1));

		}

	}



	cout << ans << endl;



	return 0;

}