akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <unordered_set>
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

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>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	ll n, k, i, j;
	cin >> n >> k;
	vl a(n), b(n);
	for (i = 0; i < n; i++) {
		int a2, b2;
		cin >> a2 >> b2;
		if (a2 > k) {
			continue;
		}
		a.push_back(a2);
		b.push_back(b2);
	}
	n = a.size();
	j = k;
	ll m = 0;
	vector<bool> k2;
	while (j > 0) {
		k2.push_back((bool)(j & 1));
		j >>= 1;
		m++;
	}
	//DEBUG_VEC(k2);
	//cout << m << endl;

	ll ans = -1;
	vector<bool> used(n,true);
	bool flag = true;
	if (m == 0 || m == 1) {
		flag = false;
	}
	while (flag) {
		ll sum = 0;
		while (!k2[m - 1]) {
			m--;
		}
		if (m == 1) {
			break;
		}
		ll m2 = m - 1;
		while (!k2[m2-1]) {
			m2--;
			if (m2 == 0) {
				flag = false;
				break;
			}
		}
		ll out = pow(2, m-1);
		for (i = 0; i < n; i++) {
			if (used[i] && ((a[i] & (ll)pow(2,m)-1) < out)) {
				sum += b[i];
			}
			for (j = m2 + 1; j < m; j++) {
				if (((ll)pow(2, j - 1)&a[i]) != 0) {
					used[i] = false;
				}
			}
		}
		ans = max(ans, sum);
		m--;

	}
	ll sum = 0;
	for (i = 0; i < n; i++) {
		if ((a[i] | k) <= k) {
			sum += b[i];
		}
	}
	ans = max(ans, sum);
	cout << ans << endl;

	
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,k;
vll a,b;
lli ans = 0;

int main(){
  cin >> n >> k;
  a = vll(n);
  b = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i] >> b[i];
  for(lli i = 0,j = 1;i < 30;i++,j <<= 1){
    if(k&j){
      lli s = (k^j)|(j-1);
      lli t = ~s;
      lli mem = 0;
      for(lli i = 0;i < n;i++){
        if((t&a[i]) == 0) mem += b[i];
      }
      ans = max(ans,mem);

    }
  }
  lli t = ~k;
  lli mem = 0;
  for(lli i = 0;i < n;i++){
    if((t&a[i]) == 0) mem += b[i];
  }
  ans = max(ans,mem);
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<vector>
#include<map>

using namespace std;

map<int, int> numcnt;

int main(void) {
        cin.sync_with_stdio(false);     cin.tie(NULL);
        int N, K;       cin >> N >> K;

        int val;
        for (int i = 0; i < N; i ++) {
                cin >> val;
                numcnt[val]++;
        }

        using P = pair<int, int>;
        priority_queue<P, vector<P>, greater<P> > pq;

        for (auto it : numcnt)
                pq.emplace(it.second, it.first);

        int res = 0;
        while (pq.size() > K) {
                P cur = pq.top(); pq.pop();
                res += cur.first;
        }

        cout << res << endl;

}


Measured memory_bytes: 11764
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  string s;
  cin >> s ;
  int n=s.size();
  ll m;
	rep(i,n){
      m=n-i-1;
      int count=0;
      if(m%2==1) continue;
      else{
        rep(j,m/2){
          if(s.at(j)==s.at(j+m/2)){
            count++;
          }
        }
      }
      if(count==m/2){
        break;
      }
    }
  cout << m << endl;
          
}

Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    static final char U = 'U';
    static final char D = 'D';
    static final char L = 'L';
    static final char R = 'R';

    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final String[] sl = s.split(" ");
        int sx = Integer.parseInt(sl[0]);
        int sy = Integer.parseInt(sl[1]);
        int tx = Integer.parseInt(sl[2]);
        int ty = Integer.parseInt(sl[3]);

        // 4 * ((tx - sx) + (ty - sy)) + 6
        for (int i = 0; i < ty - sy; i++) out.print(U);
        for (int i = 0; i < tx - sx; i++) out.print(R);
        for (int i = 0; i < ty - sy; i++) out.print(D);
        for (int i = 0; i < tx - sx; i++) out.print(L);
        out.print(L);
        for (int i = 0; i <= ty - sy; i++) out.print(U);
        for (int i = 0; i <= tx - sx; i++) out.print(R);
        out.print(D);
        out.print(R);
        for (int i = 0; i <= ty - sy; i++) out.print(D);
        for (int i = 0; i <= tx - sx; i++) out.print(L);
        out.println(U);

        out.flush();
    }
}


