akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

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

  for(int i=0; i<=n/7; i++) {
    for (int j=0; j<=n/4; j++) {
      if (n == 7*i + 4*j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from math import factorial
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:   #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True
def same(x,y):
    return find(x) == find(y)
def size(x):
    return -par[find(x)]

n,m=map(int,input().split())
par = [-1]*n
lst=[]
for i in range(m):
    a,b=map(int,input().split())
    lst.append([a-1,b-1])
lst.reverse()
anslst=[(factorial(n)//(2*factorial(n-2)))]
for i in range(m-1):
    a,b=lst[i]
    if same(a,b):
        anslst.append(anslst[-1])
    else:
        c=size(a)*size(b)
        anslst.append(anslst[-1]-c)
        union(a,b)
anslst.reverse()
for i in anslst:
    print(i)

Measured memory_bytes: 106856
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
using namespace std;
int a[100010];
bool flg[100010];
int main(){
  int N,ans=0;
  cin>>N;
  REP(i,N){
    cin>>a[i];
    a[i]--;
  }
  REP(i,N){
    if(flg[i])continue;
    flg[i]=true;
    if(a[a[i]]==i){
      ans++;
      flg[a[i]]=true;
    }
  }
  cout<<ans<<endl;
}


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

int q,a,b,c,d,k;

int main(){
	cin>>q;
	while(q--){
		cin>>a>>b>>c>>d;
		bool flag=false;
		if(a>b)
			swap(a,b),c=a+b+1-c,d=a+b+1-d,flag=true;
		k=ceil((double)b/(a+1));
		cerr<<k<<endl;
		int l=0,r=a;
		while(l<r){
			int mid=l+r+1>>1;
			int acnt=mid,bcnt=(mid-1)/k;
			acnt=a-acnt;
			bcnt=b-bcnt;
			if((acnt+1)*k>=bcnt)
				l=mid;
			else
				r=mid-1;
		}
		l=l+(l-1)/k;
		if(!flag)
			for(int i=c;i<=d;++i)
				if(i<=l)
					putchar(i%(k+1)==0?'B':'A');
				else
					putchar((a+b-i+1)%(k+1)==0?'A':'B');
		else
			for(int i=c;i>=d;--i)
				if(i<=l)
					putchar(i%(k+1)==0?'A':'B');
				else
					putchar((a+b-i+1)%(k+1)==0?'B':'A');
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec(x) vector<x>
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pair<ll,ll>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define ff first
#define ss second
#define mp make_pair
const int INF = 1e9;
const int MOD = 1e9 + 7;

vector<vector<pair<long long,long long> > >adj;
ll n;


void bfs()
{   //ll cnt=0;
    queue<ll> q;
    vec(bool) vis(n+1,false);
    vi ans(n+1,0);
    q.push(1);
    vis[1]=true;
    ans[1]=0;
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        //ll f=0;
        for(ll i=0;i<adj[u].size();i++)
        {  ll vff=adj[u][i].ff;
          ll vss=adj[u][i].ss;
            if(!vis[vff])
            {
                if(vss%2==0)
                    ans[vff]=ans[u];
                else
                {
                    if(ans[u]==0)
                        ans[vff]=1;
                    else
                        ans[vff]=0;
                }
                vis[vff]=true;
                q.push(vff);
            }
        }
    }
   for(ll i=1;i<n+1;i++)
   {
       printf("%lld\n",ans[i]);
   }
}

void initialize()
{
	ll i,x,y,z;
    scanf("%lld",&n);
    adj=vector<vector<pair<long long,long long> > >(n+1);

    for(i=0;i<n-1;i++)
    {
        scanf("%lld %lld %lld",&x,&y,&z);
        adj[x].pb({y,z});
        adj[y].pb({x,z});
    }
}

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//ll t;
	//scanf("%lld",&t);

		initialize();
		bfs();

}


Measured memory_bytes: 11316
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
using namespace std;

typedef pair<int, int> pii;

void solve() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A')cout << "T";
		else if (s[i] == 'T')cout << "A";
		else if (s[i] == 'G')cout << "C";
		else cout << "G";
	}
	cout << endl;
	return;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int n,ans;
//確定リスト
int g[9][9];
//現状
int a[9][9];

//上からy行目がまだ可能性あるか
bool check(){
    bool f=true;
    rep(i,n){
        int w=0,l=0;
        rep(j,n){
            if(i==j) continue;
            if(a[i][j]==1) w++;
            if(a[i][j]==-1)l++;
        }
        if(!(w<=(n-1)/2 and l<=(n-1)/2)) f=false;
    }
    return f;
}

//I,Jを試すよ
void dfs(int I,int J){
    if(I==n-1 and J==n-1) {
        ans++;
        // cout<<ans<<endl;
        // rep(i,n){
        //     rep(j,n){
        //         if(i==j) cout<<"x ";
        //         else cout<<a[i][j]<<" ";
        //     }cout<<endl;
        // }
        return ;
    }
    int ni,nj;
    if(I==J)ni=I+1,nj=0;
    else    ni=I,nj=J+1;
    if(I==J or a[I][J]!=0){
        if(check()) dfs(ni,nj);
        return ;
    }
    a[I][J]=1;a[J][I]=-1;
    if(check())dfs(ni,nj);
    a[I][J]=-1;a[J][I]=1;
    if(check())dfs(ni,nj);
    a[I][J]=0;a[J][I]=0;
}

void solve(){
    rep(i,n)rep(j,n)g[i][j]=0;
    rep(i,n)rep(j,n)a[i][j]=0;
    ans=0;
    int m;cin>>m;
    rep(i,m){
        int x,y;cin>>x>>y;
        x--,y--;
        g[x][y]=1;
        g[y][x]=-1;
        a[x][y]=1;
        a[y][x]=-1;
    }
    // rep(i,n){
    //     rep(j,n){
    //         if(i==j) cout<<"x ";
    //         else cout<<g[i][j]<<" ";
    //     }cout<<endl;
    // }
    
    dfs(1,0);
    cout<<ans<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    while(true){
        cin>>n;
        if(n==0) return 0;
        solve();
    }
    return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

bool test = true;
#define log(x) cout << "#x" << " : " << x << "\n";

int check(vector<long long> &b, int m, long long k) {
    int l = 0;
    int r = m-1;
    int ans = 0;
    while(l<=r) {
        int mid = (l + r)/2;
        if(b[mid] <= k) {
            ans = mid + 1;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    return ans;
}

int main()
{
    FIO;
    long long n, m, k;
    cin >> n >> m >> k;
    vector<long long> a(n), b(m);
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(i!=0)
            a[i]+=a[i-1];
    }
    for(int i=0; i<m; i++) {
        cin >> b[i];
        if(i!=0)
            b[i] += b[i-1];
    }
    
    int ans = check(b, m, k);
    for(int i=0; i<n; i++) {
        if(a[i] > k)
            break;
        ans = max(ans, i + 1 + check(b, m, k-a[i]));
    }
    cout << ans << "\n";
}



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

int main(void){
  int n;
  cin >> n;
  if(n < 10) cout << n << endl;
  else if(n < 1000) cout << 9 + max(0, (n-99)) << endl;
  else if(n < 100000) cout << 9 + 900 + max(0, (n-9999)) << endl;
  else cout << 9 + 900 + 90000 << endl;
  return 0;
}


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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int m = INT32_MAX;
    do {
        int c = 0;
        for(int i = 1; i < 3; i++) c += abs(a[i] - a[i-1]);
        m = min(m, c);
    } while(next_permutation(a, a+3));
    cout << m << '\n';
}


Measured memory_bytes: 256
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== BigInt begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== BigInt ends ======

// ====== PBDS begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== PBDS ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    while(b <= a and k > 0){
        b *= 2;
        k--;
    }
    while(c <= b and k > 0){
        c *= 2;
        k--;
    }
    cout << (b > a and c > b ? "Yes" : "No") << endl;
}

int main(){
	// #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long long N;
    string S;
    cin >> S >> N;
    string ans;
    if(N == 1){
        ans = S[0];
    }
    else{
        if(S[0] != '1'){
            ans = S[0];
        }
        else{
            ans = '1';
            for(int i=1;i<N;i++){
                if(S[i] != '1'){
                    ans = S[i];
                    break;
                }
            }
        }
    }
    cout << ans;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N), v(N);
    REP(i, N) cin >> P[i];
    REP(i, N) cin >> Q[i];
    REP(i, N) v[i] = i+1;

    int a = 0;
    int b = 0;
    int cnt = 0;
    do {
        cnt++;
        if (a == 0) {
            bool ok = true;
            REP(i, N) {
                if (v[i] != P[i]) ok = false; 
            }
            if (ok) a = cnt;
        }
        if (b == 0) {
            bool ok = true;
            REP(i, N) {
                if (v[i] != Q[i]) ok = false; 
            }
            if (ok) b = cnt;
        }
    } while (next_permutation(v.begin(), v.end()));

    print(abs(a - b));
}

signed main() {
    solve();
}


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

using namespace std;

int main(void) {
    int r, g, b;
    cin >> r >> g >> b;

    int num = g * 10 + b;
    if (num % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
//package ABC170;
import java.util.*;
import java.io.*;
import java.lang.*;
class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int x=sc.nextInt();
		int n=sc.nextInt();
		HashSet<Integer> hs=new HashSet<>();
		for(int i=0;i<n;i++)
		{
			hs.add(sc.nextInt());
		}
		if(hs.contains(x)==false)
		{
			System.out.println(x);
			return;
		}
		int num1=x-1;
		int num2=x+1;
		while(true)
		{
			if(hs.contains(num1)==false)
			{
				System.out.println(num1);
				return;
			}
			else
			{
				num1--;
			}
			if(hs.contains(num2)==false)
			{
				System.out.println(num2);
				return;
			}
			else
			{
				num2++;
			}
		}

	}

}


Measured memory_bytes: 35904
#include<stdio.h>

int main(void)
{
    int n1, n2, n3;

    scanf("%d %d %d",&n1,&n2,&n3);
    if (n1 > n2){
      int temp = n1;
      n1 = n2;
      n2 = temp;
  }
    if (n2 > n3){
      int temp = n2;
      n2 = n3;
      n3 = temp;
  }
    if (n1 > n2){
      int temp = n1;
      n1 = n2;
      n2 = temp;
  }
    printf("%d %d %d\n",n1,n2,n3);
    return (0);
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    long long ans;

    if (x / d > k)
    {
        ans = x - d * k;
    }
    else
    {
        long long cnt = x / d;
        k -= cnt;
        x -= d * cnt;
        if (k % 2 == 1)
        {
            x -= d; //
        }
        ans = x; // ans becomes -2;
    }
    cout << abs(ans) << endl;
    return 0;
}

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

int main(){
  long N,M;
  long sum=0;
  cin >> N >> M;
  vector<pair<long,long>> a;
  for(long i=0;i<N;i++){
    long b,c;
    cin >> b >> c;
    a.push_back(make_pair(b,c));
  } 
  sort(a.begin(),a.end());
  long tmp=0;
  for(pair<long,long> t:a){
    long x,y;
    tie(x,y)=t;
    if(tmp+y<M){
    	tmp += y;
        sum += x*y;
    }
    else{
      sum += (M-tmp)*x;
      break;
    }
  }
  cout << sum << endl;
}

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

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

    int ans;
    ans = M * 1900 + (N-M) * 100;
    rep(i, M) ans *= 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 8

long sort(char *str);
void swap(char *x, char *y);

int main(int argc, const char *argv[])
{
	int i, cnt;
	long ans;
	char num[SIZE];
	
	scanf("%d", &cnt);
	for(i=0; i<cnt, scanf("%s", num)!=EOF; i++)
		printf("%ld\n", sort(num));	

	return 0;
}

/* 降順ソート */
long sort(char *str)
{
	int i, j, max;
	long large = 0, small = 0;
	
	for(i=0; i<SIZE; i++){
		max = i;
		for(j=i+1; j<SIZE; j++)
			if(str[max]<str[j]) max = j;
		swap(&str[i], &str[max]);
	}

	for(i=0; i<SIZE; i++){
		large = large*10 + (str[i]-'0');
	}

	for(i=SIZE-1; i>=0; i--){
		small = small*10 + (str[i]-'0');
	}
	
	return large-small;
}

void swap(char *x, char *y)
{
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

long gcd(long x, long y) {

	if (x < y) return gcd(y, x);

    long r = x % y;
    
	while (r != 0) {
		x = y;
		y = r;
        r = x % y;
	}
	return y;

}

int main() {

	long res = 0;
	long N; cin >> N;
	long A[100009]; for (long i = 1; i <= N; i++) cin >> A[i]; res = A[1];

	for (long i = 2; i <= N; i++) res = gcd(res, A[i]);

	cout << res << endl;
}

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

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

    int right = 0, left = 0;
    for(char c: s){
        if(c == '(')right++;
        else if(c == ')'){
            if(right > 0)right--;
            else left++;
        }
    }

    if(left > 0){
        for(int i=0;i<left;++i){
            cout << '(';
        }
    }

    cout << s;

    if(right > 0){
        for(int i=0;i<right;++i){
            cout << ')';
        }
    }

    cout << endl;

    return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  
  int ans = 0;
  if(A > B){
    ans += A;
    A = A - 1;
  }else{
    ans += B;
    B = B - 1;
  }
  
  if(A > B){
    ans += A;
  }else{
    ans += B;
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import heapq


class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign


if __name__ == '__main__':
    # input = sys.stdin.readline()
    N, M = map(int, input().split())
    A = Heapq(list(map(int, input().split())), desc=True)

    for i in range(M):
        A.push(A.pop() / 2)
    print(-sum([int(i) for i in A.hq]))


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

int main(){
  string s;
  cin >> s;
  string ans = "No";
  if(s[1] == s[2]){
    if(s[0] == s[1] || s[2] == s[3]){
      ans = "Yes";
    }
  } 
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    t=1;
    while(t--)
    {
        int x,y;
        cin>>x>>y;
        if((y-2*x) >=0 && (y-2*x)%2==0 && (4*x-y) >= 0 && (4*x-y)%2==0)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>

long long pow(int x){
    long long ret = 1;
    while(x > 0){
        ret *= 2;
        x--;
    }
    return ret;
}

int main(){
    int n, k;
    std::cin >> n >> k;
    int maxNeed = 0;
    std::vector<int> needOmote(n, 0);
    for(int i = 0; i < n; i++){
        // 最初から勝利
        if(i + 1 >= k){
            needOmote[i] = 0;
        }else{
            // コイン必要
            long long tmp = i + 1;
            while(tmp < k){
                tmp *= 2;
                needOmote[i]++;
            }
            maxNeed = std::max(maxNeed, needOmote[i]);
        }
    }

    long long bunshi = 0;
    for(int i = 0; i < n; i++){
        bunshi += pow(maxNeed - needOmote[i]);
    }

    long long bunbo = n * pow(maxNeed);
    long double out = (bunshi * 1.0) / (bunbo * 1.0);

    // printf("%.10llf %.10llf\n", bunshi * 1.0, bunbo * 1.0);
    printf("%.10llf", out);

    return 0;
}


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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
ll INF=1e18+10;

int main()
{
    int n,d;cin>>n>>d;
    int a[n][d];
    rep(i,0,n)
    {
        rep(j,0,d)
        cin>>a[i][j];
    }

    int c=0;
    rep(i,0,n)
    {
        rep(j,i+1,n)
        {
            ll sum=0;
            rep(k,0,d)
            {
                sum+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
            }
            float s = sqrt(sum);
            if(s==ceil(s))
                c++;
        }
    }
    cout<<c;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	double v;
	while( std::cin >> v )
	{
		double t = v / 9.8;
		double y = 4.9 * t * t;
		int f = static_cast<int>( (y+5.0)/5.0 ) + 1;

		std::cout << f << '\n';
	}
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

	string str;
	cin >> str;

	int a = 0, b = 0, c = 0;


	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'a') {
			a++;
		}
		else if (str[i] == 'b') {
			b++;
		}
		else {
			c++;
		}
	}

	if (abs(a - b) <= 1 && abs(b - c) <= 1 && abs(c - a) <= 1) {
		cout << "YES" << endl;
	}
	else {


		cout << "NO" << endl;
	}







	return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define nl cout<<'\n'
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pll pair<long long,long long>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define sll set<long long>
#define all(v) (v).begin(),(v).end()
#define Unique(x)           (x).erase(unique(all(x)), x.end())
#define v_present(vec,x)  (find(all(vec),x)!=(vec).end())
#define present(myset,x)    ((myset).find(x)!=(myset).end())
#define Cprint(c)  for(auto i:(c)) { cout<<i<<" "; } nl
#define trace2(x,y) cout<<x<<" "<<y<<endl;
#define trace3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define trace4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<endl;
ll mod = 1e9+7;
const int MAX = 1e5+5;

using namespace std;
vector<int> dp(100005,-1);
//dp[i]=true when first person maing move with i stones remaining wins
int mini;
int n,k;
vi a(105);

int solve(int currstones){

    if(currstones<mini){
        return 0;
    }

    int &ans=dp[currstones];
    if(ans!=-1)
        return ans;
    ans=0;
    for(int i=0;i<n;i++){
        if(currstones-a[i]>=0){
            int var = solve(currstones-a[i]);

            //cout<<currstones-a[i]<<" "<<var;nl;
            if(var==0){
                ans=1;
                //cout<<"////";nl;
                return 1;
            }
        }
    }
    //cout<<"////";nl;
    return ans;

}


int main()
{
    FAST_IO;
    cin>>n>>k;
    mini=1e8;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        mini=min(mini,a[i]);
    }

    int ans=solve(k);

    if(dp[k]==true){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }

    return 0;

}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

#define MAX_N 2000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);
  ans = (ans * finv[r]) % mod;
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  make();
  ll n, m, k; cin >> n >> m >> k;
  ll ans = 0;
  ll tmp = 0;
  rep(i, n) if(i) (tmp += m*m%mod*i%mod*(n-i)%mod) %= mod;
  (ans += tmp) %= mod;
  tmp = 0;
  rep(i, m) if(i) (tmp += n*n%mod*i%mod*(m-i)%mod) %= mod;
  (ans += tmp) %= mod;
  (ans *= comb(n*m-2, k-2)) %= mod;
  cout << ans << endk;
  return 0;
}


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) (ll)arr.size()

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }

ll f[200001];

ll kCn(ll k, ll n) {
	return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD;
}

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	int n, k;
	cin >> n >> k;
	f[0] = 1;
	for (int i = 1; i <= 200000; ++i)
		f[i] = (f[i - 1] * i) % MOD;
	ll ans = 0;
	for (int i = 0; i <= min(n - 1, k); ++i) {
		ans += kCn(i, n) * kCn(i, n - 1);
		ans %= MOD;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	string S;
	int N;
	cin >> N>>S;
	string an = "Yes";
	if (N % 2 == 0) {
		rep(i, N/2) {
			if (S.at(i) != S.at(i + N / 2)) {
				an = "No";
			}
		}

	}
	else {
		an = "No";
	}
	cout << an << endl;
	
		
}

Measured memory_bytes: 256
N, X, Y = list(map(int, input().split()))
result = [0] * N


for i in range(1, N):
  for j in range(i+1, N+1):
    step = min( j-i, abs(i-X)+1+abs(j-Y), abs(i-Y)+1+abs(j-X))
    result[step] += 1

for e in result[1:]: print(e)

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

#define ll long long

using namespace std;

int bin_pow(int a, int x)
{
    if(x == 0) return 1;
    if(x % 2 == 0)
    {
        int b = bin_pow(a, x / 2);
        return b * b;
    }
    return a * bin_pow(a, x - 1);
}

multiset <int> s;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    int st,x;
    cin >> st;
    int n;
    n = bin_pow(2, st);
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        s.insert(x * (-1));
    }
    vector <int> cur;
    cur.push_back(*s.begin());
    s.erase(s.begin());
    for(int i = 0; i < st; i++)
    {
        vector <int> nv;
        for(int j = 0; j < cur.size(); j++)
        {
            if(s.upper_bound(cur[j]) == s.end())
            {
                return cout << "No", 0;
            }
            nv.push_back(*s.upper_bound(cur[j]));
            s.erase(s.upper_bound(cur[j]));
        }
        for(int j = 0; j < nv.size(); j++) cur.push_back(nv[j]);
    }
    cout << "Yes";
}


