akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
int main(void){
	char s[100002];
	scanf("%s",s);
	int n = strlen(s);
	int temp = 0;
	int temp2= 0;
	int i;
	int flag = 0;
	//010かどうかチェキ
	for(i=0;i<n;i++){
		if(flag==0){
			if(s[i]=='1'){
				temp ++ ;
			}
			flag = 1;
			continue;
		}
		if(flag==1){
			if(s[i]=='0'){
				temp++;
			}
			flag = 0;
			continue;
		}
	}
	//101かどうかチェキ
	flag = 0;
	for(i=0;i<n;i++){
		if(flag==0){
			if(s[i]=='0'){
				temp2++ ;
			}
			flag = 1;
			continue;
		}
		if(flag==1){
			if(s[i]=='1'){
				temp2++;
			}
			flag = 0;
			continue;
		}
	}
	int ans = temp;
	if(ans>temp2)ans=temp2;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    int N,K;
    vector<int> B[10];
    set<int> genre;

    cin >> N >> K;

    int dp[10][K+2];

    for(int i=0; i<N; ++i) {
        int c,g;
        cin >> c >> g;
        B[g-1].push_back(c);
        genre.insert(g-1);
    }

    for(auto g : genre) {
        sort(B[g].rbegin(),B[g].rend());
        for(int i=0; i<(int)B[g].size(); ++i) {
            if(i!=0) B[g][i]=B[g][i]+B[g][i-1]+2*i;
        }
    }

    dp[0][0]=0;
    for(int i=1; i<=K; ++i) {
        if(i<(int)B[0].size()) dp[0][i]=B[0][i-1];
        else dp[0][i]=-1;
    }

    for(int g=1; g<10; ++g) {
        dp[g][0]=0;
        for(int i=1; i<=K; ++i) {    // i ... total books ( for sale )
            dp[g][i]=dp[g-1][i];
            for(int j=0; i-(j+1)>=0 && j<min(K,(int)B[g].size()); ++j) { // j ... max book index in genre g ( for sale )
                if(dp[g-1][i-(j+1)]!=-1) {
                    dp[g][i]=max(dp[g][i],dp[g-1][i-(j+1)]+B[g][j]);
                }
            }
        }
    }


    cout << dp[9][K] << endl;

    return 0;
}

Measured memory_bytes: 3216
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var t [][]int
var a []int

func dfs(v int, p int) {
	for _, u := range t[v] {
		if u != p {
			a[u] += a[v]
			dfs(u, v)
		}
	}
}

func main() {
	var n, q int

	fmt.Scan(&n, &q)

	t = make([][]int, n)
	a = make([]int, n)

	scanner := bufio.NewScanner(os.Stdin)

	for i := 0; i < n-1; i++ {
		scanner.Scan()
		inputs := strings.Split(scanner.Text(), " ")

		p, _ := strconv.Atoi(inputs[0])
		c, _ := strconv.Atoi(inputs[1])

		p--
		c--

		t[p] = append(t[p], c)
		t[c] = append(t[c], p)
	}

	for i := 0; i < q; i++ {
		scanner.Scan()
		inputs := strings.Split(scanner.Text(), " ")

		p, _ := strconv.Atoi(inputs[0])
		x, _ := strconv.Atoi(inputs[1])

		p--

		a[p] += x
	}

	dfs(0, -1)

	buffer := bufio.NewWriter(os.Stdout)

	for _, v := range a {
      buffer.WriteString(strconv.Itoa(v))
		buffer.WriteString("\n")
	}

	buffer.Flush()
}


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

using namespace std;

using LL = long long;

int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);
	
	int n, d, a;
	cin >> n >> d >> a;	//distance, atack

	vector < pair<int,int> > v;

	for(int i = 0, x, h; i < n; ++i) {
		cin >> x >> h;
		v.push_back({x, h});
	}

	sort(v.begin(), v.end());

	LL delta = 0, ans = 0;

	queue< pair<LL,LL> > q;

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

		int x = v[i].first;
		int h = v[i].second;

		while(!q.empty() && (LL)x > q.front().first) {
			delta -= q.front().second;
			q.pop(); 
		}

		LL c = h / a + (h % a != 0) - delta; // number of bombs [x, x + 2*d - 1]
		
		if(c > 0) {
			q.push({x + 2LL * d, (LL)c});
			ans += c;
			delta += c;
		}

		
	}

	cout << ans << '\n';


	return 0;
}

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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    if (n == 0) puts("1");
    else if (n == 1) puts("2");
    else if (n == 2) puts("1");
    else puts("0");
    return 0;
}



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

using namespace std;

typedef long long ll;

const int Mod=1e9+7;
int n;
int a[200010];
ll sum[200010];
ll ans;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum[i]=(sum[i-1]+a[i])%Mod;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+(ll)a[i]*((sum[n]-sum[i])%Mod+Mod)%Mod)%Mod;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 6096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	string n;
	cin >> n;
	string ans = "AC";
	if (n[0] != *"A") {
		ans = "WA";
	}
	int cnt = 0;
	rep(i, n.size() - 1) {
		int k = i + 1;
		if (isupper(n[k])) {
			if (k == 1 || k == n.size() - 1 || n[k] != *"C") {
				ans = "WA";
			}
			cnt++;
		}
	}
	if (cnt != 1) {
		ans = "WA";
	}
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
Q = int(input())
is_prime = {i:True for i in range(10**5+1)}
is_prime[0], is_prime[1] = False, False
for i in range(2, 10**5+1):
    if is_prime[i]:
        for j in range(i*2, 10**5+1, i):
            is_prime[j] = False