Measured memory_bytes: 22484
#include <stdio.h>

int main(){
  int N,M,canSelect=0;
  scanf("%d %d",&N,&M);
  
  int syohin[N];
  int sotokuhyo=0;
  for(int i=0;i<N;i++){
    scanf("%d", &syohin[i]);
    sotokuhyo += syohin[i];
  }
  
  for(int j=0;j<N;j++){
    double limit = (double)(sotokuhyo)/(4*M);
    if(syohin[j] >= limit) canSelect++;
  }
  
  if(canSelect>=M){
    printf("Yes");
  }else{
    printf("No");
  }
}

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

int main() {
	int n;
	string S;
	cin >> n >> S;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		set<char> a,b;
		for(int j = 0; j < n; j++) {
			if (j < i)
				a.insert(S[j]);
			else
				b.insert(S[j]);
		}
		int cnt = 0;
		for(auto x : a) {
			if (b.count(x) > 0)
				cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N[3],i,g=0,n=0;
  for(i =0; i < 3; i++) {
    cin >> N[i];
  }
    for(i = 0; i < 3; i++) {
        if(N[i] == 5) {
            g++;   
        }else if(N[i] == 7) {
        n++;
    }
    }

    if(g == 2 && n == 1) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int N,a,b,A;
	cin>>N;
	if(N>=1&&N<=100)
	{
		a=N*N;
		cin>>A;
		if(A>=0&&A<=a)
		{
			b=a-A;
			cout<<b<<endl;
		}
	}
	return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vs64 a(n);
    rep (i, n) cin >> a[i];

    s64 ans;
    s64 temp = 0;
    s64 sum = 0;

    rep (i, n)
    {
        if (i & 1)
        {
            if (sum + a[i] >= 0)
            {
                temp += sum + a[i] + 1;
                sum = -1;
            }
            else
            {
                sum += a[i];
            }
        }
        else
        {
            if (sum + a[i] <= 0)
            {
                temp += 1 - (sum + a[i]);
                sum = 1;
            }
            else
            {
                sum += a[i];
            }
        }
    }
    ans = temp;

    temp = 0;
    sum = 0;

    rep (i, n)
    {
        if (!(i & 1))
        {
            if (sum + a[i] >= 0)
            {
                temp += sum + a[i] + 1;
                sum = -1;
            }
            else
            {
                sum += a[i];
            }
        }
        else
        {
            if (sum + a[i] <= 0)
            {
                temp += 1 - (sum + a[i]);
                sum = 1;
            }
            else
            {
                sum += a[i];
            }
        }
    }
    ans = MIN(ans, temp);

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Programming Contest
 * PCK2013
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int N, R, L;
			N = parseInt(st.nextToken());
			R = parseInt(st.nextToken());
			L = parseInt(st.nextToken());

			Team[] team = new Team[N + 1];

			Queue<Team> pq = new PriorityQueue<>((x, y) -> {
				if (x.point == y.point) {
					return Integer.compare(x.id, y.id);
				} else {
					return Integer.compare(y.point, x.point);
				}
			});

			for (int i = 1; i <= N; i++) {
				team[i] = new Team(i);
			}

			int elapsed = 0;
			pq.offer(team[1]);

			for (int i = 0; i < R; i++) {
				st = new StringTokenizer(br.readLine());
				int d, t, x;
				d = parseInt(st.nextToken());
				t = parseInt(st.nextToken());
				x = parseInt(st.nextToken());
				pq.peek().time += t - elapsed;
				//
				pq.remove(team[d]);
				team[d].point += x;
				pq.offer(team[d]);
				//
				if (pq.size() > 5) {
					List<Team> list = new ArrayList<>();
					for (int j = 0; j < 5; j++) {
						list.add(pq.poll());
					}
					pq.clear();
					pq.addAll(list);
				}
				//
				elapsed = t;
			}

			pq.peek().time += L - elapsed;

			//
			pq = new PriorityQueue<>((x, y) -> {
				if (x.time == y.time) {
					return Integer.compare(x.id, y.id);
				} else {
					return Integer.compare(y.time, x.time);
				}
			});

			for (int i = 1; i <= N; i++) {
				pq.offer(team[i]);
			}

			System.out.println(pq.peek().id);
		}
	}
}

class Team {

	int id, time = 0, point = 0;

	Team(int id) {
		this.id = id;
	}
}

Measured memory_bytes: 118952
# AOJ 1621: Folding a Ribbon
# Python3 2018.7.13 bal4u

