akhauriyash/Code-Regression huggingface dataset:
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

li = [a, b, c, d, e]

idx = sorted(list(map(lambda x: [x, x[1] + 10] if x[1] == 0 else x, [[0, (a % 10)], [1, (b % 10)], [2, (c % 10)], [3, (d % 10)], [4, (e % 10)]])), key=lambda x: x[1])[0][0]
print(sum(map(lambda x: li[x] if x == idx else math.ceil(li[x] * 0.1) * 10, [0, 1, 2, 3, 4])))


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    n %= 10;
    
    if (n == 2 || n == 4|| n == 5 || n == 7 || n == 9)
        cout << "hon" << endl;
    else if (n == 0 || n == 1 || 6 == n || n == 8)
        cout << "pon" << endl;
    else 
        cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


//const int mod = 1000000007;
const int MAX = 1000005;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


// lcp[i] := S と S[i:S.size()] の最長共通接頭辞の長さを記録した LCP 配列を O(|S|) で計算する
vector<int> Zalgo(const vector<int> & S){
    int N=(int)S.size();
    vector<int> res(N);
    res[0]=N;
    int i=1, j=0;
    while(i<N){
        while(i+j<N && S[j]==S[j+i]) ++j;
        res[i]=j;
        if(j==0) {++i; continue;}
        int k=1;
        while(i+k<N && k+res[k]<j) res[i+k]=res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

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

    int N; cin >> N;
    vector<int> a(N), b(N);
    vector<int> c(N), d(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    rep(i, N) {
        c[i] = a[i] ^ a[(i+1)%N];
        d[i] = b[i] ^ b[(i+1)%N];
    }

    vector<int> dcc(3*N);
    rep(i, N) dcc[i] = d[i];
    rep(i, N) dcc[i+N] = c[i];
    rep(i, N) dcc[i+2*N] = c[i];

    auto lcp = Zalgo(dcc);
    rep(i, N) if (lcp[i+N]>=N) {
        cout << i << " " << (a[i]^b[0]) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,e,f,g,h,r,w,l,num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
ll ban[30][30];
ll dp[5][500005];
bool used[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;

ll dfs(ll v,ll c,ll p){
	//pe(v);p(c);
	ll num = 1;
	if(dp[c][v] > 0){
		return dp[c][v];
	}
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		//dp[0][~~] := 白で塗る
		//dp[1][~~] := 黒で塗る
		if(G[v][i] == p)continue;
		if(c == 0){
			num *= (dfs(G[v][i],0,v) + dfs(G[v][i],1,v));
		}else{
			num *= (dfs(G[v][i],0,v));
		}
		num %= mod;
	}
	dp[c][v] = num;
	return num;
}

int main(){
	cin >> n;
	for(i=0;i<n-1;i++){
		cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}
	p((dfs(1,1,-1) + dfs(1,0,-1)) % mod);
	return 0;
}

Measured memory_bytes: 41984
// AOJ CGL_4_A Convex Hull
// 2018.5.3 bal4u

#include <stdio.h>
#include <stdlib.h>

typedef struct { int x, y; } PP;

PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
long long cross(PP a, PP b) { return (long long)a.x * b.y - (long long)a.y * b.x; }

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) { pc('0'); return; }
	if (n < 0) pc('-'), n = -n;
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}

int cmp(PP *a, PP *b)
{
	if (a->y - b->y) return a->y - b->y;
	return a->x - b->x;
}

int convex_hull(int n, PP *ps, PP *po)
{
	int i, k, j = 0;

	qsort(ps, n, sizeof(PP), cmp);
	for (i = 0; i < n; i++) {
		while (j > 1 && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) < 0) j--;
		po[j++] = ps[i];
	}
	k = j;
	for (i = n - 2; i >= 0; i--) {
		while (j > k && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) < 0) j--;
		po[j++] = ps[i];
	}
	return j-1;
}

PP p[100005], poly[100005];

int main()
{
	int n, k, i;

	n = in();
	for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in();
	k = convex_hull(n, p, poly);
	out(k), pc('\n');
	for (i = 0; i < k; i++) {
		out(poly[i].x), pc(' '), out(poly[i].y), pc('\n');
	}
	return 0;
}


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