Measured memory_bytes: 13984
#include <bits/stdc++.h>
#define INF 100
using namespace std;
const int w = 15;
const int h = 19;
typedef pair<int,int> P;
vector<string> mp(h);
map<P,int>M;
bool inmp(int x,int y){return 0<=x&&0<=y&&x<w&&y<h;}
bool goal(int x,int y){return (y==h||(y==h-1&&0<=x&&x<w));}

int mem[1<<20],used[1<<20];
int dfs(int x,int y,int bit){
  if(goal(x,y)) return 0;
  if(!inmp(x,y)) return INF;
  if(used[bit]++) return mem[bit];
  
  int res = INF;
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++){
      int nx = x+i;
      int ny = y+j;
      int nbit = bit;
      if(!inmp(nx,ny)||mp[ny][nx] != 'X') continue;

      vector<string>tmp = mp;
      while(inmp(nx,ny)&&mp[ny][nx]=='X'){
	mp[ny][nx] = '.';
	nbit |=1<<M[P(nx,ny)];
	nx+=i,ny+=j;
      }
      res=min(res,1+dfs(nx,ny,nbit));
      mp = tmp;
    }
  return mem[bit]=res;
}

int main(){

  for(int i=0;i<h;i++)cin>>mp[i];

  for(int i=0,c=0;i<h;i++)
    for(int j=0;j<w;j++) if(mp[i][j]=='X') M[P(j,i)] = c++;

  int ans; 
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j] =='O') ans=dfs(j,i,0);
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
			   

  return 0;
}