ans, low = [0]*62, [0]*62
while True:
	n, i, j = map(int, input().split())
	if n == 0: break
	i -= 1; j -= 1
	for k in range(1, n+1):
		low[n-k] = (i >> (n-k)) & 1
		if low[n-k] == 0: i = ~i
	for k in range(1, n+1):
		ans[k] = 'L' if ((j >> (n-k)) & 1) == low[k-1] else 'R'
		if low[k-1] == 0: j = ~j
	print(''.join(ans[1:n+1]))



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

#define pi2 6.28318530717958623200

int main(){
 ll n;
 ll a,b,c;
 string s,t;
 cin>>n;
 printf("%0.9lf\n",n*pi2);
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    set<char> se;
    for (int i = 0; i < s.size(); i++) {
        se.insert(s[i]);
    }
    cout << (se.size() == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#input
N, K = map(int, input().split())
S = input()

same, other = 0, 0
for i in range(N - 1):
    if S[i] == S[i + 1]:
        same += 1
    else:
        other += 1

if (other + 1) // 2 <= K:
    print(same + other)
else:
    print(same + 2 * K)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	int q,a,b;
	string s,t;
	cin>>q;
	map<string,int>m;
	for(;q--;){
		cin>>a;
		if(a==0)cin>>s>>b,m[s]=b;
		if(a==1)cin>>s,cout<<(m.find(s)==m.end()?0:m.at(s))<<endl;
		if(a==2)cin>>s,m.erase(s);
		if(a==3){cin>>s>>t;auto it1=m.lower_bound(s),it2=m.upper_bound(t);for(;it1!=it2;++it1)cout<<it1->first<<' '<<it1->second<<endl;}
	}
}



Measured memory_bytes: 27668
#include <cstdio>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int d1, d2;
        scanf("%d %d", &d1, &d2);
        ans += d2 - d1 + 1;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, batas, ans = 0;
  char s[100005];
  scanf("%d %s", &n, s);
  for (int i = 0; i < n; i++) {
    batas = i;
    while (batas + 1 < n) {
      if (s[batas + 1] != s[i])
        break;
      batas++;
    }
    i = batas;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}

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

void displaystart(vector<char> &myvector) {
  vector<char>::reverse_iterator rit = myvector.rbegin();
  for (; rit!= myvector.rend(); ++rit)
    cout<<*rit;
}

void displayend(vector<char> &myvector){
	vector<char>::iterator it = myvector.begin();
  	for (; it!= myvector.end(); ++it)
   	 cout<<*it;
}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
  string s;
  cin>>s;
  
  bool front = true;					//front true if not reversed 
  
  int q,ti,fi;
  cin>>q;
  
  char ci;
  vector<char> ft, bk;
  
  for(int i=1; i<=q; i++) {
	
	  cin>>ti;
  	  
	  if(ti == 1) {
	  	if(front)
		  front = false;
		else 
		  front = true; 
	  } 
	  	  
	  else {
	  		cin>>fi>>ci;
	  	
			if(fi == 1) {	// At the begin
	  			if(front)
	  				ft.push_back(ci);
			  		//s = ci + s;		//if not reversed
				else 
					bk.push_back(ci);
			    	//s = s + ci;
			}	  
			else {			// at the end
				if(front)	
					bk.push_back(ci);
					//s = s + ci;
				else		// at the begin if reversed
					ft.push_back(ci);
					//s = ci + s;
			}
	  }
  }
  
  	if(front){
  		displaystart(ft);
  		cout<<s;
  		displayend(bk);
	  }
  		
  	else {
  		reverse(s.begin(), s.end());
  		
  		displaystart(bk);
  		cout<<s;
  		displayend(ft);
  	}
  
  return 0;
}


Measured memory_bytes: 976
import java.util.*;
class Main {
 	public static void main(String[] args) {
    	Scanner s = new Scanner(System.in);
      	int n = s.nextInt();
      	String str = s.next();
      	System.out.println(func(str));
    } 
  
  	public static int func(String str) {
    	if (str.length() <= 2) {
        	return 0;
        }
      
      	if (str.charAt(0) == 'A' && str.charAt(1) == 'B' && str.charAt(2) == 'C' ) {
        	return 1 + func(str.substring(3));
        }
      
      	return func(str.substring(1));
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int s_length = s.length(); 
		int i = 0;
		int j = 0;
		for(i = 0; i < s_length; i++) {
			if(s.charAt(i) == 'A') {
				break;
			}
		}
		for(j = s_length - 1; j >= 0; j--) {
			if(s.charAt(j) == 'Z') {
				break;
			}
		}
		String str = s.substring(i, j + 1);
		System.out.println(str.length());
	}
}