int main(){
  ll l,r;
  cin >> l >> r;
  
  ll start,diff;
  int ans=2019*2019;
  start = l % 2019;
  diff = min((ll)2019, r-l+1);
  
  rep2(i,start,start+diff){
    rep2(j,start,i){
      ans = min(ans,(i*j)%2019);
    }
  }
  
  cout << ans << endl;
    
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	vector<int>v;
	for (int i = 0; i < m; i++) {
		int input; cin >> input;
		v.push_back(input);
	}
	int sum = accumulate(v.begin(), v.end(), 0);
	if (n - sum > 0|| n-sum==0)
		cout << (n - sum) << endl;
	else
		cout << -1 << endl;

}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

str s;
bool good;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    if((s[0]==s[1])||(s[1]==s[2])||(s[2]==s[3])){good=true;}
    if(!good)cout<<"Good\n";
    else cout<<"Bad\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

const int MaxN = 50;
const int MaxM = MaxN * 2;
const int M = 1000000007;

int n;
int a[MaxM + 1];

int f[MaxN + 1][MaxM + 1][MaxM + 1];

int main()
{
	cin >> n;
	for (int i = 1; i < n * 2; ++i)
		cin >> a[i];

	sort(a + 1, a + n * 2);

	f[n][1][1] = 1;
	for (int i = n; i > 1; --i)
		for (int j = 1; j <= (n - i) * 2 + 1; ++j)
			for (int k = 1; k <= j; ++k)
			{
				int cur = f[i][j][k];
				if (cur == 0)
					continue;

				int p = i - 1, q = n * 2 - i + 1;
				int u = j + (a[p] != a[p + 1]) + (a[q] != a[q - 1]);
				int v = k + (a[p] != a[p + 1]);

				for (int l = 1; l <= u; ++l)
				{
					int x = u - max(0, abs(l - v) - 1);
					int y = l <= v ? l : v + 1;
					f[p][x][y] = (f[p][x][y] + cur) % M;
				}
			}

	int res = 0;
	for (int i = 1; i <= n * 2 + 1; ++i)
		for (int j = 1; j <= i; ++j)
			res = (res + f[1][i][j]) % M;

	cout << res << endl;

	return 0;
}

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

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  if(B - A + 1 >= K){
    cout << "OK" << endl;
  }
  else if(A % K > B % K || A%K == 0 || B%K ==0){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define INFTY (1<<30)

using namespace std;

int h = 0, a[2000000+1];

void maxHeapify( int i) {
	int l = 2*i, r = 2*i+1;
	int largest;
	if( l <= h && a[l] > a[i]) largest = l;
	else largest = i;
	if( r <= h && a[r] > a[largest]) largest = r;
	
	if( largest != i) {
		swap(a[i], a[largest]);
		maxHeapify(largest);
	}
	return;
}

void increaseKey(int i, int k) {
	if( k < a[i]) return;
	a[i] = k;
	while( i > 1 && a[i/2] < a[i]) {
		swap(a[i], a[i/2]);
		i = i/2;
	}
}

int extract() {
	if(h < 1) return -INFTY;
	int max = a[1];
	a[1] = a[h--];
	maxHeapify(1);
	return max;
}

int main(){
	priority_queue<int> PQ;
	while(1) {
		char str[10];
		int k;
		scanf("%s", str);
		if(str[0] == 'e' && str[1] == 'n') break;
		else if(str[0] == 'i') {
			cin >> k;
			PQ.push(k);
		} else {
			cout << PQ.top() <<endl;
			PQ.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 5968
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int N, ans;
vector<int> A;

void solve(int n, int mul, vector<int> &A);

int main()
{
    cin >> N;
    A.resize(N);
    rep(0, i, N)
    {
        cin >> A.at(i);
    }
    ans = 0;
    solve(0, 1, A);
    cout << ans << endl;
}

void solve(int n, int mul, vector<int> &A)
{
    if (n == N)
    {
        if (mul % 2 == 0)
        {
            ans++;
        }
        return;
    }
    solve(n + 1, mul * (A.at(n) - 1), A);
    solve(n + 1, mul * A.at(n), A);
    solve(n + 1, mul * (A.at(n) + 1), A);
    return;
}

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

using namespace std;

#define mod 1000000007
#define int int64_t
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"

const int maxn=2e5+5;
int par[maxn],siz[maxn];
int ans;

int parent(int a)
{
    if(par[a]==a)
        return a;
    return par[a]=parent(par[a]);
}

void unionab(int a,int b)
{
    int pa=parent(a),pb=parent(b);
    if(pa==pb)
        return;
    if(siz[pa]<siz[pb])
        swap(pa,pb);
    par[pb]=pa;
    siz[pa]+=siz[pb];
    ans=max(ans,siz[pa]);
}


void solve()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        par[i]=i,siz[i]=1;

    ans=1;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        unionab(u,v);
    }
    
    cout<<ans<<endl;
}

int32_t main()
{
    fio;
    int t;
    // cin>>t;
    t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 6784
//
//  main.cpp
//  C - Rally
//
//  Created by Hashizo on 2020/02/22.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {
	ll ans = 0;

	ll n;
	cin >> n;

	double ave = 0;
	vector<ll> point(n);
	REP(i, n) {
		cin >> point[i];
		ave += point[i];
	}

	ave = round(ave / n);
	
	REP(i,n) {
		ans += (ll)pow((point[i] - ave) , 2.0);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000

int main(void){
  int i,n,j;
  int defCard[N][3];
  int cardSitu[10];
  int sum,status;

  for(i=0;scanf("%d%d%d",&defCard[i][0],&defCard[i][1],&defCard[i][2])==3;i++){}
  n=i;
  for(i=0;i<n;i++){
    for(j=0;j<10;j++)
      cardSitu[j]=1;
    for(j=0;j<3;j++)
      cardSitu[defCard[i][j]-1]=0;
    sum=0;
    for(j=0;j<10;j++)
      if(cardSitu[j]==1)
        sum+=j+1;
    status=defCard[i][0]+defCard[i][1];
    if(status+sum/7<=20)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int a=sc.nextInt();
            String op=sc.next();
            int b=sc.nextInt();
            if(op.equals("?"))break;
            System.out.println(Calc(a,op,b));
        }
    }

    public static int Calc(int a,String op,int b){
        if(op.equals("+"))return a+b;
        if(op.equals("-"))return a-b;
        if(op.equals("*"))return a*b;
        if(op.equals("/"))return a/b;
        else return -1;
    }
}


Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
               
#define pb push_back
#define PII pair<int,int>         
               
#define VS vector<string>         
#define VI vector<int>            
#define ll long long int          
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {                  
    string s;cin >> s;            
    int left=0,right=s.size()-1;  
    while(1) { 
        if(s[left] == 'A') break; 
        left++;                                                                                                                                                
    }          
    while(1) { 
        if(s[right] == 'Z') break;
        right--;
    }          
               
    cout << right - left + 1 << endl;
} 

Measured memory_bytes: 640
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);

$rootM = $M**0.5;
for($j = 2; $j <= $M+0.01; $j++){
    if($M%$j == 0){
        @$map[$j]++;
        $M/=$j;
        $rootM = $M**0.5;
        $j--;
    }
}
//@$map[$M]++;
$product = 1;
foreach($map as $prime => $count){
    $product *= nCm($count + $N - 1, $count);
    $product %= MOD;
}
printf("%d", $product);
 
//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    return factorialm($a - 1) * $a % MOD;
}
//順列
function nPm($n, $m){
    if($m == 0)return 1;
    return nPm($n, $m - 1) * ($n - $m + 1) % MOD;
}
//組み合わせ
function nCm($n, $m){
    $m = min($m, $n-$m);
    return divm(nPm($n, $m), factorialm($m));
}

Measured memory_bytes: 4604
character(10**5) S
integer cnt
read*,S
!0101のリズムとあわせてみて1010のリズムどっちがあってるか判定して
!あってる方と合わせる感じでいきます
cnt=0
do i=1, len_trim(S)
  if(mod(i,2)==1)then
    if(S(i:i)=="0")cnt=cnt+1
  else
    if(S(i:i)=="1")cnt=cnt+1
  endif
end do
print"(I0)",min(len_trim(S)-cnt,cnt)
end

Measured memory_bytes: 768
import collections

n = int(input())
A = list(map(int,input().split()))
a = collections.Counter(A)
sum_ = sum(A)

Q = int(input())
B,C = [],[]
for i in range(Q):
  lis = list(map(int,input().split()))
  B.append(lis[0])
  C.append(lis[1])

for j,b in enumerate(B):
  sum_+=a[b]*(C[j]-b)
  a[C[j]]+=a[b]
  a[b]=0
  print(sum_)
  



Measured memory_bytes: 30064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), d = in.nextInt(), g = 0;
            while (n-- > 0) {
                long x = in.nextInt(), y = in.nextInt();
                if (Math.sqrt(x * x + y * y) <= d) g++;
            }
            out.println(g);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const ll N=410000,M=1001001;
