akhauriyash/Code-Regression huggingface dataset:
var a,b,c,x,y,ans,num:int64;
function min(a,b:int64):int64;
begin
  if a<b then exit(a) else exit(b);
end;
begin
  read(a,b,c,x,y);
  if a+b>2*c then
  begin
    inc(ans,min(x,y)*2*c);
    num:=min(x,y);
    x:=x-num;
    y:=y-num;
    if x>0 then if a>2*c then
    begin
      inc(ans,x*c*2);
      y:=y-x;
      x:=0;
    end;
    if y>0 then if b>2*c then
    begin
      inc(ans,y*c*2);
      x:=x-y;
      y:=0;
    end;
  end;
  if x>0 then inc(ans,a*x);
  if y>0 then inc(ans,b*y);
  writeln(ans);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MAX_INT 10e9
int main()
{
  int n,x,k,i,j;
  cin>>k>>x;
    n= 2*k - 1 ; 
  i=0;
  j=x-k+1;
  while(i<n){
      cout<<j<<" ";
      j++;
    i++;
  }
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int N;
    scanf("%d", &N);

    vector<int> v(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &v[i]);
    }

    for (int i = 0; i < N; i++)
    {
        int c;
        scanf("%d", &c);
        v[i] -= c;
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (v[i] > 0)
        {
            ans += v[i];
        }
    }

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

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
l=[0]*1000000
ans=sum(A)

for i in A:
  l[i]+=1

for i in range(Q):
  b,c=map(int,input().split())
  ans=ans+(c-b)*l[b]
  l[c]+=l[b]
  l[b]=0
  print(ans)

Measured memory_bytes: 23816
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin >> s;
    string a = "abc";
    sort(s.begin(), s.end());

    string ans = "Yes";
    for (int i = 0; i < s.length(); i++) {
        if (s.at(i) != a.at(i)) {
            ans = "No";
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  long long n,k;
  cin>>n>>k;
  long long Min = min(n%k,abs(n%k-k));
    cout<<Min<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll mcnt = 0, pcnt = 0, zcnt = 0;
    vector<ll> m, p, z;
    REP(i, n) {
        cin >> a[i];
        if(a[i] == 0) {
            zcnt++;
        } else if(a[i] < 0) {
            mcnt++;
            m.push_back(a[i]);
        } else {
            pcnt++;
            p.push_back(a[i]);
        }
    }
    // どう選んでも0を含む
    if(n - k < zcnt) {
        cout << 0 << endl;
        return 0;
    }
    // マイナスの数がないので、単純にかける
    if(mcnt == 0) {
        sort(p.begin(), p.end(), greater<ll>());
        ll answ = 1;
        REP(i, k) {
            answ *= p[i] % MOD;
            answ %= MOD;
        }
        cout << answ << endl;
        return 0;
    }
    // プラスの数がないので、単純にかける
    if(pcnt == 0) {
        // もしゼロが入っているならマイナスになるよりはゼロの方がマシ。
        sort(m.begin(), m.end(), greater<ll>());
        if(k % 2 == 0){
            sort(m.begin(), m.end());
        }
        if(k % 2 == 1 && zcnt > 0){
            cout << 0 << endl;
            return 0;
        }
        ll answ = 1;
        REP(i, k) {
            m[i] %= MOD;
            m[i] += MOD;
            m[i] %= MOD;
            answ *= m[i] % MOD;
            answ %= MOD;
        }
        cout << answ << endl;
        return 0;
    }

    sort(m.begin(), m.end());
    sort(p.begin(), p.end(), greater<ll>());

    ll ans = 1;
    // 奇数個とるなら少なくとも一つはプラスの数になる(プラスの数は少なくとも一つは存在する)
    if(k % 2 == 1) {
        k--;
        ans *= p[0];
        reverse(p.begin(), p.end());
        p.pop_back();
        reverse(p.begin(), p.end());
    }

    ll mp = 0, pp = 0;
    ll msize = m.size(), psize = p.size();
    REP(i, k / 2) {
        bool flag = true;

        ll minu = 1;
        if(msize <= mp + 1) {
        } else {
            flag = false;
            minu = m[mp] * m[mp + 1];
        }

        ll pura = 1;
        if(psize <= pp + 1) {
        } else {
            flag = false;
            pura = p[pp] * p[pp + 1];
        }

        if(flag){
            ans *= p[pp];
            ans %= MOD;
            ans *= m[mp];
            ans %= MOD;
            ans += MOD;
            ans %= MOD;
        }else if(minu > pura) {
            minu %= MOD;
            ans *= minu;
            ans %= MOD;
            mp += 2;
        } else {
            pura %= MOD;
            ans *= pura;
            ans %= MOD;
            pp += 2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] t =new int[n];
        int time = 0;
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            time += t[i];
        }
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int p = sc.nextInt();
            int x = sc.nextInt();
            System.out.println(time - (t[p-1] - x));
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  string a = s.substr(0,5),b = s.substr(6,7),c = s.substr(14,5);
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + c >= 22 ? "bust" : "win") << "\n";
    return 0;
}


Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))
cnt_odd = 0
cnt_4 = 0