s = [0] * (10**5+1)
for i in range(1, 10**5):
    s[i+1] = s[i] + int(is_prime[i] and is_prime[(i+1)//2])
for _ in range(Q):
    left, right = map(int, input().split())
    print(s[right+1]-s[left])

Measured memory_bytes: 59236
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define RER(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
ll n, m, e[MAX_N][2], b[MAX_N];
vector<ll> ret;

ll par[MAX_N]; // 親の番号

// n要素で初期化
void init(ll n){
	for(ll i=0; i<n; i++) par[i] = i;
}

// 木の根を求める
ll root(ll x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = root(par[x]); // 経路圧縮
	}
}

bool same(ll x, ll y){
	return root[x] == root[y];
}

void unit(ll x, ll y){
	x = root(x);
	y = root(y);
	if(x==y) return;
	par[x] = y;
}

signed main(){
	cin >> n >> m;
	REP(i, m){ cin >> e[i][0] >> e[i][1]; e[i][0]--; e[i][1]--; }
	init(n);
	ll x = n * (n-1) / 2;
	fill(b, b+n, 1LL);
	ret.pb(x);
	for(ll i=m-1; i>=0; i--){
		// ll ass = 0;
		// REP(i, n) ass += b[i];
		// REP(i, n) cout << b[i] << endl;
		// cout << endl;
		// assert(ass == n);
		if(same(root(e[i][0]), root(e[i][1])))
			ret.pb(ret.back());
		else{
			// assert(b[root(e[i][0])] != 0);
			// assert(b[root(e[i][1])] != 0);
			ll y = b[root(e[i][0])];
			ll z = b[root(e[i][1])];
			x = x + y * (y-1) / 2 + z * (z-1) / 2 - (y+z) * (y+z-1) / 2;
			b[root(e[i][0])] += b[root(e[i][1])];
			b[root(e[i][1])] = 0;
			unit(e[i][1], e[i][0]);
			// ll tmp = 0;
			// REP(i, n) tmp += b[i] * (b[i] - 1) / 2;
			ret.pb(x);
		}		
	}
	reverse(ALL(ret));
	FOR(i, 1, m+1){
		cout << ret[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
int main(){
    int n,k;
    cin>>n>>k;
    int i=0;
    while(n>=pow(k,i)) i++;
    cout<<i<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
long n, k, f, y, m = 1;

void main(){
	readf("%d\n", &n);
	auto A = readln.split.to!(long[]) ~ 1;
	long* u = &A.dup[0], v = &A.dup[0];
	
	while(n - m > 1){
		k = (m + n) / 2;
		*u = *v = 0;
		foreach(a; A){
			if(*u < a) *++u = a, *++v = 1;
			else{
				while(*--u >= a){
					y = *v;
					while(--*(u + 1) >= *u && y) --y /= k;
					*--v += y;
				}
				if(*++u > a){
					while(--*u >= a && *v) --*v /= k;
					*u = a, ++*v;
				}
				++f, ++*v;
			}
		}
		*v-- > k + 1? m : n = k;
		--f, --u;
	}
	writeln(f? n: 1);
	
}


Measured memory_bytes: 16784
import sys
from heapq import heapify, heappop
from operator import itemgetter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	A = MAP()
	BC = [MAP() for _ in range(M)]
	
	BC.sort(key= itemgetter(1), reverse=True)
	
	heapify(A)
	
	ans = 0
	
	fin = False
	for b, c in BC:
		#print(A, b, c)
		for _ in range(b):
			a = A[0]
			if a>c:
				fin = True
				break
			else:
				heappop(A)
				ans += c
				N -= 1
				if N == 0:
					fin = True
					break
		if fin:
			break
	
	print(ans+sum(A))

if __name__ == '__main__':
	main()

Measured memory_bytes: 89880
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){

    int n;
    scanf("%d", &n);

    int m[101][101], p[101];

    for(int i=1; i<=n; i++){
        int r, c;
        scanf("%d %d", &r, &c);
        p[i-1] = r; //これはなかなか思いつかない
        p[i] = c;
    }

    //行列の積になっていない
    for(int i=1; i<=n; i++) m[i][i] = 0; 
    //行列の積
    for(int l=2; l<=n; l++){
        for(int i=1; i<=n-l+1; i++){
            int j=i+l-1;
            m[i][j] = (1<<21);
            for(int k=i; k<=j-1; k++){
                m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }

    printf("%d\n", m[1][n]);
    return 0;
}


Measured memory_bytes: 3248
n, k, q = map(int, input().split())
scores = [0]*(n+1)

for i in range(q):
  a = int(input())
  scores[a] += 1
  
for i in range(1, len(scores)):
  if q - scores[i] >= k:
    print("No")
  else:
    print("Yes")

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

using namespace std;

const int mx = 1e5+133;

int dp[mx][4];

int h[mx][4],n;

int solve(int i , int f){

 if(i > n) return 0;

 if(dp[i][f] != -1) return dp[i][f];

 int ret = 0;

 for(int j = 1 ;j <=3; j++){
    if(j!=f){
        ret = max(ret,h[i][j]+solve(i+1,j));
    }
 }
 return dp[i][f] = ret;
}


int main(){

   cin >> n;
  for ( int i = 1; i <= n; i++ ) {
    cin >> h[i][1] >> h[i][2] >> h[i][3];
  }

  memset ( dp, -1, sizeof(dp) );
  cout << solve ( 1, 0 ) << endl;


 return 0;
}


Measured memory_bytes: 14528
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int x, n;
	cin >> x >> n;
	vector<int>p(n);
	rep(i, 0, n)cin >> p[i];
	
	sort(p.begin(), p.end());

	int i = 0;
	while (1)
	{
		if (!binary_search(p.begin(), p.end(), x - i))
		{
			cout << x - i << endl;
			break;
		}
		if (!binary_search(p.begin(), p.end(), x + i))
		{
			cout << x + i << endl;
			break;
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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


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

    int N;
    cin >> N;

    vector<int> ans(N+1);
    ans[0] = 0;

    for(int i = 1; i < N+1; i++){
        
        ans[i] = ans[i-1] + 1;

        for(int i6 = 6; i - i6 >= 0; i6 = i6 * 6){
            chmin(ans[i], ans[i-i6]+1);
        }

        for(int i9 = 9; i - i9 >= 0; i9 = i9 * 9){
            chmin(ans[i], ans[i-i9]+1);
        }

    }

    cout << ans[N] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	cout << (N + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
/* ex3_3 
　　　　　sachiyan*/

#include <stdio.h>
#include<math.h> //math.h の標準ライブラリを使用
int main(void){
    int num, ary, ans; //入力値N,Kと答えansを定義
    scanf("%d %d", &num, &ary); //入力値N,Kを読み取る
    ans = 0; //ansに初期値0を代入
    while(pow(ary, ans) <= num){ //powはmath.hによる累乗を計算する関数
        ans++;  //K進数の最高位を探す　Kのans乗がN以下の時はそれ以上の桁が存在するので繰り返す
    }
    printf("%d\n", ans); //答えansを出力
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
#include <math.h>
int main(void)
{
	int num ,x[1000],y[1000],i;
	double z1 =0, z2 = 0, z3 = 0, z =0;

	scanf("%d",&num);
	
	
	for(i=0;i<num;i++)
	{
		scanf("%d",&x[i]);
	}
	
	
	for(i=0;i<num;i++)
	{
		scanf("%d",&y[i]);
	}
	
	
	for(i=0;i<num;i++)
	{
		if(x[i]<y[i])
		{
			z1 = z1 + y[i] - x[i];		
			z3 = z3 + (y[i] - x[i]) * (y[i] - x[i])  * (y[i] - x[i]);
		}
		
		
		if(y[i]<x[i])
		{
			z1 = z1 + x[i] -y[i];
			z3 = z3 + (x[i] - y[i]) *  (x[i] - y[i])  *  (x[i] - y[i]);
		}
		
		
		z2 = z2 + (x[i] - y[i]) *  (x[i] - y[i]);

		
		
		if(x[i]<y[i])
		{
			if(z<y[i] - x[i])
			{
				z =y[i] - x[i];
			}
		}
		if(x[i]>y[i])
		{
			if(z<x[i] -y[i])
			{
				z = x[i] -y[i];
			}
		}
	}
	
	
	
	printf("%f\n %f\n %f\n %f\n",z1,sqrt(z2),pow(z3,1.0/3.0),z);


	return 0 ;
}

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

int main() {
    int n;
    cin >> n;
    
    if (n % 2) {
        cout << n / 2 + 1 << endl;
    }
    else cout << n / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int  main()
{
	int x;
	int array[3], t;
	for (x = 0; x < 3; x++)
	{

		cin >> array[x];
	}
	for (x = 0; x < 3; x++)
	{
		for (int y = 0; y < 2; y++)
		{
			if (array[y] > array[y + 1])
			{
				t = array[y];
				array[y] = array[y + 1];
				array[y + 1] = t;
			}
		}
	}
	
	cout << array[0] << " " << array[1] << " " << array[2] << endl;
	

	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	int n, k, m;
	
	while(true){
		cin >> n >> k >> m;
		if(n == 0){
			break;
		}
		int cur = 1;
		for(int i = 1; i < n; i++){
			cur = (cur - k % i + i - 1) % i + 2;
			//cout << cur << " ";
		}
		cout << (m - cur + n) % n + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3000
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}



int main(void) {
    FAST_IO;
    
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        q.push(x);
    }
    for (int i = 0; i < m; i++) {
        int t = q.top();
        q.pop();
        t /= 2;
        q.push(t);
    }
    ll ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size() - 1; i++) {
        if ((s[i] == 'B' && s[i + 1]  == 'W') || (s[i] == 'W' && s[i + 1] == 'B')) {
            ans++;
        }
    }
    cout << ans << "\n";
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;
const ll max_n = 5003;
ll fact[max_n];
bool fact_init = false;

ll pow(ll a, ll b){
	if(b == 0) return 1;
	if(b % 2 == 1) return a * pow(a, b - 1) % MOD;

	ll d = pow(a, b / 2) % MOD;
	return d * d % MOD;
}

ll comb(ll n, ll k){
	if(!fact_init){
		fact[0] = 1;
		fact[1] = 1;

		for(ll i = 2; i < max_n; i++){
			fact[i] = fact[i-1] * i;
			fact[i] %= MOD;
		}

		fact_init = true;
	}

	ll ret = fact[n];
	ret *= pow(fact[k],MOD-2);
	ret %= MOD;
	ret *= pow(fact[n-k],MOD-2);
	ret %= MOD;
	return ret;

	// X^(-1) = X^(p-2) (mod p) (Fermat's little theorem)
}


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

	ll N, K;
	cin >> N >> K;

	for(int i = 1; i <= K; i++){
		if(i > N-K+1){
			cout << 0 << endl;
			continue;
		}

		cout << comb(K - 1, i - 1) * comb(N - K + 1, i) % MOD << endl;
	}

}


Measured memory_bytes: 256
from collections import Counter

N,M = map(int,input().split())
A = list(map(int,input().split()))

S = [0]

for i in range(N):
    S.append((S[-1]+A[i])%M)

C = Counter(S)

ans = 0

for v in C.values():
    ans += v*(v-1)//2

print(ans)

Measured memory_bytes: 16552
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
	string s;
	cin>>s;
	string s1;
	rep(i,0,s.sz){
		if(s[i]!='x'){
			s1 += s[i];
		}
	}
	string s2 = s1;
	reverse(all(s2));
	if(s1!=s2){
		cout << -1 << endl;
		return 0;
	}
	ll ans = 0;
	ll c1 = 0;
	ll c2 = 0;
	ll index1 = 0;
	ll index2 = s.sz-1;
	while(1){
		if(s[index1]=='x'){
			c1++;
			index1++;
		}
		else if(s[index2]=='x'){
			c2++;
			index2--;
		}
		else{
			ans += abs(c1-c2);
			index1++;
			index2--;
			c1 = 0;
			c2 = 0;
			if(index1>=index2){
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
vector<int> A;
int sz = 1;
void init(int n)
{
    while(sz < n) sz *= 2;
    A.resize(2 * sz - 1, 0);
}
void add(int pos, int v)
{
    pos += (sz - 1);
    A[pos] += v;
    while(pos > 0)
    {
        pos = (pos - 1) / 2;
        A[pos] = A[2 * pos + 1] + A[2 * pos + 2];
    }
}
int getSum(int s, int t, int k, int l, int r)
{
    if(l >= t or r <= s) return 0;
    if(l >= s and r <= t) return A[k];
    int mid = (l + r) / 2;
    int a = getSum(s, t, 2 * k + 1, l, mid);
    int b = getSum(s, t, 2 * k + 2, mid, r);
    return a + b;
}
int getSum(int s, int t)
{
    return getSum(s, t, 0, 0, sz);
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    init(n);
    for(int i = 0; i < q; i++)
    {
        int com, x, y; cin >> com >> x >> y;
        if(com == 0) add(x - 1, y);
        else cout << getSum(x - 1, y) << endl;
    }
    return 0;
}




Measured memory_bytes: 3804
#include<stdio.h>
 
int main(){
    int a, b, ab, count;
     
    while( scanf("%d %d", &a, &b) != EOF ){
        ab = a + b;
		count = 0;
         
        while( ab > 0 ){
            ab /= 10;
            count++;
        }
         
        printf("%d\n", count);
    }
     
	return 0;
}

Measured memory_bytes: 0
import itertools
import math

n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]

ans = 0
ps = itertools.permutations(range(n))
c = 0
for ls in ps:
    c += 1
    head, tail = ls[0], ls[1:]
    for i in tail:
        x0, y0 = xy[head]
        x, y = xy[i]
        ans += math.sqrt((x - x0) ** 2 + (y - y0) ** 2)
print(ans / c)


Measured memory_bytes: 41708
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int A, B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    boolean possible =
      A%3 == 0 || B%3 == 0 || (A+B)%3 == 0;
    System.out.println(possible ? "Possible" : "Impossible");
  }
}

Measured memory_bytes: 22996
n = gets.to_i
s_array = gets.split(" ").map(&:to_i);
q = gets.to_i
t_array = gets.split(" ").map(&:to_i);

j = 0
for i in 0..q-1 do
	left = 0
	right = n
	while left < right do
	    mid = (left + right) / 2
	    if s_array[mid] == t_array[i] then
	        j += 1
			break
	    elsif t_array[i] < s_array[mid] then
	        right = mid
	    else
	        left = mid + 1
		end
	end
end
puts j

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

int main()
{
    string s;
    cin >> s;
    if((*(s.end()-1)) != 's') s.append("s");
    else s.append("es");
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    if (a + b > c + d) {
        std::cout << "Left" << std::endl;
    } else if (a + b < c + d) {
        std::cout << "Right" << std::endl;
    } else {
        std::cout << "Balanced" << std::endl;
    }
}


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

unsigned long long gcd(unsigned long long a,unsigned long long b){
  if (b == 0){
      return a;
  }
  return gcd(b, a % b);
}

int main() {
  unsigned long long a,b,c,d;
  cin >> a >> b >> c >> d;
  
  unsigned long long ans;
  ans = b - a + 1;
  //cout << ULLONG_MAX << endl;
  //cout << b << endl;
  //cout << a << endl;
  //cout << "ans:" << b - a << " " << b << " " << a << endl;

    //a未満で最大の倍数
  unsigned long long k = a/c;if(a%c==0&&k>0) k--;
  unsigned long long m = b/c+1;if(m<0)m=0;
  ans += -m+k+1;

  //cout << ans << " " << k << " " << m << endl;
  
  k = a/d;if(a%d==0&&k>0) k--;
  m = b/d+1;if(m<0)m=0;
  ans += -m+k+1;
  
  //cout << ans << " " << k << " " << m << " a:" << 846264338327950288%846264338327950289 << endl;
  //最小公倍数
  unsigned long long s;
  s = d / gcd(c,d) * c;

  k = a/s;if(a%s==0&&k>0) k--;
  m = b/s+1;if(m<0)m=0;
  ans += m-k-1;

  //cout << ans << " " << k << " " << m << endl;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int long long i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 300005;

i64 n;
i64 a[MAXN];
i64 pre[MAXN];
i64 post[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;
    for (i64 i = 1; i <= n; i++) {
        cin >> a[i];
    }

    if (n == 2) {
        cout << abs(a[1] - a[2]) << endl;
        return 0;
    }

    for (i64 i = 1; i <= n; i++) {
        pre[i] = pre[i - 1] + a[i];
    }

    for (i64 i = n; i >= 1; i--) {
        post[i] = post[i + 1] + a[i];
    }

    i64 j = -1;
    for (i64 i = 2; i <= n - 1; i++) {
        j = i;
        if (pre[i - 1] >= post[i + 1]) {
            break;
        }
    }

    i64 R = abs(a[j] - abs(pre[j - 1] - post[j + 1]));
    cout << R << endl;


    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,t;cin>>n>>t;
    vector<pll>a(n);
    rep(i,n){
        ll x,y;cin>>x>>y;
        a[i]=mp(x,y);
    }
    sort(all(a));
    vector<vector<ll> >dp(n+1,vector<ll>(t+1,-1));
    dp[0][0]=0;
    rep(i,n){
        rep(j,t){
            if(dp[i][j]<0){
                continue;
            }
            if(j+a[i].first>=t){
                dp[i+1][t]=max(dp[i+1][t],dp[i][j]+a[i].second);
            }else{
                dp[i+1][j+a[i].first]=max(dp[i+1][j+a[i].first],dp[i][j]+a[i].second);
            }
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
        dp[i+1][t]=max(dp[i+1][t],dp[i][t]);
    }
    ll ans=0;
    rep(i,t+1){
        ans=max(ans,dp[n][i]);
        //cout<<dp[n][i]<<endl;
    }
    cout<<ans<<endl;
}


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

struct city {
  int x;
  int y;
  int64_t p;
};

struct linescore {
  int lineid;
  int64_t s;
};

int64_t recursive_score(int K,
                        vector<vector<linescore>> &city_line_scores,
                        int current_line,
                        int selected_num,
                        vector<bool> &exist_lines) {
  if (selected_num == K) {
    int64_t s = 0;
    for (int i = 0; i < (int)city_line_scores.size(); i++) {
      for (auto line_score : city_line_scores[i]) {
        if (exist_lines[line_score.lineid]) {
          s += line_score.s;
          break;
        }
      }
    }
    return s;
  }

  int64_t min_score = 100000000000000LL;
  int add_line_num = (int)exist_lines.size() - 2;
  if (current_line >= add_line_num) {
    return min_score;
  }
  int rest = (add_line_num - current_line) / 2;
  if (selected_num + rest < K) {
    return min_score;
  }
  exist_lines[current_line] = true;
  min_score = min(min_score, recursive_score(K, city_line_scores, current_line + 2, selected_num + 1, exist_lines));
  exist_lines[current_line] = false;
  exist_lines[current_line + 1] = true;
  min_score = min(min_score, recursive_score(K, city_line_scores, current_line + 2, selected_num + 1, exist_lines));
  exist_lines[current_line + 1] = false;
  min_score = min(min_score, recursive_score(K, city_line_scores, current_line + 2, selected_num, exist_lines));
  return min_score;
}

int main() {
  int N;
  cin >> N;
  vector<city> cities(N);
  for (int i = 0; i < N; i++) {
    int x, y, p;
    cin >> x;
    cin >> y;
    cin >> p;
    cities[i] = city{x, y, p};
  }

  vector<bool> exist_lines(N * 2 + 2);
  for (int j = 0; j < N; j++) {
    exist_lines[j * 2] = false;
    exist_lines[j * 2 + 1] = false;
  }
  exist_lines[N * 2] = true;
  exist_lines[N * 2 + 1] = true;

  vector<vector<linescore>> city_line_scores(N);
  for (int i = 0; i < N; i++) {
    int xi = cities[i].x;
    int yi = cities[i].y;
    int64_t pi = cities[i].p;

    vector<linescore> line_score(N * 2 + 2);

    for (int j = 0; j < N; j++) {
      int xj = cities[j].x;
      int yj = cities[j].y;

      line_score[j * 2] = linescore{j * 2, pi * abs(xi - xj)};
      line_score[j * 2 + 1] = linescore{j * 2 + 1, pi * abs(yi - yj)};
    }
    line_score[N * 2] = linescore{N * 2, pi * abs(xi)};
    line_score[N * 2 + 1] = linescore{N * 2 + 1, pi * abs(yi)};

    sort(line_score.begin(), line_score.end(), [](linescore a, linescore b) { return a.s < b.s; });
    city_line_scores[i] = line_score;
  }

  for (int K = 0; K < N; K++) {
    int64_t S = recursive_score(K, city_line_scores, 0, 0, exist_lines);
    cout << S << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>


int main(void)
{
	int i;
	char buffer[64];
	int a,b,c,d;

	scanf("%s",buffer);
	a=buffer[0]-'0';
	b=buffer[1]-'0';
	c=buffer[2]-'0';
	d=buffer[3]-'0';

	if (a+b+c+d==7)
	{
		printf("%d+%d+%d+%d=7\n",a,b,c,d);
	}
	else if (a+b+c-d==7)
	{
		printf("%d+%d+%d-%d=7\n",a,b,c,d);
	}
	else if (a+b-c+d==7)
	{
		printf("%d+%d-%d+%d=7\n",a,b,c,d);
	}
	else if (a+b-c-d==7)
	{
		printf("%d+%d-%d-%d=7\n",a,b,c,d);
	}
	else if (a-b+c+d==7)
	{
		printf("%d-%d+%d+%d=7\n",a,b,c,d);
	}
	else if (a-b+c-d==7)
	{
		printf("%d-%d+%d-%d=7\n",a,b,c,d);
	}
	else if (a-b-c+d==7)
	{
		printf("%d-%d-%d+%d=7\n",a,b,c,d);
	}
	else if (a-b-c-d==7)
	{
		printf("%d-%d-%d-%d=7\n",a,b,c,d);
	}
	else
	{
		printf("failed...\n");
	}


	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

int sosu(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) { return 0; }
	}
	return n;
}
int main() {
	int s[55] = {};
	int m = 0;
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= 55555; i++) {
		if (sosu(i) != 0&&i%5==1) {
			s[m] = i;
			if (m == 54) { break; }
			m++;
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d ", s[i]);
	}
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int begin=0, end=0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'A'){
      begin = i;
      break;
    }
  }
  
  for(int i= s.length() - 1; i >= 0; i--){
    if(s[i] == 'Z'){
      end = i;
      break;
    }
  }
  cout << end - begin + 1  << endl;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    vector<vector<ll>>arr(11, vector<ll>(26));
    vector<int>num(11, -1);
    vector<ll>inc(11); inc[0] = 0,inc[1] = 1;
    ll incl = 26;
    for (int i = 2; i < 11; i++) {
        inc[i] = inc[i - 1] + incl;
        incl *= 26LL;
    }
    ll k = 1;
    rep(i, 26)arr[10][i] = i + 1;
    for (ll i = 26; i < pow(10, 15); i *= 26) {
        for (ll j = 1; j <= 26; j++) {
            arr[10 - k][j - 1] = (i * j) + inc[k];
        }
        k++;
    }

    ll n;
    cin >> n;
    string res = "";
    int index = 0;
    rep(i, 11)num[i] = -1;
    while (n != 0) {
        for (int i = 25; i >= 0; i--) {
            if (arr[index][i] <= n) {
                n -= (arr[index][i] - inc[10 - index]);
                num[index] = i;
                break;
            }
        }
        if (index <= 10)index++;
        else break;
    }
    for (int s : num)if (s != -1)res += (s + 'a');
    cout << res << endl;

    return 0;

}


Measured memory_bytes: 3560
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *h = ALLOC (n, i32);
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, h + i);
  }
  i32 *dp = ALLOC (n, i32);
  dp[1] = ABS (h[1] - h[0]);
  for (i32 i = 2; i < n; ++i) {
    i32 x = dp[i - 2] + ABS (h[i] - h[i - 2]);
    i32 y = dp[i - 1] + ABS (h[i] - h[i - 1]);
    dp[i] = MIN (x, y);
  }
  printf ("%" PRIi32 "\n", dp[n - 1]);
}

int main (void) {
  run();
  return 0;
}

Measured memory_bytes: 896
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    tmp = list(map(int, input().split()))
    L.append(tmp[0])
    R.append(tmp[1])

ans = min(R) - max(L) + 1
if ans < 0: ans = 0
print(ans)

Measured memory_bytes: 81532
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string S;
  cin >> S;
  int n = S.size();
  int ans = 0;
  for (int s = 0; s < n; ++s) {
    for (int g = s; g < n; ++g) {
      bool ok = true;
      for (int i = s; i <= g; ++i) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
          continue;
        }
        ok = false;
      }
      if (ok) {
        ans = max(ans, g - s + 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,Q;
    cin>>N>>Q;
    string t;
    cin>>t;
    
    VECi(ll,w,N,0);
    REP(i,N-1){
        if(t[i]=='A'&&t[i+1]=='C')w[i+1]+=w[i]+1;else w[i+1]=w[i];
    }
    REP(i,Q){
        ll l,r;
        cin>>l>>r;
        cout<<w[r-1]-w[l-1]<<endl;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int M;
  cin >> M;
  cout << 48 - M <<endl;
  return 0;

}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

//ａをbで割る
long long mod_div(ll a,ll b){
	if(a % b == 0)return a/b;
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}
 
#define MAX_K 3333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}

int main(){
	ll a,b,c,x,y;
	
	while(cin >> a >> b >> c >> x >> y,a+b+c+x+y){
		
		ll ans = 0;
		ll seica = combination(a+b+c,c) * combination(a+b,b) % MOD;
		for(ll i = 0;i <= min(x,y);i++){
			ll X = x-i-a;
			ll Y = y-i-b;
			if(X < 0 || y < 0)continue;
			if(a == 0 && X > 0)continue;
			if(b == 0 && Y > 0)continue;
			ll tmp = seica;
			if(a+b+c+i-1 >= i)tmp = (tmp * combination(a+b+c+i-1,i)) % MOD;
			if(a+X-1 >= X)tmp = (tmp * combination(a+X-1,X)) % MOD;
			if(b+Y-1 >= Y)tmp = (tmp * combination(b+Y-1,Y)) % MOD;
			ans = (ans+tmp) % MOD;
		}
		
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 28708
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <bits/stdc++.h>
#include <set>
#include <vector>
#include <queue>
#include <bitset>
#define NL << endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define fill(x, y) memset(x, y, sizeof(y))
#define debug(x)                          \
    {                                     \
        cerr << #x << " = " << x << endl; \
    }
#define inarr(arr, n)                            \
    {                                       \
        for(int i =0;i<n;i++){              \
            cin >> arr[i];                  \
        }                                   \
    }
typedef long long ll;
const int MOD = 1e9 + 7;
using namespace std;

void solve()
{
    ll d,t, s;
    cin >> d >> t >> s;
    if(d <= t * s){
        cout << "Yes" << endl;
     }
     else{
         cout << "No" << endl;
     }
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t; t = 1; 
    // int t; cin >> t;
    for(int i =0;i<t;i++){
        // cout << "Case #" << i + 1 << ": ";
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 3644
#include <string.h>
#include <algorithm>
#include <queue>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
using namespace std;
typedef long long int ll;
int pos = 1;
void change()
{
    const string path = "C:\\Users\\www34\\Desktop\\data_oi\\temp";
    string p, o;
    if (pos < 10)
    {
        p = path + "\\" + (char)(pos + '0') + ".in";
        o = path + "\\" + (char)(pos + '0') + ".out";
    }
    else
    {
        p = path + "\\" + "10" + ".in";
        o = path + "\\" + "10" + ".out";
    }
    pos++;
    freopen(&p[0], "r", stdin);
    //   freopen(&o[0], "w", stdout);
}
ll x[200000 + 10];
int main()
{
    int t = 1;
    while (t--)
    {
        // change();
        ll h;
        cin >> h;
        ll base = 1;
        ll ans = 0;
        while (h != 1)
        {
            h /= 2;
            ans += base;
            base *= 2;
        }
        ans += base;
        cout << ans << endl;
    }
    return 0;
}
/*
3
3 2 1
1 2 3 
*/

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin>>n;
    out(((n-1)*n)/2);
}

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

using namespace std;

using LL = long long;

void solver() {
    int n, m; LL k;
    cin >> n >> m >> k; 

    vector< LL > prefA(n + 1), prefB (m + 1);

    for (int i = 0; i < n; ++i) {
        cin >> prefA[i + 1];
        prefA[i + 1] += prefA[i];
    }
    
    for (int i = 0; i < m; ++i) {
        cin >> prefB[i + 1];
        prefB[i + 1] += prefB[i];
    }


    /*
    cout << "prefA" << '\n';

    for(int i = 0; i <= n; ++i)
        cout << prefA[i] << ' ';
    cout << '\n';

    cout << "prefB" << '\n';

    for(int j = 0; j <= m; ++j) 
        cout << prefB[j] << ' ';
    cout << '\n';
    */
        


    int ans = 0;

    for(int i = 0; i <= n; ++i) {
        LL x = prefA[i];
        if (k - x < 0) break;

        auto it = upper_bound(prefB.begin(), prefB.end(), k - x);
        --it;

        int j = it - prefB.begin();
        ans = max(ans, i + j);
    }


    cout << ans << '\n';
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t;
    //cin >> t;
    t = 1;

    while(t--)
        solver();

    return 0;
}

Measured memory_bytes: 6304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#define int long long
using namespace std;

int n, p;
int a[100];
int comb[100][100];

signed main() {
	int i, j;
	
	cin >> n >> p;
	for (i = 0; i < n; i++) cin >> a[i];
	
	comb[0][0] = 1;
	for (i = 1; i <= n; i++) {
		for (j = 0; j <= i; j++) {
			if (j == 0) comb[i][j] = 1;
			else comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
	
	int zero = 0;
	for (i = 0; i < n; i++) if (a[i] % 2 == 0) zero++;
	
	int ans = 0;
	for (i = 0; i <= n - zero; i++) {
		if (i % 2 == p) {
			ans += comb[n - zero][i];
		}
	}
	ans *= (1LL << (zero));
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;
int main() {
	int a, b;
	cin>>a>>b;
	int ans=0;
	for(int i=0; i<2; ++i) {
		ans+=max(a, b);
		if(a>b)--a;
		else --b;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<sstream>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
struct P
{
  int x,y;
  P(int x=0,int y =0):x(x),y(y){}
};
string G[8];
int dx[] = {0,1,0,-1,1,1,-1,-1};
int dy[] = {1,0,-1,0,1,-1,1,-1};

int getValue(int x,int y,const bool phase)
{
  int cnt = 0;
  rep(i,8)
    {
      int nx = x;
      int ny = y;
      int dirCost = 0;
      while(true)
	{
	  nx += dx[i];
	  ny += dy[i];
	  if(!(0 <= nx && nx < 8 && 0 <= ny && ny < 8))
	    {
	      dirCost = 0; 
	      break;
	    }
	  if(!phase)
	    {
	      if(G[ny][nx] == 'o')break;
	      if(G[ny][nx] == '.')
		{
		  dirCost = 0;
		  break;
		}
	      if(G[ny][nx] == 'x')dirCost++;	      
	    }

	  if(phase)
	    {
	      if(G[ny][nx] == 'x')break;
	      if(G[ny][nx] == '.')
		{
		  dirCost = 0;
		  break;
		}
	      if(G[ny][nx] == 'o')dirCost++;	      
	    }
	}
      cnt += dirCost;
    }
  return cnt;
}

bool draw(P p,const bool phase,const int dir)
{
  if(!(0 <= p.x && p.x < 8 && 0 <= p.y && p.y < 8))return false;
  if(G[p.y][p.x] == '.')return false;
  if(phase && G[p.y][p.x] == 'x')return true;
  else if(!phase && G[p.y][p.x] == 'o')return true;
  bool res;
  if(res = draw(P(p.x+dx[dir],p.y+dy[dir]),phase,dir))G[p.y][p.x] = (phase?'x':'o');
  return res;
}

void print()
{
  rep(i,8)cout << G[i] << endl;
}

int main()
{
  bool phase = false;
  bool passM,passW;
  int maxCostM,maxCostW;
  rep(i,8)
    cin >> G[i];

  while(true)
    {
      passM = passW = false;
      maxCostM = maxCostW = 0;
      P M,W;
      phase = false;

      rep(i,8)
	{
	  rep(j,8)
	    {
	      if(G[i][j] != '.')continue;
	      int v = getValue(j,i,phase); 
	      if(v > maxCostM)
		{
		  M = P(j,i);
		  maxCostM = v;
		}
	    }
	}

      if(!maxCostM)passM = true;
      else 
	{
	  G[M.y][M.x] = 'o';
	  rep(k,8)draw(P(M.x+dx[k],M.y+dy[k]),phase,k);
	}

      //cout << "MaMi" << endl;
      //print();

      phase = !phase;	

      for(int i=7;i>=0;i--)
	{
	  for(int j=7;j>=0;j--)
	    {
	      if(G[i][j] != '.')continue;
	      int v = getValue(j,i,phase); 
	      if(v > maxCostW)
		{
		  W = P(j,i);
		  maxCostW = v;
		}
	    }
	}

      if(!maxCostW)passW = true;
      else 
	{
	  G[W.y][W.x] = 'x';
	  rep(k,8)draw(P(W.x+dx[k],W.y+dy[k]),phase,k);
	}

      if(passW & passM)break;
      //cout << "WitCh" << endl;
      //print();
    }

  print();

  return 0;
}

Measured memory_bytes: 1184
// 1_4_C
#include<stdio.h>

int main()
{
	int a, b;
	char op;

	while(1){
		scanf("%d %c %d", &a, &op, &b);
		if(op == '?'){
			break;
		}

		switch(op){
			case '+':
				printf("%d\n", a+b);
				break;
			case '-':
				printf("%d\n", a-b);
				break;
			case '*':
				printf("%d\n", a*b);
				break;
			case '/':
				printf("%d\n", a/b);
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
s = input()
t = input()
lens, lent = len(s), len(t)
minimum = float('inf')
for i in range(lens - lent + 1):
  diff = 0
  for j in range(lent):
    if s[i + j] != t[j]:
      diff += 1
  minimum = min(minimum, diff)
  if minimum == 0:
    break
print(minimum)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,P=0;
  cin >> N;
  vector<int> vec(N-1);
  for(int i=0;i<N-1;i++){
    cin >> vec.at(i);
  }
  vector<int> BT(N);
  for(int i=0;i<N-1;i++){
    BT.at(vec.at(i)-1)++;
  }
  for(int i=0;i<N;i++){
    cout << BT.at(i) <<endl;
  }
}

Measured memory_bytes: 4828
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n;
	cin >> n;
	if (n%10==9) {
		cout << "Yes" << endl;
		return 0;
	}
	n /= 10;
	if (n == 9) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    bool OK = 0;
    REP(i,9){
        REP(j,9){
            if(N == (i+1)*(j+1))OK = 1;
        }
    }
    if(OK){
        cout <<"Yes"<< "\n";
    }else{
        cout <<"No"<< "\n";
    }
}

Measured memory_bytes: 256
n = int(input())


diff = [0]*n

a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))


ans = -100000
for i in range(n):
    tmp = 0
    for j in range(n):
        if j < i:tmp+=a1[j]
        elif j == i: tmp += (a1[j] +a2[j])
        else:tmp+=a2[j]
    
    ans = max(ans,tmp)

print(ans)


Measured memory_bytes: 3060
s=str(input())
m=''
for i in range(len(s)):
    c=str(s[i])
    if(s[i].islower()):
        c=s[i].upper()
    elif(s[i].isupper()):
        c=s[i].lower()
    else:
         c=s[i]
    m+=c
print(m)
        


Measured memory_bytes: 5560