Measured memory_bytes: 9500
#include <bits/stdc++.h>
#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() {
	int	N;
	cin >> N;
	vector<int> vec1(N);
	rep(i, N)
		cin >> vec1.at(i);
	int	M;
	cin >> M;
	vector<int> vec2(M);
	rep(i, M)
		cin >> vec2.at(i);
	cout << includes(vec1.begin(), vec1.end(), vec2.begin(), vec2.end()) << endl;
}



Measured memory_bytes: 4372
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1<<19;

int n;
ll a[N];
ll dp[N];
ll may, may2;

int V[N];
int tam;

void getsubmasks(int mask, int i = 0, int sub=0){
	if(i==tam){
		if(a[sub]>may){
			may2=may;
			may=a[sub];
		}else if(a[sub]>may2) may2=a[sub];
		return;
	}
	getsubmasks(mask, i+1, sub);
	getsubmasks(mask, i+1, sub | (1<<V[i]));
}

int main(){
	scanf("%d",&n);
	int tot= 1<<n;
	For(i,0,tot) scanf("%lld",&a[i]);
	For(msk,1,tot){
		tam=0;
		For(j,0,n)
			if((msk>>j)&1) V[tam++]=j;
		may = -1;
		may2=-1;
		getsubmasks(msk);
		dp[msk] = may+may2;
	}
	For(i,1,tot){
		dp[i]=max(dp[i],dp[i-1]);
		printf("%lld\n",dp[i]);
	}
	return 0;
}



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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int N;
  cin>>N;
  string S[N];
  int P[N];
  tuple<string,int,int> arr[N];
  rep(i,N){
    cin>>S[i]>>P[i];
    arr[i]=make_tuple(S[i],-P[i],i+1);
  }
   sort(arr,arr+N);
  rep(i,N)
    cout<<get<2>(arr[i])<<endl;
  return 0;
}
  


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

