akhauriyash/Code-Regression huggingface dataset:
all = list(map(int, input().split()))

N = all[0]
Y = all[1]

yu = -1
hi = -1
no = -1
for i in range(N+1):
    for j in range((N+1)-i):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y==total:
            yu = i
            hi = j
            no = c
            break
        else:
            continue
    else:
        continue 
    break

print(str(yu) + " " + str(hi) + " " + str(no))

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll MOD = 1e9+7;

class mint{
    ll n;
public:
    mint(ll m = 0){
        n = ((m % MOD) + MOD) % MOD;
    }
    mint operator-() const {
        return mint(-n);
    }
    mint& operator+=(const mint& m){
        n += m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator-=(const mint& m){
        n += MOD - m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& m){
        n *= m.n;
        n %= MOD;
        return *this;
    }
    mint operator+(const mint& m) const{
        mint res(*this);
        res += m;
        return res;
    }
    mint operator-(const mint& m) const{
        mint res(*this);
        res -= m;
        return res;
    }
    mint operator*(const mint& m) const{
        mint res(*this);
        res *= m;
        return res;
    }
    mint pow(ll t) const{
        if(t == 0) return mint(1);
        mint m = pow(t>>1);
        m *= m;
        if(t & 1 == 1) m *= *this;
        return m;
    }
    // for prime modulo
    mint inv() const{
        return pow(MOD-2);
    }
    mint& operator/=(const mint& m){
        (*this) *= m.inv();
        n %= MOD;
        return *this;
    }
    mint operator/(const mint& m) const{
        mint res(*this);
        res /= m;
        return res;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.n;
        return os;
    }
};

vector<ll> v;
mint fact[2000000];
mint inv_fact[2000000];

mint comb(ll a, ll b){
    return fact[a] * inv_fact[b] * inv_fact[a-b];
}

int main(){
    ll N,M;
    cin >> N >> M;
    fact[0] = mint(1);
    for(int i=1;i<2000000;i++) fact[i] = mint(i) * fact[i-1];
    for(int i=0;i<2000000;i++) inv_fact[i] = fact[i].inv();
    ll m = M;
    for(int i=2;i*i<=M;i++){
        ll c = 0;
        while(m % i == 0){
            m /= i;
            c++;
        }
        if(c>0) v.push_back(c);
    }
    if(m > 1) v.push_back(1);
    mint ans(1);
    for(auto &e : v){
        ans *= comb(N+e-1,e);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const long long INF = 1LL << 60;
const ll C = 1000000000+7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for(int i=0; i<N; i++) cin >> x[i];

    ll min_time = INF;
    for(int i=0; i<=N-K; i++) {
        ll t1 = abs(x[i]) + abs(x[i+K-1] - x[i]);
        ll t2 = abs(x[i + K - 1]) + abs(x[i+K-1] - x[i]);
        min_time = min(min_time, min(t1, t2));
    }
    cout << min_time << endl;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
const int M=1000000007;
int n,k,i,j,m;
long long ans,f[2005][2005],g[2005][2005],C[2005][2005];
int main()
{
	scanf("%d %d",&n,&m);
	for(i=0;i<=2000;++i)
	{
		g[i][0]=C[i][0]=C[i][i]=1;
		for(j=1;j<i;++j)
		{
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%M;
			g[i][j]=g[i][j-1]+C[i][j];
		}
		if(i!=0)
			g[i][i]=g[i][i-1]+C[i][i];
		for(j=i+1;j<=2000;++j)
			g[i][j]=g[i][j-1];
	}
	for(i=0;i<=2000;++i)
		f[0][i]=1;
	for(i=1;i<=2000;++i)
	{
		f[i][0]=g[i-1][0];
		for(j=1;j<=2000;++j)
			f[i][j]=(f[i][j-1]+g[i-1][j])%M;
	}
	for(i=0;i<=n;++i)
		for(j=0;j<=i&&j<m;++j)
			ans=(ans+C[m-1][j]*f[j][i-j])%M;
	cout<<(ans%M+M)%M;
}


Measured memory_bytes: 93056
from bisect import bisect_left as bl
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    i = 0
    p.sort()
    a = bl(p, x)
    if a == n:
        print(x)
    elif p[a] != x:
        print(x)
    else:
        while(True):
            i += 1
            if p[bl(p, x-i)] != x-i:
                print(x-i)
                break
            else:
                a = bl(p, x+i)
                if a == n:
                    print(x+i)
                    break
                elif p[a] != x+i:
                    print(x+i)
                    break

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

int main() {
  unsigned long long L[87];

  int N;
  cin >> N;

  L[0]=2;
  L[1]=1;

  for (int i=2; i<=N; i++) L[i] = L[i-1] + L[i-2];
  cout << L[N] << endl;
}


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

using ll = long long;

ll test(vector<ll> A) {
	int res = 0;
	int N = int(A.size());
	while (true) {
		pair<ll, int> best(-1ll, -1);
		for (int i = 0; i < N; i++) {
			best = max(best, pair<ll, int>(A[i], i));
		}
		if (best.first < N) break;
		for (int i = 0; i < N; i++) {
			if (best.second == i) {
				A[i] -= N;
			} else {
				A[i] += 1;
			}
		}
		res++;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll K; cin >> K;
	const int N = 50;
	vector<ll> A(N);
	ll cnt = K / N;
	int rem = K - cnt * N;
	assert(cnt * N + rem == K);
	for (int i = 0; i < N; i++) {
		A[i] = i + N * cnt - (N-1) * cnt;
	}
	for (int i = 0; i < rem; i++) {
		A[i] += N;
		for (int j = 0; j < N; j++) {
			if (i != j) {
				A[j] -= 1;
			}
		}
	}
	// assert(test(A) == K);

	cout << N << '\n';
	for (int i = 0; i < N; i++) {
		cout << A[i] << " \n"[i==N-1];
	}

	return 0;
}

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

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = new int[n];
            var sorted = new int[n];
            for (var i = 0; i < n; i++)
            {
                var a = int.Parse(Console.ReadLine());
                ai[i] = a;
                sorted[i] = a;
            }
            Array.Sort(sorted);
            var max = sorted[sorted.Length - 1];
            var second = sorted[sorted.Length - 2];

            for (var i = 0; i < ai.Length; i++)
            {
                if (ai[i] == max) Console.WriteLine(second);
                else Console.WriteLine(max);
            }
        }
    }
}


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

string s;
string t;

int main(){
  
  cin>>s;

  for(int i=0;i<s.size();i++)
    if(s[i]!='x') t+=s[i];

  for(int i=0;i<t.size()/2;i++)
    if(t[i]!=t[t.size()-(i+1)]){
      cout<<-1<<endl;
      return 0;
    }
  
  int l=0, r=s.size()-1;
  
  int ans=0;
  
  while(l<r){
    
    int lcnt=0, rcnt=0;
    
    while(s[l]=='x') lcnt++, l++;
    while(s[r]=='x') rcnt++, r--;
    l++, r--;
    ans+=abs(lcnt-rcnt);
  }

  cout<<ans<<endl;
  
  return 0;
}


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


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b;
    cin >> a >> b;
    if(a % b == 0) cout << 0 << '\n';
    else cout << 1 << '\n';
    return 0;   
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long N, std::vector<long long> a){
    sort(all(a));
    ll ans=0;
    rep(i,N){
        if(i%2==0){
            ans+=a[N-1-i];
        }else{
            ans-=a[N-1-i];
        }
    }
    op(ans);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c;
	string str;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	cout<<max({a+b,2*a-1,2*b-1});




	cout<<endl;
} 


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