for ai in a:
    if ai % 2 == 1:
        cnt_odd += 1
    if ai % 4 == 0:
        cnt_4 += 1
        
if cnt_4 >= cnt_odd:
    ans = "Yes"
else: 
    ans = "No"

if N == cnt_4 + cnt_odd and cnt_4 >= cnt_odd-1:
    ans = "Yes"
    
print(ans)

Measured memory_bytes: 14252
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int min = (n - m) * 100 + m * 1900;
        System.out.println(min * (int) Math.pow(2, m));
    }
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;

int main() {
  int N, flg = 0;
  cin >> N;
  for(int i = 0; i * 7 <= N; i++) {
    if((N - i * 7) % 4 == 0) {flg = 1; break;}
  }
  if(flg) cout << "Yes";
  else cout << "No";
  
  return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
typedef pair<int,int> pie;
#define all(x) (x).begin(),(x).end()
#define int long long int
int32_t main() {
	//freopen("g:/coding/cpp/input.txt","r",stdin);
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<int> a(x), b(y), c(z);
	for(int i=0;i<x;i++) {
		cin >> a[i];
	}
	for(int i=0;i<y;i++) {
		cin >> b[i];
	}
	for(int i=0;i<z;i++) {
		cin >> c[i];
	}
	sort(all(a), greater<int>());
	//debug()<<imie(a);
	sort(all(b), greater<int>());
	sort(all(c), greater<int>());
	multiset<ll> sums;
	for(int i=0;i<x;i++) {
		if((int)sums.size() > k && a[i] + b[0] + c[0] < *sums.begin()) break;
		//cout<<"working\n";
		for(int j=0;j<y;j++) {
			if((int)sums.size() > k && a[i] + b[j] + c[0] < *sums.begin()) break;
			for(int l=0;l<z;l++) {
				ll sum = a[i] + b[j] + c[l];
				if(sum <= *sums.begin() && (int)sums.size()>=k) break;
				sums.insert(sum);
				if((int)sums.size() > k+1) sums.erase(sums.begin());
			}
		}
	}
	int check = 0;
	for(auto it = sums.rbegin();k>0 && it!=sums.rend();++it, --k) {
		cout<<*it<<"\n";
		++check;
	}
	debug()<<imie(check);
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll X;
    cin >> X;
    ll n = (sqrt(1+8*X) - 1) /2;
    while ( n * (n+1) /2 < X) n++;
    return n;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<map>
#include<cmath>
#include<queue>
#include<set>
#include<string>
using namespace std;
typedef pair<int,int> P;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
const LL maxn=4e5+10;
const double eps=1e-9;
LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int read1()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int main()
{
    LL n,a,b;
    cin>>n>>a>>b;
    LL res=0;
    res+=((n/(a+b))*a);
    n%=(a+b);
    res+=min(a,n);
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int N, i, j, x, f = 0;

	scanf("%d", &N);

	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			x = i * j;
			if (x == N) {
				f = 1;
			}
		}
	}

	if (f == 0) {
		printf("No\n");
	}
	else if (f == 1) {
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 256
import math

dates = [int(i) for i in input().split(" ")]
X = dates[0]
K = dates[1]
D = dates[2]
numDiv = math.ceil(abs(X) / D)

if numDiv < K:
    if X >= 0:
        X -= numDiv * D
        K -= numDiv
    else:
        X += numDiv * D
        K -= numDiv
else:
    if X >= 0:
        X -= K * D
        K = 0
    else:
        X += K * D
        K = 0

if X >= 0:
    if K % 2 == 0:
        print(abs(X))
    else:
        print(abs(X - D))
else:
    if K % 2 == 0:
        print(abs(X))
    else:
        print(abs(X + D))


Measured memory_bytes: 9208
#include<stdio.h>
int main(void){
    int n;
    long long a,b,c,d,e;
    c=-1000000;
    d=1000000;
    e=0;
    scanf("%d",&n);
    for(a=0;a<n;a++){
        scanf("%lld",&b);
        if(b>c){
            c=b;
        }
        if(b<d){
            d=b;
        }
        e=e+b;
    }
    printf("%lld %lld %lld\n",d,c,e);
    return 0;
}

Measured memory_bytes: 600
n = int(input())
l = []
for _ in range(n):
    a,b = map(int,input().split())
    l.append([b,a])
l.sort()
sum = 0
check = 0
for i in l:
    a = i[1]
    b = i[0]
    sum += a
    if sum > b:
        check = 1
        break
if check == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 35608
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    long long x;
    cin >> x;
    long long ans = 0;
    long long base = 100;
    const double inter = 1 + 0.01;

    while (1)
    {
        if (base >= x)
        {
            break;
        }
        base = base * inter;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iostream>
#include <utility>
 
using namespace std;
 
 
int main() {
    int n;
    cin >> n;
 
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
 
    vector<int> cost(n);
    cost[0] = 0;
    cost[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        cost[i] = min(cost[i-2] + abs(h[i] - h[i-2]), cost[i-1] + abs(h[i] - h[i-1]));
    }
 
    cout << cost[n-1] << endl;
 
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;

void maxHeapify(vector<int>&a,int i){
	int left=i*2,right=i*2+1,largest;
	if(left<a.size()&&a.at(left)>a.at(i))largest=left;
	else largest=i;
	if(right<a.size()&&a.at(right)>a.at(largest))largest=right;
	if(largest!=i){
		swap(a.at(largest),a.at(i));
		maxHeapify(a,largest);
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h;
	cin>>h;
	vector<int>a(h+1);
	for(int i=1;i<=h;++i)cin>>a.at(i);
	for(int i=h/2;i>=1;--i)maxHeapify(a,i);
	for(int i=1;i<=h;++i)cout<<" "s<<a.at(i);
	cout<<"\n"s;
}


Measured memory_bytes: 4556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

//command
//c++ atcoder.cpp -std=c++14
//./a.out

//cout << setprecision(12) << ans << endl;

//fill(score, score+202020, 0);
#define NN 2020202

bool sosuu[NN];

void init(){
  fill(sosuu, sosuu+NN, true);
  for (int i=2;i<=sqrt(NN);i++){
    int j = 2;
    while(i*j < NN){
      sosuu[i*j] = false;
      j += 1;
    }
  }
}

int main(){
  init();
  //cout << sosuu[17] << endl;
  ll n;
  cin >> n;

  vl ans = {11};
  ll now  = 11;
  while(ans.size() < n){
    now += 5;
    if (sosuu[now]) ans.push_back(now);
  }

  for (int i=0;i<ans.size();i++) cout << ans[i] << " ";
  cout << endl;
  //cout << dp[N][T] << endl;
}


Measured memory_bytes: 2176
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        w1: i64, w2: i64, s1: i64, s2: i64, e: i64, lim: i64,
    }

    let mut ans = (100*w1, 0); // (water + sugar, sugar)
    for i1 in 0..=lim / (100*w1) {
        let water1 = 100 * w1 *i1;
        for i2 in 0..=(lim - water1) / (100*w2) {
            let water2 = 100 * w2 * i2;
            let water = water1 + water2;
            for j1 in 0..=(lim - water) / s1 {
                let sugar1 = s1 * j1;
                for j2 in 0..=(lim - water - sugar1) / s2 {
                    let sugar2 = s2 * j2;
                    let sugar = sugar1 + sugar2;
                    let total = water + sugar;

                    if e * (water/100) < sugar {
                        break;
                    }
                    
                    if total * ans.1 < ans.0 * sugar {
                        ans = (total, sugar);
                    }
                }
            }
        }
    }
    println!("{} {}", ans.0, ans.1);
}


Measured memory_bytes: 2184
#include <bits/stdc++.h>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, m;
    cin >> n >> m;
    ll x[m], y[m];
    rep(i, m) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    bool ans[n] = {};
    ll num[n];
    rep(i, n) { num[i] = 1; }
    ans[0] = true;

    rep(i, m) {
        if (ans[x[i]]) {
            ans[y[i]] = true;
        }
        num[x[i]]--;
        num[y[i]]++;
        if (num[x[i]] == 0) {
            ans[x[i]] = false;
        }
    }

    ll count = 0;
    rep(i, n) {
        if (ans[i])
            count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 5996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n;
cin >> n;
map<ll, ll> mp;
for (ll i = 0; i < n;i++){
    ll t;
    cin >> t;
    if (t % 4 == 0) mp[4]++;
    else if(t%2==0)
        mp[2]++;
    else
        mp[1]++;
}
if(mp[2]==0){
    if (mp[4] * 2 + 1 >= n) cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
else if (mp[2] + mp[4] * 2 >= n)
    cout << "Yes" << endl;
else
    cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[4][4];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
      if(i==0&&j==0||i==2&&j==2||i==1&&j==1){
	cout<<a[i][j];
      }
    }
  }
  cout<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  lli n,m,l,sum;
  lli A[100][100],B[100][100],C[100][100];

  cin>>n>>m>>l;
  rep(i,n){
    rep(j,m){
      cin>>A[i][j];
    }
  }
  rep(i,m){
    rep(j,l){
      cin>>B[i][j];
    }
  }

  rep(i,n){
    rep(j,l){
      sum=0;
      rep(k,m){
	sum += A[i][k]*B[k][j];
      }
      cout<<sum;
      if(j!=l-1)
	cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{	
	ll N, A, B;
	cin >> N >> A >> B;

	vector<ll> X(N);
	rep(i, N) cin >> X[i];

	ll cost = 0;
	rep(i, N - 1)
	{
		ll walk = A * (X[i + 1] - X[i]);

		cost += min(walk, B);
	}

	cout << cost << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    string s;
    cin >> s;
    const int l = s.size() - 1;
    bool ans = true;
    rep(i,l/2){
        if (s[i] != s[l-i]) ans = false;
    }
    rep(j,l/4){
        if (s[j] != s[(l/2)-1-j]) ans = false;
    }
    int count = 0;
    for(int k = ((l+4)/2); k < ((l+4)/4); ++k){
        if (s[k] != s[l-count]) ans = false;
        count++;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	scanf("%d" ,&N);
	int s[N];
	int count=0,max=0;
	for(int i=0;i<N;i++)
	{
		scanf("%d", &s[i]);
		if(max<s[i])
		{
			max=s[i];
		}
	}
	int t = s[0];
	for(int i=0;i<max;i++)
	{
		for(int j=0;j<N;j++)
		{
			
			if(((s[j]==0)&&(j!=0)&&(t!=0))||((j==N-1)&&(s[j]>0)))
			{
				count=count+1;
			}
			
			t =s[j];
			if(s[j]>0)
			{
				s[j]=s[j]-1;
				
			} 
		}
	}
	printf("%d", count);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;


int main()
{
    int n;
    cin >> n;

    set<string> st;

    for (int i = 0; i < n; i++) {
        string x;
        cin >> x;
        st.insert(x);
    }

    cout << st.size();

    return 0;
}



Measured memory_bytes: 19224
c = [ [0,0,0] for _ in range(3)]
for i in range(3):
  c[i] = list(map(int, input().split()))
for a0 in range(101):
  b0 = c[0][0] - a0
  b1 = c[0][1] - a0
  b2 = c[0][2] - a0
  if (((c[1][0]-b0) == (c[1][1]-b1) == (c[1][2]-b2)) and
      ((c[2][0]-b0) == (c[2][1]-b1) == (c[2][2]-b2))):
    print("Yes")
    break
else:
  print("No")



Measured memory_bytes: 3064
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int N;
  cin >> N;
  vector<int> d;
  rep(i, N) {
    int di;
    cin >> di;
    d.pb(di);
  }

  int maxGo = 0;
  for (int i = 0; i < N; i++) {
    // DEBUG(i);
    // DEBUG(maxGo);
    if(maxGo < i) break;
    maxGo = max((d[i] / 10) + i, maxGo);
  }

  if (maxGo < (N - 1)) {
    cout << "no" << endl;
    return 0;
  }

  int minBack = N - 1;
  for(int i = N - 1; i > 0 ; i--) {
    // DEBUG(i);
    // DEBUG(minBack);
    if(i < minBack) break;
    minBack = min(minBack, i - (d[i] / 10));
  }

  if (minBack > 0) {
    cout << "no" << endl;
    return 0;
  }

  cout << "yes" << endl;
}


Measured memory_bytes: 5004
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    # print((pow(10, n) - (pow(9, n) + pow(9, n) - pow(8, n))) % mod)
    print((pow(n, 10) - (pow(n, 9) + pow(n, 9) - pow(n, 8))) % mod)
    # ans = 0
    # now = 0
    # for i in range(n):

    #     for j in range(10):


def pow(n, num):
    s = num
    for i in range(1, n):
        s = s * num % mod
    return s

# def pow(a, n):
#     x = 1
#     while n > 0:
#         if(n & 1):
#             x *= a
#         a = a*a
#         n >>= 1
#     return x


if __name__ == "__main__":
    main()


Measured memory_bytes: 69708
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include<iomanip>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)

typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

long double p[3010];
long double dp[3010][3010];

void Main()
{
	int N; cin >> N;
	rep(i, N) cin >> p[i];

	rep(i,N) {
		rep(j, N) dp[i][j] = 0;
	}
	dp[0][0] = 1;
	rep(i, N) {
		for (int j = 0; j <= i + 1; ++j) {
			if (j == 0) {
				dp[i + 1][j] = dp[i][j] * (1 - p[i]);
			} else {
				dp[i + 1][j] = dp[i][j - 1] * p[i] + dp[i][j] * (1 - p[i]);
			}
		}
	}
	long double res = 0;
	rep(i,N+1) {
		if (i > N / 2) {
			res += dp[N][i];
		}
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 141568
#include <bits/stdc++.h>
using namespace std;

int main(){
  string N;
  cin >> N;

  if(N.at(0) == N.at(1) && N.at(1) == N.at(2)){
    cout << "Yes" << endl;
  }
  else if(N.at(1) == N.at(2) && N.at(2) == N.at(3)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(){
    char N[4];
    for(int i=0; i<4; i++)cin>>N[i];
    if(N[1]==N[2] && (N[1]==N[0] || N[2]==N[3]))cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	int n;
	cin >> n;
	rep(i, n) {
		string x, y;
		cin >> x >> y;
		int xl = x.length(), yl = y.length();
		vector<vector<int>> com(xl, vector<int>(yl, 0));
		rep(j, xl) {
			rep(k, yl) {
				if (j == 0) {
					if (k == 0) {
						if (x[j] != y[k]) {
							com[j][k] = 0;
						}
						else {
							com[j][k] = 1;
						}
					}
					else {
						if (com[j][k-1] == 1) {
							com[j][k] = 1;
						}
						else {
							if (x[j] != y[k]) {
								com[j][k] = 0;
							}
							else {
								com[j][k] = 1;
							}
						}
					}
				}
				else {
					if (k == 0) {
						if (com[j-1][k] == 1) {
							com[j][k] = 1;
						}
						else {
							if (x[j] == y[k]) {
								com[j][k] = 1;
							}
							else {
								com[j][k] = 0;
							}
						}
					}
					else {
						if (x[j] == y[k]) {
							com[j][k] = com[j - 1][k - 1]+1;
						}
						else {
							com[j][k] = max(com[j][k - 1], com[j - 1][k]);

						}
					}
				}
				//cout << com[j][k] <<" ";
			}
			//cout << x[j]<<endl;
		}
		cout << com[xl - 1][yl - 1] << endl;
	}
}




Measured memory_bytes: 6844
#include<bits/stdc++.h>
using namespace std;
const int N=505,f1[4]={1,0,-1,0},f2[4]={0,1,0,-1};
int n,p,x,y,i,j,d[N][N],ans,w[N][N];
void dfs(int x,int y){
	for(int i=0;i<4;++i){
		int nx=x+f1[i],ny=y+f2[i];
		if(d[nx][ny]>d[x][y]+w[nx][ny])
			d[nx][ny]=d[x][y]+w[nx][ny],dfs(nx,ny);
	}
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)w[i][j]=1,d[i][j]=min(min(i,n-i+1),min(j,n-j+1));
	for(i=1;i<=n*n;++i){
		scanf("%d",&p);x=(p-1)/n+1;y=(p-1)%n+1;
		ans+=--d[x][y];w[x][y]=0;dfs(x,y);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 21304
#include<bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int m = N + 1;
    for (int i = 0; i < N; i++){
        int p;
        cin >> p;
        if (p <= m){
            ans++;
            m = p;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        A:isize,
        B:isize,
        C:isize,
        mut K:isize,
    }
    let mut ans = 0isize;
    ans += min(A, K);
    K -= min(A, K);
    K -= min(B, K);
    ans -= min(C, K);
    println!("{}", ans);
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define double long double
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll r, c, k;
	cin >> r >> c >> k;
	vector<vector<ll>> arr;
	vector<vector<vector<ll>>> dp;
	arr.resize(r + 1); dp.resize(r + 1);
	for (ll i = 0; i <= r; i++)
	{
		arr[i].resize(c + 1, 0);
		dp[i].resize(c + 1);
		for (ll j = 0; j <= c; j++)
			dp[i][j].resize(4, 0);
	}
	// ll arr[r + 1][c + 1]; ll dp[r + 1][c + 1][4];
	for (ll i = 0; i <= r; i++)
	{
		for (ll j = 0; j <= c; j++)
		{
			arr[i][j] = 0;
			for (ll k = 0; k < 4; k++)
				dp[i][j][k] = 0;
		}
	}
	while (k--)
	{
		ll r1, c1, val;
		cin >> r1 >> c1 >> val;
		arr[r1][c1] = val;
	}
	for (ll i = 1; i <= r; i++)
	{
		for (ll j = 1; j <= c; j++)
		{
			vector<ll> v;
			v.resize(4, 0);
			if (i == 1 && j == 1 )
			{
				if (arr[i][j] != 0)
					dp[i][j][1] = arr[i][j];
			}
			else if (i == 1)
			{

				if (arr[i][j] != 0)
				{
					dp[i][j][1] = max(dp[i][j - 1][0] + arr[i][j], dp[i][j - 1][1]);
					dp[i][j][2] = max(dp[i][j - 1][1] + arr[i][j], dp[i][j - 1][2]);
					dp[i][j][3] = max(dp[i][j - 1][2] + arr[i][j], dp[i][j - 1][3]);
				}
				else
				{
					for (ll k = 0; k < 4; k++)
						dp[i][j][k] = dp[i][j - 1][k];
				}
			}
			else if (j == 1)
			{
				if (arr[i][j] != 0)
				{
					ll ans1 = 0;
					for (ll k = 0; k < 4; k++)
						ans1 = max(ans1, dp[i - 1][j][k]);
					dp[i][j][0] = ans1;
					dp[i][j][1] = arr[i][j] + ans1;
				}
				else
				{
					ll ans1 = 0;
					for (ll k = 0; k < 4; k++)
						ans1 = max(ans1, dp[i - 1][j][k]);
					dp[i][j][0] = ans1;
				}
			}
			else
			{
				if (arr[i][j] == 0)
				{
					ll ans1 = 0;
					for (ll k = 0; k < 4; k++)
						ans1 = max(ans1, dp[i - 1][j][k]);
					for (ll k = 0; k < 4; k++)
						dp[i][j][k] = max(ans1, dp[i][j - 1][k]);
				}
				else
				{
					ll ans1 = 0;
					for (ll k = 0; k < 4; k++)
						ans1 = max(ans1, dp[i - 1][j][k]);
					dp[i][j][0] = max(dp[i][j - 1][0], ans1);
					dp[i][j][1] = arr[i][j] + max(ans1, dp[i][j - 1][0]);
					dp[i][j][1]=max(dp[i][j][1],dp[i][j-1][1]);
					dp[i][j][2] = max(dp[i][j - 1][2], arr[i][j] + dp[i][j - 1][1]);
					dp[i][j][3] = max(dp[i][j - 1][3], arr[i][j] + dp[i][j - 1][2]);
					// dp[i][j][3] = max(ans1, dp[i][j - 1][2]);
				}
			}
		}
	}
	// for (ll k = 0; k < 4; k++) {
	// 	for (ll i = 1; i <= r; i++)
	// 	{
	// 		for (ll j = 1; j <= c; j++)
	// 		{  cout << dp[i][j][k] << " ";}
	// 		cout << endl;
	// 	}
	// 	cout << endl << endl;
	// }
	ll ans = 0;
	for (ll k = 0; k < 4; k++)
		ans = max(ans, dp[r][c][k]);
	cout << ans;
	return 0;
}



Measured memory_bytes: 706904
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int r, g, b, n;
    scan(r, g, b, n);

    int ans;

    foreach (i ; 0 .. 3001) {
        foreach (j ; 0 .. 3001) {
            int rem = n - i * r - j * g;
            if (rem < 0) continue;
            if (rem % b) continue;
            ans++;
        }
    }

    writeln(ans);
}























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
import bisect



q = int(input())

M = {}
list_key_sorted = []

for _ in range(q):
    
    command, *list_num = input().split()

    if   command == "0":
        # insert(key, x)
        key = list_num[0]
        x = int(list_num[1])

        if key not in M:
            bisect.insort_left(list_key_sorted, key)

        M[key] = x
    elif command == "1":
        # get(key)
        key = list_num[0]
        if key in M:
            if M[key] == None:
                print(0)
            else:
                print(M[key])
        else:
            print(0)
    elif command == "2":
        # delete(key)
        key = list_num[0]
        if key in M:
            M[key] = None
    elif command == "3":
        # dump(L, R)
        L = list_num[0]
        R = list_num[1]

        index_left = bisect.bisect_left(list_key_sorted, L)
        index_right = bisect.bisect_right(list_key_sorted, R)

        for index in range(index_left, index_right):
            key_ans = list_key_sorted[index]
            if M[key_ans] != None:
                print(key_ans, M[key_ans])
    else:
        raise


Measured memory_bytes: 38812
#include <bits/stdc++.h>
using namespace std;

/*
参考：
https://atcoder.jp/contests/abc156/submissions/10291478
https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
*/

const int MOD = 1000000007;

// a^n mod m
long long modpow(long long a, long long n, long long m) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod m を計算する
// m を素数、a を m の倍数でない整数として
long long modinv(long long a, long long m) {
    return modpow(a, m - 2, m);
}

void solve() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  
  int all_bouquet = modpow(2, n, MOD) - 1;
//   int all_bouquet = my_pow(2, n) - 1;


  long long a_res = 1;
  for (int i = 0; i < a; i++) {
      a_res = (a_res * (n - i)) % (MOD);
  }
  for (int i = 0; i < a; i++) {
      a_res = (a_res * modinv(a - i, MOD)) % (MOD);
  }

  long long b_res = 1;
  for (int i = 0; i < b; i++) {
      b_res = (b_res * (n - i)) % (MOD);
  }
  for (int i = 0; i < b; i++) {
      b_res = (b_res * modinv(b - i, MOD)) % (MOD);
  }

  long long result = (all_bouquet - a_res - b_res) % (MOD);
  if (result < 0) {
      result += MOD;
  }
  cout << result << endl;

}

int main() {
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
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<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	string s; cin>>s;
	int n=s.size();
	VI candi;
	rep(i,n-1){
		if(s[i]!=s[i+1]) candi.PB(max(i+1,n-i-1));
	}
	candi.PB(n);
	sort(ALL(candi));
	cout<<candi[0]<<endl;
	return 0;
}


Measured memory_bytes: 720
S=' '+input()
T=' '+input()
n=len(S)
m=len(T)
dp=[[n+m]*(m+1) for _ in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
    for j in range(1,m+1):
        dp[i][j]=min([dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+(S[i-1]!=T[j-1])])
print(dp[n][m])


Measured memory_bytes: 43116
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

const ll MOD = 1e9+7;
ll modpow(ll a, ll b) {
	if (b == 0) return 1;
	if (b & 1) return modpow(a, b - 1) * a % MOD;
	ll half = modpow(a, b / 2) % MOD;
	return (half * half) % MOD;
}

ll fact[2200000];
ll nCk(ll N, ll K) {
	ll A = fact[N], B = fact[N-K] * fact[K] % MOD; //A = n!, B = k!(n-k)!
	ll invB = modpow(B, MOD - 2); // B2 = B^(MOD-2)
	ll ans = A * invB;
	ans %= MOD;
	return ans;
}

ll sqrt25[1100000];
ll sqrt26[1100000];

int main() {
	int K; string S;
	cin >> K >> S;
	fact[0] = sqrt25[0] = sqrt26[0] = 1;
	for (int i = 1; i <= 1e6; i++) sqrt25[i] = sqrt25[i - 1] * 25 % MOD;
	for (int i = 1; i <= 1e6; i++) sqrt26[i] = sqrt26[i - 1] * 26 % MOD;
	for (int i = 1; i <= 2e6; i++) fact[i] = fact[i - 1] * i % MOD;

	ll ans = 0;
	for (int i = 0; i <= K; i++) {
		ll comb1 = sqrt25[K - i] * sqrt26[i] % MOD;
		ll comb2 = nCk(S.size() + K - i - 1, S.size() - 1);
		ans = (ans + comb1 * comb2 % MOD) % MOD;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 35600
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
int n,m;
vector<int>k[14];
int p[14];
bool check(int S){
    bool cg[14];
    int q=S;
    for(int i=1;i<=n;i++){
        if(S&1)cg[i]=1;
        else cg[i]=0;
        S>>=1;
    }
    int am[14];
    for(int i=1;i<=m;i++){
        am[i]=0;
        for(int j=0;j<k[i].size();j++){
            am[i]+=cg[k[i][j]];
        }
    }

    for(int i=1;i<=m;i++){
        if((am[i]%2)!=(p[i]%2))return 0;
    }
    return 1;
}
int LiangJiaJun(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,o;scanf("%d",&o);
        for(int j=1;j<=o;j++){
            scanf("%d",&x);
            k[i].push_back(x);
        }
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&p[i]);
    }

    int ans=0;
    for(int S=0;S<(1<<n);S++){
        if(check(S)){
            //cout<<S<<endl;
            ++ans;
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

////////////////いろいろあるよ//////////////////////////////////
int main(){
	int a;
  	int N;
  	cin >> a >> N;
  	int data[N];
  	REP(i,N)cin >> data[i];
  /*
  	bool pre = false;
  	REP(i,N){
    	if(data[N]==ans){
        	pre = true;
          	break;
        }
    }
  	if(pre == false){cout << ans << endl; return 0;}
  */
  
  	REP(i,101){
    	bool boo1 = false;
      	bool boo2 = false;
  		REP(j,N){
          //cout << data[j] << " " << a+i << " " << a-i << endl;
    		if(data[j]==a+i){
        		boo1 = true;
              	//cout << data[j] << " a" << boo1 << endl;
       	 	}
          	if(data[j]==a-i){
        		boo2 = true;
              	//cout << data[j] << " " << boo2 << endl;
       	 	}
   	 	}
      	if(boo1 == false && boo2 == false){cout << min(a+i,a-i) << endl; return 0;}
  		if(boo1 == false){cout << a + i << endl; return 0;}
      	if(boo2 == false){cout << a - i << endl; return 0;}
    }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
const int twx=1000+100;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int h,w,a,b;
int asd[twx][twx]={};
void init()
{
	h=read();
	w=read();
	a=read();
	b=read();
}
void work()
{
	f1(1,b,i)
	{
		f1(1,a,j)
		{
			asd[i][j]=1;
		}
	}
	f1(b+1,h,i)
	{
		f1(a+1,w,j)
		{
			asd[i][j]=1;
		}
	}
	f1(1,h,i)
	{
		f1(1,w,j)
		{
			printf("%d",asd[i][j]);
		}
		puts("");
	}
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    init();
    work();
	return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <cstring>

using namespace std;
typedef long long ll;

bool red[10005];
bool green[10005];
bool blue[10005];

int rr[10005];
int gg[10005];
int bb[10005];

int main() {

  int n;
  cin >> n;
  string s;
  cin >> s;

  for(int i = 0; i < n; i++) {
    if(s[i] == 'R') red[i] = true;
    else if(s[i] == 'G') green[i] = true;
    else blue[i] = true;
  }

  for(int j = n - 1; j >= 0; j--) {
    if(s[j] == 'R') rr[j]++;
    if(s[j] == 'G') gg[j]++;
    if(s[j] == 'B') bb[j]++;
    rr[j] += rr[j+1];
    gg[j] += gg[j+1];
    bb[j] += bb[j+1];
  }

  ll ans = 0;
  // cout << rr[0] <<"  "<<gg[0]<<"  "<<bb[0] << endl;
  
  for(int i = 0; i < n-2; i++) {
    if(s[i] == 'R') {
   
      for(int j = i + 1; j < n-1; j++) {
	if(s[j] == 'R') continue;
	if(s[j] == 'G') {
	  ans += bb[j+1];
	  if(blue[2*j-i]) ans--;
	}
	if(s[j] == 'B') {
	  ans += gg[j+1];
	  if(green[2*j-i]) ans--;
	}
      }
    }

      if(s[i] == 'G') {
   
      for(int j = i + 1; j < n-1; j++) {
	if(s[j] == 'G') continue;
	if(s[j] == 'R') {
	  ans += bb[j+1];
	  if(blue[2*j-i]) ans--;
	}
	if(s[j] == 'B') {
	  ans += rr[j+1];
	  if(red[2*j-i]) ans--;
	}
      }
    }
      
      if(s[i] == 'B') {
	
	for(int j = i + 1; j < n-1; j++) {
	  if(s[j] == 'B') continue;
	  if(s[j] == 'G') {
	    ans += rr[j+1];
	    if(red[2*j-i]) ans--;
	  }
	  if(s[j] == 'R') {
	    ans += gg[j+1];
	    if(green[2*j-i]) ans--;
	  }
	}
      }
      //  cout << ans << endl;
  }

  cout << ans << endl;
  
}

  


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
using namespace std;

int a[21],n;
int solve(int i, int k){
    if(k == 0)  return 1;
    if(i >= n)  return 0;
    return (solve(i+1, k)||solve(i+1, k-a[i]));
}

int main()
{
    cin>>n;
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    int op,q;
    scanf("%d",&op); 
    while(op--){
        scanf("%d",&q);
        if(solve(0, q))
        	printf("yes\n");
        else 
        	printf("no\n");
    }
    return 0;
    
}



Measured memory_bytes: 3148