using namespace std;

int main(){
  int N, M, X, Y, x, y, max_x = -110, min_y = 110;

  cin >> N >> M >> X >> Y;
  for(int i = 0; i < N; i++){
    cin >> x;
    if(max_x < x) max_x = x;
  }
  for(int i = 0; i < M; i++){
    cin >> y;
    if(y < min_y) min_y = y;
  }

  if(max_x < min_y && X < max_x && min_y <= Y) cout << "No War" << endl;
  else cout << "War" << endl;


  return 0;

}


Measured memory_bytes: 256
def solve(H, W, h, w):
    return (H - h) * (W - w)


def main():
    H, W = map(int, input().split())
    h, w = map(int, input().split())
    
    ans = solve(H, W, h, w)
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <cmath>

using namespace std;

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

  int a,b,c;
  cin>> a>> b>>c;
  cout<<c/a*b<<'\n';





}

Measured memory_bytes: 3588
import java.util.Scanner;
 
public class Main {
	static int N;
	static int W;
	static long[] w = new long[110];
	static long[] v = new long[110];
	static long[][] dp = new long[110][100100];
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		N = sc.nextInt();
		W = sc.nextInt();
		
		for(int i = 0; i < N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		
		//dp[何番目の商品か][超えない重さ] = 価値の総和
		
		for(int i = 0; i < N; i++) {
			for(int sum_w = 0; sum_w <= W; sum_w++) {
				if(sum_w - w[i] >= 0) {
					//dp[i+1][sum_w] = dp[i][重さ-商品の重さ=残りの重さ] + 商品の価値 = 価値の総和
					dp[i+1][sum_w] = Math.max(dp[i+1][sum_w], dp[i][(int) (sum_w-w[i])]+v[i]);
				}
				dp[i+1][sum_w]=Math.max(dp[i+1][sum_w], dp[i][sum_w]);
			}
		}
		System.out.println(dp[N][W]);
	}
}