Measured memory_bytes: 26404
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/



void Main(){
    double n;
    cin >> n;
    cout << n*2*PI << endl;
    
}

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


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<P,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    ll Q;
    cin >> Q;
    string S;
    cin >> S;
    vector<ll> l(Q,0);
    vector<ll> r(Q,0);
    for(ll i=0;i<Q;i++){cin>>l[i]>>r[i];l[i]--;r[i]--;}
    vector<ll> until(N,0);
    for(ll i=1;i<N;i++){
        until[i]=until[i-1];
        if(S[i-1]=='A'&&S[i]=='C')until[i]++;
        //print(until[i])
    }
    for(ll i=0;i<Q;i++){
        if(l[i]==0){
            print(until[r[i]])
            continue;
        }
        ll ans=until[r[i]]-until[l[i]-1];
        if(S[l[i]-1]=='A'&&S[l[i]]=='C')ans--;
        print(ans);
    }
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N, M;
    cin >> N >> M;
    map<int,int> WA;
    vector<bool> AC(N, false);

    rep(i, M){
        int p;
        string S;
        cin >> p >> S; p--;
        if(AC[p] == true) continue;

        if(S == "WA") WA[p]++;
        else AC[p] = true; 
    }

    int ac = 0, wa = 0;
    rep(i ,N) {
        if(AC[i] == true) ac++;
    }
    
    for(auto p : WA) {
        if(AC[p.first]) wa += p.second;
    }

    cout << ac << " " << wa << endl;

}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i=0; i<(n); i++)
#define rep_from_1(i, n) for(int i=1; i<n; i++)
using namespace std;

int main() {
    // ---------------------------------------------------
    int K, N;
    cin >> K >> N; // K=20, N=3
    vector<int> A(N);
    rep(i, N) cin >> A.at(i); // A.at(0)=5, A.at(1)=10, A.at(2)=15
    // cout << "End of initialization" << endl;
    // ---------------------------------------------------
    vector<int> dis(N);
    dis.push_back(K+ A.at(0) - A.at(N-1));
    rep_from_1(i, N) dis.push_back(A.at(i) - A.at(i-1));
    // ---------------------------------------------------
    sort(dis.begin(), dis.end());
    reverse(dis.begin(), dis.end());
    cout << K - dis.at(0) << endl;
    // ---------------------------------------------------
}

Measured memory_bytes: 2560
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long h,w; cin>>h>>w;
    if(h==1 || w==1) cout<<1<<endl;
    else if(h%2==1 and w%2==1) cout<<((((h/2)+1)+(h/2))*(w/2))+((h/2)+1);
    else if(h%2==0 and w%2==1) cout<<(h/2)*w;
    else if(w%2==0 and h%2==1) cout<<(w/2)*h;
    else cout<<(h/2)*w;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    H, W = [int(item) for item in input().split()]

    grid = [[item for item in input()] for _ in range(H)]

    # print(grid)

    def chk(i,j):
        next_node_list = [
            [max(0, i-1), j],
            [min(H-1, i+1), j],
            [i, max(0, j-1)],
            [i, min(W-1, j+1)]
        ]


        if grid[i][j] == '#':
            for next_node in next_node_list:
                if next_node == [i, j]:
                    pass
                else:
                    if grid[next_node[0]][next_node[1]] == '#':
                        return True
            else:
                return False
        else:
            return True


    def loop_chk(H, W):
        for i in range(H):
            for j in range(W):
                # print(i,j, chk(i,j))
                if chk(i,j):
                    pass
                else:
                    return False
        else:
            return True

    if loop_chk(H, W):
        print('Yes')
    else:
        print('No')
    

if __name__ == "__main__":
    resolve()


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

int main() {
  ll n;
  cin >> n;
  ll ans = n*(n-1)/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n, m;
    cin>>n>>m;
    vector<vector<int>> vec(n, vector<int>(m));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin>>vec[i][j];

    // vector<pair<int, int>> odds;
    vector<vector<int>> store;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++){
            if(vec[i][j]&1 && j != m-1){
                store.push_back({i, j, i, j+1});
                --vec[i][j];
                ++vec[i][j+1];
            }
        }
        for(int i = 0; i < n; i++){
            if(vec[i][m-1]&1 && i != n-1){
                store.push_back({i, m-1, i+1, m-1});
                --vec[i][m-1];
                ++vec[i+1][m-1];
            }
        }
