akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

// http://kazuma8128.hatenablog.com/entry/2018/02/28/102130
template <typename T, const T id>
class CHT {
	struct line {
		T a, b;
		line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
		T get(T x) { return a * x + b; }
	};
	struct node {
		line l;
		node *lch, *rch;
		node(line l_) : l(l_), lch(nullptr), rch(nullptr) {}
		~node() {
			if (lch) delete lch;
			if (rch) delete rch;
		}
	};

private:
	const int n;
	const vector<T> pos;
	node *root;

public:
	CHT(const vector<T>& pos_) : n(pos_.size()), pos(pos_), root(nullptr) {}
	~CHT() {
		if (root) delete root;
	}
	void insert(T a, T b) {
		line l(a, b);
		root = modify(root, 0, n, l);
	}
	T get(T x) const {
		int t = lower_bound(pos.begin(), pos.end(), x) - pos.begin();
		assert(t < n && pos[t] == x);
		return sub(root, 0, n, t);
	}

private:
	node* modify(node *p, int lb, int ub, line& l) {
		if (!p) return new node(l);
		if (p->l.get(pos[lb]) >= l.get(pos[lb]) && p->l.get(pos[ub - 1]) >= l.get(pos[ub - 1])) return p;
		if (p->l.get(pos[lb]) <= l.get(pos[lb]) && p->l.get(pos[ub - 1]) <= l.get(pos[ub - 1])) {
			p->l = l;
			return p;
		}
		int c = (lb + ub) / 2;
		if (p->l.get(pos[c]) < l.get(pos[c])) swap(p->l, l);
		if (p->l.get(pos[lb]) <= l.get(pos[lb]))
			p->lch = modify(p->lch, lb, c, l);
		else
			p->rch = modify(p->rch, c, ub, l);
		return p;
	}
	T sub(node *p, int lb, int ub, int t) const {
		if (!p) return id;
		if (ub - lb == 1) return p->l.get(pos[t]);
		int c = (lb + ub) / 2;
		if (t < c) return max(p->l.get(pos[t]), sub(p->lch, lb, c, t));
		return max(p->l.get(pos[t]), sub(p->rch, c, ub, t));
	}
};


int main(){
	ll N,C;
	cin >> N >> C;
	vector<ll> h(N+1,0),dp(N+1,INF),as;
	FOR(i,1,N+1)cin >> h[i];
	dp[1] = 0;
	as = h;
	sort(as.begin(), as.end());
	as.erase(unique(as.begin(), as.end()), as.end());
	CHT< ll, -INF > cht(as); //最大値を求める
	cht.insert(2*h[1],-1*(dp[1]+h[1]*h[1])); //今回は最小値がほしいので-を付ける
	//参考　http://kazuma8128.hatenablog.com/entry/2018/02/28/102130
	FOR(i,2,N+1){
		dp[i] = h[i]*h[i] + C - cht.get(h[i]);
		cht.insert(2*h[i],-1*(dp[i]+h[i]*h[i]));
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 15872
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <deque>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	int n;
	ll maxv;
	scanf("%d %lld",&n,&maxv);
	ll totv=maxv;
	ll totd=0LL;
	deque<pair<ll,ll> >deq;
	ll ret=0LL;
	for(int i=0;i<n-1;i++)
	{
		ll a,b;
		scanf("%lld %lld",&a,&b);
		while(!deq.empty() && deq.back().first<b) deq.pop_back();
		deq.pb(mp(b,totd));
//printf("%d %d %lld %lld %lld\n",i,deq.size(),totv,totd,ret);
		totd+=a;
		while(totv<=totd)
		{
			ll bef=totv;
			while(!deq.empty())
			{
				if(bef+deq.front().first-deq.front().second>maxv)
				{
					totv=max(totv,maxv+deq.front().second);
					deq.pop_front();
				}
				else
				{
					break;
				}
			}
			ll kai=deq.front().first;
			ll prev=deq.front().second;
			if(!deq.empty())
			{
				totv=min(maxv+prev,max(totv,bef+kai));
				ll pv=max(0ll,min((totd-totv)/kai,(prev+maxv-totv)/kai));
        			ret+=pv;
        			totv+=pv*kai;
      			}
      			ret++;
//cout << ret << " " << totv << endl;
      		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  int N=S.size();
  int a=999;
  for(int i=0;i<=N-3;i++){
  int b= (S[i]-'0')*100+(S[i+1]-'0')*10+S[i+2]-'0';
    a=min(a,abs(b-753));
  
  }
cout<<a<<endl;
}


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

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i]; 
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];

    vector <ll> ab;
    rep(i,x){
        rep(j,y){
            ab.push_back(a[i]+b[j]);
        }
    }

    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());

    vector <ll> abc;
    rep(i, min(k, (int)ab.size())){
        rep(j, z){
            abc.push_back(ab[i] + c[j]);
        }
    }

    sort(abc.begin(), abc.end());
    reverse(abc.begin(), abc.end());

    rep(i, k){
        cout << abc[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 42856
#include <iostream> 
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using std::cin;
using std::cout;
using std::endl;
using std::string;
int main() 
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a)
        cout << k << endl;
    else if (k <= (a + b))
        cout << a << endl;
    else
        cout << (2 * a) - (k - b) << endl;
    
    
    

    

}

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

