akhauriyash/Code-Regression huggingface dataset:
N = int(input())
s = [0] * N
t = [0] * N
for i in range(N):
    a, b = map(str, input().split())
    s[i] = a
    t[i] = int(b)

X = str(input())

flag = False
Sum = 0

for i in range(N):

    if flag:
        Sum += t[i]
    elif s[i] == X:
        flag = True

print(Sum)

Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 200000
using namespace std;
typedef long long LL;
char str[MAXN+5];
int n,seq[MAXN+5];
int main()
{
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=n;i>=1;i--)
		if(str[i]=='C'&&str[i-1]=='B')
			seq[++seq[0]]=1,i--;
		else if(str[i]=='A')
			seq[++seq[0]]=2;
		else
			seq[++seq[0]]=0;
	int precnt=0;
	LL ans=0;
	for(int i=1;i<=seq[0];i++)
	{
		if(seq[i]==2)
			ans+=1LL*precnt;
		else if(seq[i]==1)
			precnt++;
		else
			precnt=0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum;


int main()
{
	fast;
	// cin>>n;
	fs(ar,5);
	cin>>n;
	sort(ar+1,ar+6);
	if(ar[5]-ar[1]<=n)
		cout<<"Yay!";
	else
		cout<<":(";

}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

void solve() {
    double PI = 3.14159265359;
    double r;
    cin >> r;
    cout << 2 * r * PI << endl;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    while(t--)
        solve();
    return 0;
}


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

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

    int bw = 0, wb = 0;
    for (int i = 0, n = s.size(); i < n; i++)
        if ((s.at(i) - '0') == (i % 2 == 0))
            bw++;
        else
            wb++;

    cout << min(bw, wb) << endl;
}

Measured memory_bytes: 3704
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

use std::collections::HashSet;