using namespace std;
vector<pair<int , bool> > v[17];
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++) {
        int r;
        cin >> r;
        while(r --) {
            int x , y;
            cin >> x >> y;
            v[i].push_back({x , y});
        }
    }
    int ans = 0;
    for(int musk = 0; musk <= pow(2 , n) - 1; musk ++) {
        set<int> st1 , st2;
        int cnt = 0;
        int ch = 1;
        for(int j = 0; j < n; j ++) {
            if((musk>>j)&1) {
                if(st2.count(j+1)) {
                        ch = 0;
                        break;
                    }
                        else {
                            st1.insert(j+1);
                        }
                cnt ++;
                for(int i = 0; i < v[j].size(); i ++) {
                    if(v[j][i].second) {
                        if(st2.count(v[j][i].first)) {
                            ch = 0;
                            break;
                        }
                        else {
                            st1.insert(v[j][i].first);
                        }
                    }
                    else {
                        if(st1.count(v[j][i].first)) {
                            ch = 0;
                            break;
                        }
                        else {
                            st2.insert(v[j][i].first);
                        }
                    }
                }
            }
        }
        if(ch && (int)st1.size() == cnt) {
            ans = max(ans , cnt);
        }
    }
    cout << ans;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;


#define F first
#define S second

#define ERR 1e-9