vector<ll> divisor(ll n) {
  vector<ll> v;
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      v.push_back(i);
      if(i*i!=n) v.push_back(n/i);
    }
  }
  sort(v.begin(),v.end());
  return v;
}

int main() {
  ll n;
  cin >> n;
  ll a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a,a+n);
  vector<ll> p=divisor(a[n-1]);
  ll ans=0,l=0;
  for(int r=0; r<p.size(); r++) {
    while(l<n&&a[l]<=p[r]) {
      ans+=p[r]-a[l];
      l++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3852
#写経：再起で書き直し
#https://drken1215.hatenablog.com/entry/2020/05/04/190252

def dfs(A):
    # 終端条件 --- 10 重ループまで回したら処理して打ち切り
    ans = 0
    if len(A) == N:
        return score(A)
    prev_last = A[-1] if len(A) > 0 else 1
    for v in range(prev_last, M+1):
        A.append(v)
        ans = max(ans, dfs(A))
        A.pop()  # これが結構ポイント
    return ans

def score(A):
    temp = 0
    for q in abcd:
        if A[q[1]-1] - A[q[0]-1] == q[2]:
            temp += q[3]
    return temp


N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
print(dfs([]))



Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 300005

bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}

ll dp[N];
vl v[N];

ll dfs(ll m)
{
    if(!sz(v[m]))
    return dp[m]=0;
    if(dp[m]!=0)
    return dp[m];
    else
    {
        ll s=-1;
        fab(i,0,sz(v[m]))
            s=max(s,dfs(v[m][i]));
        return dp[m]=1+s;
    }
}

int main()
{
	sup; 
	ll n,m,mx=-1;
	cin>>n>>m;
	fab(i,0,m)
	{
	    ll a,b;
	    cin>>a>>b;
	    v[a].pb(b);
	}
	fab(i,1,n+1)
	    if(!dp[i])
	        mx=max(mx,dfs(i));
	pr(mx);
	//prarr(dp,1,n+1);
    return 0;
}


Measured memory_bytes: 13568
#include <stdio.h>

g(int n){
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(n==i*j){
       return 1;
      }
    }
  }
  return 0;
}
  

int main(){
  int n;
  scanf("%d",&n);
  if(g(n)==1){
    printf("Yes");
  }else{
    printf("No");
  }
}
  

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=s-1; i>=s; i--)

const ll INF = 1e15;

