akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
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/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll 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(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  COMinit();
  ll n;
  cin>>n;
  map<char,ll> mp;
  ll ans=0;
  ll cnt=0;
  rep(i,n){
    string s;
    cin>>s;
    if(s[0]!='M'&&s[0]!='A'&&s[0]!='R'&&s[0]!='C'&&s[0]!='H') continue;
    mp[s[0]]++;
    cnt++;
  }
  if(mp.size()<3){
    cout<<0<<endl;
    return 0;
  }
  ans=cnt*(cnt-1)*(cnt-2)/6;
  for(auto x:mp){
    if(x.second==2){
      ans-=cnt-2;
    }
    if(x.second>=3){
      ans-=(cnt-x.second)*(x.second)*(x.second-1)/2;
      ans-=x.second*(x.second-1)*(x.second-2)/6;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 27008
#include<stdio.h>
#define N 10000
int A[2000001],C[N],B[2000001];
int main()
{
  int i,n;
 
  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N;i++){
    C[i]=0;
  }
  for(i=1;i<n+1;i++){
    C[A[i]]+=1;
  }
  for(i=0;i<N;i++){
    C[i]+=C[i-1];
  }
  for(i=n+1;i>0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]-=1;
  }

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 16268
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		final String S = sc.next();

		sc.close();

		String ans = null;
		switch (S) {
		case "Sunny":
			ans = "Cloudy";
			break;
		case "Cloudy":
			ans = "Rainy";
			break;
		case "Rainy":
			ans = "Sunny";
			break;

		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>
#include<ctype.h>
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	a[0] = toupper(a[0]);
	b[0] = toupper(b[0]);
	c[0] = toupper(c[0]);
	cout << a[0] << b[0] << c[0];
}

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

struct pos {
    int x, y;
};
vector<pos> DXY = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int route[40][40];

void maze(int W, int H) {
    int Y[W][H], T[W][H];
    string S;
    rep(k, 2*H-1) {
        int hk = k / 2;
        if (k%2==0) {
            rep(wk, W - 1) cin >> Y[wk][hk];
        } else {
            rep(wk, W) cin >> T[wk][hk];
        }
    }

    rep(x, W) rep(y, H) route[x][y] = 0;

    queue<pos> que;
    que.push({0, 0});
    route[0][0] = 1;

    while (!que.empty()) {
        pos now = que.front();
        que.pop();

        for (auto dxy: DXY) {
            int nx = now.x + dxy.x, ny = now.y + dxy.y;
            if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
            if (route[nx][ny] == 0) {
                bool ok = true;
                if (abs(dxy.x) == 1) {
                    if (Y[min(nx, now.x)][now.y] == 1) ok = false;
                } else if (abs(dxy.y) == 1){
                    if (T[now.x][min(ny, now.y)] == 1) ok = false;
                }

                if (ok) {
                    route[nx][ny] = route[now.x][now.y] + 1;
                    que.push({nx, ny});
                }
            }
        }
    }

    cout << route[W-1][H-1] << endl;
}

int main() {
    int w, h;
    while (cin >> w >> h, w || h) {
        maze(w, h);
    }

    return 0;
}


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

int main(){
  ll h, n, i, sum=0;
  cin>>h>>n;
  ll arr[n];
  for(i=0; i<n; i++){
    cin>>arr[i];
    sum += arr[i];
  }
  if(sum>=h)
    cout<<"Yes\n";
  else
    cout<<"No\n";

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  long ans = 1;
  for (auto a : A) {
    if (__builtin_mul_overflow(ans, a, &ans)) return cout << -1 << "\n", 0;
  }
  cout << ((ans > (long) 1e18) ? -1 : ans) << "\n";
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    char preC='.';
    rep(i,0,T.size()){
        char c=T.at(i);
        if(c=='?'){
            T.at(i)='D';
        }

        preC=c;
    }

    cout<<T<<endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> cumulative(vector<vector<int>>& count, int K){
    vector<vector<int>> res(K*2+1, vector<int>(K*2+1));
    vector<int> line(K*2+1);
    for(int y = 0; y < K*2; ++y){
        line[0] = 0;
        for(int x = 0; x < K*2; ++x){
            line[x+1] = line[x] + count[y][x];
        }
        res[y+1][0] = 0;
        for(int x = 0; x < K*2; ++x){
            res[y+1][x+1] = res[y][x+1] + line[x+1];
        }
    }
    /*
    cerr << "---" << endl;
    for(int y = 0; y < K*2+1; ++y){
        for(int x = 0; x < K*2+1; ++x){
            cerr << res[y][x] << " ";
        }
        cerr << endl;
    }
    cerr << "---" << endl;
    */
    return res;
}

int part(vector<vector<int>>& cum, int y1, int x1, int y2, int x2){
    return cum[y2][x2] - cum[y2][x1] - cum[y1][x2] + cum[y1][x1];
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<vector<int>> wc(K*2, vector<int>(K*2));
    vector<vector<int>> bc(K*2, vector<int>(K*2));
    for(int i = 0; i < N; ++i){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c =='W'){
            wc[y%(K*2)][x%(K*2)] += 1;
        }else{
            bc[y%(K*2)][x%(K*2)] += 1;
        }
    }
    vector<vector<int>> wcc = cumulative(wc, K);
    vector<vector<int>> bcc = cumulative(bc, K);
    int best = 0;
    for(int dy = 0; dy <= K; ++dy){
        for(int dx = 0; dx <= K; ++dx){
            int cnt = 0;
            cnt += part(bcc, 0, 0, dy, dx);
            cnt += part(wcc, dy, 0, dy+K, dx);
            cnt += part(bcc, dy+K, 0, K*2, dx);
            cnt += part(wcc, 0, dx, dy, dx+K);
            cnt += part(bcc, dy, dx, dy+K, dx+K);
            cnt += part(wcc, dy+K, dx, K*2, dx+K);
            cnt += part(bcc, 0, dx+K, dy, K*2);
            cnt += part(wcc, dy, dx+K, dy+K, K*2);
            cnt += part(bcc, dy+K, dx+K, K*2, K*2);
            best = max(best, cnt);
            int cnt2 = 0;
            cnt2 += part(wcc, 0, 0, dy, dx);
            cnt2 += part(bcc, dy, 0, dy+K, dx);
            cnt2 += part(wcc, dy+K, 0, K*2, dx);
            cnt2 += part(bcc, 0, dx, dy, dx+K);
            cnt2 += part(wcc, dy, dx, dy+K, dx+K);
            cnt2 += part(bcc, dy+K, dx, K*2, dx+K);
            cnt2 += part(wcc, 0, dx+K, dy, K*2);
            cnt2 += part(bcc, dy, dx+K, dy+K, K*2);
            cnt2 += part(wcc, dy+K, dx+K, K*2, K*2);
            best = max(best, cnt2);
        }
    }
    cout << best << endl;
    return 0;
}

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

int main(){
    int n;cin>>n;
    int h[n+1],d[n+1];
    h[0]=0;d[0]=0;
    for(int i=1;i<=n;i++){
        cin>>h[i];d[i]=0;
    }
    d[n]=h[n];
    for(int i=n;i>=1;i--){
        if(h[i-1]<=d[i])d[i-1]=h[i-1];
        else if(h[i-1]==d[i]+1) d[i-1]=d[i];
        else if(h[i-1]>d[i]+1){
            cout << "No"<<endl;
            return 0;
        }
    }
    cout <<"Yes"<<endl;
}

Measured memory_bytes: 4392
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    pt, xt = list(map(int, input().split()))
    p.append(pt)
    x.append(xt)

for j in range(m):
    print(sum(t)-t[p[j]-1]+x[j])


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	char a[1001];
	cin>>a;
	bool e=0,w=0,n=0,s=0;
	for(int i=0;i<1000;i++){
		if(a[i]==0)break;
		if(a[i]=='N')n=1;
		if(a[i]=='W')w=1;
		if(a[i]=='E')e=1;
		if(a[i]=='S')s=1;
	}
	if(n&&s&&e&&w)cout<<"Yes"<<endl;
	else if(n&&s&&!e&&!w)cout<<"Yes"<<endl;
	else if(!n&&!s&&e&&w)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    cout << fixed << setprecision(10);
    ll n;cin>>n;
    double ans=0;
    vector<double> vec(n);
    For(i,n){
        double s;cin>>s;
        vec.at(i)=1/s;
    }
    sort(vec.begin(),vec.end());
    For(i,n){
        ans+=vec.at(i);
    }
    ans=1/ans;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    public class ABC096D
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int primaryNum = 0;
            HashSet<int> primary = new HashSet<int>();
            for (int index = 2; index <= 55555; index++)
            {
                if (IsPrimary(index, primary) && index % 5 == 1)
                {
                    primary.Add(index);
                    primaryNum++;
                    if (primaryNum == N)
                    {
                        break;
                    }
                }
            }
            Console.WriteLine(string.Join(" ", primary.ToArray<int>()));
        }

        private static bool IsPrimary(int num, HashSet<int> primary)
        {
            foreach (int p in primary)
            {
                if (num % p == 0)
                {
                    return false;
                }
            }

            for (int index = 2; index < num; index++)
            {
                if (num % index == 0)
                {
                    return false;
                }
            }

            return true;
        }
    }
}