/*

    for(int i = 1; i < odds.size(); i += 2){
        pair<int, int> fst = odds[i-1], snd = odds[i];
        if(fst.first == snd.first){
            while(snd.second != fst.second){
                store.push_back({fst.first, fst.second, fst.first, fst.second+1});
                ++fst.second;
            }
        }
        else{
            int d = 1;
            if(fst.second > snd.first)
                d = -1;
            while(snd.second != fst.second){
                store.push_back({fst.first, fst.second, fst.first, fst.second+d});
                fst.second += d;
            }
            while(snd.first != fst.first){
                store.push_back({fst.first, fst.second, fst.first+1, fst.second});
                ++fst.first;
            }
        }
    }*/
    cout<<store.size()<<"\n";
    for(auto itr : store){
        cout<<itr[0]+1<<" "<<itr[1]+1<<" "<<itr[2]+1<<" "<<itr[3]+1<<"\n";
        // cout<<"\n";
    }
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}


Measured memory_bytes: 11080
#include <stdio.h>
int main(void)
{
	int v[7][2];
	int d[7];
	int i;
	
	for(i=0;i<7;i++){
		scanf("%d %d", &v[i][0],&v[i][1]);
	}
	
	for(i=0;i<7;i++)
	d[i]=v[i][0]-v[i][1];
	
	for(i=0;i<7;i++)
	printf("%d\n",d[i]);
	
	return 0;
}

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