Measured memory_bytes: 127828
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vector<P> work(N);
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        work[i] = {b, a};
    }
    sort(ALL(work));

    ll now = 0;
    for(auto w : work){
        auto f = w.first, t = w.second;
        now += t;
        if(now > f) drop("No");
    }

    drop("Yes");

    return 0;
}

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

int main(){
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  
  if((A + B) > (C + D)){
    cout << "Left" << endl;
  }else if((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  
}

Measured memory_bytes: 256
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
   input! {
      n:usize,m:usize,
      mut h:[usize;n],
      ab:[(Usize1,Usize1);m]
   }
   let q = h.clone();
   let mut v = vec![vec![]; n];
   for (i, j) in ab {
      v[i].push(j);
      v[j].push(i);
   }
   let mut arr = vec![];
   let mut fg = vec![false; n];
   for i in 0..n {
      arr.push((h[i], i));
   }
   arr.sort();
   arr.reverse();
   let mut ans = 0_usize;
   for i in 0..n {
      if !fg[arr[i].1] {
         ans += 1;
         let mut flag = false;
         for j in &v[arr[i].1] {
            if q[arr[i].1] <= q[*j] {
               flag = true;
            }
            fg[*j] = true;
         }
         if flag {
            ans -= 1;
         }
         fg[arr[i].1] = true
         //println!("{}", arr[i].1);
      }
      //println!("{:?}", &h);
   }
   println!("{}", ans);
}

Measured memory_bytes: 14340
from math import cos, pi
a, b, h, m = map(int, input().split())
arg_a = 0.5*(60*h + m)
arg_b = 6*m
arg = max(arg_a,arg_b) - min(arg_a,arg_b)
if arg >= 180:
    arg = 360 - arg
cos_arg = cos(arg*pi/180)
dd = a**2 + b**2 - 2*a*b*cos_arg
print(dd**(1/2))

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

int main() {
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << w * h / 2.0 << " " << (2 * x == w && 2 * y == h) << endl;
  return 0;
}


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

int main() {
  
  vector<int> vec(3);
  for (int i=0; i<3; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  if (abs(5-vec.at(0))+abs(5-vec.at(1))+abs(7-vec.at(2))==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int64 INF = 1LL << 40 - 1;
constexpr int64 LINF = 1LL << 60 + 1;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)


signed main() {
  INIT;
	VAR(int, n);
	map< int, int > mp;
	vector< PAIR > a;
	REP(i, n) {
		VAR(int, j);
        int p;
        REP(k, 31) {
          if ((1 << k) > j) {
            p = 1LL << k;
            break;
          }
        }
		a.push_back(make_pair(j, p));
		mp[j]++;
	}

	sort(ALL(a), [](PAIR x, PAIR y){ if (x.first == y.first) return x.second < y.second; return x.first < y.first;});
	a.erase(unique(ALL(a)), a.end());

	int ans = 0;
	RREP(i, a.size()) {
			if (!mp.count(a[i].first)) break;
			int target = a[i].second - a[i].first;
			if (target == a[i].first) {
				int tmp = mp[target] / 2;
				mp[target] -= tmp * 2;
				ans += tmp;
			} else {
				int tmp1 = mp[target];
				int tmp2 = mp[a[i].first];
				mp[target] -= min(tmp1, tmp2);
				mp[a[i].first] -= min(tmp1, tmp2);
				ans += min(tmp1, tmp2);
			}
	}

	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 29164
S = list(input())
L = len(S)
K = int(input())
idx = 0
while K > 0:
    # aまでの必要な回数
    if S[idx] == "a" and idx < L-1:
        idx += 1
        continue
        
    k = 123 - ord(S[idx])
    if k > K:
        if idx < L-1:
            # aまで操作できないのに、操作すると辞書順でより後ろの文字列になってしまうので、次の文字へ
            idx += 1
        else:
            # 一番後ろの場合
            t = chr(ord(S[idx])+(K%26))
            S[idx] = t
            K = 0
    else:
        K -= k
        S[idx] = "a"
        if idx < L-1:
            idx += 1

print("".join(S))


Measured memory_bytes: 49520
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) A[i] = scanner.nextInt();

    long[] gcdlr = new long[N];
    long[] gcdrl = new long[N];
    gcdlr[0] = A[0];
    gcdrl[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++) gcdlr[i] = gcd(gcdlr[i - 1], A[i]);
    for (int i = N - 2; i >= 0; i--) gcdrl[i] = gcd(gcdrl[i + 1], A[i]);

    long max = Math.max(gcdlr[N - 2], gcdrl[1]);
    for (int i = 1; i < N - 1; i++) max = Math.max(max, gcd(gcdlr[i - 1], gcdrl[i + 1]));
    System.out.println(max);
  }

  private static long gcd(long i, long j) {
    if (i > j) return gcd(j, i);
    while (i > 0) {
      long r = j % i;
      j = i;
      i = r;
    }
    return j;
  }
}


Measured memory_bytes: 50640
n = input()
flag = False
for i in range(len(n)):
    if 2 <= int(n[i]) <= 9:
        flag = True
        break
if int(n[-1]) == 1:
    flag = True

if flag == True:
    ans = 0
    for i in range(len(n)):
        ans += int(n[i])
else:
    ans = 9
    for i in range(len(n)):
        ans += int(n[i])
print(ans)

Measured memory_bytes: 3316
<?php
fscanf(STDIN,"%d %d %d",$N,$M,$C);
$B = explode(' ',trim(fgets(STDIN)));
// echo gettype($B);
$ans = 0;
for ($i = 0; $i < $N; $i++) {
    $sum = 0;
    $A = explode(' ',trim(fgets(STDIN)));
    //  var_dump($A);
    for ($j = 0; $j < $M; $j++) {
     $sum += $A[$j] * $B[$j];
    }
    if ($sum + $C > 0) {
        $ans ++;
    }
}
echo $ans;

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n, l;
  cin >> n >> l;
  ll a = 1 + l - 1;
  ll b = n + l - 1;

  ll sum = 0;
  for(ll i = 1; i <= n; i++){
    sum += i + l - 1;
  }

  if(a <= 0 && b >= 0) cout << sum << endl; 
  else if(a > 0) cout << sum - a << endl;
  else if(b < 0) cout << sum - b << endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]
