akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


vector<ll> b(51,0);
vector<ll> bp(51,0);
vector<ll> p(51,0);

ll dfs(ll x, int lv){
    ll ans = 0;
    if(x == 0){
        return 0;
    }
    if(x>=1){
        x--;
    }
    if(x < bp[lv]){
        ans += dfs(x, lv-1);
        return ans;
    }else{
        ans += p[lv];
        x -= bp[lv];
    }
    if(x>=1){
        x--;
        ans++;
    }
    if(x==0){return ans;}
    if(x < bp[lv]){
        ans += dfs(x, lv-1);
        return ans;
    }else{
        ans += p[lv];
        x -= bp[lv];
    }
    if(x>=1){
        x--;
    }
    return ans;
}


int main() {
    ll n, x;
    cin >> n >> x;


    bp[0] = 1;
    b[0] = 0;
    p[0] = 1;
    ll pnum = 1;
    for(int i = 1; i < 51; i++){
        bp[i] = 2*bp[i-1]+3;
        pnum *=2;
        p[i] = pnum + p[i-1];
        b[i] = bp[i] - p[i];
    }

    ll ans = dfs(x,n-1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>

#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(obj) (obj).begin(), (obj).end()
// #define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  string t;
  
  cin >> s;
  cin >> t;

  int res = 0;
  REP(i, 3) {
    if (s[i] == t[i]) {
      ++res;
    }
  }
  
  cout << res;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int min = a[k - 1] - a[0];
	int x;
	for (int i = 1;i <= n - k;i++) {
		x = a[i + k - 1] - a[i];
		if (x < min) {
			min = x;
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll x[n], sum = 0;

    rep(i, n){
        cin >> x[i];
    }
    rep(i, n - 1){
        sum += min(b, a * (x[i + 1] - x[i]));
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

/*
 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} */

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
  ll N;
  vector<ll> CNT(100005);
  cin >> N;

  ll sum = 0;
  for (ll i= 1; i<= N; i++){
    ll tmp;
    cin >> tmp;
    CNT.at(tmp) ++;
    sum += tmp;
  }

  ll Q;
  cin >> Q;

  //cout << sum << endl;


  for (ll i= 1; i<= Q; i++){
    ll b, c;
    cin >> b >> c;
    sum = sum - b * CNT.at(b) + c * CNT.at(b);
    CNT.at(c) = CNT.at(c) + CNT.at(b);
    CNT.at(b) = 0;
    cout << sum << endl;
  }

  return 0;
}


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

int ans[50001] = {};

int main() {
	int i, j, k, n, m, c;

	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> c;
		for (j = 0; j + c <= n; j++) {
			if(ans[j + c] == 0)ans[j + c] = ans[j] + 1;
			else ans[j + c] = min(ans[j + c], ans[j] + 1);
		}
	}

	cout << ans[n] << endl;





	return 0;
}

Measured memory_bytes: 3244
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
	int k,t;
	cin >> k >> t;
	int a[105] ={},b[10005]={};;

	for(int i =0; i < t;i++){
		cin >> a[i];
	}

	if(t != 1){

	int c = 0,nold = -1;
	
	while(c < k){
	//	for(int i =0; i < t;i++)cout << a[i];
	//	cout <<endl;

		int n = 0;
		for(int i =0; i < t;i++){
         if(a[i] != 0){
         	n = i;
         	break;
         }
		}
		if(c%2 == 0){
			for(int i =0; i < t;i++){
				if(a[i] != 0 && a[i] >= a[n] && (nold  != i))n = i;
			}
		}else{
		 	for(int i =0; i < t;i++){
				if(a[i] != 0 && a[i] <= a[n] && (nold  != i))n = i;
			}
		}
	//	cout << n<<endl;
		
		b[c] = n;
		a[n]--;
        nold = n;
		c++;
	}
//	for(int i =0; i < k;i++)cout << b[i] ;
//	cout <<endl;
	
	
	int cnt = 0;
	for(int i =1; i < k;i++)if(b[i-1] == b[i])cnt++;
     cout << cnt <<endl;
	
	}else cout << k-1 <<endl;
	
	return 0;
}

Measured memory_bytes: 256
def check(m,f,r):
    if m==-1 or f==-1: return 'F'
    elif m+f >= 80: return 'A'
    elif m+f >= 65 and  m+f < 80: return 'B'
    elif m+f >= 50 and  m+f < 65: return 'C'
    elif m+f >= 30 and  m+f < 50: 
        if r<50: return 'D'
        else: return 'C'
    elif m+f < 30: return 'F'

while True:
    m,f,r = map(int, input().split())
    if m==-1 and f==-1 and r==-1:
        break
    else:
        print(check(m,f,r))


Measured memory_bytes: 5596
#include<stdio.h>
int ary[10010];
int isPrime(int n){
	int i;
	if(ary[n]==2){
		return 0;
	}
	else if(ary[n]==1){
		return 1;
	}
	if(n % 2 == 0){
		ary[n]=2;
		return 0;
	}
	for(i = 3; i * i <= n; i += 2)
		if(n % i == 0){
			ary[n]=2;
			return 0;
		}
	ary[n]=1;
	return 1;
}

int main(){
	int n;
	int i,j;
	ary[0]=2;
	ary[1]=2;
	ary[2]=1;
	int c;
	for(;scanf("%d",&n)!=EOF;){
		c=0;
		for(i=1;i<=n;i++){
			if(isPrime(i)&&isPrime(n-i+1))c++;
		}
		printf("%d\n",c);

	}



	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

//Problem B War II
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), T = sc.nextInt(), H = sc.nextInt(), L = sc.nextInt();
		int[] t = new int[N], h = new int[N];
		for(int i=0;i<N;i++){
			t[i] = sc.nextInt(); h[i] = sc.nextInt();
		}
		int id = 0, res = -1, Z = 0;
		for(;;){
			if(t[id]==0 && h[id]==0){
				res = id; break;
			}
			if(0 < t[id]){
				Z+=10; t[id]--; T++;
			}
			else{
				Z+=100; h[id]--; H++;
			}
			if(L<T){
				res = id; break;
			}
			if(90 <= Z){
				int r = Z-90;
				Z = 0;
				int U = -1;
				for(int u=0;u<=H;u++){
					if(r<100*u){
						break;
					}
					if((r-100*u)/10 <= T){
						U = u;
						break;
					}
				}
				if(U==-1){
					res = id; break;
				}
				h[id] += U;
				t[id] += (r-U*100)/10;
				H-=U;
				T-=(r-U*100)/10;
			}
			id = (id+1)%N;
		}
		System.out.println(res+1);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
    
#define fastIO ios::sync_with_stdio(false);	cin.tie(NULL); cout.tie(NULL);
#define asc(s) sort(s.begin(),s.end())
#define des(s) sort(s.rbegin(),s.rend())
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define rev(v) reverse(v.begin(), v.end())
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define precision(x,p) fixed<<setprecision(p)<<x
#define mod 1000000007
#define PI 3.14159265358979
typedef long long ll;
    
vector<string> split(string s)
{
    istringstream buf(s);
    istream_iterator<string>beg(buf), end;    
    vector<string>list(beg, end);
    return list;
}
    
    
bool isvowel(char c)
{
    string s = "aeiou";
    if(find(s.begin(),s.end(), c) != s.end()) return true;
    return false; 
}

bool cmp(pair <int,int> &a, pair <int,int> &b)
{
    return a.second > b.second || (a.second==b.second && a.first>b.first);
}

void solve()
{
    int n,T;
    cin>>n>>T;

    int ans = INT_MAX;
    int c, t;

    for(int i=0;i<n;i++)
    {
        cin>>c>>t;

        if(t<=T && c<ans)
            ans = c;
    }

    if(ans==INT_MAX) cout<<"TLE";
    else cout<<ans;


    
}


int main()
{
    fastIO

    int t=1;
    // cin>>t;
    
    for(int test_case=1;test_case<=t;test_case++)
        solve();
    
        return 0;
}   

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

pair<bool,bool> occur[1024 * 1024];

int main(){
	int N,M;cin>>N>>M;
	for(int i=0;i<N;i++){
		int x;cin>>x;
		if(occur[x].first == true){
			cout<<0<<endl;
			return 0;
		}
		occur[x].first = true;
	}
	
	for(int i=0;i<M;i++){
		int x;cin>>x;
		if(occur[x].second == true){
			cout<<0<<endl;
			return 0;
		}
		occur[x].second = true;
	}
	
	long long fr = 0,fc = 0;
	long long ways = 1;
	for(int i=N*M,j=0;i>=1;i--,j++){
		if(occur[i].first && occur[i].second){
			fr += 1;
			fc += 1;
		}else if(occur[i].first){
			ways = (ways * fc) % MOD;
			fr += 1;
		}else if(occur[i].second){
			ways = (ways * fr) % MOD;
			fc += 1;
		}else {
			ways = (ways * (fr*fc - j)) % MOD;
		}
	}
	cout<<ways<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;
ll inf = 1000000007ll;

ll n,m,p;
vector<tuple<ll,ll,ll>> es;

int main(void)
{
  cin >> n >> m >> p;
  es.resize(m);
  REP(i,m) {
    ll a,b,c;
    cin >> a >> b >> c;
    es[i]=make_tuple(a,b,p-c);
  }
  queue<ll> q;
  vector<bool> reachable_from(n+1);
  vector<bool> reachable_to(n+1);
  q.push(n);
  while(!q.empty()) {
    ll pos = q.front();
    q.pop();
    if(reachable_from[pos]) continue;
    reachable_from[pos] = true;
    for(auto t:es) {
      ll a,b,c;
      tie(a,b,c) = t;
      if(b == pos) q.push(a);
    }
  }

  q.push(1);
  while(!q.empty()) {
    ll pos = q.front();
    q.pop();
    if(reachable_to[pos]) continue;
    reachable_to[pos] = true;
    for(auto t:es) {
      ll a,b,c;
      tie(a,b,c) = t;
      if(a == pos) q.push(b);
    }
  }

  vector<tuple<ll,ll,ll>> usable;
  for(auto t:es) {
    ll a,b,c;
    tie(a,b,c) = t;
    if(reachable_to[a] && reachable_from[b]) usable.push_back(t);
  }

  vector<ll> d(n+1,inf);
  d[1] = 0;
  bool flag = true;
  REP(i,16384) {
    if(!flag) break;
    flag = false;
    for(auto t:usable) {
      ll a,b,c;
      tie(a,b,c) = t;
      if(d[b] > d[a] + c) {
        d[b] = d[a] + c;
        flag = true;
      }
    }
  }

  if(flag) cout << -1 << endl;
  else cout << max(0ll,-d[n]) << endl;

  return 0;
}


Measured memory_bytes: 640
// ----- Author Info -------
// Khaled Alam - Ninjo
// khaledalam.net@gmail.com
//--------------------------

#include <bits/stdc++.h>
using namespace std;

#define fi         first
#define se         second
#define pb         push_back
#define mp         make_pair
#define ll         long long
#define sz         size()
#define all(a)     (a).begin(), (a).end()
#define rep(i,z)   for(int i=0;i<(z);i++)
#define ones       __builtin_popcount //__popcnt
#define iFile(a)   freopen(#a, "r", stdin)
#define oFile(a)   freopen(#a, "w", stdout)
#define ios        ios_base::sync_with_stdio(0)
#define tm         cerr<<"Time elapsed: "<<clock()<<" ms\n"

int main() {
	//iFile(input.txt);
	//oFile(output.txt);

	int n;
	cin >> n;
	int a[n * 2];
	for (int &it : a)cin >> it;

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

	int res = 0;
	rep(i,n)res += a[i*2];

	cout << res << '\n';
	return 0;
}


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

using namespace std;
using ll = long long;
const int INF = 1e9;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> cost(m), uni(m);
    for(int i = 0; i < m; i++) {
        int c;
        cin >> cost[i] >> c;
        for(int j = 0; j < c; j++) {
            int b; cin >> b; b--;
            uni[i] |= (1<<b);
        }
    }
    vector<vector<int>> dp(m + 1, vector<int>(1<<n, INF));
    dp[0][0] = 0;

    for(int i = 0; i < m; i++) {
        for(int bit = 0; bit < (1<<n); bit++) {
            dp[i + 1][bit | uni[i]] = min(dp[i][bit] + cost[i], dp[i + 1][bit | uni[i]]);
            dp[i + 1][bit] = min(dp[i][bit], dp[i + 1][bit]);
        }
    }
    cout << (dp[m][(1<<n) - 1] == INF ? -1 : dp[m][(1<<n) - 1]) << endl;
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int t[100005],lf[100005],rt[100005],ac[100005];
signed main()
{
	int peak,road;
	cin>>peak>>road;
	for (int i=0;i<peak;i++){
		cin>>t[i];
	}
	for (int i=0;i<road;i++){
		cin>>lf[i]>>rt[i];lf[i]--,rt[i]--;
		if (t[lf[i]]>=t[rt[i]])  ac[rt[i]]=1;
		if (t[rt[i]]>=t[lf[i]])  ac[lf[i]]=1;
	}
	int ans=0;
	for (int i=0;i<peak;i++){
		if (ac[i]==0)  ans++;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 6752
#include <iostream>
using namespace std;
#define NOFA 100000

int main() {
  int n; cin >> n;
  int c[NOFA] = {};
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    if (a > 0) c[a-1]++;
    c[a]++;
    if (a < NOFA - 1) c[a+1]++;
  }
  int ans = 0;
  for (int i = 0; i < NOFA; i++) ans = max(ans, c[i]);
  cout << ans << endl;
}

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        mut v: [usize; 2 * n]
    }
    v.sort();
    let mut ans = 0;
    for i in 0..n {
        ans += v[2 * i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int64_t n;
  cin >> n;
  vector<int64_t>a(n);
  rep(i,n)cin >> a.at(i);
  int64_t tcount =0;
  int64_t fcount =0;
  rep(i,n) if(a.at(i)%4==0)fcount++;
  rep(i,n) if(a.at(i)%4!=0 && a.at(i)%2==0)tcount++;
  if(n%2==0){//guusuunotoki
    if(fcount + tcount*0.5 >= n*0.5)cout <<"Yes"<<endl;
    else cout << "No" << endl;
  }
  else{
    if(fcount >= (n-1)*0.5)cout<<"Yes"<<endl;
    else{
      if(tcount >= n - 2 * fcount){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    }
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define db double
#define pb push_back
#define wrln cout<<'\n';
#define pii pair<int,int>

using namespace std;
const int H=1e9;
const int N=1e5+100;

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

    //freopen("test11.INP","r",stdin);
   // freopen("test.OUT","w",stdout);

    float d,t,s;
    cin>>d>>t>>s;
    d/=s;
    if (d<=t) cout<<"Yes"; else cout<<"No";


}


Measured memory_bytes: 3736
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
    int n;

    while (1){
        cin >> n;
        if(n==0){
            break;
        }
        
        int s[1000];
        double m=0,sig=0;

        for(int i=0;i<n;i++){
            cin >> s[i];
            m+=s[i];
        }
        m=m/n;

        for(int j=0;j<n;j++){
            sig+=pow(s[j]-m,2);
        }

        printf("%.6lf\n",sqrt(sig/n));
    }

    return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>//可変長配列
#include<algorithm>//sort,二分探索,など
#include<map>//map(辞書)

using namespace std;

int main(void){
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = scan.nextInt();
        long out = 0;
        for(int i = 1; i < n; i++){
            if(a[i - 1] > a[i]){
                out += a[i - 1] - a[i];
                a[i] += a[i - 1] - a[i];
            }
        }
        System.out.println(out);
        scan.close();
    }

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

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

template<typename T>
struct CumulativeSum {
    vector<T> s;
    CumulativeSum(const vector<T> &nums) {
        int n = nums.size();
        s.resize(n + 1, 0);
        for (int i = 0; i < n; ++i) {
            s[i + 1] = s[i] + nums[i];
        }
    }
    // [l, r), l and r is 0-indexed.
    T sum(int l, int r) {
        return s[r] - s[l];
    }
};

/*
    verified https://onlinejudge.u-aizu.ac.jp/problems/0516
*/
int main() {
    int n, k;
    vector< long long > ress;
    while (cin >> n >> k) {
        if (n == 0) break;
        vector<long long> nums(n);
        for (int i = 0; i < n; ++i) cin >> nums[i];
        CumulativeSum<long long> cs(nums);
        long long res = numeric_limits<long long>::min();
        for (int i = 0; i <= n - k; ++i) {
            long long val = cs.sum(i, i + k);
            res = max(res, val);
        }
        ress.push_back(res);
    }
    for (long long res : ress) cout << res << endl;
}



Measured memory_bytes: 4384
def readinput():
    a,b=map(int,input().split())
    return a,b

def main(a,b):
    if a>=13:
        return b
    elif a>=6:
        return b//2
    else:
        return 0

if __name__=='__main__':
    a,b=readinput()
    ans=main(a,b)
    print(ans)


Measured memory_bytes: 8984
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

//a, bの最大公約数．a > b
ull gcd(ull a, ull b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
//a, bの最小公倍数
ull lcm(ull a, ull b) {
    return a*(b/gcd(a, b));
}

void solve(){
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for(int i = 0; i < h; i++){
        if(row[i]){
            for(int j = 0; j < w; j++){
                if(col[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

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

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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	vector<pair<int64_t, int64_t>> v(n);
	for (int64_t i = 0; i < n; i++)
	{
		v[i] = {as[i], i};
	}
	sort(v.begin(), v.end());
	set<int64_t> st;
	st.insert(-1);
	st.insert(n);
	int64_t ans = 0;
	for (auto &p : v)
	{
		auto itr = st.lower_bound(p.second);
		int r = *itr, l = *(--itr);
		ans += p.first * (r - p.second) * (p.second - l);
		st.insert(p.second);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  
  int a[100];
  for(int i=0;i<n;i++) cin>>a[i];


  for(int i=0;i < n-1-i;i++) swap(a[i], a[n-1-i]);

  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  
  return 0;
}



Measured memory_bytes: 3104
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 2000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

ll multiply(ll a, ll b)
{
	return (a*b) % MOD;
}

ll my_pow(ll n, ll x)
{
	ll y = 1;

	while(x)
	{
		if(x&1)
		{
			y = (y * n) % MOD;
		}
		n = (n * n) % MOD;
		x >>=1;
	}
	return y % MOD;
}

ll inv_fact(ll x)
{
	return my_pow(x,MOD-2);
}

ll combinari(ll n, ll k)
{
	if(n < k)
		return 0;
	if(n == k)
		return 1;
	
	ll res = 1;
	for(int i = n; i>= n - k + 1; --i)
	{
		res = (res * i) % MOD;
	}
	ll res2 = 1;
	for(int i = 1; i<= k; ++i)
	{
		res2=(res2*i) % MOD;
	}
	res2 = inv_fact(res2);
	return (res * res2) % MOD;
}

int main()
{

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

	int n,a,b;
	cin >> n >> a >> b;

	ll res = my_pow(2,n) - combinari(n,a);
	if(res < 0)
	{
		res+= MOD;
		
	}
	res%=MOD;
	res = res - combinari(n,b);
	if(res < 0)
	{
		res+= MOD;
	}
	res%=MOD;

	cout << res-1;



    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int x, n;
	cin >> x >> n;
	vector<int> P(n, 0);
	for (int i=0; i<n; i++) cin >> P[i];
	sort(P.begin(), P.end());
	if (!binary_search(P.begin(), P.end(), x)){
		cout << x << endl;
		return 0;
	}
	int dif = 1;
	while(true) {
		if(!binary_search(P.begin(), P.end(), x - dif)) {
			cout << x - dif << endl;
			return 0;
		} else if (!binary_search(P.begin(), P.end(), x + dif)) {
			cout << x + dif << endl;
			return 0;
		}
		dif++;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int d[N];
  for (int i = 0; i < N; i++)
  {
    cin >> d[i];
  }
  sort(d,d+N);
  int M = N/2;
  cout << d[M]-d[M-1] ;
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>

typedef long long ll;

using namespace std;

const int MAX = 1e5 + 5, MODULO = 1e9 + 7;

vi v[MAX];

void solve() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<ll>> dp(n, vector<ll> (m, 0LL));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.') {
        if (i > 0)
          dp[i][j] += dp[i - 1][j];
        if (j > 0) 
          dp[i][j] += dp[i][j - 1];
        dp[i][j] %= MODULO;
      }
    }
  }
  cout << dp[n - 1][m - 1];
}

int main() {
  ios::sync_with_stdio(false);
  srand (time(NULL));
  int t = 1;
  // cin >> t;
  while (t--) solve();
  return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>=0 || b>=0){
		if(a<=0 && 0<=b){
			puts("Zero");
		}else{
			puts("Positive");
		}
	}else{
		if(abs(b-a+1)%2==0){
			puts("Positive");
		}else{
			puts("Negative");
		}
	}
	return 0;
}

Measured memory_bytes: 128
//Link : https://atcoder.jp/contests/agc034/tasks/agc034_c

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005
#define mod 1000000007
vector<int> adj[N];

int add(int x,int y) {
  int ret = (x+y);
  if(ret>=mod) {
    ret -= mod;
  } else if(ret<0) {
    ret += mod;
  }
  return ret;
}

int mul(int x,int y) {
  return (ll)x*y%mod;
}

int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    x = mul(x,x);
    c/=2;
  }
  return ret;
}

int invTwo;

struct node {
  int dp[3];
};

node merge(node &a,node &b) {
  node ret;
  ret.dp[0] = ret.dp[1] = ret.dp[2] = 0;
  for(int i=0;i<3;++i) {
    for(int j=0;j<3;++j) {
      int st = min(2,(i+j));
      ret.dp[st] = add(ret.dp[st], mul(a.dp[i],b.dp[j]));
    }
  }
  return ret;
}

deque<node> dp[N];

void dfs(int id) {
  int bigNode = -1,size = -1;
  for(int ch : adj[id]) {
    dfs(ch);


    if( size< (int)dp[ch].size()) {
      size =(int)dp[ch].size();
      bigNode = ch;
    }
  }
  int initialized = -1;
  if(bigNode!=-1) {
    swap(dp[id],dp[bigNode]);
  }
  for(int ch : adj[id]) {
    if(ch!=bigNode) {
      int pos = 0;
      for(deque<node>::iterator it = dp[ch].begin(),jt = dp[id].begin();
      it!= dp[ch].end();++it,++pos,++jt) {
        if(initialized<pos) {
          (*jt).dp[2] = 0;
          (*jt).dp[0] = add(1,-(*jt).dp[1]);
        }
        (*it).dp[2] = 0;
        (*it).dp[0] = add(1,-(*it).dp[1]);
        (*jt) = merge(*jt,*it);
      }
      initialized = max(initialized, (int)dp[ch].size()-1);
    }
  }
  node tmp;
  tmp.dp[0] = tmp.dp[1] = invTwo;
  tmp.dp[2] = 0;
  dp[id].push_front(tmp);
}

void solve() {
  int n;scanf("%d ", &n);
  for(int i=1;i<=n;++i) {
    int p;scanf("%d ",&p);
    adj[p].push_back(i);
  }
  invTwo = mypow(2,mod-2);
  dfs(0);
  int ret = 0;
  for(node tmp : dp[0]) {
    ret = add(ret, tmp.dp[1]);
  }
  for(int i=0;i<n+1;++i) {
    ret = mul(ret,2);
  }
  printf("%d\n", ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 236916
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Data.Maybe

m :: Int
m = 10^9+7

solve :: VUM.IOVector Bool -> VUM.IOVector Int -> Int -> IO Int
solve oks dp n = do  
  forM_ [0..n-1] $ \i ->
    forM_ [i+1..min n (i+2)] $ \j -> do
      judge <- VUM.read oks j
      when judge $ do
        now <- VUM.read dp i
        next <- VUM.read dp j
        VUM.write dp j ((now+next) `mod` m)
  VUM.read dp n

main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  (oks :: VUM.IOVector Bool) <- VUM.replicate (n+1) True
  forM_ [1..m] $ \_ -> do
    x <- BS.getLine
    let Just (i,_) = BS.readInt x
    VUM.write oks i False
  
  (dp :: VUM.IOVector Int) <- VUM.replicate (n+1) 0
  VUM.write dp 0 1
  solve oks dp n >>= print

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;

int n;
main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    int n4 = 0, n2 = 0, n0 = 0;
    for(int i = 0; i < n; ++i)
    {
        int temp; cin >> temp;
        if(temp % 4 == 0) {n4++; continue;}
        if(temp % 2 == 0) {n2++; continue;}
        n0++;
    }
    if(n2 > 0)
    {
        if(n4 >= n0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        if(n4 >= n0-1)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int N, M;
    cin >> N >> M;
    vector<P> A(M);
    rep(i, M) cin >> A.at(i).first >> A.at(i).second, A.at(i).first--;
    for (int i = 0; i < 1000;i++){
        string s = to_string(i);
        if(s.size()!=N)
            continue;
        bool l = true;
        rep(j,M){
            if(s.at(A.at(j).first)-'0'!=A.at(j).second)
                l = false;
        }
        if (l){
            cout << s << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

vector<vector<int>> g;

int grundy(int cur, int parent)
{
    int ret = 0;
    for (auto& n : g[cur]) {
        if (n == parent)
            continue;
        ret ^= grundy(n, cur) + 1;
    }
    return ret;
}

int main()
{
    cin.tie(0);

    int n;
    cin >> n;
    g.resize(n);

    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;

        g[x].push_back(y);
        g[y].push_back(x);
    }

    int g = grundy(0, -1);

    cout << (g == 0 ? "Bob" : "Alice") << endl;

    return 0;
}


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

vector<int> add(vector<int> a, vector<int> b){
    int shape = a.size();
    vector<int> out(shape);
    rep(i, shape) out[i] = a[i] + b[i];
    return out;
}

int get_min(vector<int> vec){
    int i = 10000000;
    for (auto v:vec) i = min(i, v);
    return i;
}

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cost(n);
    vector<vector<int>> algo;
    rep(i, n){
        cin >> cost[i];
        vector<int> a(m);
        rep(j, m) cin >> a[j]; algo.push_back(a);
    }
    bool ok = false;
    int final_cost = 10000000;
    for (int i = 0; i < (1<<n);i++){
        vector<int> books(m);
        int tmp_cost = 0;
        rep(j, n){
            if (i >> j & 1){
                books = add(books, algo[j]);
                tmp_cost += cost[j];
            }
        }
        if (get_min(books) >= x){
            ok = true;
            final_cost = min(tmp_cost, final_cost);
        }
    }
    if (ok) cout << final_cost << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));
  int ans=0;
  rep(i,n){
    int x=lower_bound(all(a),b[i])-a.begin();
    int y=upper_bound(all(c),b[i])-c.begin();
    y=n-y;
    ans+=x*y;
  }
  cout<<ans<<endl;
}


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

public class P
{
	public int ax { get; set; }
	public int ay { get; set; }
	public int bx { get; set; }
	public int by { get; set; }
	public int step { get; set; }
}

public class hello
{
	public static int w, h;
	public static bool[,] map;
	public static void Main()
	{
		while (true)
		{
			string[] line = Console.ReadLine().Trim().Split(' ');
			w = int.Parse(line[0]);
			h = int.Parse(line[1]);
			if (w == 0 && h == 0) break;
			line = Console.ReadLine().Trim().Split(' ');
			var ay = int.Parse(line[0]) - 1;
			var ax = int.Parse(line[1]) - 1;
			line = Console.ReadLine().Trim().Split(' ');
			var by = int.Parse(line[0]) - 1;
			var bx = int.Parse(line[1]) - 1;
			map = new bool[h, w];
			for (int i = 0; i < h; i++)
			{
				line = Console.ReadLine().Trim().Split(' ');
				for (int j = 0; j < w; j++)
					if (line[j] == "0") map[i, j] = true;
			}
			var ans = getAns(ax, ay, bx, by);
			if (ans == -1) Console.WriteLine("NA");
			else Console.WriteLine(ans);
		}
	}
	static int getAns(int asx, int asy, int bsx, int bsy)
	{
		var dx = new int[] { 0, 1, 0, -1 };
		var dy = new int[] { 1, 0, -1, 0 };
		var used = new bool[h, w, h, w];
		var q = new Queue<P>();
		q.Enqueue(new P { ax = asx, ay = asy, bx = bsx, by = bsy, step = 0 });
		used[asx, asy, bsx, bsy] = true;
		while (q.Count() > 0)
		{
			var t = q.Dequeue();
			if (t.step > 100) return -1;
			if (t.ax == t.bx && t.ay == t.by) return t.step;
			for (int i = 0; i < 4; i++)
			{
				var nax = t.ax + dx[i];
				var nay = t.ay + dy[i];
				var nbx = t.bx - dx[i];
				var nby = t.by - dy[i];
				if (!(nax >= 0 && nax < h && nay >= 0 && nay < w) ||!map[nax, nay]) { nax = t.ax; nay = t.ay; }
				if (!(nbx >= 0 && nbx < h && nby >= 0 && nby < w) || !map[nbx, nby]) { nbx = t.bx; nby = t.by; }
				if (!used[nax, nay, nbx, nby])
				{
					q.Enqueue(new P { ax = nax, ay = nay, bx = nbx, by = nby, step = t.step + 1 });
					used[nax, nay, nbx, nby] = true;
				}
			}
		}
		return -1;
	}
}


Measured memory_bytes: 37904
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut ans = 0;
    if n >= 1 {
        ans += n * (n - 1) / 2;
    }
    if m >= 1 {
        ans += m * (m - 1) / 2;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

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

  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0.0));
  dp.at(0).at(0) = 1.0;

  for (int i = 0; i < N; i++)
  {
    double p;
    cin >> p;
    for (int j = 0; j < N; j++)
    {
      dp.at(i + 1).at(j + 1) += dp.at(i).at(j) * p;
      dp.at(i + 1).at(j) += dp.at(i).at(j) * (1.0 - p);
    }
  }
  
  double ans = 0.0;
  for (int i = N / 2 + 1; i <= N; i++)
  {
    ans += dp.at(N).at(i);
  }
  cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABT = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
            var A= ABT[0];
            var B = ABT[1];
            var T = ABT[2];

            var C = Math.Floor((T + 0.5) / A);

            Console.WriteLine(C*B);
        }
    }
}


Measured memory_bytes: 11092
n,t=map(int,input().split())
t_list=list(map(int,input().split()))
s = 0
for i in range(1, n):
  if t_list[i]-t_list[i-1] >= t:
    s += t
  else:
    s += t_list[i]-t_list[i-1]
print(s+t)

Measured memory_bytes: 30888
'use strict';
// inputに入力データ全体が入る
function Main(input) {
  let count = 0;
  for(let i = 1 ; i <= input; i++){
    let num = i.toString();
    if(num.length%2 === 1){
      count ++;
    }
  }
  console.log(count);  	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
int main(){
int a,b,c;
cin>>a;
multiset<pair<int,int>>ajk;
for(int i=0;i<a;i++){
  cin>>b;
ajk.insert({b,i});

}
while(!ajk.empty()){
  pair<int,int>p=*ajk.begin();
  ajk.erase(ajk.begin());
  cout<<p.second+1<<" ";
}
}

Measured memory_bytes: 5504
N, K = map(int, input().split())
mod = 10 ** 9 + 7
d = [0] * (K + 1)
for i in range(1, K + 1):
    d[i] = pow(K // i, N, mod)
for i in range(K, 0, -1):
    for j in range(2 * i , K + 1, i):
        d[i] -= d[j]
        d[i] %= mod
ans = 0
for i in range(1, K + 1):
    ans += d[i] * i
    ans %= mod
print(ans)

Measured memory_bytes: 68872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n;
  cin >> n;
  pll l,r;
  ll temp;
  string s;
  map<string,ll> c;
  c["Vacant"]=0;
  c["Male"]=1;
  c["Female"]=-1;
  cout << 0 << endl;
  cin >> s;
  if(c[s]==0) {
    return 0;
  }
  l=pll(0,c[s]);
  cout << n-1 << endl;
  cin >> s;
  if(c[s]==0) {
    return 0;
  }
  r=pll(n-1, c[s]);
  temp=(n-1)/2;
  while(1) {
    cout << temp << endl;
    cin >> s;
    ll ans=c[s];
    if(ans==0) break;
    if((temp-l.first)%2) {
      if(ans!=l.second) {
        l=pll(temp,ans);
      }
      else {
        r=pll(temp,ans);
      }
    }
    else {
      if(ans==l.second){
        l=pll(temp,ans);
      }
      else {
        r=pll(temp,ans);
      }
    }
    temp=(l.first+r.first)/2;
  }
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> a(n);
    rep(i,n) {
        cin >> a[i].first.first >> a[i].first.second;
        a[i].first.second = a[i].first.second*-1;
        a[i].second = i;
    }
    sort(all(a));
    rep(i,n) cout << a[i].second+1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long T = long.Parse(Console.ReadLine());
		for(var i=0;i<T;i++){
			string[] str = Console.ReadLine().Split();
			long A = long.Parse(str[0]);
			long B = long.Parse(str[1]);
			long C = long.Parse(str[2]);
			long D = long.Parse(str[3]);
			string ans = "Yes";
			if(A < B || D < B){
				ans = "No";
			} else if(B <= C){
				ans = "Yes";
			} else if(B - Gcd(D,B) + A % Gcd(D,B) > C){
				ans = "No";
			}
			Console.WriteLine(ans);
		}
	}

	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

// Tがいくつであるかは関係ない
// 安いところで買って買った町以降の一番高いところで売る
// 後ろから差分の大きさが一番大きくなるように見ていく

int main(){
    int N,T;
    cin >> N >> T;
    vector<int> A(N);
    rep(i,N) cin >> A[i];    
    
    // とりあえず利益が最大になる時の利益を出す
    int max_n = A[N-1];
    vector<int> D(N);
    for(int i=N-1;i>=0;i--){
        max_n = max(max_n,A[i]);
        D[i] = max_n - A[i];
    }
    auto max_itr = max_element(D.begin(),D.end());
    int max_num = *max_itr;
    max_n = A[N-1];
    int min_cnt = 0;
    int max_cnt = 0;
    int ans = 0;
    for(int i=N-1;i>=0;i--){
        if(max_n<A[i]){
            if(min_cnt!=0){
                if(min_cnt>max_cnt){
                    ans+=max_cnt;
                }else{
                    ans+=min_cnt;
                }
            }
            max_n = A[i];
            max_cnt = 1;
            min_cnt = 0;
            continue;
        }
        if(A[i] == max_n - max_num){
            min_cnt++;
            continue;
        }
        if(A[i] == max_n){
            max_cnt++;
            continue;
        }
    }
    if(A[0]!=max_n){
        if(min_cnt!=0){
            if(min_cnt>max_cnt){
                ans+=max_cnt;
            }else{
                ans+=min_cnt;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define MAX 2000006

int n;

long long int k[MAX];
long long int rv[MAX];

#define MOD 1000000007
long long int ppow(long long int i, long long int j){
	long long int res = 1;
	while (j){
		if (j & 1LL){
			res *= i;
		}
		j >>= 1LL;
		i *= i;
		if (i >= MOD)i %= MOD;
		if (res >= MOD)res %= MOD;
	}
	return res;
}

void init(){
	k[0] = 1;
	for (int i = 1; i < MAX; i++){
		k[i] = k[i - 1];
		k[i] *= i;
		if (k[i] >= MOD)k[i] %= MOD;
	}
	rv[MAX - 1] = ppow(k[MAX - 1], MOD - 2);
	for (int i = MAX - 2; i >= 0; i--){
		rv[i] = rv[i + 1];
		rv[i] *= (i+1LL);
		if (rv[i] >= MOD)rv[i] %= MOD;
	}
}

long long int K(int a, int b){
	a += b;
	a--;
	if (a < b)return 0;
	long long int up = k[a];
	long long int dw = rv[b]*rv[a-b];
	if (dw >= MOD)dw %= MOD;
	up *= dw;
	if (up >= MOD)up%=MOD;
	return up;
}
long long int comb(int emp){
	if (emp == 0)return 1;
	int must = emp+1;
	int shape = n - emp - must;
	if (shape < 0)return 0;
	return K(emp + 1, shape);
}

int main(){
	cin >> n;
	init();
	long long int sum = 0;
	long long int ans = 0;
	n--;
	for (int i = 1; i <= n; i++){
		long long int until = comb(n - i);
		long long int tmp  = until*k[i];
		if (tmp >= MOD)tmp %= MOD;
		tmp *= k[n - i];
		if (tmp >= MOD)tmp %= MOD;
		long long int p = tmp;
		tmp -= sum;
		if (tmp < 0)tmp += MOD;
		sum = p;
		ans += tmp*(long long int)(i);
		if (ans >= MOD)ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 31488
#include <cstdio>
#include <algorithm>
using namespace std;
int n , m , x , y , v[105][105][2];
short f[105][105][105][105];
signed main() {
	scanf("%d %d" , &n , &m);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			char s = getchar();
			while(s != 'o' && s != '.' && s != 'E') s = getchar();
			if(s == 'E') x = i , y = j;
			else if(s == 'o') {
				v[i][j][0] = v[i - 1][j][0] + 1;
				v[i][j][1] = v[i][j - 1][1] + 1;
			}
			else {
				v[i][j][0] = v[i - 1][j][0];
				v[i][j][1] = v[i][j - 1][1];
			}
		}
	}
	int ans = 0;
	for (int l = 0; l <= y - 1; ++l) {
		for (int r = 0; r <= m - y; ++r) {
			for (int u = 0; u <= x - 1; ++u) {
				for (int d = 0; d <= n - x; ++d) {
					ans = max(ans , (int)f[l][r][u][d]);
					if(l + r < y - 1) f[l + 1][r][u][d] = max((int)f[l + 1][r][u][d] , (int)f[l][r][u][d] + v[min(x + d , n - u)][y - l - 1][0] - v[max(x - u - 1 , d)][y - l - 1][0]);
					if(l + r < m - y) f[l][r + 1][u][d] = max((int)f[l][r + 1][u][d] , (int)f[l][r][u][d] + v[min(x + d , n - u)][y + r + 1][0] - v[max(x - u - 1 , d)][y + r + 1][0]);
					if(u + d < x - 1) f[l][r][u + 1][d] = max((int)f[l][r][u + 1][d] , (int)f[l][r][u][d] + v[x - u - 1][min(y + r , m - l)][1] - v[x - u - 1][max(y - l - 1 , r)][1]);
					if(u + d < n - x) f[l][r][u][d + 1] = max((int)f[l][r][u][d + 1] , (int)f[l][r][u][d] + v[x + d + 1][min(y + r , m - l)][1] - v[x + d + 1][max(y - l - 1 , r)][1]);
				}
			}
		}
	}
	printf("%d" , ans);
	return 0;
}

Measured memory_bytes: 53436
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

template<class T>using vector3d=vector<vector2d<T>>;

/*!* [minmax_assign] *!*/
/*+* 最大値、最小値の代入 *+*/
template<class T>bool max_assign(T&x,const T y){if(x < y) { x = y; return true;} else return false;}
template<class T>bool min_assign(T&x,const T y){if(x > y) { x = y; return true;} else return false;}

int main() {
    const i64 INF = 1e18;
    int R, C, K;
    cin >> R >> C >> K;
    vector3d<i64> dp(4, vector2d<i64>(R, vector<i64>(C, -INF)));
    vector2d<i64> val(R, vector<i64>(C, 0));
    for(int k = 0; k < K; k++) {
        int y, x;
        i64 v;
        cin >> y >> x >> v;
        y--, x--;
        val[y][x] = v;
    }
    dp[0][0][0] = 0;
    for(int i = 0; i < R; i++) {
        for(int j = 0; j < C; j++) {
            for(int n = 3; n >= 0; n--) {
                if(j > 0) {
                    max_assign(dp[n][i][j], dp[n][i][j - 1]);
                }
                if(i > 0) {
                    max_assign(dp[0][i][j], dp[n][i - 1][j]);
                }
            }
            for(int n = 3; n > 0; n--) {
                max_assign(dp[n][i][j], dp[n - 1][i][j] + val[i][j]);
            }
        }
    }
    i64 ans = 0;
    for(int n = 0; n <= 3; n++) {
        max_assign(ans, dp[n][R - 1][C - 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 355344
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	string a,b;
	cin>>a>>b;
	int maxv=1000000000;
	for(int i=0;i<=a.size()-b.size();i++){
		int sum=0;
		for(int j=i;j<i+b.size();j++){
			if(a[j]!=b[j-i]){
				sum++;
			}
		}
		maxv=min(maxv,sum);
	}
	cout<<maxv;
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){
    char c;
    scanf("%c", &c);
    switch(c){
        case 'a':
            printf("vowel");
            break;

        case 'e':
            printf("vowel");
            break;

        case 'i':
            printf("vowel");
            break;

        case 'o':
            printf("vowel");
            break;

        case 'u':
            printf("vowel");
            break;

        default:
            printf("consonant");
            break;
    }

}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll l = (a-1)/x+1;
    //cout << l << endl;
    if(a==0){
        l=0;
    }
    //cout << l << endl;
    ll r = b/x+1;
    cout << r-l << endl;
    return 0;
}

Measured memory_bytes: 256