struct node{
	ll x,id;
}f[N];
ll n,m,T,cnt,a[N],b[N],c[N],g[N],ans[N],x,y,z,k,aa,bb,cc;
bool mycmp(node a,node b)
{
	return a.x>b.x;
}
int main() 
{
	scanf("%lld%lld%lld%lld%lld",&x,&y,&aa,&bb,&cc);
	for (int i=1;i<=aa;i++) 
	{
		scanf("%lld",&a[i]);
		f[++m].x=a[i]; f[m].id=1;
	}
	for (int i=1;i<=bb;i++) 
	{
		scanf("%lld",&b[i]);
		f[++m].x=b[i]; f[m].id=2;
	}
	for (int i=1;i<=cc;i++) 
	{
		scanf("%lld",&c[i]);
		f[++m].x=c[i]; f[m].id=3;
	}
	sort(f+1,f+m+1,mycmp);
	ll ans=0;
	for (int i=1;i<=m;i++)
	{
		if (k>=x+y) break;
		if (f[i].id==1)
		{
			if (x) x-=1,ans+=f[i].x;
		}
		if (f[i].id==2)
		{
			if (y) y-=1,ans+=f[i].x;
		}
		if (f[i].id==3)
		{
			ans+=f[i].x;
			k++;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 10832
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int used[100000];
vector<int> v1[100000];
vector<int> conn;

void dfs(int s, int c){
  conn.push_back(s);
  for(int i=0; i<v1[s].size(); i++){
    if(used[v1[s][i]]==c) continue;
    used[v1[s][i]]=c;
    dfs(v1[s][i], c);
  }
  return;
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	if(m==0){
		printf("%d\n", -1);
		return 0;
	}
  vector<P> ce[1000001];
  vector<int> v[300000];
	for(int i=0; i<m; i++){
		int p, q, c;
		scanf("%d %d %d", &p, &q, &c);
		p--; q--;
      ce[c].push_back(P(p, q));
	}
  int ind=100000;
  for(int c=1; c<=1000000; c++){
    if(ce[c].empty()) continue;
    for(int i=0; i<ce[c].size(); i++){
      int p=ce[c][i].first, q=ce[c][i].second;
      v1[p].push_back(q);
      v1[q].push_back(p);
    }
    for(int i=0; i<ce[c].size(); i++){
      int p=ce[c][i].first;
      if(used[p]==c) continue;
      conn.clear();
      used[p]=c;
      dfs(p, c);
      for(int j=0; j<conn.size(); j++){
        int q=conn[j];
        v[q].push_back(ind);
        v[ind].push_back(q);
      }
      ind++;
    }
    for(int i=0; i<ce[c].size(); i++){
      int p=ce[c][i].first, q=ce[c][i].second;
      v1[p].clear();
      v1[q].clear();
    }
  }
	int d[300000];
	fill(d, d+300000, INF);
	d[0]=0;
	queue<int> que;
	que.push(0);
	while(!que.empty()){
      int x=que.front();
      que.pop();
      for(int i=0; i<v[x].size(); i++){
        if(d[v[x][i]]==INF){
          d[v[x][i]]=d[x]+1;
          que.push(v[x][i]);
        }
      }
    }
 
	if(d[n-1]<INF){
		printf("%d\n", d[n-1]/2);
	}else{
		printf("%d\n", -1);
	}
	return 0;
}


Measured memory_bytes: 53752
import java.util.Random;
import java.util.Scanner;

public class Main {
    static int d = 365;
    static int[] c = new int[26];
    static int[][] s = new int[d][26];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        d = sc.nextInt();
        for (int i=0;i<26;i++){
            c[i]=sc.nextInt();
        }
        for (int i=0;i<d;i++){
            for (int j=0;j<26;j++){
                s[i][j]=sc.nextInt();
            }
        }
        int[] t = new int[d];
        for (int i=0;i<d;i++)t[i]=sc.nextInt()-1;
        function(t);
    }
    static long function(int[] contest){
        long satisfaction = 0;
        int[] interval = new int[26];
        for (int i=0;i<d;i++){
            satisfaction+=s[i][contest[i]];
            for (int j=0;j<26;j++)interval[j]++;
            interval[contest[i]]=0;
            for (int j=0;j<26;j++)satisfaction-=c[j]*interval[j];
            System.out.println(satisfaction);
        }
        return  satisfaction;
    }
}


Measured memory_bytes: 46460
from sys import stdin, stdout
from collections import Counter
for _ in range(1):#int(stdin.readline())
    n=int(stdin.readline())
    a=list(map(int, stdin.readline().split()))
    d=Counter(a);s=sum(a)
    q=int(stdin.readline())
    for qq in range(q):
        old,new=map(int, stdin.readline().split())
        times=d[old]
        s+=times*(new-old)
        d[old]=0
        d[new]=d.get(new,0)+times
        print(s)


Measured memory_bytes: 24112
n = int(input())
print(0)
L = R = input()
if L == "Vacant":
    exit()

l = 0
r = n
while True:
    m = (l + r) // 2
    print(m)
    M = input()
    if M == "Vacant":
        exit()
    if (M == L) ^ ((m - l) % 2 == 1):
        l = m
        L = M
    else:
        r = m
        R = M



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

const int MOD=1e9+7;

signed main(){
    int N,K;
    cin>>N>>K;
    int ans=0;
    int ls=0;
    int rs=0;
    for(int i=0;i<=N+1;i++){
        if(i>=K){
          ans+=rs-ls+1;
          ans%=MOD;
        }
        rs+=N-i;
        ls+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n,x=0,y=0,ans=100000,c=0;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  rep(i,0,n){
    if(a[i]!=i+1) c++;
  }
  if(c==0||c==2) co("YES");
  else co("NO");
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int A[1000000],n;

int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(right+left)/2;
    if(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    else if(key<A[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarySearch(k))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1416
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
using namespace std;
const int SIZE=5*1e5;
const LL INF=1LL<<58;
LL N,A;
LL solve(LL x,LL c,bool downable){
	if(N<=x) return 0;
	LL minium=N+A;
	if(downable) minium=min(minium,min(solve(x*c,c,true)+c+A,solve(x*(c-1),c-1,false)+c-1+A));
	else minium=min(minium,solve(x*c,c,false)+c+A);
	return minium;
}
int main(){
	cin >> N >> A;
	LL minimum=N+A;
	FOR(i,1,100){
		LL c=pow(N,1.0/i);
		if(c==1) break;
		minimum=min(minimum,solve(1,c+1,true));
	}
	cout << minimum-A << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
//sort(y,y+j, greater<int>());
ll x[1000000];
int main()
{
    ll a,b,c,d,e,i,j,k,n,sq,mul,r;
    char s[10000];
    in>>s;
    b=strlen(s);
    if(s[b-1]=='s'){out<<s<<"es"<<nl;}
    else {out<<s<<"s"<<nl;}


}


Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define N 100005
#define LL long long
using namespace std;
int fs[N],nt[2*N],dt[2*N],n,m,sz[N],mw,mi,m2;
LL pr[2*N],ans;
void link(int x,int y,int z)
{
	nt[++m]=fs[x];
	dt[fs[x]=m]=y;
	pr[m]=z;
}
void dfs(int k,int fa)
{
	sz[k]=1;
	int mx=0;
	for(int i=fs[k];i;i=nt[i])
	{
		int p=dt[i];
		if(p!=fa)
		{
			dfs(p,k);
			sz[k]+=sz[p];
			mx=max(mx,sz[p]);
			ans+=(LL)min(sz[p],n-sz[p])*pr[i]*(LL)2;
		}
	}
	if(max(mx,n-sz[k])==mi) m2=k;
	if(max(mx,n-sz[k])<mi) mi=max(mx,n-sz[k]),mw=k,m2=0;
}
int main()
{
	cin>>n;
	mi=n;
	fo(i,1,n-1)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		link(x,y,z),link(y,x,z);
	}
	dfs(1,0);
	if(m2==0) 
	{
		mi=1802201963;
		for(int i=fs[mw];i;i=nt[i]) mi=min(mi,(int)pr[i]);
		ans-=mi;
	}
	else
	{
		for(int i=fs[mw];i;i=nt[i])
		{
			if(dt[i]==m2) 
			{
				ans-=pr[i];
				break;
			}
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 9472
<?php
$input_line = trim(fgets(STDIN));
$s = explode(" ", $input_line);

$N = $s[0];
$A = $s[1];
$B = $s[2];
$sum = 0;
$array = [];

for ($i = 0; $i <= $N; $i++) {
	$array[] = $i;
}

foreach ($array as $num) {
	$num_array = str_split($num);
  	$num_sum = array_sum($num_array);
  	if ($A <= $num_sum && $num_sum <= $B) {
    	$sum += $num;
    }
}

echo $sum;
?>

Measured memory_bytes: 5364
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, Q;
vector<int> E[101010];
//---------------------------------------------------------------------------------------------------
int heiro[101010], vis[101010];
int dfs(int cu, int pa = -1) {
    vis[cu] = 1;
    fore(to, E[cu]) if (to != pa) {
        if (vis[to] == 1) {
            heiro[to] = 1;
            heiro[cu] = 1;
            return 1;
        } else {
            if (dfs(to, cu)) {
                if (heiro[cu] == 1) return 0;
                heiro[cu] = 1;
                return 1;
            }
        }
    }
    return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) {
        int a, b; cin >> a >> b; a--; b--;
        E[a].push_back(b); E[b].push_back(a);
    }

    dfs(0);


    cin >> Q;
    rep(_, 0, Q) {
        int a, b; cin >> a >> b; a--; b--;
        if (heiro[a] and heiro[b]) printf("2\n");
        else printf("1\n");
    }
}



Measured memory_bytes: 12548
str = input().split(" ")
N = int(str[0])
W = int(str[1])
value = [0 for i in range(N)]
weight = [0 for i in range(N)]
dp = [[0 for i in range(W+1)] for l in range(N+1)]

for i in range(N):
    str = input().split(" ")
    value[i] = int(str[0])
    weight[i] = int(str[1])

for i in range(N):
    for w in range(W+1):
        if w >= weight[i]:
            dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 42268
#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int ini, fim, grupo, grupototal=0;

    for(int i=0;i<n;i++){
        scanf("%d %d",&ini, &fim);
        if(fim>ini){
            grupo=(fim+1)-ini;
        }
        else{
            grupo=(ini+1)-fim;
        }

        grupototal=grupototal+grupo;
    }
    printf("%d\n", grupototal);
    return 0;
}


Measured memory_bytes: 128
/************************************************
 *Author*        :skyNebula
 *Created Time*  : 一  1/14 12:05:22 2019

*********************************************/

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>


using namespace std;
#define debug(x) cout << #x << " " << "=" << " " << (x) << endl;
#define ms(a,b) memset(a,b,sizeof(a);
typedef pair<int, int> pii;
typedef long long LL;
const int mod = 1e9 + 7;
const int MaxN = 2e5;

char s1[MaxN + 5];
char s2[MaxN + 5];
bool ans;
int ck[200];
int ck2[200];

bool check(char s1[],char s2[]){
    int l = strlen(s1);
    for(int i = 0; i < l; i++){
        if(s1[i] != s2[i] || ck[s1[i]] == 0){

/*
            cout << s1[i] << ":" << s2[i] << endl;
            cout << ck[s1[i]] << endl;
            cout << (ck[s1[i]]!=s2[i]) << endl;
*/

            if(ck[s1[i]] == 0)
                ck[s1[i]] = s2[i];
            else if(ck[s1[i]] != s2[i]){
                return false;
            }
        }
    }

    for(int i = 'a'; i <= 'z'; i++){
        ck2[ck[i]]++;
    }
    for(int i = 1; i < 200; i++){
        if(ck2[i]>=2){
            return false;
        }
    }

    return true;
}


int main()
{
    cin >> s1;
    cin >> s2;
    ans = check(s1,s2);
    if(ans){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0
    m = sum(B) - sum(A)
    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += (B[i] - A[i] + 1) // 2

    if _diff_B <= m and _diff_A <= m:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 73364
use proconio::{input, fastout};
use proconio::marker::Usize1;
use std::collections::*;

#[fastout]
fn main() {
    input!{
        n: usize,
        m: usize,
        route: [(Usize1, Usize1);m],
    }
    let mut to: Vec<Vec<usize>> = vec![Vec::new();n+5];
    for i in 0..m {
        to[route[i].0].push(route[i].1);
        to[route[i].1].push(route[i].0);
    }

    let inf: usize = 1001001001;
    let mut q: VecDeque<usize> = VecDeque::new();
    let mut dist: Vec<usize> = vec![inf;n];
    let mut pre: Vec<usize> = vec![inf;n];
 
    dist[0] = 0;
    q.push_front(0);
    while !q.is_empty() {
        let v = q[0];
        q.pop_front();
        for &i in &to[v] {
            if dist[i] != inf {
                continue;
            } else {
                dist[i] = dist[i] + 1;
                pre[i] = v;
                q.push_back(i);
            }
        }
    }

    println!("Yes");
    for i in 0..n {
        if i==0 {
            continue;
        } else {
            let mut ans = pre[i];
            ans += 1;
            println!("{}", ans);
        }
    }
}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

ll dp[2005];

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

  int s;
  cin >> s;

  for (int i = 0; i <= s; i++) dp[i] = 0;

  dp[0] = 1;
  for (int i = 3; i <= s; i++) {
    for (int j = 3; j <= i; j++) {
      dp[i] += dp[i - j];
      dp[i] %= mod;
    }
  }

  cout << dp[s] << '\n';
}


Measured memory_bytes: 3656
#import time


def func():
    N = int(input())
    step = [0 for i in range(N+1)]

    for i in range(1, N+1):
        minimum = step[i-1]+1
        p = 0
        r = 0
        while i >= 9 ** (p+1):
            p += 1
            minimum = min(minimum, 1+step[i-9**p])
        while i >= 6 ** (r+1):
            r += 1
            minimum = min(minimum, 1+step[i-6**r])
        step[i] = minimum

    print(step[N])

if __name__ == "__main__":
 #   start = time.time()
    func()
 #   elapsed_time = time.time() - start
 #   print("elapsed_time:{0}".format(elapsed_time) + "[sec]")


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

int main()
{
  int x;
  cin>>x;
  
  if(x>=400 && x<=599) cout<<"8";
  if(x>=600 && x<=799) cout<<"7";
  if(x>=800 && x<=999) cout<<"6";
  if(x>=1000 && x<=1199) cout<<"5";
  if(x>=1200 && x<=1399) cout<<"4";
  if(x>=1400 && x<=1599) cout<<"3";
  if(x>=1600 && x<=1799) cout<<"2";
  if(x>=1800 && x<=1999) cout<<"1";
}

Measured memory_bytes: 3580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author GYSHGX868
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskD solver = new TaskD();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskD {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      char[] s = in.nextString().toCharArray();
      int half = s.length / 2;
      int numPapers = 0;
      int answer = 0;
      for (char c : s) {
        if (c == 'g') {
          if (numPapers < half) {
            numPapers++;
            answer++;
          }
        } else {
          if (numPapers < half) {
            numPapers++;
          } else {
            answer--;
          }
        }
      }
      out.printLine(answer);
    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(int i) {
      writer.println(i);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public String nextString() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      StringBuilder res = new StringBuilder();
      do {
        if (Character.isValidCodePoint(c)) {
          res.appendCodePoint(c);
        }
        c = read();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      boolean isSpaceChar(int ch);

    }

  }
}



Measured memory_bytes: 21716
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; ll L; cin >> N >> L; ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  ll b[N-1]; ll ma = 0, mai;
  rep(i, N-1){
    b[i] = a[i]+a[i+1];
    if(ma<b[i]){
      ma=b[i];
      mai=i;
    }
  }
  if(ma<L){
    cout << "Impossible" << endl; return 0;
  }
  cout << "Possible" << endl;
  rep(i, mai){
    cout << i+1 << endl;
  }
  for(int i=N-2; i>=mai; i--){
    cout << i+1 << endl;
  }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
 
using namespace std;
#define int long long
int n,f[100005][2],base=1e9+7,pa[100005],con[100005],ok[100005];
vector<int> v[100005];
void BFS()
{
    queue<int> q;
    q.push(1);
    ok[1]=1;
    while(q.size())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<v[u].size();i++)
        {
            if(ok[v[u][i]]==0)
            {
                ok[v[u][i]]=1;
                pa[v[u][i]]=u;
                q.push(v[u][i]);
                con[u]++;
            }
        }
    }
}
int F(int i,int ok)
{
    if(f[i][ok]!=-1) return f[i][ok];
    else if(con[i]==0) return 1;
    else
    {
        //cout<<i<<" "<<ok<<'\n';
        int gt=1;
        for(int j=0;j<v[i].size();j++)
        {
            if(i==pa[v[i][j]])
            {
                int res=0;
                res=(res+F(v[i][j],0))%base;
                if(ok==0) res=(res+F(v[i][j],1))%base;
                gt=(gt*res)%base;
            }
        }
        f[i][ok]=gt;
        return gt;
    }
}
main()
{
    cin>>n;
    memset(f,-1,sizeof(f));
    for(int i=1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    BFS();
    //cout<<con[2];
    cout<<(F(1,0)+F(1,1)+base)%base<<'\n';
    //cout<<F(1,0)<<" "<<F(1,1);
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
#define is(x) cout << #x << " = " << x << endl;
using namespace std;
const int N=500000;
int nxt(){int x;cin >> x;return x;}
int32_t main(){
    base
    string a,b;
    cin>>a>>b;
    b.pop_back();
    cout<<(a==b?"Yes":"No");
    exit
}


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

int main(){
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);std::cin.tie(nullptr);
	int l,r,d;
	cin >> l >> r >> d;
	cout << r/d-(l-1)/d << endl;
	return 0;
}

Measured memory_bytes: 3608
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
int N, X, Y;
int sz[1000000];
int bfs(int s) {
	queue<int>que;
	vector<int>dist(N,INF);
	dist[s] = 0;
	que.push(s);
	while (!que.empty()) {
		int u = que.front(); que.pop();
		if (dist[u + 1] == INF&&u+1<N) {
			dist[u + 1] = dist[u] + 1;
			que.push(u + 1);
		}
		if (dist[u - 1] == INF&&u-1>=0) {
			dist[u - 1] = dist[u] + 1;
			que.push(u - 1);
		}
		if (u == X&&dist[Y]==INF) {
			dist[Y] = dist[u] + 1;
			que.push(Y);
		}
		if (u == Y && dist[X] == INF) {
			dist[X] = dist[u] + 1;
			que.push(X);
		}
		sz[dist[u]]++;
		
	}
}

int main()
{
	cin >> N >> X >> Y;
	X--; Y--;
	rep(i, N) {
		bfs(i);
		//cout << "work" << endl;
	}
	rep(i, N-1) {
		cout << sz[i+1]/2 << endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0543

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        total = int(input())
        if total == 0:
            break
        books = [int(input()) for _ in range(9)]
        print(total - sum(books))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7708