S = list(combinations_with_replacement(range(1, m + 1), n))

ans = 0
for s in S:
    cnt = 0
    for a, b, c, d in abcd:
        if s[b - 1] - s[a - 1] == c:
            cnt += d
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 21452
let () =
  let n,y = Scanf.scanf "%d %d " (fun a b -> a,b) in

  let res = ref [-1; -1; -1] in

  for i=0 to n do
    for j=0 to n-i do
      let k = n-i-j in
      if 10000 * i + 5000 * j + 1000 * k = y then
        res := [i;j;k]
      else ()
    done;
  done;

  Printf.printf "%d %d %d\n" (List.nth !res 0) (List.nth !res 1) (List.nth !res 2)


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


string X;
//-----------------------------------------------------------------
int main() {
	cin >> X;

	int N = X.length();

	int ans = 0;
	int cnt = 0;
	rep(i, 0, N) {
		if (X[i] == 'S')
			cnt++;
		else
			cnt--;
		if (cnt < 0) {
			ans++;
			cnt = 0;
		}
	}

	cout << ans*2 << endl;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        for (int i = 0; i < number; i++) {
            int []a = new int[3];
            a[0] = sc.nextInt();
            a[1] = sc.nextInt();
            a[2] = sc.nextInt();
            Arrays.sort(a);

            if (a[0] * a[0] + a[1] * a[1]==a[2] * a[2]) {
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}

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

int main(){
	string S;
	cin >> S;
	int ans = 0;
	rep(i, (S.size() + 1) / 2) {
		if (S.at(i) != S.at(S.size() - 1 - i)) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

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

int main(){
  long long n,k,i;
  cin >> n >> k;
  vector<long long> a(n);
  for(i=0;i<n;++i){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  if(k>a[n-1]){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  vector<long long> b(n);
  long long ma=0;
  if(n>=2){
    for(i=0;i<n-1;++i){
      b[i+1]=gcd(a[i],b[i]);
    }
    ma=b[n-1];
    }else{
      ma=a[0];
    }
  if(k%ma==0){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;


}


Measured memory_bytes: 1792
a,b=map(int,input().split())
s=0
g=0
if a==1:
  s=300000
elif a==2:
  s=200000
elif a==3:
  s=100000
else:
  s=0
if b==1:
  g=300000
elif b==2:
  g=200000
elif b==3:
  g=100000
else:
  g=0
if a==1 and b==1:
  print(g+s+400000)
else:
  print(s+g)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	if ((s == "a") || (s == "e") || (s == "i") || (s == "o") || (s == "u")) cout << "vowel";
	else cout << "consonant";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define regi register int
int n,m,q;
int pos[200001],d[200001],c[200001];
int color[200001][20];
std::vector<int>e[300001];
inline int read(){int r=0,c=0,w;for(;!isdigit(c=getchar());r=c);for(w=c^48;isdigit(c=getchar());w=w*10+(c^48));return r^45?w:-w;}
void dfs(int x, int d, int c){
	if(color[x][d]||d==-1)
	  return;
	color[x][d]=c;
	for(regi i=0;i<e[x].size();++i) {
		regi y=e[x][i];
		dfs(y,d-1,c);
	}
	dfs(x,d-1,c);
}
main(){
  n=read();
  m=read();
	for(regi i=1,x,y;i<=m;++i){
		x=read();
		y=read();
		e[x].push_back(y);
		e[y].push_back(x);
	}
	q=read();
	for(regi i=1;i<=q;++i){
		pos[i]=read();
		d[i]=read();
		c[i]=read();
	}
	for(regi i=q;i;--i)
		dfs(pos[i],d[i],c[i]);
	for(regi i=1;i<=n;++i)
		printf("%d\n",color[i][0]);
	return 0;
}

Measured memory_bytes: 22648