int main(){

    int a, b, q; cin >> a >> b >> q;

    ll s[a], t[b], x[q];
    rep(i, a){
        cin >> s[i];
    }
    rep(i, b){
        cin >> t[i];
    }
    rep(i, q){
        cin >> x[i];
    }

    rep(iq, q){
        ll dsn, dsp, dtn, dtp;

        int isl = 0, isr = a-1;
        if(x[iq] <= s[0]){
            isl = -1;
            isr = 0;
            dsn = INF;
            dsp = s[0] - x[iq];
        }
        else if(s[a-1] <= x[iq]){
            isl = a-1;
            isr = a;
            dsn = x[iq] - s[a-1];
            dsp = INF;
        }
        else{
            while(true){
                if(isr == isl + 1){
                    dsn = x[iq] - s[isl];
                    dsp = s[isr] - x[iq];
                    break;
                }
                int is = (isl + isr)/2;

                if(s[is] == x[iq]){
                    isl = is;
                    isr = isl + 1;
                }
                else if(s[is] < x[iq]){
                    isl = is;
                }
                else{
                    isr = is;
                }
            }
        }

        int itl = 0, itr = b-1;
        if(x[iq] <= t[0]){
            itl = -1;
            itr = 0;
            dtn = INF;
            dtp = t[0] - x[iq];
        }
        else if(x[iq] >= t[b-1]){
            itl = b-1;
            itr = b;
            dtn = x[iq] - t[b-1];
            dtp = INF;
        }
        else{
            while(true){
                if(itr == itl + 1){
                    dtn = x[iq] - t[itl];
                    dtp = t[itr] - x[iq];
                    break;
                }
                int it = (itl + itr)/2;

                if(t[it] == x[iq]){
                    itl = it;
                    itr = itl + 1;
                }
                else if(t[it] < x[iq]){
                    itl = it;
                }
                else{
                    itr = it;
                }
            }
        }

        ll ans1 = max(dtp, dsp);
        ll ans2 = dtp + dsn + min(dtp, dsn);
        ll ans3 = dtn + dsp + min(dtn, dsp);
        ll ans4 = max(dtn, dsn);

        ll ans = min(ans1, min(ans2, min(ans3, ans4)));

        // cout << "iq " << iq << endl;
        // cout << "is " << isl << " it " << itl << endl;
        // cout << " dsn " << dsn;
        // cout << " dsp " << dsp;
        // cout << " dtn " << dtn;
        // cout << " dtp " << dtp << endl;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
const ll N = 1e5 + 4 ;
ll dp[2][N] ;
void solve()
{
    dp[0][0] = 0 ;
    dp[1][0] = 1 ;
    string s ;
    cin >> s ;
    ll n = sz(s) ;
    rep( i , 0 , n )
    {
        if( s[i] == '0' )
        {
            dp[0][i+1] = (3*dp[0][i])%hell ;
            dp[1][i+1] = dp[1][i] ;
        }
        else
        {
            dp[0][i+1] = (3*dp[0][i]+dp[1][i])%hell;
            dp[1][i+1] = (2*dp[1][i])%hell;
        }
    }
    cout << (dp[0][n]+dp[1][n])%hell;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 2000
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://apc001.contest.atcoder.jp/tasks/apc001_b>
問題文============================================================
 長さ N の数列 a1,a2,..,aN と b1,b2,..,bN が与えられます。
 以下の操作を 0 回以上好きなだけ繰り返して、数列 a と b を一致させられるか判定してください。
 
 操作： 1 以上 N 以下の整数 i,j (一致していてもよい)を選び、次の2つのことを同時に行う。
 
 ai に 2 を足す
 bj に 1 を足す

=================================================================

解説=============================================================
全体で必要な操作回数は
 Σb - Σa
 
 ここで、 ai < bi であり Σ(bi - ai + 1)/2 の個数が全体で必要な操作回数以下であればyes
 そうでなければ no となる
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N),b(N);
    for(auto&in:a) cin >> in;
    for(auto&in:b) cin >> in;
    ll Cnt = accumulate(b.begin(),b.end(),0LL) - accumulate(a.begin(), a.end(),0LL);
    for(int i = 0; i < N;i++){
        if(a[i] < b[i]){
            Cnt -= (b[i]-a[i]+1)/2;
        }
    }
    if(Cnt >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
S = gets.chomp
MOD = 10 ** 9 + 7

dp = Array.new(4) { Array.new(S.size + 1, 0) }
dp[0][0] = 1

S.chars.each_with_index do |c, i|
  4.times do |j|
    if c == '?'
      dp[j][i + 1] += dp[j][i] * 3
    else
      dp[j][i + 1] += dp[j][i]
    end
  end

  dp[1][i + 1] += dp[0][i] if c == 'A' || c == '?'
  dp[2][i + 1] += dp[1][i] if c == 'B' || c == '?'
  dp[3][i + 1] += dp[2][i] if c == 'C' || c == '?'

  4.times do |j|
    dp[j][i + 1] %= MOD
  end
end

puts dp[3][S.size]

Measured memory_bytes: 12668
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        string S = ReadLine();
        int ans = 0;
        int j = S.Length - 1;
        for(int i = 0; i < S.Length / 2; i++)
        {
            if(S[i] != S[j])
            {
                ans++;
            }
            j--;
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: u64,
    }
    let M = (N as f64).powf(0.5) as u64;
    let mut ans = 1000000000000;
    for i in 1..M+1{
        if N%i==0{
            ans = min(ans, max(i.to_string().len(), (N/i).to_string().len()));
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, D = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    d2=D**2
    cnt=0
    for x,y in S:
        if x**2+y**2<=d2:
            cnt+=1
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 103904
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main() {
    int n;
    map<char, int> mp[50];
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < s.length(); j++) mp[i][s[j]]++;
    }
    string res = "";
    for (char a = 'a'; a <= 'z'; a++) {
        int num = 500, tmp;
        for (int i = 0; i < n; i++) {
            if (mp[i][a]) tmp = mp[i][a];
            else tmp = 0;
            num = min(num, tmp);
        }
        for (int i = 0; i < num; i++) res += a;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Gosu_Hiroo
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

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; }

//#define int ll

class CExceptionHandling {
public:
    pair<int, int> P[202020];
void solve(std::istream& cin, std::ostream& cout) {
    ll N;
    cin >> N;
    _for(i,N)P[i] = {readint, i};
    sort(P, P+N);
    int ind = P[N-1].second;
    int mx = P[N-1].first, mxx = P[N-2].first;
    _for(i,ind)cout << mx << endl;
    cout << mxx << endl;
    _for(i,N-ind-1)cout << mx << endl;

}


};


#undef int
int main() {


	CExceptionHandling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
	ll a,b,n;
	cin >> a >> b >> n;
	//for(int i = 1;i<=n;i++){cout<<i*a/b-a*(i/b)<<endl;}
	if(n>=b-1)
	{
		cout<<(b-1)*a/b-a*((b-1)/b)<<endl;
	}
	else
	{
		cout<<n*a/b-a*(n/b)<<endl;
	}
	
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

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

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	if(a1 + a2 + a3 >= 22) cout << "bust";
	else cout << "win";

	
	return 0;
}

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

using namespace std;

#define FOR( i, k, n ) for ( int i = ( k ); i < ( int )( n ); ++i )
#define REP( i, n ) FOR( i, 0, n )

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

#define MAX_S 32

bool IsRight( char );

int main()
{
	while( 1 ) {
		char str[ MAX_S + 1 ];
		cin >> str;
		if( str[ 0 ] == '#' ) break;

		int ans = 0;
		bool hand = IsRight( str[ 0 ] );
		for( int i = 1; str[ i ] != '\0'; ++i ) {
			if( hand != IsRight( str[ i ] ) ) {
				hand = IsRight( str[ i ] );
				++ans;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

bool IsRight( char key ) {
	const char rights[ 11 ] = { 'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm' };
	REP( i, 11 ) if( key == rights[ i ] ) { return  true; }
	return false;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,m;
ll l[200010],r[200010];
vector<P> ps;

int main(){
  cin>>n>>m;
  rep(i,m){
    ll x,y;
    cin>>x>>y;
    y--;
    ps.push_back(P(x,y));
  }
  sort(all(ps));
  rep(i,n)l[i]=r[i]=i;
  rep(i,m){
    l[ps[i].se+1]=l[ps[i].se];
    r[ps[i].se]=r[ps[i].se+1];
  }
  cout<<r[0]-l[0]+1;
  repl(i,1,n)cout<<" "<<r[i]-l[i]+1;
  cout<<endl;
  return 0;
}



Measured memory_bytes: 7504
#include <iostream>
#include <queue>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    priority_queue<int> q;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        q.push(l);
    }
    int t = 0;
    for (int i = 0; i < k; i++) {
        t += q.top();
        q.pop();
    }
    cout << t << endl;
    return 0;
}

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

int main()
{
    string a,b;
    cin >> a >> b;
    if((a[0] == b[2]) && (a[1] == b[1]) && (a[2] == b[0])){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
def parallel_divide(H, W):
    return 0 if W % 3 == 0 else H
 
def perpendicular_divide(H, W):
    if W % 2 == 0:
        return W // 2
    S1 = (H - 1) // 3 if H % 3 == 1 else (H + 1) // 3
    S2 = (W + 1) // 2 * (H - S1)
    S3 = (W - 1) // 2 * (H - S1)
    S1 = S1 * W
    return max(S1, S2, S3) - min(S1, S2, S3)
 
H, W = map(int, input().strip().split(' '))
print(min(parallel_divide(H, W), parallel_divide(W, H), perpendicular_divide(H, W), perpendicular_divide(W, H)))

Measured memory_bytes: 3064
N , M  = input().split()
A   = input().split()
N , M  = int(N) , int(M)
for i in range(M):
    A[i] = int(A[i])
#print(A , M , N)
for i in range(M):
    N -= A[i]
if N < -1:
    N = -1
print(N)


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

using namespace std;

int n, m;
vector< set< pair<int, int> > > cost(200,set< pair<int,int> >());

int prim()
{
	int res=0;
	set<int> v;
	v.insert(0);
	while(v.size()<n)
	{
		pair<int, int> mini(100000007, -1);
		for(set<int>::iterator it=v.begin();it!=v.end();it++)
		{
			for(set<  pair<int, int> >::iterator it2=cost[*it].begin();it2!=cost[*it].end();it2++)
				if(v.find((*it2).second)==v.end())
				{
					if(mini.first>(*it2).first)
						mini=(*it2);
					break;
				}
		}
		v.insert(mini.second);
		res+=mini.first;
	}
	return res;
}

int main()
{
	while(1)
	{
		cin >> n >> m;
		if(n==0&&m==0) break;
		for(int i=0;i<m;i++)
		{
			int a, b, c;
			cin >> a >> b >> c;
			cost[a].insert(pair<int, int>(c, b));
			cost[b].insert(pair<int, int>(c, a));
		}
		cout << prim() << endl;
		for(int i=0;i<m;i++)
			cost[i].clear();
	}
	return 0;
}

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

	public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			long X = sc.nextLong();
			long A = sc.nextLong();
			long B = sc.nextLong();
			if(B-A <= 0){
				System.out.println("delicious");
			}else if(B-A > 0 && B-A <= X){
				System.out.println("safe");
			}else if(B-A > X){
				System.out.println("dangerous");
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21844
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    int k = 0;
    int i = 0;
    for (i = 0; i < s.size(); ++i) {
        k = i;
        bool ok = true;
        REP(j, t.size()) {
            if (k >= s.size()) break;
            if (s[k] != t[j]) {
                ok = false;
                break;
            }
            k++;
        }
        if (ok) break;
    }
    cout << i + t.size() << endl;
    return 0;
}


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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

ll N, M;
ll a[2*int(1e5)];

bool sat(ll m) {
  ll left = 2*m;
  ll right = 2*N - 1;
  while (left < right) {
    if (a[left] + a[right] < M)  return false;
    left ++;
    right --;
  }
  return true;
}

ll binsch(ll l, ll r) {
  while (l + 1 < r) {
    ll mid = (l + r) / 2;
    if (sat(mid))  r = mid;
    else           l = mid;
  }
  return r;
}

ll calc(ll left, ll right, ll shift, ll res) {
    while (left < right) {
      ll v = a[left] + a[right] - shift;
      DLOG("v %lld", v);
      if (res < v)  res = v;
      left++;
      right--;
    }
    return res;
}

int main() {
  cin >> N >> M;
  for (ll i = 0; i < 2*N; i++)  cin >> a[i];
  sort(a, a+2*N);
  ll border = binsch(-1, N);
  DLOG("border %lld\n", border);
  ll ans = calc(0, 2*border-1, 0, 0);
  ans = calc(2*border, 2*N-1, M, ans);
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
int n;
int a[N], b[N];
int Count(int l,int r){
	return upper_bound(b+1,b+n+1,r) - upper_bound(b+1,b+n+1,l-1);
}
int main(){
	cin >> n;
	for(int i=1;i<=n;i++) cin >> a[i];
	for(int i=1;i<=n;i++) cin >> b[i];
	int ans = 0;
	for(int k=28;k>=0;k--){
		int T = 1<<k;
		for(int i=1;i<=n;i++) a[i] %= (T<<1), b[i] %= (T<<1);
		sort(b+1,b+n+1);
		int cnt = 0;
		for(int i=1;i<=n;i++){
			cnt += Count(T - a[i], (T<<1) - a[i] - 1);
			cnt += Count(T + (T<<1) - a[i], (T<<2) - a[i] - 1);
		}
		if(cnt%2) ans += T;
	}
	cout << ans;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#https://atcoder.jp/contests/abc054/tasks/abc054_b
n,m=mii()

mata=[]
matb=[]

for i in range(n):
    arra=list(ss())
    mata.append(arra)
for i in range(m):
    arrb=list(ss())
    matb.append(arrb)
ans=False
#print(n-m+1)
for i in range(n-m+1):
    for j in range(n-m+1):
        chk=0
        for p in range(m):
            for q in range(m):
                if mata[p+i][q+j]==matb[p][q]:
                    chk+=1

        if chk==m*m:
            ans=True
        
if ans:
    print("Yes")
else:
    print("No")
                

Measured memory_bytes: 65516
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<sstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define make_pair mkp;
const int maxn=2e3+10;

pair<int,int>a[maxn];

ll dp[maxn][maxn];

//下面采用递归的方法进行求解因为我们只需要求解：
//max(dp[l+1][r]+a*|p-l|,dp[l][r-1]+a*|p-r|),a表示当前的值，p表示当前的位置。。。

ll solve(int cnt,int l,int r){//cnt表示的是p数组的下标
	if(l>r)return 0;
	if(~dp[l][r])return dp[l][r];
	ll ans=1LL*a[cnt].first*abs(a[cnt].second-l)+solve(cnt+1,l+1,r);
	ans=max(ans,1LL*a[cnt].first*abs(a[cnt].second-r)+solve(cnt+1,l,r-1));
	return dp[l][r]=ans;
}

int main(){
//区间dp求解，，，采用的方式是首先进行排序之后放在左右断点上面。。。

	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int num;
		cin>>num;
		a[i]={num,i};
	}
	sort(a+1,a+n+1,greater<PII>());
	memset(dp,-1,sizeof(dp));
	cout<<solve(1,1,n)<<endl;
	

	return 0;	
}

Measured memory_bytes: 35324
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/
#define int ll

ll mpow(ll a, int b) {
    if(b < 0)
        return 0;
    ll ans = 1;
    for(; b; b>>=1, a = (a*a%MOD))
        if(b&1)
            ans = (ans * a) % MOD;
    return ans;
}

signed main() {
	EmiliaMyWife

    string s;
    cin >> s;

    int n = s.size();
    ll ans = 0;
    map<char,int> cnt, cnt2;
    for(int i = 0; i < n; i++) {
        cnt[s[i]]++;
    }
    for(int i = 0; i < n; i++) {
        cnt[s[i]]--;
        if(s[i]=='B' || s[i]=='?') {
            ll owo = ((cnt2['A']*mpow(3, cnt2['?'])) + cnt2['?']*mpow(3, cnt2['?']-1))%MOD;
            ll ouo = ((cnt['C']*mpow(3, cnt['?'])) + cnt['?']*mpow(3, cnt['?']-1))%MOD;
            ans = (ans + owo*ouo) % MOD;
        }
        //cout << ans << ' ';
        cnt2[s[i]]++;
    }
    cout <<ans;

	return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int h,w;
    while(cin >> h >> w, h || w){
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if((i+j) % 2 == 0){
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;

  vector<int> v(n), ans;
  rep(i, 0, n) cin >> v[i];

  while (v.size()) {
    bool del = false;
    repr(i, 0, v.size()) {
      if (v[i] == i + 1) {
        ans.push_back(v[i]);
        v.erase(v.begin() + i);
        del = true;
        break;
      }
    }
    if (!del) {
      cout << -1 << endl;
      return 0;
    }
  }

  repr(i, 0, n) cout << ans[i] << endl;
}


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

nm = n % 10
d = ['']*11
d[2] = 'hon'
d[4] = 'hon'
d[5] = 'hon'
d[7] = 'hon'
d[9] = 'hon'

d[0] = 'pon'
d[1] = 'pon'
d[6] = 'pon'
d[8] = 'pon'

d[3] = 'bon'

print(d[nm])


Measured memory_bytes: 61828
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define b_max 100


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int tmp=a;
    int cnt = 0;
    while(1){
        cnt+=1;
        if(cnt == b_max +100) break;
        if(tmp % b ==c){
            cout << "YES" << endl;
            return 0;
        }
        tmp+=a;
    }
    cout << "NO" << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void start()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}
signed main()
{
	start();
	int x,y;
	cin>>x>>y;
	int t=0,c=0;
	if(y&1)
	{
		cout<<"No\n";
		return 0;
	}
	t=(y-(2*x))/2;
	c=x-t;
	if(t>=0 && c>=0 && ((t+c)==x) && ((4*t + 2*c)==y))
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[100010],ans;
vector<long long> v[10010],z;
int main(){
	cin>>n>>m;
	for (int i=1;i<=m;i++) z.push_back(i);
	for (long long i=0;i<n;i++){
		long long x,y;
		cin>>x>>y;
		v[y].push_back(x);
	}
	for (int i=0;i<=10000;i++) sort(v[i].begin(),v[i].end());
	for (int i=10000;i>=0;i--)
		for (long long j=v[i].size()-1;j>=0;j--){
			long long lbound=0,rbound=z.size();
			while (lbound<rbound){
				long long mid=(lbound+rbound)/2;
				if (z[mid]>=v[i][j])
					rbound=mid;
				else
					lbound=mid+1;
			}
			if (z[lbound]>=v[i][j]&&lbound<z.size()){
				ans+=i;
				z.erase(z.begin()+lbound);
			}
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
typedef long ll;
int main(){
   ll a, b, c;
   cin>>a>>b>>c;
   ll k;
   cin>>k;
    ll ans = a;
   if(k<=a){
       ans = k;
       cout<<ans<<endl;
       return 0;
   } 
   k = k-a;
   if(k<=b){
       cout<<ans<<endl;
       return 0;
   }
   k = k-b;
   ans = ans - k;
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3512
import scala.collection.mutable
import scala.util.control.Breaks._

object Main extends App {
  val n = io.StdIn.readInt()
  val an = io.StdIn.readLine().split(' ').map(_.toInt)
  val cache = mutable.Set.empty[Int]
  var ans = "YES"
  breakable {
    for (a <- an) if (cache(a)) {ans = "NO"; break()} else cache(a) = true
  }
  println(ans)
}

Measured memory_bytes: 56172
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

typedef VI vec;
typedef VVI mat;

// mod
int M;

// A*B????¨????
mat mul(mat &A, mat &B) {
  mat C(A.size(), vec(B[0].size()));
  for(int i=0; i<(int)A.size(); ++i) {
    for(int k=0; k<(int)B.size(); ++k) {
      for(int j=0; j<(int)B[0].size(); ++j) {
        C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % M;
      }
    }
  }
  return C;
}

// A*B????¨????
vec mul(mat &A, vec &B) {
  vec C(A.size());
  for(int i=0; i<(int)A.size(); ++i) {
    for(int j=0; j<(int)B.size(); ++j) {
      C[i] = (C[i] + A[i][j]*B[j]) % M;
    }
  }
  return C;
}

// A^n????¨???? m*m?????????n??????O(m^3logn)
// ?????¬???????????¨???????????????????????¢????????§??¨????????°????????????????????§O(m^2logn)??????????????????
mat pow(mat A, ll n) {
  mat B(A.size(), vec(A.size()));
  for(int i=0; i<(int)A.size(); ++i) B[i][i] = 1;
  while(n > 0) {
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}

signed main(void)
{
  while(true) {
    ll n, m, a, b, c, t;
    cin >> n >> m >> a >> b >> c >> t;
    if(!n) break;
    vec s(n);
    REP(i, n) cin >> s[i];

    M = m;
    mat A(n, vec(n));
    REP(i, n) A[i][i] = b;
    REP(i, n-1) A[i+1][i] = a, A[i][i+1] = c;

    A = pow(A, t);
    vec ret = mul(A, s);
    
    REP(i, n) {
      cout << ret[i];
      if(i != n-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3100
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, h = map(int, readline().split())
    a = [0] * n
    b = [0] * n

    for i in range(n):
        a[i], b[i] = map(int, readline().split())

    a_max = max(a)
    b.sort(reverse=True)
    rem = h

    ans = 0

    for x in b:
        if x >= a_max:
            rem -= x
            ans += 1
            if rem <= 0:
                break
        else:
            break
    if rem > 0:
        ans += (rem + a_max - 1) // a_max
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42716
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    //freopen("a.in","r",stdin);
    int n,x;
    scanf("%d%d",&n,&x);
    int x1;
    cin>>x1;
    int gd=abs(x-x1);
    for(int i=2;i<=n;++i)
    {
        int u;
        cin>>u;
        gd=gcd(gd,abs(x-u));
    }
    cout<<gd;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	int N, K;
	string S;
	cin >> N >> K >> S;

	vector<int> a;//個数
	char tmp='1';
	int cnt = 0;

	for (int i = 0; i < N;i++) {
		if (S.at(i) == tmp) {
			cnt++;
		}
		else {
			a.push_back(cnt);
			cnt = 1;
			tmp = S.at(i);
		}
	}

	a.push_back(cnt);
	
	/*///////////////////////////////////////
	for (auto&i:a) {
		cout << i << " ";
	}
	cout << "\n";*/

	int add = K * 2 + 1;
	
	vector<int> sums(a.size()+1);

	for (int i = 0; i < a.size(); i++) {
		sums.at(i + 1) = sums.at(i) + a.at(i);
	}
	
	/*///////////////////////////////////////
	for (auto&i : sums) {
		cout << i << " ";
	}
	cout << "\n";*/

	int left = 0, right = 0;
	int ans = 0;
	
	for (int i = 0; i < a.size(); i+=2) {
		left = i;
		right = min((int)a.size(), i+add);
		int tmp = sums.at(right) - sums.at(left);
		ans = max(ans, tmp);
	}

	cout << ans << "\n";

	return 0;
}

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

int main(){
    cin>>X;
    vector<int> prime;
    prime.push_back(2);
    
    for(int i=3;i<X;i++){
        bool ju=true;
        for(int a=0;a<prime.size();a++){
            if(i%prime.at(a)==0){
                ju=false;
                break;
            }
        }
        if(ju) prime.push_back(i);
    }
    
    int next=X;
    while(true){
        bool kan=true;
        for(int b=0;b<prime.size();b++){
            if(next%prime.at(b)==0){
                kan=false;
                break;
            }
        }
        if(kan){
            
            break;
        }
        next++;
    }
    if(X==2)cout<<2<<endl;
    else cout<<next<<endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
int v;
const int N=1e5+5, mod=((int)1e9+7);
vector<int> g[N];
struct node{
	int b=1, w=1, t=2;
}a[N];
void dfs(int v, int par=-1)
{
	for(auto child : g[v])
	{
		if(child!=par)
		{
			dfs(child, v);
			a[v].b *= a[child].w;
			a[v].b%=mod;
			a[v].w *= a[child].t;
			a[v].w %= mod;
			a[v].t = a[v].b+a[v].w;
			a[v].t%=mod;
		}
	}
}
signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>v;
	for(int i=0; i<v-1; ++i){
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(1, -1);
	cout<<a[1].t;
	return 0;	
}

Measured memory_bytes: 18332