#if !ONLINE_JUDGE && !EVAL
    #define dbg_var(x) cerr << #x << ": " << x << "\n";
    #define dbg_iter(x, y) cerr  << #x << ": " << print_iterable(x, y) << "\n";
#else
    #define dbg_var(x)
    #define dbg_iter(x, y)
#endif // ONLINE_JUDGE

template <typename T1, typename T2>
string print_iterable( T1 begin_iter, T2 end_iter){
    bool first = true;
    stringstream res;
    res << "[ ";
    for(; begin_iter != end_iter; ++begin_iter){
        if(!first) res << ", ";
        first = false;
        res << *begin_iter;
    }
    res << " ]";
    return res.str();
}

void aggMax(int & res, int x){ if(x > res)res = x; }
void aggMin(int & res, int x){ if(x < res)res = x; }

int II(){ int i; cin >> i; return i; }
void OI(int i){ cout << i; }

// constraints
#define MAXN 1000000

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N = II();
    vi H(N);
    for(auto & x : H) x = II();

    int res = 0, maxx = 0;

    for(int i=0; i<N; i++){
        if(H[i] >= maxx) res++;
        maxx = max(maxx, H[i]);
    }

    OI(res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mod             1000000007
#define rep(i,n)        for (int i = 0; i < n; ++i)
#define REP(i,k,n)      for (int i = k; i < n; ++i)
#define REPR(i,k,n)     for (int i = k; i >= n; --i)
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define pii             pair<int,int>
#define mp              make_pair
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll              long long
#define w(x)            int x; cin>>x; while(x--)
#define mem(a, b)       memset(a, (b), sizeof(a))

void solve() {
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, abs(n % k - k)) << endl;
} 
int main() {
    fast
    solve();
    return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3596
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}

struct UnionFind
{
    int n, num;
    vector<int> sz, par;
    UnionFind() {}
    UnionFind(int n_) : n(n_), num(n_), sz(n_, 1), par(n_, 0) { iota(par.begin(), par.end(), 0); }
    int find(int x)
    {
        return (x == par[x] ? x : par[x] = find(par[x]));
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (sz[x] < sz[y])
            swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
        num--;
    }
    int size(int x)
    {
        return sz[find(x)];
    }
    int count() const
    {
        return num;
    }
};