int main()
{
	int A, B, C;
	
	cin >> A >> B >> C;
	
	if ((A == 7 && B == 5 && C == 5) ||
		(A == 5 && B == 7 && C == 5) ||
		(A == 5 && B == 5 && C == 7))
	{
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    set<int> mochis;
    rep(i, n) {
        int d;
        cin >> d;
        mochis.insert(d);
    }

    cout << mochis.size() << endl;
}

Measured memory_bytes: 764
// defines
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define casti static_cast<int>
#define cast static_cast
#define ll long long int
#define vi vector<int>
#define vpi vector<pair<int,int >>

// includes
#include <bits/stdc++.h>

using namespace std;

ll modF=1e9+7;

// topcoder



//codechef and codeforces and atcoder

int main(){
    boost_io;
    ll n;
    cin>>n;
    ll h;
    ll i=n;
    string ans="";
    while(i>0){
        h=i%26;
        if(h==0){
            ans="z"+ans;
            i/=26;
            i--;
        }
        else{
            i/=26;
            ans=cast<char>(h+96)+ans;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;



int main() {

    vector<int>bells(3);
    rep(i, 3) cin >> bells[i];
    sort(bells.begin(),bells.end());

    cout << bells[0] + bells[1] << endl;

}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  if (a[a.size()-1] < k) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  each (i, a) {
    if (i == k) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  ll x = gcd(a[0], a[1]);
  for (ll i = 2; i < n; ++i) {
    x = gcd(x, a[i]);
  }

  if (k % x == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
mod = 10**9+7
def f(x):
  if x <= n-k+1:
    a = 1
    b = 1
    for i in range(1, x+1):
      a *= n-k+2-i
      b *= i
    for i in range(1, x):
      a *= k-i
      b *= i
  else:
    a=0
    b=1
  return a//b%mod

for i in range(1, k+1):
  print(f(i))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define inf 1e18
#define ll long long int
int main()
{
	ll dp[1<<13]; dp[0]=0;
	ll N,M,i,cost,X,j,y,i1,i3;
	for(i=1;i<pow(2,12);i++) dp[i]=inf;
	cin>>N>>M;
	for(i=0;i<M;i++)
	{
		cin>>cost>>X;
		ll t=0;
		for(j=0;j<X;j++)
		{ cin>>y; t=t^(1<<(y-1)); }
		dp[t]=min(dp[t],cost);
	}
	vector<int> v1,v2,v3;
	for(i=0;i<pow(2,N);i++)
	{
		for(j=0;j<pow(2,N);j++)
		{
			dp[i|j]=min(dp[i|j],dp[i]+dp[j] );
		}
	}
	dp[(1<<N)-1]==inf?cout<<"-1": cout<<dp[(1<<N)-1];
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string S;
	cin >> S;
	string year, month;
	year = S.substr(0, 4);
	month = S.substr(5, 2);
	if (stoi(year) > 2019) {
		cout << "TBD" << endl;
	}
	else {
		if (stoi(month) > 4) {
			cout << "TBD" << endl;
		}
		else {
			cout << "Heisei" << endl;
		}
	}
}

Measured memory_bytes: 256
import sys
N = int(input())

MALE = 1
FEMALE = 2
UNKNOWN = -1

states = [UNKNOWN for _ in range(N)]


def query(i):
    i %= N
    if states[i] != UNKNOWN:
        return states[i]
    print(i)
    state = input()
    if state == 'Vacant':
        sys.exit()
    elif state == 'Male':
        states[i] = MALE
    elif state == 'Female':
        states[i] = FEMALE
    else:
        return query(i)
    return states[i]


imin = 0
imax = N - 1
smin = query(imin)
smax = query(imax)

while True:
    imid = (imax + imin) // 2
    smid = query(imid)

    minside = False
    if smid == smin and (imid - imin) % 2 == 1:
        minside = True
    if smid != smin and (imid - imin) % 2 == 0:
        minside = True

    if minside:
        imax = imid
        smax = smid
    else:
        imin = imid
        smin = smid
    
    #print('min:', imin, 'max:', imax)


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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int x, y, ans = 0;
  cin >> x >> y;

  if(x == 1) ans += 300000;
  else if (x == 2) ans += 200000;
  else if (x == 3) ans += 100000;
  
  if (y == 1) ans += 300000;
  else if (y == 2) ans += 200000;
  else if (y == 3) ans += 100000;

  if(x == 1 && y == 1) ans += 400000;

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 3652
s = list(input())
sum = 0
for i in range(2 ** (len(s)-1)):
  st = str(s[0])
  for j in range(len(s)-1):
    if (i >> j) & 1:
      st = st + "+" + str(s[j+1])
    else:
      st = st + str(s[j+1])
      
  for item in st.split('+') :
    sum += int(item)
print(sum)

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

const unsigned long long int MAX=1000000000+7;

int cnt[100001];

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

  unsigned long long int total=1;
  for(int i=0;i<N/2;i++){
    if(total*2>MAX) total=(total*2)%MAX;
    else total*=2;
  }
  
  bool flag=true;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    cnt[a]++;
    if(N<=a) flag=false;
  }

  if(N%2==0){
    if(cnt[0]>0) flag=false;
  }else{
    if(cnt[0]>1||cnt[0]==0) flag=false;
  }


  if(flag){
    for(int i=0;i<=N;i++){
      if(cnt[i]>2||(i!=0&&cnt[i]==1)){
	flag=false;
	break;
      }
    }
  }
  
  if(!flag){
    cout<<'0'<<endl;
    return 0;
  }

  cout<<total%MAX<<endl;
  return 0;
}


Measured memory_bytes: 768
N, M = map(int, input().split())

A = [[0, 0] for _ in range(N)]

for _ in range(M):
    p, s = input().split()
    if s == "AC":
        if not A[int(p)-1][0]:
            A[int(p)-1][0] = 1
    else:
        if not A[int(p)-1][0]:
            A[int(p)-1][1] += 1

ans = [0, 0]
for ac, wa in A:
    if ac:
        ans[0] += 1
        ans[1] += wa

print(*ans)

Measured memory_bytes: 14580
#include <iostream>
#include<string>
#include<cmath>
#include<vector>
using std::cin;
using std::cout;
using std::vector;
void in(vector<int> &a,int n)
{
	for(int i=0;i<n;i++)
	cin>>a[i];	
}
int main()
{
	int n,i1,j1,j2;
	vector<int> a(3);
	in(a,3);
	i1=3;
	if(a[1]==a[2])
	i1--;
	if(a[1]==a[0])
	i1--;
	if(a[2]==a[0])
	i1--;
	if(a[1]==a[2] && a[1]==a[0])
	i1=1;
	cout<<i1;
	return 0;		
}


Measured memory_bytes: 256
#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;

    int ans = 0;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] == s[i - 1] && s[i] == '0') {
            s[i] = '1';
            ans++;
        }
        else if (s[i] == s[i - 1] && s[i] == '1') {
            s[i] = '0';
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    string l; cin>>l;
    ll n=l.size();
    vector<ll> r(n,0),u(n,0);
    r[0]=2; u[0]=1;
    for(ll i=1;i<n;i++){
        if(l[i]=='1'){
            r[i]=(2*r[i-1])%MOD;
            u[i]=(r[i-1]+3*u[i-1])%MOD;
        }
        else{
            r[i]=r[i-1]%MOD;
            u[i]=3*u[i-1]%MOD;
        }
    }
    cout<<(r[n-1]+u[n-1])%MOD<<endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<long long> x(n);
    vector<long long> y(m);
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < m; i++) cin >> y[i];
    x.insert(x.begin(), -1e18);
    y.insert(y.begin(), -1e18);
    x.push_back(1e18);
    y.push_back(1e18);
    while (q--) {
        long long u;
        cin >> u;
        long long s[2];
        long long t[2];
        s[0] = *lower_bound(x.begin(), x.end(), u);
        s[1] = *prev(upper_bound(x.begin(), x.end(), u));
        t[0] = *lower_bound(y.begin(), y.end(), u);
        t[1] = *prev(upper_bound(y.begin(), y.end(), u));
        long long ans = 8e18;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                ans = min(ans, abs(u - s[i]) + abs(s[i] - t[j]));
                ans = min(ans, abs(u - t[j]) + abs(s[i] - t[j]));
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4448
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let arr = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let arr = Array.append arr [|0|] in
  let a_l = Array.to_list arr in

  let cum f init l =
    let rec aux prev res = function
      | [] -> res
      | hd :: tl -> 
        let acc = f prev hd in
        aux hd (acc::res) tl
    in
    aux init [] l
  in

  let l = cum (fun x y -> abs (y-x)) 0 a_l in
  let ans = List.fold_left (+) 0 l in

  let rec aux res = function
    | [] -> res
    | hd1 :: hd2 :: hd3 :: tl -> 
      let acc = abs (hd3-hd1) - (abs (hd3-hd2) + abs(hd2-hd1)) in
      aux (acc::res) (hd2::hd3::tl)
    | _ -> res
  in

  let l = aux [] (0::a_l) in
  let l = List.rev l in
  List.iter (fun x -> Printf.printf "%d\n" @@ ans+x) l;


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin >>s;
  string ans="No";
  if((s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3]))ans="Yes";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	llint a, b;
	cin >> a >> b;
	if (2 * a >= b) {
		cout << b / 2 << endl;
	}
	
	else {
		cout << a + (b - 2 * a) / 4 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n;
    cin >> n;
    vi a(n);
    int b0 = 0, b1 = 0, b2 = 0;
    rep(i, n) {
        cin >> a[i];
        if(a[i] % 2 == 0) {
            if(a[i] % 4 == 0) b2++;
            else b1++;
        } else {
            b0++;
        }
    }

    bool can = false;
    if(b1 == 0) {
        if(b2 + 1 >= b0) can = true;
    } else if(b2 >= b0) can = true;

    Yn(can);

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string s;
    cin >> s;
    int n=s.size();
    if(n&1){
        char ch=s[n/2];
        int ctr=1;
        while(n/2-ctr>=0){
            if(s[n/2-ctr]==ch&&s[n/2+ctr]==ch) ctr++;
            else break;
        }
        print(n/2+ctr);
    }else{
        if(s[n/2-1]!=s[n/2]) print(n/2);
        else{
            char ch=s[n/2];
            int ctr=1;
            while(n/2-ctr-1>=0){
                if(s[n/2-ctr-1]==ch&&s[n/2+ctr]==ch) ctr++;
                else break;
            }
            print(n/2+ctr);
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main(){
  ld a,b,h,m; cin >> a >> b >> h >> m;

  ld zishin,hunshin;
  zishin = ( h*60 + m ) / 2;
  hunshin = 6 * m;
  // cout << zishin << endl;
  // cout << hunshin << endl;

  ld sa = abs(zishin - hunshin) * 2 * 3.141592653589793238462643383279 / 360;
  if(sa == 0){
    cout << fixed << setprecision(25) << abs(a - b) << endl;
    return 0;
  }

  //cout << sa  << ' ' << cos(sa) << endl;
  ld ccc = sqrt(abs((a*a) + (b*b) - (2*a*b*cos(sa))));
  //ld c = sqrt(ccc);


  cout << fixed << setprecision(25) << ccc << endl;
}



Measured memory_bytes: 4168
import itertools


N, M, Q = map(int, input().split())
int_list = [list(map(int, input().split())) for i in range(Q)]

num = [i for i in range(1, M+1)]

row = list(itertools.combinations_with_replacement(num, N))

point_max = 0
for i in range(len(row)):
    r = list(row[i])
    point = 0
    for j in range(Q):
        a = int_list[j][0]
        b = int_list[j][1]
        c = int_list[j][2]
        d = int_list[j][3]
        if r[b-1] - r[a-1] == c:
            point += d
    point_max = max(point, point_max)

print(point_max)



Measured memory_bytes: 21544
N, A, B = map(int, input().split())
L = 0

for i in range(N+1):
    T = (i//10000) + ((i//1000)%10) + ((i//100)%10) + ((i//10)%10) + (i%10)
    if (A<=T) and (T<=B):
        L += i

print(L)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cout<<elem;}cerr<<endl;}

int main(){
	int n;
	cin>>n;
	
	int ans=0;
	REP(i,n){
		int a;
		cin>>a;
		if((i+1)%2 and a%2) ans++;
	}
	
	cout<<ans<<endl;
}

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


void solve(std::string S, long long w){
  for(long long i = 0; i < S.size(); i++){
    if(i%w == 0) cout << S[i];
  }

  cout << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
  std::cin >> S;
  long long w;
  scanf("%lld",&w);
    solve(S, w);
    return 0;
}


Measured memory_bytes: 3624
import math

n = int(input())

prm_dict = {}
for i in range(2, math.floor(math.sqrt(n))):
    while n % i == 0:
        n //= i
        if i not in prm_dict.keys():
            prm_dict[i] = 0
        prm_dict[i] += 1
    if n == 1:
        break
if n != 1:
    prm_dict[n] = 1

ans = 0
for prm in prm_dict.keys():
    prm_cnt = prm_dict[prm]
    i = 1
    while prm_cnt >= i:
        prm_cnt -= i
        i += 1
        ans += 1

print(ans)


Measured memory_bytes: 9032
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main()
{
	int n, q;
	cin >> n;
	vector<int> a(n);
	map<int, int> numCount;
	long long sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
		numCount[a[i]]++;
	}
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int b, c;
		cin >> b >> c;
		sum += numCount[b] * (c - b);
		numCount[c] += numCount[b];
		//cout << numCount[b] << ' ' << b << "'s turing into " << c << endl;
		numCount[b] = 0;
		//cout << "There are " << numCount[c] << ' ' << c << "'s now" << endl;
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 8044
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K, V[50];
    cin >> N >> K;
    REP(i, N) cin >> V[i];

    int ans = 0;
    REP(i, K) {
        int take = min(N, K - i);
        REP(j, take + 1) {
            int L = j - 1, R = max(L + 1, N - K + i + j);
            priority_queue<int, vector<int>, greater<int>> q;
            REP(l, L + 1) q.push(V[l]);
            FOR(r, R, N) q.push(V[r]);

            REP(d, i) {
                if (q.empty()) break;
                int top = q.top();
                if (top < 0) q.pop();
                else break;
            }
            int sum = 0;
            while (!q.empty()) {
                sum += q.top(); q.pop();
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from time import time
import bisect
from random import randint
d = int(input())
T = time()
c = [0]+list(map(int,input().split()))
s = [0]
for i in range(d):
    s.append([0]+list(map(int,input().split())))
dic = defaultdict(int)
contest = [[] for _ in range(27)]
contests = [-1]*(d+1)
for i in range(1,d+1):
    maxscore = 0
    maxcontest = -1
    for k in range(1,27):
        score = 0
        score += s[i][k]
        score += c[k]*(i-dic[k])
        if score > maxscore:
            maxscore = score
            maxcontest = k
    dic[maxcontest] = i
    contests[i] = maxcontest
    contest[maxcontest].append(i)
ans = 0
for i in range(1,d+1):
    ans += s[i][contests[i]]
penalty = [0]*27
for i in range(1,27):
    p = 0
    cur = 1
    for j in contest[i]:
        blank = j-cur
        cur = j+1
        p += blank*(blank+1)//2*c[i]
    blank = d+1-cur
    p += blank*(blank+1)//2*c[i]
    ans -= p
    penalty[i] = p
def dscore(d,q):
    old = contests[d]
    ds = 0
    ds -= s[d][old]
    ds += s[d][q]
    ds += penalty[old]
    ds += penalty[q]
    p1 = 0
    p2 = 0
    cur = 1
    contest_o = contest[old][:]
    contest_o.remove(d)
    contest_q = contest[q][:]
    bisect.insort(contest_q,d)
    for j in contest_q:
        blank = j-cur
        cur = j+1
        p1 += blank*(blank+1)//2*c[q]
    blank = d+1-cur
    p1 += blank*(blank+1)//2*c[q]
    for j in contest_o:
        blank = j-cur
        cur = j+1
        p2 += blank*(blank+1)//2*c[old]
    blank = d+1-cur
    p2 += blank*(blank+1)//2*c[old]
    ds -= p1+p2
    return (ds,p1,p2)
while time()-T < 1.8:
    di = randint(1,d)
    qi = randint(1,26)
    old = contests[di]
    ds,p1,p2 = dscore(di,qi)
    if ds > 0:
        ans += ds
        penalty[old] = p2
        penalty[qi] = p1
        contest[old].remove(di)
        bisect.insort(contest[qi],di)
        contests[di] = qi
for i in range(1,d+1):
    print(contests[i])


Measured memory_bytes: 83088