Measured memory_bytes: 13404
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long[] w = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[] sum = new long[n + 1];
        for (int i = 1; i <= n; i++)
            sum[i] = sum[i - 1] + w[i - 1];
        long total = w.Sum();
        long ans = long.MaxValue;
        foreach (var ws in sum)
            ans = Min(ans, Abs(ws - (total - ws)));
        Console.WriteLine(ans);
    }
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>>a(n,vector<int>(m));
  vector<int>b(m);
  for(int i = 0;i < n;i++){
    for(int j = 0;j < m;j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0;i < m;i++){
    cin >> b[i];
  }
  for(int i = 0;i < n;i++){
    long ans = 0;
    for(int j = 0;j < m;j++){
      ans += a[i][j]*b[j];
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;

map<string,int> num;
map<string,int> pt;
char table[6][6];

char word[10];

int used[6][6];

int dx[]={-1,0,1,0,-1,-1,1,1};
int dy[]={0,1,0,-1,-1,1,-1,1};

int dfs(int x,int y,int p){
	if( p >= 8 || used[x][y] || table[x][y] == 0 ) return 0;
	used[x][y]=1;
	word[p]=table[y][x];
	word[p+1]=0;
	if( pt.count(string(word)) ){
		num[string(word)]++;
	}
	for(int i = 0 ; i < 8 ; i++)
		dfs(x+dx[i],y+dy[i],p+1);
	used[x][y]=0;
}
int dp[10010];
int main(){
	int N;
	cin >> N;
	while(N--){
		string name;
		int p;
		cin >> name >> p;
		pt[name]=p;
	}
	for(int i = 0 ; i < 4 ; i++)
		cin >> (table[i+1]+1);
	for(int i = 1 ; i <= 4 ; i++){
		for(int j = 1 ; j <= 4 ; j++){
			//cout << table[i][j];
			dfs(i,j,0);
		}
	}
	vector< pair<int,int> > item; // wei cost
	for( map<string,int>::iterator it = num.begin(); it != num.end(); ++it){
		string name = it->first;
		int cnt = it->second;
		int c = 1;
		while(cnt-c>=0){
			item.push_back(make_pair(c*name.size(),c*pt[name]));
			cnt-=c;
			c*=2;
		}
		if(cnt){
			item.push_back(make_pair(cnt*name.size(),cnt*pt[name]));
		}
	}
	int T;
	cin >> T;
	for(int i = 0 ; i < item.size() ; i++){
		for(int j = T ; j >= item[i].first ; j--){
			dp[j]=max(dp[j-item[i].first]+item[i].second,dp[j]);
		}
	}
	cout << *max_element(dp,dp+10010) << endl;
	
	
}

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

long long egcd(long long a, long long b) {
  if(a < b) return egcd(b, a);
  long long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


bool IsPrime(long long num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0) return false;
    }
    return true;
}
vector< long long > divisor(long long n) {
  vector< long long > ret;
  for(long long i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
long long counter(long long n,vector< long long > ret){
    long long ans=0;
    for(int i=0;i<ret.size();i++){
        if(IsPrime(ret[i])) ans++;
    }
    return ans;
}

void solve(long long N, long long M){
    long long G=egcd(N,M);
    long long ans=counter(G,divisor(G));
    ans++;
    printf("%lld\n",ans);
}



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


Measured memory_bytes: 384
s = input()
data = dict()
for c in s:
    if c not in data:
        data[c] = 1
    else:
        data[c] = data[c] + 1
ans = True
for d in data:
    if data[d] != 2:
        ans = False
print('Yes' if ans and len(data) == 2 else 'No')

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


int main(void){
  int n, flg;
  list<int> b,ans;
  
  cin >> n;
  for(int i=0; i<n; i++){
    int t; cin >> t;
    b.push_front(t);
  }
  while (!b.empty()){
    flg=0;
    int i=n;
    for (auto itr=b.begin(); itr!=b.end(); itr++, i--){
//      cout << "(" << *itr << "," << i << ")";
      if (*itr==i){
//        cout << endl;
        ans.push_front(i);
        itr = b.erase(itr);
        n--;
        flg=1;
        break;
      }
    }
    if (!flg) break;
  }
  if (flg) {
    for (auto itr=ans.begin(); itr!=ans.end(); itr++) cout << *itr << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int  long long
using namespace std;
int n,m,ans,cnt;
pair<int,int>a[100010];
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(register int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i].first,&a[i].second);
	sort(a+1,a+n+1);
	for(register int i=1;i<=n;i++)
		if(cnt+a[i].second<m)
		{
			ans+=a[i].first*a[i].second;
			cnt+=a[i].second;
		}
		else
		{
			ans+=a[i].first*(m-cnt);
			break;
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{

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

    int[][] a = new int[3][3];

    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        a[i][j] = Integer.parseInt(sc.next());
      }
    }

    int n = Integer.parseInt(sc.next());

    for(int k=0; k<n; k++){
      int t = Integer.parseInt(sc.next());

      for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
          if(a[i][j] == t)
          a[i][j] = 0;
        }
      }
    }

    for(int i=0; i<3; i++){
      if((a[i][0] + a[i][1] + a[i][2] == 0)|| (a[0][i] + a[1][i] + a[2][i] == 0)){
        System.out.println("Yes");
        break;
      }
      if(i==0 &&((a[0][0] + a[1][1] + a[2][2]  == 0) || (a[0][2] + a[1][1] +a[2][0] ==0 ))){
        System.out.println("Yes");
        break;
      }
      if (i==2)
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22100
N = int(input())
C = input()

l, r = 0, N - 1
ans = 0
while l < r:
    if C[l] == 'R':
        l += 1
    elif C[r] == 'W':
        r -= 1
    else:
        ans += 1
        l += 1
        r -= 1
print(ans)

Measured memory_bytes: 9448
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
using namespace std;
  
#define int long long int 
typedef vector<int> vi;
typedef vector<pair<int, int>> vpi;
typedef vector<vi> vvi;
const int mod = 1e9 + 7; 

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define debug(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define TC int t; cin >> t; while (t--) 

int ans(int in[], int n, int dp[]) {
	if(n <= 0) return INT_MAX;
	if(n == 1) return dp[n] = 0;
	if(dp[n] != -1) return dp[n];
	int i = ans(in + 1, n - 1, dp) + abs(in[0] - in[1]); 
	int j = ans(in + 2, n - 2, dp) + abs(in[0] - in[2]);
	dp[n] = min(i, j);
	return dp[n]; 
}

void Panda() {
    int n;
    cin >> n;
    int in[n], dp[n + 1];
    for(int i = 0 ; i < n; i++) cin >> in[i], dp[i] = -1;
    dp[n] = -1;
    cout << ans(in, n, dp)<< endl;
}
  
int32_t main() {
 
    FAST;

    
    Panda();

    return 0; 
} 

Measured memory_bytes: 9816
#include <bits/stdc++.h>
#define PII pair<int,int>
#define ll long long
#define maxn 1000010
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, a;
	cin >> h >> a;
	int cnt = 0;
	while (h > 0)
	{
		h -= a;
		cnt++;
	}
	cout << cnt;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
long long n,m,a[100005],sum,ans,k,t,w;
int main()
{
	cin>>n>>k;
	t=(n-k);
	w=(n-1)/k;
	n-=(w*k);
	
	if (n==k)
	{
		cout<<0<<endl;
		return 0;
	}
	cout<<min(n,k-n)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[8005],dp[8005][16005],k;
void DP(int x){
	dp[x][a[x]+8000]=1;
	for(int i=x+2;i<=k;i+=2)
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
}
int main(){
	string s;
	int x,y,n,w=0,ans;
	cin>>s>>x>>y;
	n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='F')
			w++;
		else{
			a[++k]=w;
			w=0;
		}
	}
	a[++k]=w;
	DP(1);
	DP(0);
	if(k%2==0)
		ans=dp[k][y+8000]&&dp[k-1][x+8000];
	else
		ans=dp[k][x+8000]&&dp[k-1][y+8000];
	if(ans==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 497916
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    loop {
        let n = get();
        let m: usize = get();
        if n == 0 && m == 0 { break; }
        let r = get();
        let mut hist = vec![Vec::new(); n];
        for _ in 0 .. r {
            let t: usize = get();
            let n: usize = get::<usize>() - 1;
            let m: usize = get::<usize>() - 1;
            get_word();
            hist[n].push((m, t));
        }
        const T: usize = 1500;
        let mut imos = vec![vec![0i32; T]; m];
        for hist in &hist {
            for j in 0 .. hist.len() / 2 {
                let m = hist[2 * j].0;
                imos[m][hist[2 * j].1] += 1;
                imos[m][hist[2 * j + 1].1] -= 1;
            }
        }
        for i in 0 .. m {
            for j in 0 .. T - 1 {
                imos[i][j + 1] += imos[i][j];
            }
            for j in 0 .. T {
                imos[i][j] = min(imos[i][j], 1);
            }
            for j in 0 .. T - 1 {
                imos[i][j + 1] += imos[i][j];
            }
        }
        let q = get();
        for _ in 0 .. q {
            let ts: usize = get();
            let te: usize = get();
            let m: usize = get();
            println!("{}", imos[m - 1][te - 1] - imos[m - 1][ts - 1]);
        }
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 68388
#include <stdio.h>

int main(){
    int a,b,c,x,i,j,k,r=0;

    scanf("%d %d %d %d",&a,&b,&c,&x);

    for(i=0;i<=x/500;i++)
        for(j=0;j<=(x-500*i)/100;j++){
            k=x-500*i-100*j;

            r+=k%50 == 0 && c>=k/50 && a >= i && b>=j;
        }

        printf("%d\n",r);
        return 0;

    }


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
struct Activities
{
  int a,b,c;
};
int maxHappiness(vector<Activities> arr,int n)
{
  int dp[n+1][3];
  
  dp[1][0]=arr[1].a;
  dp[1][1]=arr[1].b;
  dp[1][2]=arr[1].c;
  
  for(int i=2;i<=n;i++)
  {
   dp[i][0]=arr[i].a+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=arr[i].b+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=arr[i].c+max(dp[i-1][0],dp[i-1][1]);
  }
  
  return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
  
  
  

int main()
{
  int n,k;
  cin>>n;
  vector<Activities> arr(n+1);
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i].a;
    cin>>arr[i].b;
    cin>>arr[i].c;
  }
  
  int tot_happiness=maxHappiness(arr,n);
  cout<<tot_happiness;
  
  return 0;
}
  

Measured memory_bytes: 6620
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!



void solve(){
    
    ll n,m;
    cin>>n>>m;
    
    vector<pll> arr;
    for(ll i=0;i<n;i++){
        ll p,c;
        cin>>p>>c;
        arr.push_back({p,c});
    }
    sort(all(arr));
    ll cans=m;
    ll ans=0;
    for(ll i=0;i<n;i++){
        ll p=arr[i].Fi;
        ll c=arr[i].Se;
        if(cans>c){
            cans-=c;
            ans+=c*p;
        }
        else{
            ans+=cans*p;
            cans=0;
            break;
        }
    }
    cout<<ans<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    int n;
    while(cin>>n,n){
        vector<vector<int>> dp(n,vector<int>(n,1));
        string s;
        rep(i,n){
            cin>>s;
            rep(j,n){
                if(s[j]=='*'){
                    dp[i][j]=0;
                }
            }
        }
        int mx=0;
        rep(i,n){
            rep(j,n){
                if(i==0||j==0||dp[i][j]==0) continue;
                dp[i][j]=min({dp[i-1][j-1],dp[i][j-1],dp[i-1][j]})+1;
                mx=max(dp[i][j],mx);
            }
        }
        cout<<mx<<endl;
    }
}



Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	int n,m;
	cin>>n>>m;
	vb vis(n*m);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a--;b--;c--;d--;
	vvb v(n,vb(m));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char k;
			cin>>k;
			if(k=='.')v[i][j]=1;
		}
	}
//	for(int i=0;i<n;i++){
//		for(int j=0;j<m;j++){
//			cout<<v[i][j];
//		}
//		cout<<endl;
//	}
	deque<pii>q;
	q.emplace_front(a*m+b,0);
	while(!q.empty()){
		int u=q.front().fi;
		int dist=q.front().se;
//		cerr<<u<<' '<<dist<<endl;
		q.pop_front();
		if(u==c*m+d){
			cout<<dist;
			return;
		}
		if(vis[u])continue;
		vis[u]=1;
		if(u/m+1<n&&v[u/m+1][u%m]){
			if(!vis[u+m])q.emplace_front(u+m,dist);
		}
		if(u/m-1>=0&&v[u/m-1][u%m])if(!vis[u-m])q.emplace_front(u-m,dist);
		if(u%m+1<m&&v[u/m][u%m+1])if(!vis[u+1])q.emplace_front(u+1,dist);
		if(u%m-1>=0&&v[u/m][u%m-1])if(!vis[u-1])q.emplace_front(u-1,dist);
		for(int i=-2;i<3;i++){
			for(int j=-2;j<3;j++){
				if(u/m+i<0||u/m+i>=n)continue;
				if(u%m+j<0||u%m+j>=m)continue;
				if(i==0&&abs(j)<=1)continue;
				if(j==0&&abs(i)<=1)continue;
				if(v[u/m+i][u%m+j]){
					if(!vis[u+i*m+j])q.emplace_back(u+i*m+j,dist+1);
				}
			}
		}
	}
	cout<<-1;
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 4284
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

    vector<vector<int>> A(N);
    for (int i=1; i<N; i++)
    {
        int a;
        cin>>a;
        a--;
        A[a].push_back(i);
    }

    function<int(int)> f = [&](int p)
    {
        vector<int> D;
        for (int a: A[p])
            D.push_back(f(a));
        sort(D.begin(), D.end());
        reverse(D.begin(), D.end());
        int r = 0;
        for (int i=0; i<(int)D.size(); i++)
            r = max(r, D[i]+i+1);
        return r;
    };
    cout<<f(0)<<endl;
}


Measured memory_bytes: 13568
N = int(input())
map_a = map(int, input().split())
list_a = list(map_a)

d = [0]*8
tourist = 0

for i in range(N):
  if(1<= list_a[i]< 400):
    d[0]+= 1
  elif(400<= list_a[i]< 800):
    d[1]+= 1
  elif(800<= list_a[i]< 1200):
    d[2]+= 1
  elif(1200<= list_a[i]< 1600):
    d[3]+= 1
  elif(1600<= list_a[i]< 2000):
    d[4]+= 1
  elif(2000<= list_a[i]< 2400):
    d[5]+= 1
  elif(2400<= list_a[i]< 2800):
    d[6]+= 1
  elif(2800<= list_a[i]< 3200):
    d[7]+= 1
  else:
    tourist+= 1
    
color = 8- d.count(0)
min_color = max(color, 1)
max_color = color+ tourist

print(min_color, max_color)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)

vector<LL> h;
int N = 0, A = 0, B = 0;

bool enough(LL T)
{
	LL count = 0;
	rep (i, N)
	{
		if (h[i] - B * T > 0)
		{
			count +=(h[i] - B * T) / (A - B);
			if ((h[i] - B * T) % (A - B) != 0)
				count++;
		}
	}
	if (count <= T)
	{
		return true;
	}
	return false;
}

LL search(LL m, LL M)
{
	if (M <= m)
	{
		return m;
	}
	LL n = (m + M) / 2;
	bool e = enough(n);
	
	if (e)
	{
		return search(m, n);
	}
	else
	{
		return search(n + 1, M);
	}

	return -1;
}

int solve()
{
	scanf("%d %d %d", &N, &A, &B);

	h.resize(N);
	rep(i, N)
	{
		scanf("%d", &h[i]);
	}

	LL max = *std::max_element(h.begin(), h.end());
	printf("%d", search(0, max));
	return 0;
}

int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 1024
toFloat :: Int -> Float
toFloat = fromRational . toRational

main = do
    [w,h,x,y] <- map read . words <$> getLine :: IO [Int]
    if w == x*2 && h == y*2
        then putStrLn $ show ((toFloat (w*h)) /2) ++ " " ++ "1"
        else putStrLn $ show ((toFloat (w*h)) /2) ++ " " ++ "0"



Measured memory_bytes: 4076
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int,int> pii;
typedef std::pair<int,double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;



void solve(){
    int x;
    cin >> x;
    if (x < 30) cout << "No";
    else cout << "Yes";
}


int main(){
    int T;
    //cin >> T;
    T = 1;
    while(T--){
        solve();
        cout << endl;
    }
}











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

int main(){
    int N,X;
    cin >> N >> X;
    int L[N];
    for(int n=0; n<N; n++){
        cin >> L[n];
    }
    int temp = 0;
    int res = 1;
    for(int n=0; n<N; n++){
        temp += L[n];
        if(temp <= X){
            res++;
        }
        else{
            break;
        }
    }
    cout << res << endl;
}


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

#define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N;
  // int M;
  // array<int, 1000000> A;;
  // string S;
  // string T;

  int A, B;

  cin >> A >> B;

  if (A % 2 == 1 && B % 2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

int main(void) {
	// your code goes here
	char s[110];
	scanf("%s", s);
	int l=strlen(s);
	int arr[26]={0};
	int i;
	for(i=0; i<l; ++i){
		++arr[s[i]-97];
	}
	for(i=0; i<26; ++i){
		if(arr[i]%2!=0){
			break;
		}
	}
	if(i==26) printf("Yes");
	else printf("No");
}


Measured memory_bytes: 128
a,b,c=list(map(int,input().split()))
k=int(input())
while a>=b and k>0:
    k-=1
    b*=2
while b>=c and k>0:
    k-=1
    c*=2
if c>b and b>a:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61704
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, n, s;
	while (cin >> n) {
		s = 0;
		for (a = 0; a < 10; a++) {
			for (b = 0; b < 10; b++) {
				for (c = 0; c < 10; c++) {
					for (d = 0; d < 10; d++) {
						if (a + b + c + d == n) {
							s += 1;
						}
					}
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n;
  cin>>n;
  vin a(n+2);
  a[0]=0;
  a[n+1]=0;
  rep(i,1,n+1) cin>>a[i];
  ll sum=0;
 
  
  rep(i,1,n+2){
   sum+=abs(a[i]-a[i-1]); 
  }
  
  rep(i,1,n+1){
    ll c=sum;
    
    if(a[i]>a[i+1]&&a[i]>a[i-1] || a[i]<a[i+1]&&a[i]<a[i-1]) c-=2*min(abs(a[i]-a[i-1]),abs(a[i]-a[i+1]));
   cout<<c<<endl; 
  }
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

int main()
{
    fastio;
    lli a,b;
    cin>>a>>b;
    if(a<b)swap(a,b);
    if(a==b)cout<<0<<endl;
    else if((a-b)%2)cout<<"IMPOSSIBLE"<<endl;
    else cout<<(a-b)/2+b<<endl;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,m,dis,idx;
  cin >> n >> m;
  vector<ll> a(n),b(n),c(m),d(m);
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    cin >> c[i] >> d[i];
  }
  for(int i=0;i<n;i++){
    dis = 10000000000000000;
    idx = 0;
    for(int j=0;j<m;j++){
      ll tmp = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(tmp<dis){
        idx = j;
        dis = tmp;
      }
    }
    cout << idx+1<<endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = []
mod = int(1e9 +7)

def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for _ in range(n-2):
            a, b = b, a + b
        return b

def main():
    is_no_ans = False
    for i in range(M):
        a_i = int(input())
        a.append(a_i)
        if i != 0 and a[i-1]+1 == a_i:
            is_no_ans = True
    if is_no_ans:
        print(0)
        return

    ans = 1
    left = 0
    a.append(N+1)
    for x in a:
        ans = ans* Fib(x - left) %mod
        left = x + 1
    print(ans)
main()

Measured memory_bytes: 49240
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;



int main() {
	char tar[11];
	scanf("%s", tar);
	int n;
	scanf("%d", &n);
	int cou = 0;
	REP(i, n) {
		char ring[11];
		scanf("%s", &ring);
		bool f = 0;
		string str = ring;
		str += str;
		if (str.find(tar) != -1)
			cou++;
	}
	printf("%d\n", cou);
	
	return 0;
}

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

int a, b, c;

void solve() {
    cin >> a >> b >> c;
    cout << (c - a + b > 0 ? c - a + b : 0) << "\n";
}

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

Measured memory_bytes: 3664
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    result = 'APPROVED'
    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                pass
            else:
                result = 'DENIED'
                break
    print(result)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;

long gauss(long n){
    if(n==1) return 1;
    else{
        if(n%2==1) n--;
        return 1+gauss(n/2);
    }
}
 
int main(){
    long h;
    cin >> h;
    long a=gauss(h);
    long ans=0;
   
        for(long i=1;i<=a;i++) ans+=pow(2,i-1);
   
    cout << ans << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string input2 = Console.ReadLine();

            int ans = input.Length;

            for (int length = 0; length <= input.Length - input2.Length;length ++)
            {
                int diff = 0;
                for(int pos= 0;pos<input2.Length;pos++)
                {
                    if (input2[pos]!=input[pos+length])
                    {
                        diff++;
                    }
                }
                ans = ans > diff ? diff : ans; 
            }

            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 25968
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h> 
#include<stdio.h>
using namespace std;
const int N=1e5+10;
vector <int> E[N];
int color[N],cnt[3];
int main()
{
    queue <int> que;
    int n,x,y;
    cin>>n;
    for(int i=1;i<n;i++)
	{ 
        cin>>x>>y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    color[1]=1;
	color[n]=2;
    que.push(1); 
    que.push(n);
    while(!que.empty())
	{
        int tmp=que.front();
        que.pop();
        cnt[color[tmp]]++;
        for(int i=0;i<E[tmp].size();i++)
		{
            int v=E[tmp][i];
            if(color[v]) continue;
            color[v]=color[tmp];
            que.push(v);
        }
    }
    if(cnt[2]>=cnt[1]) cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
    return 0;
}

Measured memory_bytes: 6272
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(N: Long){
    println("ABC$N")
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    solve(N)
}



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

#define int long long

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int x; cin >> x;
	for(int b = -200; b <= 200; b++) {
		int want = x + b*b*b*b*b;
		int have = pow(want, 0.2);
		if(have*have*have*have*have == x + b*b*b*b*b) {
			cout << have << ' ' << b << '\n';
			return 0;
		}
	}
				
	return 0;
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, a, b;
    cin >> n >> a >> b;
    if(a > b || (n == 1 && (a != b)))
    {
        cout << "0\n";
        return 0;
    }
    long long l = (n - 1) * a + b;
    long long r = (n - 1) * b + a;
    cout << r - l + 1 << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
ll dp[10][20];//dp[i][j]代表以i开头的j位数有多少个lunlun 
ll sum[20], pos;
ll k;
void dfs(ll num, ll lst) {
	if (num > pos) return;
	if (num == 1) {
		for (ll i = 1; i < 10; i++) {
			if (k > dp[i][pos - num + 1]) {
				k -= dp[i][pos - num + 1];
			} else {
				putchar(i + '0');
				dfs(num + 1, i);
				break;
			}
		}
	} else {
		for (ll i = lst - 1; i <= lst + 1; i++) {
			if (i < 0 || i > 9) continue;//记住特判 
			if (k > dp[i][pos - num + 1]) {
				k -= dp[i][pos - num + 1];
			} else {
				putchar(i + '0');
				dfs(num + 1, i);
				break;
			}
		}
	}
}
int main() {
	cin >> k;
	for (ll i = 0; i < 10; i++) {
		dp[i][1] = 1;
	}
	sum[1] = 9;
	for (ll j = 2; j <= 10; j++) {
		for (ll i = 0; i < 10; i++) {
			if (i != 0 && i != 9) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1];
			else if (i != 0) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
			else if (i != 9) dp[i][j] = dp[i][j - 1] + dp[i + 1][j - 1];
			if (i != 0) sum[j] += dp[i][j];
		}
	}
	for (ll i = 1; i <= 20; i++) {
		if (k > sum[i]) {
			k -= sum[i];
		} else {
			pos = i;
			break;
		}
	}
	dfs(1, 0);
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,k;
    cin>>a>>b>>k;
    set<int> s;
    for(int i=0;i<k;i++) if(a+i<=b) s.insert(a+i);
    for(int i=1;i<=k;i++) if(a<=b-k+i&&b-k+1<=b) s.insert(b-k+i);
    for(auto x:s) cout<<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
int MAX_V = 200100;
vector <vector<pair <int,int>>> g(MAX_V,vector <pair <int,int>>());
pair <int,int> treedfs(int now, vector <bool> &v, int cost=0 ){
    
    if(v[now]) return {-1, -1};
    else v[now] = true;
    pair <int,int> ret = {cost, now};
    for(int i=0;i<g[now].size();i++){
        ret = max(ret, treedfs( g[now][i].F,v,cost + g[now][i].S));
    }
    return ret;
}
int Tree_diameter(){
    vector <bool>  v(MAX_V) ;
    pair <int,int> step1 = treedfs(0,v,0);
    vector <bool>  v2(MAX_V) ;
    pair <int,int> step2 = treedfs(step1.S,v2,0);
   return step2.F;
}
signed main(void){
    int n; cin>>n;
    rep(i,n-1){
        int a,b; cin>>a>>b; a--; b--;
        g[a].push_back({b,1});
        g[b].push_back({a,1});
    }
    int x = Tree_diameter();
    if(x%3 == 1) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
}


Measured memory_bytes: 29952
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)

const int MAX = 2000;
const int MOD = 1001;


struct UnionFind {
    //number of parents(par[i] = i => root)
    vector <int> par;
    //rank of tree
    vector <int> rank;

    UnionFind(int n) : par(n), rank(n, 1) {
        //initialize
        rep(n, i) par[i] = i;
    }

    //find root (keiroasshuku at the same time)
    int root(int x){
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //unite
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) swap(x, y);
        par[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
    }

    //same tree?
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

int f[MAX];

void solve(void){
	int V, d;

	f[0] = 1, f[1] = 2;
	rep(MOD, i) f[i+2] = (f[i] + f[i+1]) % MOD;

	while (cin >> V >> d) {
		UnionFind uf(V);
		rep(V, i) {
			Rep(i+1, V-1, j) {
				if (abs(f[i+1]-f[j+1]) < d) uf.unite(i, j);
			}
		}
		set <int> s;
		rep(V, i) s.insert(uf.root(i));
		cout << s.size() << endl;
	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3120
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int g;
    while (scanf("%d", &g) != EOF) {
        int f = 0;
        rep (i, 10) if (g&(1<<i)) {
            if (f) printf(" ");
            f = 1;
            printf("%d", 1<<i);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 0
W, H, N = map(int, input().split())
xl, xr = 0, W
yd, yu = 0, H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        xl = max(xl, x)
    if a == 2:
        xr = min(xr, x)
    if a == 3:
        yd = max(yd, y)
    if a == 4:
        yu = min(yu, y)
if xl >= xr or yd >= yu:
    print(0)
else:
    print((xr - xl) * (yu - yd))

Measured memory_bytes: 3064