void main() {
    int n,m;
    R(n,m);
    UnionFind uf(n);
    REP(i,m) {
        int a,b;
        R(a,b);
        --a; --b;
        uf.unite(a,b);
    }
    int ans=0;
    REP(i,n) {
        if ( uf.find(i)==i ) {
            chmax(ans,uf.sz[i]);
        }
    }
    W(ans);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define int long long
#define INF 2e+18
#define MOD 1000000007
using namespace std;

signed main(){
	int n,a,b,x[100001],lst1 = 0,lst2 = 0,dp1[100010] = {},dp2[100010] = {};
	cin >> n >> a >> b;
	for(int i = 0;i < n;i++) cin >> x[i];
	dp1[1] = 1;
	dp2[1] = 1;
	for(int i = 1;i < n;i++){
		int ind = min((int)(upper_bound(x,x + n,x[i] - a) - x + 1),i);
		int tmp = (dp1[i] + dp2[ind] - dp2[min(lst2,ind)] + MOD) % MOD;
		ind = min((int)(upper_bound(x,x + n,x[i] - b) - x + 1),i);
		dp2[i + 1] = (dp2[i] + dp1[ind] - dp1[min(lst1,ind)] + MOD) % MOD;
		dp1[i + 1] = tmp;
		if(x[i] - x[i - 1] < a) lst1 = i;
		if(x[i] - x[i - 1] < b) lst2 = i;
	}
	cout << (dp1[n] - dp1[lst1] + dp2[n] - dp2[lst2] + MOD * 2) % MOD << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int N, X; std::cin >> N >> X;
  std::vector<int> L(N);
  for(int i=0; i<N; i++) std::cin >> L[i];

  std::vector<int> D(N+1);
  D[0] = 0;
  for(int i=0; i<N; i++) D[i+1] = D[i] + L[i];

  int ans = 0;
  for(int i=0; i<=N; i++) {
    if ( D[i] <= X ) ans++;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<tuple>
using namespace std;
int x[10][10], dp[10][10][7];
int sx, sy, gx, gy, H, W;
int main() {
	while (true) {
		cin >> W >> H; if (H == 0 && W == 0)break;
		for (int i = 0; i < 100; i++) {
			x[i / 10][i % 10] = 0;
			for (int j = 0; j < 7; j++)dp[i / 10][i % 10][j] = 1 << 30;
		}
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j]; if (x[i][j] == 2) { sx = i; sy = j; x[i][j] = 1; }
				if (x[i][j] == 3) { gx = i; gy = j; x[i][j] = 1; }
			}
		}
		dp[sx][sy][6] = 0; queue<tuple<int, int, int> >Q; Q.push(make_tuple(sx, sy, 6));
		while (!Q.empty()) {
			int a1 = get<0>(Q.front()), a2 = get<1>(Q.front()), a3 = get<2>(Q.front()); Q.pop();
			int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; if (a3 <= 1)continue;
			for (int i = 0; i < 4; i++) {
				int cx = a1 + dx[i], cy = a2 + dy[i];
				if (x[cx][cy] == 0)continue;
				if (x[cx][cy] == 1 && dp[cx][cy][a3 - 1]>dp[a1][a2][a3] + 1) {
					dp[cx][cy][a3 - 1] = dp[a1][a2][a3] + 1; Q.push(make_tuple(cx, cy, a3 - 1));
				}
				if (x[cx][cy] == 4 && dp[cx][cy][6]>dp[a1][a2][a3] + 1) {
					dp[cx][cy][6] = dp[a1][a2][a3] + 1; Q.push(make_tuple(cx, cy, 6));
				}
			}
		}
		int minx = 1 << 30; for (int i = 1; i < 7; i++) { if (minx>dp[gx][gy][i])minx = dp[gx][gy][i]; }
		if (minx == 1 << 30) { minx = -1; }cout << minx << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
n = int(input())
A = list(map(int, input().split()))
q = int(input())

num_sum = sum(A)
B = [0]*(10**5+1)

for i in A:
    B[i] += 1


for i in range(q):
    b, c = map(int, input().split())
    B[c] += B[b]
    num_sum += (c-b)*B[b]
    B[b] = 0
    print(num_sum)


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

int main(){
	long n,p,l=0,k=1;
  	bool ok=true;
	cin >> n >> p;
  	if(n>40) {
    	cout << 1 << endl;return 0; 
    }
  	vector<long> a(20);
  	vector<long> co(20);
  	a[0]=2;
  	while(p%2==0) {
    	co[0]++;
      	p/=2;
    }
  	long i;
  	for(i =3;i*i<=p;i+=2){
    	while(p%i==0) {
          	if(ok) {
				l++;
              	a[l] = i;
              	ok=false;
            }
            co[l]++;
          	p/=i;
        }
      	ok = true;
    }
  	if(p!=1) {
    	l++;
      	a[l] = p;
      	co[l] = 1;
    }
  	k = (long)pow(2.0, (int)(co[0] / n));
  	for(int j = 1; j<=l; j++) {
    	while(co[j] >= n) {
      		k *= a[j];
          	co[j] -= n;
        } 
	}
	cout << k;
}


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

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

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max() - 1;
constexpr auto llinf = numeric_limits<ll>().max() - 1LL;

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
  for (auto it = st; it != en; it++) {
    cout << *it << " ";
  }
  cout << endl;
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
  for (auto it = st; it != en; it++) {
    cout << (*it).first << ":" << (*it).second << " ";
  }
  cout << endl;
}
template<typename T>
void debug(initializer_list<T> list) {
  for (auto el : list) {
    cout << el << " ";
  }
  cout << endl;
}

constexpr ll mod = ll(1e9 + 7);

ll mult(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }

ll power(ll a, ll b) {
  ll result = 1LL;
  while (b) {
    if (b % 2LL) result = mult(result, a);
    a = mult(a, a);
    b /= 2LL;
  }
  return result;
}

ll divide(ll a, ll b) { return mult(a, power(b, mod - 2)); }

ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }

ll subtract(ll a, ll b) { return ((a - b) % mod + mod) % mod; }



void solve() {
  int n;
  cin >> n;
  vi a(n + 1), b(n + 1), c(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
  vvi memo(n + 1, vi(4, -1));
  memo[0][1] = memo[0][2] = memo[0][3] = 0;
  for (int i = 1; i <= n; i++) {
    memo[i][1] = a[i] + max(memo[i - 1][2], memo[i - 1][3]);
    memo[i][2] = b[i] + max(memo[i - 1][1], memo[i - 1][3]);
    memo[i][3] = c[i] + max(memo[i - 1][1], memo[i - 1][2]);
  }
  cout << *max_element(all(memo[n]));
  cout << "\n";
}

#define REPEAT 0
#define CASE 0

int main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #if REPEAT
    int t;
    cin >> t;
    repa(i, 1, t) {
      #if CASE
        cout << "Case #" << i << ": ";
      #endif
      solve();
    }
  #else
    solve();
  #endif
  return 0;
}


Measured memory_bytes: 9808
from heapq import heappush, heappop
INF = 10 ** 20
while True:
  n, m, p = map(int, input().split())
  if n == 0:
    break
  edges = [[] for _ in range(n)]
  for _ in range(m):
    x, y, w = map(int, input().split())
    edges[x].append((y, w))
    edges[y].append((x, w))
  que = []
  heappush(que, (0, 0))
  shortest_counter = [[0] * n for _ in range(n)]
  shortest_counter[0][0] = 1
  dist = [INF] * n
  dist[0] = 0
  path_counter = [0] * n
  path_counter[0] = 1
  while que:
    total, node = heappop(que)
    count = shortest_counter[node]
    for to, w in edges[node]:
      new_total = total + w
      new_count = [i for i in count]
      new_count[to] += path_counter[node]
      if dist[to] > new_total:
        dist[to] = new_total
        shortest_counter[to] = [i for i in new_count]
        path_counter[to] = path_counter[node]
        heappush(que, (new_total, to))
      elif dist[to] == new_total:
        shortest_counter[to] = [i + j for i, j in zip(shortest_counter[to], new_count)]
        path_counter[to] += path_counter[node]
  for _ in range(p):
    print(shortest_counter[n - 1][int(input())] / path_counter[n - 1])
  print()
 


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int n; cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int ans = 0;
  for(int i = 0; i < n; ++i) for(int j = i+1; j < n; ++j) ans += d[i]*d[j];
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
int main()
{
	string s;
	cin>>s;
	map<char,int>mp;
	for(int i=0;i<(int)s.size();i++)
	{
		mp[s[i]]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++)
	{
		if(it->second % 2==1)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    // Your code here!
    var a = readLine()!!.toInt()
    var b = readLine()!!.toInt()
    var sum = a + b
    
    when(sum){
        3 -> print(3)
        4 -> print(2)
        5 -> print(1)
    }

}


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

int main() {
    int n;
    int x, a[110];
    cin >> n >> x;
    for(int i = 0; i < n; ++i) cin >> a[i];
    
    sort(a, a + n);
    
    int res = 0;
    bool exist_child = false;
    for(int i = 0; i < n; ++i) {
        if(x >= a[i]) {
            x -= a[i];
            ++res;
        }
        else {
            exist_child = true;
            break;
        }
    }
    
    if(x == 0) cout << res << endl;
    else if(exist_child && x > 0) cout << res << endl;
    else cout << res - 1 << endl;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {
    static class Solver {
        MyReader mr = new MyReader();

        public void solve() {
            String fir = mr.next();
            String sec = mr.next();

            int a = mr.nextInt();
            int b= mr.nextInt();

            String u = mr.next();

            if(u.equals(fir))a--;
            else if(u.equals(sec))b--;

            System.out.println(a+" "+b);
        }
    }

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

    static class MyReader {
        BufferedReader br;
        StringTokenizer st;

        MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String res = "";
            try {
                res = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return res;
        }

        Integer[] nextIntArray(int n) {
            Integer[] arr = new Integer[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }

            return arr;
        }

        Long[] nextLongArray(int n) {
            Long[] arr = new Long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }

            return arr;
        }

        String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }

    static void swap(int[] arr, int i, int j) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

}




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

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



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define inf 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define se second
#define fi first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	string s;
	cin>>s;
	int n=s.length();
	for(int i=0;i<n/2;++i)
	{
		if(s[i]!=s[n-i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	// cout<<((n-1)/2)<<"\n";
	for(int i=0;i<((n-1)/2)/2;++i)
	{
		if(s[i]!=s[(n-1)/2-i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)

int main(){
	int r,D,x2000;
	cin >> r >> D >> x2000;
	
	int x=x2000;
	for(int i=1;i<=10;i++){
		x=r*x-D;
		cout << x << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int len;
		if (s.length() % 2 == 0) {
			len = s.length() - 2;
		} else {
			len = s.length() - 1;
		}

		for (int i = len; i > 0; i--) {
			if (s.substring(0, i / 2).equals(s.substring(i / 2, i))) {
				System.out.println(i);
				return;
			}
			i--;
		}
		System.out.println(false);
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> v(h,vector<char>(w,'\0'));
    queue<int> qh,qw;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>v[i][j];
            if(v[i][j]=='#'){
                qh.push(i);qw.push(j);
            }
        }
    }
    int y,x,cnt=qh.size(),ans=0,flag=0;
    while(!qh.empty()){
        cnt--;
        y=qh.front(); x=qw.front();
        qh.pop(); qw.pop();
        for(int i=0;i<4;i++){
            int ny=y+dy[i],nx=x+dx[i];
            if(ny>=0&&ny<h&&nx>=0&&nx<w){
                if(v[ny][nx]=='.'){
                    v[ny][nx]='#';
                    qh.push(ny); qw.push(nx);
                    flag=1;
                }
            }
        }
        if(cnt==0 && flag){
            ans++;
            cnt=qh.size();
            flag=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9472
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,x=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(x<=k){
      x*=2;
    }
    else
      x+=k;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 888
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Arrays;
import java.util.Collections;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a == 5 && b == 7 && c == 5){
            System.out.println("YES");
        }else if(a == 7 && b == 5 && c == 5){
            System.out.println("YES");
        }else if(a == 5 && b == 5 && c == 7){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
	}
}

Measured memory_bytes: 21844
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n;cin>>n;
	while(n)
	{
		ll d = n%10;
		if(d==7)
		{
			cout<<"Yes\n";
			return 0;
		}
		n/=10;
	}
	cout<<"No\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    for(int i=0;i<tx-sx;i++){
        cout<<"R";
    }
    for(int i=0;i<ty-sy;i++){
        cout<<"U";
    }
    for(int i=0;i<tx-sx;i++){
        cout<<"L";
    }
    for(int i=0;i<ty-sy;i++){
        cout<<"D";
    }
    cout<<"D";
    for(int i=0;i<tx-sx+1;i++){
        cout<<"R";
    }
    for(int i=0;i<ty-sy+1;i++){
        cout<<"U";
    }
    cout<<"L";
    cout<<"U";
    for(int i=0;i<tx-sx+1;i++){
        cout<<"L";
    }
    for(int i=0;i<ty-sy+1;i++){
        cout<<"D";
    }
    cout<<"R"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





ll A, B, C;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B >> C;

    ll ans = 0;

    int x = min(B, C);

    ans += 2LL * x;
    B -= x;
    C -= x;

    x = min(A, C);
    ans += x;
    A -= x;
    C -= x;

    ans += B;

    if (C) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define endl '\n'
//#define int long long


signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int n; cin >> n;
        map<string,int> freq;
        set<string> vec;
        int mx = 0;
        while (n--) {
                string str; cin >> str;
                mx = max(mx, ++freq[str]);
                vec.emplace(str);
        }
        vector<string> ans;
        for (const auto w: vec) {
                if (freq[w] == mx) ans.emplace_back(w);
        }


        for (const auto w: ans)
                cout << w << endl;



        return 0;
}

/*

*/

Measured memory_bytes: 34928
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for (int i = -100; i <= 100; i++) {
			int tmp = 0;
			for (int j = 0; j < n; j++) {
				tmp += (int) Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, tmp);
		}
		System.out.println(ans);
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int count = 0; 
  for(int i=a; i<=b; i++) {
    string s = to_string(i);
    if(s.at(0) == s.at(4) && s.at(1) == s.at(3)) {
      count++;
    }
  }
  cout << count << endl;
}

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

int main(){
    int n;
    cin >> n;
    string S[n];
    for(int i=0; i<n; i++){
        cin >> S[i];
    }

    int A;
    A= (int) 'z' - 'a' + 1;
    int list[A]={0};

    for(int i=0; i<n; i++){
        int list_tmp[A]={0};
        for(int j=0; j<S[i].size(); j++){
            list_tmp[ (int) S[i][j] - 'a' ]+=1;
        }
        if( i==0 ){
            for(int k=0; k<A; k++){
                list[k]=list_tmp[k];
            }
        }else{
            for(int k=0; k<A; k++){
                if( list[k]>list_tmp[k] ){
                    list[k]=list_tmp[k];
                }
            }
        }
    }

    for(int i=0; i<A; i++){
        for(int j=0; j<list[i]; j++){
            cout << (char) ( (int) 'a' + i );
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
int main()
{
    int s[100001], t[50001];
    int n,q;
    int i,j;
    int count = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &s[i]);

    scanf("%d", &q);
    for (i = 0; i < q; i++) scanf("%d", &t[i]);
    
    for (i = 0; i < q; i++){ //compare t to s
        int left = 0;
        int right = n;
        while (left < right){
            int mid = (left + right)/2;
            if (t[i] == s[mid]){    //found
                count++;
                break;
            }
            if (t[i] > s[mid]){    //right
                left = mid + 1;
            }
            else if(t[i] < s[mid]){   //left
                right = mid;
            }
        }
    }
    printf("%d\n", count);
}


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

int main() {
    int A, B;
    cin >> A >> B;

    int sum, sub, mul;
    sum = A + B;
    sub = A - B;
    mul = A * B;

    cout << std::max(std::max(sum, sub), mul) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void call(int n) {
  int x;
  int i = 1;

  do {
    x = i;
    if(x % 3 == 0) {
      printf(" %d", i);
    } else {
      do {
        if(x % 10 == 3) {
          printf(" %d", i);
          x = 0;
        }
        x /= 10;
      } while(x);
    }
  } while(++i <= n);
  printf("\n");
}

int main(){
  int n;

  scanf("%d", &n);
  call(n);
}



Measured memory_bytes: 2132
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

#define f first
#define s second
#define INF (1<<29)

using namespace std;

typedef pair<double,double>pii;

double dist(pii a,pii b){
  return sqrt(pow(a.f-b.f,2)+pow(a.s-b.s,2));
}

const double EPS=1e-10;

double dot(pii a,pii b){
  return a.f*b.f+a.s*b.s;
}

double cross(pii a,pii b){
  return a.f*b.s-a.s*b.f;
}

double norm(pii a){
  return sqrt(a.f*a.f+a.s*a.s);
}

int ccw(pii a, pii b, pii c) {
  b.f -= a.f; 
  b.s -= a.s; 
  c.f -= a.f;
  c.s -= a.s;
  if (cross(b, c) > 0)   return +1;
  if (cross(b, c) < 0)   return -1;
  if (dot(b, c) < 0)     return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}

bool isCross(pii a1,pii a2,pii b1,pii b2){
  return ccw(a1,a2,b1)*ccw(a1,a2,b2)<=0 &&
    ccw(b1,b2,a1)*ccw(b1,b2,a2)<=0;
}

int main(void){
  
  int na,nb;
  cin >> na >> nb;
  
  vector<pii>a(na),b(nb);
  
  for(int i=0;i<na;i++)cin >> a[i].f >> a[i].s;
  for(int i=0;i<nb;i++)cin >> b[i].f >> b[i].s;
  
  double ans=isCross(a[0],a[1],b[0],b[1])?INF:dist(a[0],a[1])+dist(b[0],b[1]);
  for(int i=2;i<na;i++){
    double d=dist(a[0],a[i])+dist(a[i],a[1]);
    if(!isCross(a[0],a[i],b[0],b[1]) && 
       !isCross(a[i],a[1],b[0],b[1]))ans=min(ans,d+dist(b[0],b[1]));
    
    for(int j=2;j<na;j++){
      if(!isCross(a[0],a[i],b[0],b[1]) &&
	 !isCross(a[i],a[j],b[0],b[1]) &&
	 !isCross(a[j],a[1],b[0],b[1]))
	ans=min(ans,dist(a[0],a[i])+dist(a[i],a[j])+dist(a[j],a[1])+dist(b[0],b[1]));
    }
  }
  
  for(int i=2;i<nb;i++){
    double d=dist(b[0],b[i])+dist(b[i],b[1]);
    if(!isCross(b[0],b[i],a[0],a[1]) &&
       !isCross(b[i],b[1],a[0],a[1]))ans=min(ans,d+dist(a[0],a[1]));
    
    for(int j=2;j<nb;j++){
      if(!isCross(b[0],b[i],a[0],a[1]) &&
	 !isCross(b[i],b[j],a[0],a[1]) &&
	 !isCross(b[j],b[1],a[0],a[1]))
	ans=min(ans,dist(b[0],b[i])+dist(b[i],b[j])+dist(b[j],b[1])+dist(a[0],a[1]));
    }    
  }
  
  if(ans==INF)cout << -1 << endl;
  else {
    printf("%.9f",ans);
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1308
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }




void solve(){
    ll h,n,a[1010],b[1010];
    cin>>h>>n;
    rep(i,n) cin>>a[i]>>b[i];
    ll dp[1100][10100];
    rep(i,n+2)rep(j,h+2) dp[i][j]=LLINF;
    rep(i,n+1) dp[i][0]=0;
    rep(i,n){
        rep(j,h+1){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            if(j>=a[i]) dp[i+1][j]=min(dp[i+1][j],dp[i+1][j-a[i]]+b[i]);
        }
    }
    ll ans=dp[n][h];
    rep(j,h){
        rep(i,n){
            if(j+a[i]>=h) chmin(ans,dp[n][j]+b[i]);
        }
    }
    cout<<ans<<endl;
    // cout<<"--"<<endl;
    // cout<<"     ";
    // rep(j,h+1) cout<<j<<" ";
    // cout<<endl;
    // rep(i,n+1){
    //     cout<<"i: "<<i<<" ";
    //     rep(j,h+1){
    //         if(dp[i][j]==LLINF) cout<<"x ";
    //         else cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    

}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


Measured memory_bytes: 82684