fn main() {
    scan!(x, n; i32);
    let n = n as usize;
    let forbiddens = if n > 0 {
        scan!(fb; Vec<i32>);
        fb
    } else {
        vec![]
    };
    let forbiddens = forbiddens
        .into_iter()
        .collect::<HashSet<_>>();

    let res;
    let mut d = 0;
    loop {
        let a = x - d;
        if !forbiddens.contains(&a) {
            res = a;
            break;
        }
        let b = x + d;
        if !forbiddens.contains(&b) {
            res = b;
            break;
        }
        d += 1;
    }

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


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool f = true;
    int l = s.size();
    for(int i = 0; i < l; i++){
        if(s.at(i) != s.at(l - i - 1))
            f = false;
    }
    int n = (l - 1) / 2;
    for(int i = 0; i < n; i++){
        if(s.at(i) != s.at(n - i - 1))
            f = false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=131075;
int ch[N][2],w[N];
struct Node{
	ll x,y;
};
vector <Node> v[N];
ll lim;
void insert(vector <Node>&ans,Node x){
	if (ans.empty()||x.y<ans.back().y) ans.push_back(x);
}
vector <Node> merge(vector <Node> v1,vector <Node> v2){
	vector <Node> ans;ans.clear();
	int pos=-1;
	for (int i=0;i<v1.size();i++){
		while (pos+1<v2.size()&&v1[i].y+v2[pos+1].x<=lim) ++pos;
		if (pos>=0&&(ans.empty()||v2[pos].y<ans.back().y))
			ans.push_back((Node){v1[i].x,v2[pos].y});
	}
	return ans;
}
vector <Node> mergesort(vector <Node> v1,vector <Node> v2){
	int i=0,j=0;vector <Node> ans;ans.clear();
	while (i<v1.size()&&j<v2.size())
		if (v1[i].x<v2[j].x||(v1[i].x==v2[j].x&&v1[i].y<v2[j].y)) insert(ans,v1[i]),i++;
		else insert(ans,v2[j]),j++;
	while (i<v1.size()) insert(ans,v1[i]),i++;
	while (j<v2.size()) insert(ans,v2[j]),j++;
	return ans;
}
void dfs(int x){
	v[x].clear();
	if (!ch[x][0]){
		if (w[x]<=lim)
			v[x].push_back((Node){w[x],w[x]});
		return;
	}
	dfs(ch[x][0]),dfs(ch[x][1]);
	v[x]=mergesort(merge(v[ch[x][0]],v[ch[x][1]]),merge(v[ch[x][1]],v[ch[x][0]]));
	for (int i=0;i<v[x].size();i++) v[x][i].x+=w[x],v[x][i].y+=w[x];
}
bool check(ll l){
	lim=l;dfs(1);
	return v[1].size()>0;
}
int main (){
//	freopen ("a.in","r",stdin);
	int n;scanf ("%d",&n);
	for (int i=2;i<=n;i++){
		int f;scanf ("%d%d",&f,&w[i]);
		if (ch[f][0]) ch[f][1]=i;else ch[f][0]=i;
	}
	ll l=0,r=0,ans=0;
	for (int i=1;i<=n;i++) r+=w[i];
	while (l<=r){
		ll mid=(l+r)>>1;
		if (check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf ("%lld",ans);
	return 0;
}

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

int gcd(int x,int y);

int main(){
	int n,m;
	int x,y;
	cin >> n >> m;
	if(n < m){
		x = m;
		y = n;
	}else{
		x = n;
		y = m;
	}
	cout << gcd(x,y) << endl;
}

int gcd(int x,int y){
	if(y != 0){
		return gcd(y,x%y);
		}else{
		return x;
	}
}

Measured memory_bytes: 3080
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        for(int i = 0; i < k; i++){
            if(i % 2 == 0){
                if(a % 2 == 0) a /= 2;
                else a = (a-1)/2;
                b += a;
            }
            else{
                if(b % 2 == 0) b/=2;
                else b = (b-1) / 2;
                a += b;
            }
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	pair<ll, ll> p[n];
	ll x[n], y[n];
	for(int i=0; i<n; i++){
		ll a, b;
		cin >> a >> b;
		p[i]=make_pair(a, b);
		x[i]=a;
		y[i]=b;
	}
	sort(x, x+n);
	sort(y, y+n);

	ll ans=LLONG_MAX;
	for(int i=0; i+1<n; i++){
		for(int j=i+1; j<n; j++){
			for(int l=0; l+1<n; l++){
				for(int m=l+1; m<n; m++){
					int cnt=0;
					for(int q=0; q<n; q++){
						if(x[i]<=p[q].first && p[q].first<=x[j]	&& y[l]<=p[q].second && p[q].second<=y[m]){
							cnt++;
						}
					}
					if(cnt>=k){
						ans=min(ans, (x[j]-x[i])*(y[m]-y[l]));
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    int cnt = 0;
    rep(i, h) rep(j, w) {
        char tmp_c;
        cin >> tmp_c;
        if ( tmp_c == '#' ) {
            ++cnt;
        }
    }
    if ( cnt == h + w -1 ) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cassert>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD 1000000007
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  long long n,m;cin>>n>>m;
  long long a[n];
  long long lc = 1;
  int fisk;
  for(int i = 0; n > i; i++){
    cin>>a[i];
    int k = 0;
    if(a[i]%2){
      cout << 0 << endl;
      return 0;
    }
    int tmp = a[i];
    a[i]/=2;
    while(!(tmp%2)){
      tmp/=2;
      k++;
    }
    if(!i)fisk = k;
    if(fisk != k){
      cout << 0 << endl;
      return 0;
    }
    lc = lcm(lc,a[i]);
    if(lc > m){
      cout << 0 << endl;
      return 0;
    }
  }

  cout << ((m/lc)+1)/2;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        ll n, k;
        cin >> n >> k;
        ll a[n + 2];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        // cerr << x << endl;
        ll ans = 0;
        for (ll i = (ll) 1 << 45; i != 0; i >>=  1) {
            // cerr << x << endl;
            if (ans + i > k) continue;
            ll cnt = 0;
            for (int j = 0; j < n; j++) {
                if (a[j] & i) cnt++;
            }
            if (cnt <= n / 2) ans ^= i;
        }
        ll res = 0;
        for (int i = 0; i < n; i++) res += (a[i] ^ ans);
        cout << res << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

bool isOK(ll x, ll K, vector<ll> &A, vector<ll> &F) {
  ll s = 0;
  for (int i = 0; i < A.size(); i++) {
    s += max(0ll, A[i] - x / F[i]);
  }
  return (s <= K);
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N), F(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> F[i];
  }
  sort(A.begin(), A.end());
  sort(F.rbegin(), F.rend());
  ll l = -1, r = 1e12;
  while (l + 1 < r) {
    ll center = (l + r) / 2;
    if (isOK(center, K, A, F)) {
      r = center;
    } else {
      l = center;
    }
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cstdlib>


using namespace std;

int main(){
        int64_t x, k, d, x2, k2;
        int64_t ans = 0;

        cin >> x >> k >> d;

        if(abs(x)/k >= d){
                ans = abs(x) - d*k;
        }else{
                x2 = abs(x)%d;
                k2 = k - abs(x)/d;

                if(k2%2 == 0){
                        ans = x2;
                }else{
                        ans = d-x2;
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	int a1=0,a2=0,a4=0;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		if( x % 2 == 1 ){
			a1 ++;
		}
		else if ( x % 4 == 0 ){
			a4++;
		}
		else{
			a2++;
		}
	}
	if( a4 >= a1 ){
		cout<<"Yes"<<endl;
		return 0;
	}
	else if( a2 == 0 && a4+1 >= a1 ){
		cout<<"Yes"<<endl;
		return 0;
	}
	else{
		cout<<"No"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main 
{
    public static void main(String[] args) 
    {
        Scanner stdIn = new Scanner(System.in);
        while(stdIn.hasNext())
        {
            int n = stdIn.nextInt();
            if(n == 0)
            {
                break;
            }
            List<Integer> list = new ArrayList<Integer>();
            for(int i = 0; i < n; ++i)
            {
                int a = stdIn.nextInt();
                list.add(a);
            }
            Collections.sort(list);
            int sum = 0;
            for(int i = 1; i < list.size() - 1; ++i)
            {
                sum += list.get(i);
            }
            System.out.println(sum / (list.size() - 2));
        }
    }
}


Measured memory_bytes: 29456
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
		int H = in.nextInt();
		int W = in.nextInt();
		if(H==0&&W==0){
			break;
		}
		for(int i = 0; i<H ; i++){
			for(int j = 0; j<W ; j++){
				if(i%2==1&&j%2==0||i%2==0&&j%2==1){
					System.out.print(".");
				}else{
					System.out.print("#");
							}
						}
					System.out.println();
					}
					System.out.println();
				}
			}
		}

Measured memory_bytes: 34748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  rep(i, 3) cout << s.at(i);
  cout << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1000100];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%1d",&a[i]);
    if(n==1)
    {
        printf("%d\n",a[1]);
        return 0;
    }
    n--;
    for(int i=1;i<=n;++i)a[i]=abs(a[i]-a[i+1]);
    int eo=0;
    int fl=0;
    for(int i=1;i<=n;++i)
    {
        eo^=(a[i]&1)*(((n-1)&(i-1))==(i-1));
        if(a[i]==1)fl=1;
    }
    if(eo)
    {
        puts("1");
        return 0;
    }
    if(fl)
    {
        puts("0");
        return 0;
    }
    for(int i=1;i<=n;++i)a[i]/=2;
    eo=0;
    for(int i=1;i<=n;++i)
        eo^=(a[i]&1)*(((n-1)&(i-1))==(i-1));
    puts(eo?"2":"0");
    return 0;
}


Measured memory_bytes: 4096
a,b,c = map(int,(input().split()))
cnt = 0

while a%2==0 and b%2==0 and c%2==0:
    if a == b == c :
        cnt = -1
        break
    ta,tb,tc = a,b,c
    a = tb/2 + tc/2
    b = ta/2 + tc/2
    c = ta/2 + tb/2
    cnt += 1

print(cnt)


Measured memory_bytes: 9144
#include <cstdio>
#include <vector>
using namespace std;

int H, W;
char a[110][110];
int n;
int si, sj, ti, tj;
int nd[110][110];
vector<vector<int> > G(20010);
vector<vector<int> > G2(20010);
int res;
int vis[20010];
int last[20010];

int dfs(int u)
{
	int i;
	if(u == n+nd[ti][tj])
		return 1;
	for(i=0; i<G[u].size(); i++){
		int v = G[u][i];
		if(vis[v]==0 && G2[u][i] > 0){
			vis[v] = 1;
			last[v] = u;
			if(dfs(v) )
				return 1;
		}
	}
	return 0;
}

int find_path()
{
	int i;
	for(i=0; i<2*n; i++)
		vis[i] = 0;
	vis[nd[si][sj]] = 1;
	if( dfs(nd[si][sj]) )
		return 1;
	else
		return 0;
}

void solve()
{
	int i, j, k;
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			if(a[i][j] == 'S'){
				si = i, sj = j;
			}
			if(a[i][j] == 'T'){
				ti = i, tj = j;
			}
		}
	}
	if(si==ti || sj==tj){
		printf("-1\n");
		return ;
	}
	n = 0;
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			if(a[i][j] != '.'){
				nd[i][j] = n;
				n ++;
			}
		}
	}
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			if(a[i][j] != '.'){
				for(k=0; k<W; k++){
					if(k==j)
						continue;
					if(a[i][k] != '.'){
						G[nd[i][j]].push_back(n+nd[i][k]);
						G2[nd[i][j]].push_back(1);
						G[n+nd[i][k]].push_back(nd[i][j]);
						G2[n+nd[i][k]].push_back(0);
						//break;
					}
				}
				/*for(k=j-1; k>=0; k--){
					if(a[i][k] != '.'){
						G[nd[i][j]].push_back(n+nd[i][k]);
						G2[nd[i][j]].push_back(1);
						G[n+nd[i][k]].push_back(nd[i][j]);
						G2[n+nd[i][k]].push_back(0);
						break;
					}
				}*/
				for(k=0; k<H; k++){
					if(k==i)
						continue;
					if(a[k][j] != '.'){
						G[nd[i][j]].push_back(n+nd[k][j]);
						G2[nd[i][j]].push_back(1);
						G[n+nd[k][j]].push_back(nd[i][j]);
						G2[n+nd[k][j]].push_back(0);
						//break;
					}
				}
				/*for(k=i-1; k>=0; k--){
					if(a[k][j] != '.'){
						G[nd[i][j]].push_back(n+nd[k][j]);
						G2[nd[i][j]].push_back(1);
						G[n+nd[k][j]].push_back(nd[i][j]);
						G2[n+nd[k][j]].push_back(0);
						break;
					}
				}*/
				G[n+nd[i][j]].push_back(nd[i][j]);
				G2[n+nd[i][j]].push_back(1);
				G[nd[i][j]].push_back(n+nd[i][j]);
				G2[nd[i][j]].push_back(0);
			}
		}
	}
	
	int u, v;
	while(find_path() ){
		v = n+nd[ti][tj];
		while(v!=nd[si][sj]){
			u = last[v];
			for(i=0; i<G[u].size(); i++){
				if(G[u][i] == v){
					G2[u][i] --;
					break;
				}
			}
			for(i=0; i<G[v].size(); i++){
				if(G[v][i] == u){
					G2[v][i] ++;
					break;
				}
			}
			v = u;
		}
		res ++;
	}
	printf("%d\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d", &H, &W);
	for(i=0; i<H; i++)
		scanf("%s", a[i]);
	solve();
	return 0;
}

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

using namespace std;
int A[200001],b[5];
int main()
{
    int i,j,x,n,ans;
    cin>>n;
    for(i=0; i<n; i++)
        scanf("%d",&A[i]);
    if(n==2)
    {
        for(i=0;i<2;i++)
            cout<<A[1-i]<<endl;
    }
    else
    {
        for(i=0; i<2; i++)
        {
            b[i]=A[i];
            for(j=i+1; j<n; j++)
                if(b[i]<A[j])
                {
                    b[i]=A[j];
                    if(i==0)
                        x=j;
                }
            if(i==0)
            {
                ans=A[i];
                A[i]=b[i];
                A[x]=ans;
            }
        }
        for(i=0; i<n; i++)
        {
            if(i==x)
                cout<<b[1]<<endl;
            else
                cout<<b[0]<<endl;
        }
    }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int D, G;
	cin >> D >> G;
    vector<int> p(D), c(D);
    rep(i, D) cin >> p[i] >> c[i];
    vector<int> v(D);
    iota(all(v), 0);

    int ans = INF;
    while (true) {
        int solve = 0, score = 0;
        for (auto i : v) {
            if (score + 100*(i+1)*p[i] + c[i] <= G) {
                solve += p[i];
                score += 100*(i+1)*p[i] + c[i];
            } else {
                int less = G - score;
                if (less == 0) break;
                solve += min(p[i], (less - 1)/(100*(i+1)) + 1);
                break;
            }
        }        
        ans = min(ans, solve);
        if (!next_permutation(all(v))) break;
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N,A,B = map(int, input().split())

def uoo(num):
    res1 = 0
    for i in str(num):
        res1 += int(i)
    return res1

res = 0
for i in range(1,N+1):
    tmp = uoo(i)
    if A <= tmp and tmp <= B:
        res += i

print(res)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int cnt=n,sum=0;
    vector<int> a(n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a.begin(),a.end());
    for(int i=n-1;i>=0;i--){
        if(sum+a[i]<k) sum+=a[i];
        else cnt=i;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int gcd( int x, int y )
{
  if ( y == 0 )
    return x;

  int z = x % y;

  return gcd(y, z);
}

int main()
{
  int a,b;
  
  while ( cin >> a >> b )
    {
      int g = gcd(a, b);
      int l = a / g * b;
      cout << g << " " << l << endl;
    }
  
  return 0;
}

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


double tannri(int y,int r){
	return (1+y*r/100.0);
}
double hukuri(int y,int r){
	return pow(1+r/100.0,(double)y);
}

int main(){
	int n,y;
	while(cin>>n&&n){
		cin>>y;
		int tb,tr=-1;
		int hb,hr=-1;
		while(n--){
			int b,r,t;
			cin>>b>>r>>t;
			if(t==1){
				if(tr<r){
					tb=b;
					tr=r;
				}
			}else{
				if(hr<r){
					hb=b;
					hr=r;
				}
			}	
		}
		if(tr!=-1 && (hr==-1 || tannri(y,tr) > hukuri(y,hr))){
			cout<<tb<<endl;
		}else cout<<hb<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>

int g[102], m;
int cnt;

void shell_sort(int n, int *a)
{
	int i, j, h, lim;
	int key;

	lim = n / 9;		// 要素数/9
	if (lim < 40) lim = 40;
	
	g[0] = 1;
	m = 0; do m++, g[m] = 3*g[m-1]+1;
	while (g[m] < n && g[m] <= lim);

	cnt = 0, h = g[m-1];
	while (h > 0) {
		for (i = h; i < n; i++) {
			key = a[i];
			j = i-h; while (j >= 0 && a[j] > key) {
				cnt++;
				a[j+h] = a[j];
				j -= h;
			}
			a[j+h] = key;
		}
		h /= 3;
	}
}

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

char buf[20];
void mypr(int n)
{
	int i;
	if (n == 0) { pc('0'); return; }
	i = 0; while (n) buf[i++] = n%10 +'0', n /= 10;
	while (i) pc(buf[--i]);
}

int a[1000002];

int main()
{
	int N, i;

	N = in(); for (i = 0; i < N; i++) a[i] = in();

	shell_sort(N, a);
	
	mypr(m), pc('\n');
	mypr(g[m-1]); for (i = m-2; i >= 0; i--) pc(' '), mypr(g[i]); pc('\n');
	mypr(cnt), pc('\n');
	for (i = 0; i < N; i++) mypr(a[i]), pc('\n');

	return 0;
}



Measured memory_bytes: 5520
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < (i##_MACRO); i++)
#define RANGE(i, a, b) for(int i = (a), i < (b), i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MOD(x) ((x) % static_cast<int>(1e9 + 7))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int r;
	scanf("%d", &r);
	printf("%d\n", r * r);
	return 0;
}

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

int x,y,ice[100][100],del[100][100];
int dn[4]={-1,1,0,0};
int dm[4]={0,0,1,-1};

///(n,m)から歩き始めた時に，割る最大数を返す

int move(int n,int m,int len){
  int tmp=len;
  del[n][m] = 1;
  for(int i=0;i<4;i++){
    int nn=n+dn[i],nm=m+dm[i];
    if(ice[nn][nm]==1/*いけるかどうか*/ && del[nn][nm]==0/*きたかどうか*/){
      tmp = max(tmp,move(nn,nm,len+1));
    }
    
  }
  del[n][m]=0;
  return tmp;
  
  /*  for(int i=0;i<4;i++){
    int nn=n+dn[i],nm=m+dm[i];
    if(ice[nn][nm]==1){
      len++;
      del[n][m]=2;
      move(nn,nm,len+1);
      del[n][m]=1;
    };
    if(ice[n-1][m]==0&&ice[n][m-1]==0&&ice[n+1][m]==0&&ice[n][m+1]==0)
      
  }
  return max(len,move(n,m,len));
  */
}

int main(){
  while(true){
    scanf("%d%d",&x,&y);

    if(x==0&&y==0){break;}

    for(int j=0;j<=y;j++){
      for(int i=0;i<=x;i++){
	ice[i][j]=0;
	del[i][j]=0;
      }
    }

    for(int j=1;j<=y;j++){
      for(int i=1;i<=x;i++){
	scanf("%d",&ice[i][j]);
      }
    }

    int ans=0;
    for(int j=1;j<=y;j++){
      for(int i=1;i<=x;i++){
	ans = max(move(i,j,0),ans);
      }
    }
    printf("%d\n",ans);
  }

}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[200005],b[200005],sum=0,s=0;
const int mod=1000000007;
int main()
{
    cin>>n;
    for(int i=0;i<n;++i)
        {
            cin>>a[i];
            s+=a[i];
            s%=mod;
            b[i+1]=s;
        }
    b[0]=0;
    for(int i=0;i<n;++i)
    {
        sum+=a[i]*b[i]%mod;
        sum%=mod;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 6748
s = input()
a = list(s)
n = len(s)
ansa = 0
ansb = 0
for i in range(n):
    if i%2 == 0 and int(a[i]) == 0:
      ansa = ansa + 1

    if i%2 == 1 and int(a[i]) == 1:
      ansa = ansa + 1    
    
    if i%2 == 0 and int(a[i]) == 1:
      ansb = ansb + 1
        
    if i%2 == 1 and int(a[i]) == 0:
      ansb = ansb + 1
     
        
if ansa > ansb:
  print(ansb)
else :
  print(ansa)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
const int N=1e4+10;
int n;
int a[N];
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		if(i*i+1+1+i+1+1>n) break;
		for(int j=i;j<=n;j++) {
			if(i*i+j*j+1+i+j+1>n) break;
			for(int k=j;k<=n;k++) {
				int sum=i*i+j*j+k*k+i*j+i*k+j*k;
				// cout<<sum<<endl;
				if(sum>n) break;
				if(i==j && j==k) a[sum]+=1;
				else if(i==j || j==k) a[sum]+=3;
				else a[sum]+=6;
			}
		}
	}
	for(int i=1;i<=n;i++) cout<<a[i]<<"\n";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> a.at(i).at(j);
    }
  }
  
  vector<bool> row(H), col(W);
  bool flag_row=false, flag_col=false;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      if (j==0 && a.at(i).at(j) == '.') flag_row = true;
      if (a.at(i).at(j) == '#') flag_row = false;
    }
    row.at(i) = flag_row;
    flag_row = false;
  }
  
  for (int i=0; i<W; i++){
    for (int j=0; j<H; j++){
      if (j==0 && a.at(j).at(i) == '.') flag_col = true;
      if (a.at(j).at(i) == '#') flag_col = false;
    }
    col.at(i) = flag_col;
    flag_col = false;
  }
  
  for (int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if (!(row.at(i) || col.at(j))){
        cout << a.at(i).at(j);
      }
    }
    if (!(row.at(i))) cout << endl;
  }
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool f[100001];//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      f[i]=false;
    //}
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c[10000000],d,cmp,cmpp,m,h,w,x,y,sum=0,pos=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n >> a >> b;
       rep(i,n)cin>>c[i];
       if(n==1){
           Cout(Abs(c[0],b));
           return 0;
       }
       cmp=Abs(c[n-2],c[n-1]);
       cmpp=Abs(c[n-1],b);
       Cout(max(cmp,cmpp));
       
       
return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i=0,n,c,ans=0,a[114514]={0};
	vector<int>u;
	for(cin>>n;i<n;cin>>a[i++]);
	sort(a,a+n);
	for(i=0;i<n;)
	{
		for(c=1;a[i]==a[1+i++];c++);
		u.push_back(c);
	}
	for(int x:u)ans+=x%2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1276
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = A[::-1]
b = B[::-1]
Sum = 0
for k in range(N-1,-1,-1):
    if b[k] >= a[k+1]:
        Sum += a[k+1]
        b[k] = b[k] - a[k+1]
    else:
        Sum += b[k]
        b[k] = 0
    if b[k] - a[k] >= 0:
        Sum += a[k]
        a[k] = 0
    else:
        Sum += b[k]
        a[k] = a[k] - b[k]
print(Sum)

Measured memory_bytes: 19080
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  s = input()
  if s[0] == 'A':
    Cs = s[2:len(s)-1]
    #print(Cs)
    if Cs.count('C') == 1:
      s = s.replace('A',"").replace('C',"")
      for i in range(len(s)):
        #print(s)
        if 'a' <= s[i] <= 'z':
          pass
        else:
          print('WA')
          exit()
      print('AC')
    else:
      print('WA')
    
    
  else:
    print('WA')
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
import sys


def LI():
    return list(map(int, input().split()))


N, M = LI()
if abs(N-M) >= 2:
    print(0)
    sys.exit()
mod = pow(10, 9)+7
x = 1
if N == M:
    for i in range(1, N+1):
        x = (x*i) % mod
    ans = (x*x*2) % mod
else:
    A = max(N, M)
    B = min(N, M)
    for i in range(1, B+1):
        x = (x*i) % mod
    y = (x*A) % mod
    ans = (x*y) % mod
print(ans)


Measured memory_bytes: 9136
#include <iostream>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	for(int i=1;i<=n;i++) {
		int x = i;
		if(x%3 == 0) {
			cout << " " << i;
		} else {
			do {
				if (x%10 == 3) {
					cout << " " << i;
					break;
				}	
			} while (x/=10);
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll solve(vector<int> x, int t){
    if(sz(x)==0) return 100000;
    ll ans=100000;
    rep(i,0,1<<sz(x)){
        ll res=0;
        int cnt=0;
        rep(j,0,sz(x)){
            if(i&(1<<j)){
                res+=x[j];
                cnt++;
            }
        }
        if(cnt>0) ans=min(ans, 10*(cnt-1)+abs(res-t));
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,A,B,C;
    cin>>N>>A>>B>>C;
    int l[N];
    rep(i,0,N){
        cin>>l[i];
    }
    ll ans=100000;
    rep(i,0,pow(3,N)){
        vector<int> a,b,c;
        ll j=i;
        int cnt=0;
        while(cnt<N){
            if(j%3==0) a.pb(l[cnt]);
            if(j%3==1) b.pb(l[cnt]);
            if(j%3==2) c.pb(l[cnt]);
            j/=3;
            cnt++;
        }
        ans=min(ans, solve(a,A)+solve(b, B)+solve(c, C));
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vecll var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prseq(var, n)    rep(i,n){cout << var[i] << " ";} cout << endl
#define prseql(var, n)   rep(i,n){cout << var[i] << " " << endl;}

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n+1);
  arrll(b,n);

  ll ans=0;
  rep(i,n){
    ll pow = b[i];
    ans += min(pow, a[i]);
    pow -= min(pow, a[i]);
    ans += min(pow, a[i+1]);
    a[i+1] -= min(pow, a[i+1]);
  }

  prt(ans);

}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    
    vector<pair<ll, int>> s(n);
    REP(i, n) s[i] = pair<ll, int>{a[i], i};
    sort(ALL(s));
    reverse(ALL(s));
    s.push_back(pair<ll, int>{0, n});
    vector<ll> ans(n, 0);
    int m = s[0].second;
    for (int i = 0; i < n; ++i) {
        ans[m] += (s[i].first - s[i + 1].first) * (i + 1);
        m = min(m, s[i + 1].second);
    }
    
    REP(i, n) cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 7172
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

struct robot {
	int x_min;
	int x_max;
	robot(int ix, int il) {
		x_min = ix - il;
		x_max = ix + il; 
	}
};

// ���l x_max �Ń\�[�g���邽�߂̔�r���Z�q
bool cmp_max(const robot& a, const robot& b) {
	return a.x_max > b.x_max;
}

int main() {

	int N;
	cin >> N;

	int x, l;
	vector<robot> val;
	for (int i = 0; i < N; i++) {
		cin >> x >> l;
		val.push_back(robot(x, l));
	}

	// ���{�b�g�̃A�[���̍ő�l�Ń\�[�g�i���ׂ��̏��j
	sort(val.begin(), val.end(), cmp_max);

	// ���{�b�g�̐�
	int ans = 1;

	// �S�Ẵ��{�b�g�Ɋւ����×~�@�ŒT��
	robot dval = val.back();
	robot nval = robot(0, 0);
	val.pop_back();
	while (val.size() > 0) {
		// �c�����{�b�g������
		nval = dval;

		while (val.size() > 0 && nval.x_max > dval.x_min) {
			dval = val.back();
			val.pop_back();
		}

		// ���{�b�g�̐����X�V
		ans += 1;
	}

	// �Ō�̃��{�b�g�̊m�F
	if (nval.x_max > dval.x_min) {
		// �ߏ�ɐ����グ�������폜
		ans -= 1;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1400
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, M = MI()
    A = LI()
    s = sum(A)
    A = sorted(A, reverse=True)

    for i in range(M):
        a = s / (4 * M)
        # print(a)
        if A[i] < a:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include <stdio.h>

  int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int a[n];
    for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    for(int i=0;i<n-k;i++){
      (a[i]<a[i+k])?puts("Yes"):puts("No");
    }
  return 0;
  }


Measured memory_bytes: 2844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,M,K;
  cin>>N>>M>>K;
  VL A(N),B(M);
  rep(i,N) cin>>A[i];
  rep(i,M) cin>>B[i];
  VL AA(N+1),BB(M+1);
  rep(i,N) AA[i+1]=AA[i]+A[i];
  rep(i,M) BB[i+1]=BB[i]+B[i];
  int ans=0;
  rep(i,N+1){
    ll tmp=AA[i];
    if(tmp>K) break;
    ll X=lb(all(BB),K-tmp)-BB.begin();
    if(K-tmp==*lb(all(BB),K-tmp)){
      if(ans<i+X) ans=i+X;
    }else{
      if(ans<i+X-1) ans=i+X-1;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 9588
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
   int a,b,c,d,e,k;
   scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
   if(e-a<=k){
    printf("Yay!");
   }
   else{
    printf(":(");
   }
    return 0;
}


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

using namespace std;

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

	int ret=n,mi=1000;
	for(int i=0;i<n;i++)
	{
		x-=m[i];
		mi=min(mi,m[i]);
	}
	ret+=x/mi;
	cout<< ret<< endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		java.util.Arrays.sort(p);
		int ans = 0;
		for(int i = 0; i < k; i++) {
			//System.out.println(p[i]);
			ans+= p[i];
		}
		System.out.println(ans);
	}
}

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

 int main()
 {
 	int n,c=1,k=0;
 	cin>>n;
   string s;
   cin>>s;
   
   stack<char> st;
   st.push(s[0]);
   
   for(int i=1;i<n;i++)
   {
   	if(st.top()!=s[i])
   	    st.push(s[i]);
   }
   cout<<st.size()<<endl;
   
  return 0;
}
      

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ll a,b;
	cin>>a>>b;
	ll x = a,y = 0;
	bool isok = false;
	while(x>=0)
	{
		if(x<0)break;
		ll cnt = x*2+y*4;
		if(cnt == b)isok = true;
		x--;y++;
	}
	if(isok)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int solve(){
  string a,b;
  cin>>a>>b;

  if(a.size()!=b.size()){return a.size() < b.size(); }
  else {
    int i=0;
    while(i<a.size() && a[i] ==b[i]) i++;
    if(i==a.size()) return -1;
    else return a[i] < b[i];
  }
}

int main(){
  int r = solve();
  if(r==-1) cout << "EQUAL" << endl;
  else if(r==1) cout << "LESS" << endl;
  else cout << "GREATER" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,min=0,max=0,n,a,c,col[9]={};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        c=0;
        while(1){
            if((a-400)>=0&&c!=8){
                a=a-400;
                c++;
            }
            else{
                col[c]++;
                break;
            }
        }
    }
    for(i=0;i<8;i++){
        if(col[i]!=0){
            min++;
            max++;
        }
    }
    if(min==0&&col[8]!=0){
        min=1;
    }
    max=max+col[8];
    
    
    printf("%d %d",min,max);
}

Measured memory_bytes: 128
#include <stdio.h>
#define NUMBER 3

int main(){
  
	char S[NUMBER];
  
  	scanf("%s",S);
  
  	if(S[0] == S[1] && S[1] == S[2] && S[0] == S[2]){
      	printf("No");
    }else{
      	printf("Yes");
    }

  	return 0;
}
    	


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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

ll f(ll n) {
    ll ret = (n % 2 == 1) ? 0 : n;

    if (((n + 1) / 2) % 2 == 1) {
        ret ^= 1;
    }

    return ret;
}

signed main() {
    ll A, B;
    cin >> A >> B;

    ll ans = 0;

    if (A == 0) {
        ans = f(B);
    } else if (B == 0) {
        ans = 0;
    } else {
        ans = f(A-1) ^ f(B);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> hs(n);
    for (int& h : hs) {
        cin >> h;
    }
    for (int i = n-1; i >= 1; --i) {
        if (hs[i] < hs[i-1]-1) {
            cout << "No" << endl;
            return 0;
        }
        if (hs[i] == hs[i-1]-1) {
            --hs[i-1];
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 768
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

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

		BookStrategy strategy = new BookStrategy();


		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		int x = stdIn.nextInt();



		for (int i = 0; i < n; i++) {
			Book book = new Book(stdIn.nextInt());
			IntStream.range(0, m).forEach(j -> book.addSkill(stdIn.nextInt()));

			strategy.addBook(book);
		}

		System.out.println(strategy.getAllPattern(x));

		stdIn.close();
	}
}

class BookStrategy {
	private List<Book> bookList = new ArrayList<Book>();

	public void addBook(Book book) {
		bookList.add(book);
	}

	public int getAllPattern(int threshold) {
		int size = bookList.size();
		int min = Integer.MAX_VALUE;

		for (int i = 0; i < (int)Math.pow(2, size); i++) {
			List<Integer> binaryArray = convertToBinary(i, size);

			int price = getPrice(binaryArray);

			if(!isOverThreshold(binaryArray, threshold)) {
				continue;
			}

			min = Integer.min(min, price);

		}

		if(min == Integer.MAX_VALUE) {
			return -1;
		}

		return min;

	}

	private int getPrice(List<Integer> binaryArray) {
		int total = 0;

		int size =binaryArray.size();

		for (int i = 0; i < size; i++) {
			total += bookList.get(i).getPrice() * binaryArray.get(i);

		}

		return total;
	}

	private boolean isOverThreshold(List<Integer> binaryArray, int x) {
		int[] skills = new int[bookList.get(0).getSkills().size()];

		int size =binaryArray.size();

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

			if(binaryArray.get(i) == 0) {
				continue;
			}

			List<Integer> inputSkills = bookList.get(i).getSkills();
			for(int j = 0; j < skills.length; j++) {
				skills[j] += inputSkills.get(j);
			}

		}

		for (int skill : skills) {
			if(skill < x) {
				return false;
			}
		}


		return true;
	}

	private List<Integer> convertToBinary(int num, int digit) {
		String binary = String.format("%"+digit+"s", Integer.toBinaryString(num)).replaceAll(" ", "0");
		List<Integer> flags = new ArrayList<Integer>();

		for (String bin : binary.split("")) {
			flags.add(Integer.parseInt(bin));
		}

		return flags;
	}
}

class Book {
	private int price;

	private List<Integer> skills = new ArrayList<>();

	public Book(int price) {
		this.price = price;
	}

	public void addSkill(int s) {
		skills.add(s);
	}

	public int getPrice() {
		return price;
	}

	public List<Integer> getSkills() {
		return skills;
	}


}

Measured memory_bytes: 56860