akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W,N;cin>>H>>W>>N;
  vector<int>grid(H*W,-1);
  int l=0;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    for(int j=0;j<a;j++){grid[l]=i+1;l++;}
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i%2)cout<<grid[i*W+j]<<" ";
      else cout<<grid[i*W+W-j-1]<<" ";
    }
    cout<<endl;
  }
}

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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int W[10], K[10], sum, i;
	for(i = 0; i < 10; i++) {
		cin >> W[i];
	}
	for(i = 0; i < 10; i++) {
		cin >> K[i];
	}
	sort(W, W+10);
	sort(K, K+10);
	sum = 0;
	for(i = 0; i < 3; i++) {
		sum += W[9-i];
	}
	cout << sum << " ";
	sum = 0;
	for(i = 0; i < 3; i++) {
		sum += K[9-i];
	}
	cout << sum << endl;

	return 0;

}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long Long;
typedef pair<int,int> PII;

typedef vector<int> VI;

int mem[102][8];
int dp(int ch, int ik, int K, int W) {
	if (ch == 0) return ik == K;
	if (mem[ch][ik] != -1) return mem[ch][ik];
//	cout << string(ik, '\t') << ch << " " << ik << endl;
	int L = (1 << (W - 1));
	Long w = 0;
	for (int i = 0; i < L; ++i) {
		if ( (i >> 1) & i ) continue;
		if (ik < W-1 && ik > 0) {
			int baf = (i >> (ik)) & 1;
			int bbe = (i >> (ik-1)) & 1;
			if (baf) {
				w += dp(ch-1, ik+1, K, W);
			} else if (bbe) {
				w += dp(ch-1, ik-1, K, W);
			} else {
				w += dp(ch-1, ik, K, W);
			}
		} else if (ik < W-1) {
			int b = (i >> (ik)) & 1;
			if (b) {
				w += dp(ch-1, ik+1, K, W);
			} else {
				w += dp(ch-1, ik, K, W);
			}
		} else if (ik > 0) {
			int b = (i >> (ik - 1)) & 1;
			if (b) {
				w += dp(ch - 1, ik - 1, K, W);
			} else {
				w += dp(ch - 1, ik, K, W);
			}
		} else {
			w += dp(ch-1, ik, K, W);
		}
	}
	return mem[ch][ik] = w % 1000000007;

}

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

	int H, W, K;
	cin >> H >> W >> K;
	memset(mem, -1, sizeof(mem));
	cout << dp(H, 0, K-1, W) << endl;

}

/*
QC 8D JD 10S 9D

2D 5D JD KC AC



 */

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

int main() {
	int a, b;
	cin >> a >> b;

	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a*b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void swap(int *a,int *b){

	int tmp;

	tmp=*a;
	*a=*b;
	*b=tmp;
}

void array_swap(int a[],int b[],int n){
	for(int i=0;i<n;i++){
		swap(&a[i],&b[i]);
	}
}

int main(){

	int n,m,k;
	int c[200];
	int tmp[200];

	cin>>n;
	for(int i=0;i<2*n;i++){
		c[i]=i+1;
	}

	cin>>m;
	for(int i=0;i<m;i++){
		cin>>k;
		if(k==0){
			for(int i=0;i<n;i++){
				tmp[i*2]=c[i];
				tmp[i*2+1]=c[n+i];
			}
		}
		else{
			for(int i=0;i<k;i++){
				tmp[2*n-k+i]=c[i];
			}
			for(int i=0;i<2*n-k;i++){
				tmp[i]=c[k+i];
			}
		}
		array_swap(c,tmp,2*n);
	}
	for(int i=0;i<2*n;i++){
		cout<<c[i]<<endl;
	}
}

Measured memory_bytes: 1164
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i64 = int64_t;
using f64 = double;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
if (comp(xmax, x)) {
xmax = x;
return true;
}
return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
if (comp(x, xmin)) {
xmin = x;
return true;
}
return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
cout << a;
if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
print(vec);
  }
}

struct ProconInit {
static constexpr int IOS_PREC = 15;
static constexpr bool AUTOFLUSH = false;

ProconInit() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(IOS_PREC);
if (AUTOFLUSH)
cout << unitbuf;
}
} PROCON_INIT;
#pragma endregion

signed main()
{
	int a,b;
	cin >> a >> b;
	if(a+b>=10){
		print("error");
	}
	else{
		print(a+b);
	}
	return 0;
}


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

int main(int argc, char const *argv[])
{
    int N;
    int K;
    int X;
    int Y;
    cin >> N >> K >> X >> Y;
    int ans = 0;

    if (N <= K)
    {

        for (int i = 1; i <= N; i++)
        {
            ans = ans + X;
        }
    }
    else
    {
        for (int i = 1; i <= K; i++)
        {
            ans = ans + X;
        }

        for (int i = K + 1; i <= N; i++)
        {
            ans = ans + Y;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int h, w; cin>>h>>w;
    vector<string> c(h);
    for(int i=0; i<h; i++) cin>>c[i];

    vector<int> plus;
    vector<int> minus;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(c[i][j] == 'B'){
                plus.emplace_back(j + i);
                minus.emplace_back(j - i);
            }
        }
    }

    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end());

    int ma1 = plus[plus.size() - 1] - plus[0];
    int ma2 = minus[minus.size() - 1] - minus[0];

    cout << max(ma1, ma2) << endl;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for(int i =0;i < n; i++) {
        int a;
        cin >> a;
        pq.push(a);
    }
    for(int i = 0; i < m; i++) {
        int v = pq.top() / 2;
        pq.pop();
        pq.push(v);
    }
    ll ans = 0;
    while(!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	rep(i,n){
		cin>>h[i];
	}
	sort(begin(h),end(h));
	int ans=INF;
	rep(i,n){
		if(i+k-1>=n) break;
		chmin(ans,h[i+k-1]-h[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
// After contest.
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>

using namespace std;

const int maxn = 1002;
const int mo = 1e9 + 7;

int n, m;
long long sum_a[maxn*maxn], sum_b[maxn*maxn];
bool a[maxn*maxn], b[maxn*maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;

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

	for (int i = 0; i < m; ++i)
	{
		cin >> tmp;
		if (b[tmp]) {
			cout << 0 << endl;
			return 0;
		}
		b[tmp] = 1;
	}
	
	long long ans = 1;
	for (int i = n*m; i >= 1; --i) {
		sum_a[i] = sum_a[i+1] + a[i];
		sum_b[i] = sum_b[i+1] + b[i];

		if (a[i] && b[i])
			continue;

		if (a[i])
			ans = ans * sum_b[i] % mo;
		else
			if (b[i])
				ans = ans * sum_a[i] % mo;
			else {
				long long cur = (sum_a[i] * sum_b[i] - (n*m - i)) % mo;
				ans = ans * cur % mo;
			}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
 
using namespace std;
 
int main(){
 
    double x,y,z,maximum,tmp;
 
    while(true){
        scanf("%lf %lf %lf",&x,&y,&z);
        if(x == 0 && y == 0 && z == 0)break;
 
        maximum = 0;
 
        for(double i = 1; i <= z-1; i+=1){
            for(double k = i; k <= z-1; k++){
                if(i+k > z)break;
 
                if(floor(i*(100+x)/100)+floor(k*(100+x)/100) == z){
                    tmp = floor(i*(100+y)/100) + floor(k*(100+y)/100);
                    maximum = max(maximum,tmp);
                }
            }
        }
 
        printf("%.0f\n",maximum);
 
    }
 
    return 0;
}


Measured memory_bytes: 2676
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
//1-indexed
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT():n(-1){}
	BIT(int n_,T a):n(n_),bit(n_+1,a){}

	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
};
main()
{
	int n,q;
	scanf("%d%d",&n,&q);
	BIT<int>a(n,0);
	int c,x,y;
	for(;~scanf("%d%d%d",&c,&x,&y);)
	{
		if(!c)a.add(x,y);
		else printf("%d\n",a.sum(y)-a.sum(x-1));
	}
}



Measured memory_bytes: 3412
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int

	fmt.Scanf("%d", &x)

	for i := -118; i <= 119; i++ {
		for j := -119; j <= 118; j++ {
			if x == int(math.Pow(float64(i), 5)-math.Pow(float64(j), 5)) {
				fmt.Println(i, j)
				return
			}
		}
	}
}


Measured memory_bytes: 1820
# https://atcoder.jp/contests/abc114/tasks/abc114_d
# https://betrue12.hateblo.jp/entry/2018/12/02/224027
# https://coonevo.hatenablog.com/entry/2020/03/18/192431

from collections import defaultdict

MAX_N = 101

def solve():
    n = int(input())
    # dp[i][j]: i番目までの素因数で約数をj個持つ数の個数
    # 2 ~ n までの素因数分解 (これがn!の素因数分解)
    e = [0] * (n + 1)
    for i in range(2, n + 1):
        cur = i
        for j in range(2, i + 1):
            while cur % j == 0:
                e[j] += 1
                cur //= j

    primes = []
    for i in range(n + 1):
        if e[i] > 0:
            primes.append(i)

    dp = [[0] * MAX_N for _ in range(MAX_N)]
    dp[0][1] = 1
    for i in range(len(primes)):
        for j in range(MAX_N):
            for cnt in range(e[primes[i]] + 1):
                dp[i + 1][min(100, j * (cnt + 1))] += dp[i][j]
    print(dp[len(primes)][75])

if __name__ == '__main__':
    solve()

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

using namespace std;
using LL=long long;

int n, k, p[5005], c[5005];
LL ans = -1E18, pre[10005];
bool vis[5005];
vector<int> V;

void getCircle(int x) {
    vis[x] = true;
    int u = x;
    V.clear();
    V.push_back(x);
    while (p[u] != x) {
        V.push_back(p[u]);
        u = p[u], vis[u] = true;
    }
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
        scanf("%d", &p[i]);
    for (int i = 1; i <= n; i++)
        scanf("%d", &c[i]);
    for (int i = 1; i <= n; i++)
        if (!vis[i]) {
            getCircle(i);
            int m = V.size();
            for (int j = 1; j <= m; j++)
                pre[j] = pre[j + m] = c[V[j - 1]];
            for (int j = 1; j <= m * 2; j++)
                pre[j] += pre[j - 1];
            int f = k / m, kk = k % m;
            for (int kkk = 1; kkk <= m && kkk <= k; kkk++)
                for (int o = 0; o <= m; o++)
                    if (pre[m] > 0) {
                        if (kkk <= kk)
                            ans = max(ans, pre[o + kkk] - pre[o] + f * pre[m]);
                        else
                            ans = max(ans, pre[o + kkk] - pre[o] + max(f - 1, 0) * pre[m]);
                    } else
                        ans = max(ans, pre[o + kkk] - pre[o]);
        }
    printf("%lld", ans);
    return 0;
}

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

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

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N;
    cin >> N;
    vi A(N+1, 0);
    for(int i=1;i<=N;i++) {
        cin >> A[i];
    }

    vi B(N+1);
    for(int i=N;i>=1;i--) {
        B[i] = A[i];
        for(int j=2*i;j<=N;j+=i) B[i] ^= B[j];
    }

    int num_boxes = 0;
    for(int i=0;i<=N;i++) {
        if (B[i] == 1) num_boxes ++;
    }

    cout << num_boxes << endl;

    if (num_boxes > 0) {
        for(int i=0;i<=N;i++) {
            if (B[i] == 1) cout << i << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string str, wkStr;
    int cnt;
    int ary[26]= {0};
    
    while(getline(cin, str)){
        cnt = str.length();
    
        for(int i=0; i<cnt; i++){
            wkStr = toupper(str[i]);

            if(wkStr=="A"){
                ary[0]++;
            }else if(wkStr=="B"){
                ary[1]++;
            }else if(wkStr=="C"){
                ary[2]++;
            }else if(wkStr=="D"){
                ary[3]++;
            }else if(wkStr=="E"){
                ary[4]++;
            }else if(wkStr=="F"){
                ary[5]++;
            }else if(wkStr=="G"){
                ary[6]++;
            }else if(wkStr=="H"){
                ary[7]++;
            }else if(wkStr=="I"){
                ary[8]++;
            }else if(wkStr=="J"){
                ary[9]++;
            }else if(wkStr=="K"){
                ary[10]++;
            }else if(wkStr=="L"){
                ary[11]++;
            }else if(wkStr=="M"){
                ary[12]++;
            }else if(wkStr=="N"){
                ary[13]++;
            }else if(wkStr=="O"){
                ary[14]++;
            }else if(wkStr=="P"){
                ary[15]++;
            }else if(wkStr=="Q"){
                ary[16]++;
            }else if(wkStr=="R"){
                ary[17]++;
            }else if(wkStr=="S"){
                ary[18]++;
            }else if(wkStr=="T"){
                ary[19]++;
            }else if(wkStr=="U"){
                ary[20]++;
            }else if(wkStr=="V"){
                ary[21]++;
            }else if(wkStr=="W"){
                ary[22]++;
            }else if(wkStr=="X"){
                ary[23]++;
            }else if(wkStr=="Y"){
                ary[24]++;
            }else if(wkStr=="Z"){
                ary[25]++;
            }
        }    
    }
    
    printf("a : %d\n", ary[0]);
    printf("b : %d\n", ary[1]);
    printf("c : %d\n", ary[2]);
    printf("d : %d\n", ary[3]);
    printf("e : %d\n", ary[4]);
    printf("f : %d\n", ary[5]);
    printf("g : %d\n", ary[6]);
    printf("h : %d\n", ary[7]);
    printf("i : %d\n", ary[8]);
    printf("j : %d\n", ary[9]);
    printf("k : %d\n", ary[10]);
    printf("l : %d\n", ary[11]);
    printf("m : %d\n", ary[12]);
    printf("n : %d\n", ary[13]);
    printf("o : %d\n", ary[14]);
    printf("p : %d\n", ary[15]);
    printf("q : %d\n", ary[16]);
    printf("r : %d\n", ary[17]);
    printf("s : %d\n", ary[18]);
    printf("t : %d\n", ary[19]);
    printf("u : %d\n", ary[20]);
    printf("v : %d\n", ary[21]);
    printf("w : %d\n", ary[22]);
    printf("x : %d\n", ary[23]);
    printf("y : %d\n", ary[24]);
    printf("z : %d\n", ary[25]);
    
}



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

using namespace std;
typedef long long int ll;

ll p(ll x, ll y)
{
    if(y==0)
    return 1;
    else if(y%2)
    return x*p(x, y-1)%1000000007;
    else
    return p(x, y/2)*p(x, y/2)%1000000007;
}
ll yuk(ll x)
{
    return p(x, 1000000005);
}
int main() {
    
    ll k, i, dap=0, length=0, power=1, comb=1, inverse25;
    string s;
    cin>>k;
    cin>>s;
    length=(long long int)s.length();
    
    for(i=1;i<=k;i++)
{
    power*=25;
    power%=1000000007;
    comb*=(length+k-i+1);
    comb%=1000000007;
    comb*=yuk(i);
    comb%=1000000007;
}
inverse25=yuk(25);
    for(i=0;i<=k;i++)
    {
        ll hey;
        hey=(power*comb)%1000000007;
        
        dap+=hey;
        dap%=1000000007;
        power*=inverse25;
        power%=1000000007;
        comb*=(k-i);
        comb%=1000000007;
        comb*=yuk(length+i+1);
        comb%=1000000007;
    }
    
    
    cout<<dap;
    
    return 0;
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C>> X>> Y;
  if(A+B<=2*C) cout<<A*X+B*Y<<endl;
  else {
    if(X<=Y){
      if(B>=2*C) cout<<2*C*Y<<endl;
      else		 cout<<2*C*X+B*(Y-X)<<endl;
    }
    else	{
      if(A>=2*C) cout<<2*C*X<<endl;
      else		 cout<<2*C*Y+A*(X-Y)<<endl;
    }
  }
}
      

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n, h = list(map(int, input().rstrip('\n').split()))
    a = []
    b = []
    for i in range(n):
        ta, tb = list(map(int, input().rstrip('\n').split()))
        a.append(ta)
        b.append(tb)
    ma = max(a)
    b.sort()
    cnt = 0
    for i in range(10 ** 20):
        if len(b) != 0:
            pb = b.pop()
            if pb > ma:
                cnt += 1
                h -= pb
                if h <= 0:
                    print(cnt)
                    exit()
            else:
                cnt += ((h + ma - 1) // ma)
                print(cnt)
                exit()
        else:
            cnt += ((h + ma - 1) // ma)
            print(cnt)
            exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 52316
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

use std::collections::HashMap;

fn main() {
    let v: Vec<u32> = read_vec();
    let (n, m) = (v[0], v[1]);
    let mut map = HashMap::new();
    for _ in 0..m {
        let v2: Vec<u32> = read_vec();
        let (s, c) = (v2[0], v2[1]);

        if map.contains_key(&s) {
            if map.get(&s).unwrap() != &c {
                println!("{}", -1);
                return;
            }
        } else {
            map.insert(s, c);
        }
    }

    if n == 3 {
        for i in 100..1000 {
            if let Some(d1) = map.get(&3) {
                if i % 10 != *d1 {
                    continue;
                }
            }
            if let Some(d2) = map.get(&2) {
                if (i % 100) / 10 != *d2 {
                    continue;
                }
            }
            if let Some(d3) = map.get(&1) {
                if i / 100 != *d3 || *d3 == 0 {
                    continue;
                }
            }
            println!("{}", i);
            return;
        }
    }

    if n == 2 {
        if map.contains_key(&3) {
            println!("{}", -1);
            return;
        }
        for i in 10..100 {
            if let Some(d1) = map.get(&2) {
                if i % 10 != *d1 {
                    continue;
                }
            }
            if let Some(d2) = map.get(&1) {
                if i / 10 != *d2 || *d2 == 0 {
                    continue;
                }
            }
            println!("{}", i);
            return;
        }
    }

    if n == 1 {
        if map.contains_key(&3) || map.contains_key(&2) {
            println!("{}", -1);
            return;
        }
        for i in 0..10 {
            if let Some(d1) = map.get(&1) {
                if i != *d1 {
                    continue;
                }
            }
            println!("{}", i);
            return;
        }
    }

    println!("{}", -1);
}


Measured memory_bytes: 4352
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        System.out.println(roaming(n,k));
    }
    public static int roaming(int n, int k){
        int m = 1_000_000_007;
        BigInteger bigM = BigInteger.valueOf(m);
        if(k>=n-1){
            long factB = 1;
            for (int i = 2; i <= n-1; i++) {
                factB = factB*i%m;
            }
            long topF = 1;
            for (int i = 2*n-1; i >= n+1; i--) {
                topF = topF*i%m;
            }
            return BigInteger.valueOf(topF).multiply(BigInteger.valueOf(factB).modInverse(bigM)).mod(bigM).intValue();
        }else{
            BigInteger s = BigInteger.ONE;
            BigInteger tmp = BigInteger.ONE;
            for (int i = 1; i <= k; i++) {
                tmp = tmp.multiply(BigInteger.valueOf(n-i)).mod(bigM).multiply(BigInteger.valueOf(n-i+1))
                        .multiply(BigInteger.valueOf(i).modInverse(bigM).pow(2));
                s = s.add(tmp).mod(bigM);
            }
            return s.intValue();
        }
    }
}

Measured memory_bytes: 96416
#include <stdio.h>


int gcd(int x, int y)
{
	int tmp, r;
	
	if(x < y)
	{
		tmp = x;
		x = y;
		y = tmp;
	}
	
	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	
	return x;
}


int main(void)
{
	int x, y;
	
	scanf("%d %d", &x, &y);
	
	printf("%d\n", gcd(x, y));
	
	return 0;
}



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

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   
  string s,t;
  cin>>s>>t;
  
  for(int i=0;i<s.size();i++)
  {
      if(s[i]!=t[i])
      {
          cout<<"No"<<endl;
          return 0;
      }
  }
  
  cout<<"Yes"<<endl;

}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

ll power(ll x, ll y, ll p){
   ll res = 1;
   x = x % p;
   while (y > 0) {
      if (y & 1)
         res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
      ll n,x,m; cin >> n >> x >> m;
      map <ll, ll> mp;
      mp[x] = 1;
      ll prev = x;
      ll ans = x;
      std::vector<ll> v;
      v.push_back(x);
      for(ll i = 2; i <= n; i++){
         ll f = (prev * prev) % m;
         if(mp.find(f) != mp.end()){
            ll dist = i - mp[f];
            ll rem = n - i + 1;
            ll val = rem / dist;
            ll tval = 0;
            for(ll j : v){
               if(j == f) break;
               tval += j;
            }
            tval = ans - tval;
            ans += (val * tval);
            for(ll j = mp[f] - 1; j < mp[f] - 1 + (rem % val); j++){
              ans += v[j];
            }
            break;
         }
         mp[f] = i;
         prev = f;
         ans += f;
         v.push_back(f);
      }
      cout << ans << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


Measured memory_bytes: 6764
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define ull unsigned long long
#define IO(x,y) freopen(x,"r",stdin);freopen(y,"w",stdout)
#define fo(x) while(x-->0)
#define nl '\n'
#define pb push_back

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// IO("in.txt", "out.txt");
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	int i;
	for(i=0; i<n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	int dp[3][n];
	dp[0][n-1]=a[n-1];
	dp[1][n-1]=b[n-1];
	dp[2][n-1]=c[n-1];
	for(i=n-2; i>=0; i--){
		dp[0][i]=a[i]+max(dp[1][i+1],dp[2][i+1]);
		dp[1][i]=b[i]+max(dp[0][i+1],dp[2][i+1]);
		dp[2][i]=c[i]+max(dp[0][i+1],dp[1][i+1]);
	}
	cout << max(dp[0][0],max(dp[1][0],dp[2][0]));
}


Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
string s,t;
int main()
{
    cin>>s>>t;
    int lens=s.size();
    int lent=t.size();
    if(lens!=(lent-1)){printf("NO\n");return 0;}
    for(int i=0;i<lens;i++)
    {
        if(s[i]!=t[i])
        {
            printf("No\n");
            return 0;
        }
        if(!(s[i]>='a'&&s[i]<='z'))
        {
             printf("No\n");
            return 0;
        }
         if(!(t[i]>='a'&&t[i]<='z'))
        {
             printf("No\n");
            return 0;
        }

    }
     printf("Yes\n");

}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int sumdig(int a){
    int sum=0;
    while(a>0){
        sum += a%10;
        a /= 10;
    }
    return sum;
}

int main(){
    int n;
    cin >> n;
    int ans = 1000000;
    for(int i=1;i<n;i++){
        int a=i,b=n-i;
        ans = min(ans,sumdig(a)+sumdig(b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vector<bool>IsPrime(MAX+1,true);
    vector<int>Prime(MAX+1,0); //Primearray
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(IsPrime[i]){
            for(int j = 2;i*j<MAX;j++)
                IsPrime[i*j] = false;//?テつエ???テつー??????Primearray???????テつエ??????????????????テつー?????テつィ???false???
            Prime[Primecounter] = i;
            Primecounter++;
        }
    }
    int n;
    while(cin>>n,n){
        int maxi=0;
        for(int i=n; i>=2; i--){
            if(IsPrime[i]&&IsPrime[i-2]){
                cmax(maxi,i);
                break;
            }
        }
        cout<<maxi-2<<" "<<maxi<<endl;
    }
}

Measured memory_bytes: 42968
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <limits>
#include <random>
#include <utility>
#include <vector>

namespace procon {
  class UnionFind {
  private:
    struct nodeinfo {
      int par;
      int rank;
      nodeinfo(int par) : par(par), rank(0) {}
    };
    std::vector<nodeinfo> node;

  public:
    UnionFind(int n) : node() {
      node.reserve(n);
      for (int i = 0; i < n; ++i) {
	node.push_back(nodeinfo(i));
      }
    }
    int root(int x) {
      if (node[x].par == x) {
	return x;
      }
      return node[x].par = root(node[x].par);
    }
    void unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) {
	return;
      }
      if (node[x].rank < node[y].rank) {
	node[x].par = y;
      } else {
	node[y].par = x;
	if (node[x].rank == node[y].rank) {
	  ++node[x].rank;
	}
      }
    }
    bool is_same_set(int x, int y) { return root(x) == root(y); }
  };
}
  
int main(void) {
  int size, n_query;
  std::cin.read((char *)&size, sizeof(int));
  std::cin.read((char *)&n_query, sizeof(int));

  std::vector<uint64_t> query(n_query);
  std::cin.read((char *)query.data(), sizeof(uint64_t) * n_query);

  const int mask = (1 << 30) - 1;

  uint64_t res = 123456789;
  procon::UnionFind uf(size);
  for (uint64_t q : query) {
    const int com = q >> 60;
    const int x = (q >> 30) & mask;
    const int y = (q >> 0) & mask;
    assert(0 <= x && x < size);
    assert(0 <= y && y < size);
    if (com) {
      res = res * 17 + (uf.is_same_set(x, y) ? 1 : 0);
    } else {
      uf.unite(x, y);
    }
  }
  std::cout << res << std::endl;
  return 0;
}



Measured memory_bytes: 89032
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/

ll dist (ll a, ll b, ll x) {
    if ((a-x)*(b-x) < 0) {
        return abs(a-b) + min(abs(a-x), abs(b-x));
    } else {
        return max(abs(a-x), abs(b-x));
    }
}

int main() {
    int a, b; cin >> a >> b;
    int q; cin >> q;
    vector<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];
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    rep(i,q) {
        int ta = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
        int tb = lower_bound(t.begin(), t.end(), x[i]) - t.begin();
        if (ta == a) ta--;
        if (tb == b) tb--;
        // if (ta == 0) ta++;
        // if (tb == 0) tb++;
        // cout << ta << ' ' << tb << endl;
        ll ans = dist(s[ta], t[tb], x[i]);
        if (ta-1 >= 0) chmin(ans, dist(s[ta-1], t[tb], x[i]));
        if (tb-1 >= 0) chmin(ans, dist(s[ta], t[tb-1], x[i]));
        if (ta-1 >= 0 && tb-1 >= 0) chmin(ans, dist(s[ta-1], t[tb-1], x[i]));
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
def actual(A, B, K):
    min_a = A
    max_a = min(A + (K - 1), B)

    min_b = max(B - (K - 1), max_a + 1)
    max_b = B

    left = list(range(min_a, max_a + 1))
    right = list(range(min_b, max_b + 1))

    return '\n'.join(map(str, sorted(set(left + right))))

  
A, B, K = map(int, input().split())
print(actual(A, B, K))

Measured memory_bytes: 9060
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int sum = 0;

        for(int a = 0; a <= 9; a++){
            for(int b = 0; b <= 9; b++){
                for(int c = 0; c <= 9; c++){
                    for(int d = 0; d <= 9; d++){
                        for(int e = 0; e <= 9; e++){
                            if ((n >= 10000*a + 1000*b + 100*c + 10*d + e) && (x <= a+b+c+d+e) && (y >= a+b+c+d+e) ){
                                sum = sum + (10000*a + 1000*b + 100*c + 10*d + e);
                            }
                        }
                    }
                }
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 22612
import itertools

n,m = map(int, input().split())

lights = []
for i in range(m):
    a = list(map(int, input().split()))
    lights.append(a[1:])
ps = list(map(int, input().split()))

def check(status, switches, p):
    cnt = 0
    for s in status:
        if s in switches:
            cnt += 1
    return cnt % 2 == p

total = 0
for status in range(2**n):
    on = []
    for i in range(n):
        if status & 2**i:
            on.append(i+1)
    all_light = True
    for i in range(m):
        if not check(on, lights[i], ps[i]):
            all_light = False
            break
    if all_light:
        total += 1
print(total)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    int ans = 0;
    rep(i, 0, n-2){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            ans++;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    LL k;
    cin >> s >> k;
    int index = -1;
    REP(i,0,s.size()) if (s[i] != '1') {
        index = i;
        break;
    }
    if (index == -1) cout << 1 << endl;
    else if (k <= index) cout << 1 << endl;
    else cout << s[index] << endl;
}

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

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

int main(){

    string n;
    cin >> n;
    int sum = 0;
    for (int i = 0;i < n.size() ;i++){
        sum += n.at(i) - '0';
    }
    int num = stoi(n);
    if (num % sum == 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))


cnt=0

for i in range(1,n-1):
  if p[i]!=max(p[i-1],p[i],p[i+1]) and p[i]!=min(p[i-1],p[i],p[i+1]):
    cnt+=1

print(cnt)

Measured memory_bytes: 8828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define inf 100000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dp[105][4][2];
int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    int K;
    cin >> K;
    dp[0][0][0] = 1;
    rep(i,n)rep(j,4)rep(k,2) {
        int nd = s[i] - '0';
        rep(d,10) {
            int ni = i+1, nj  = j, nk = k;
            if(d != 0) nj++;
            if(nj > K) continue;
            if(k == 0) {
                if(d > nd) continue;
                if(d < nd) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
}



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

using namespace std;

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

    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    int dp[n+1][m+1] = {};

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    int index = dp[n][m]; 
    char lcs[index+1]; 
    lcs[index] = '\0'; 
  
    int i = n, j = m; 
    while (i > 0 && j > 0){ 
        if(s[i-1] == t[j-1]){ 
            lcs[index-1] = s[i-1];  
            i--; j--; index--;    
        } 
        else if(dp[i-1][j] > dp[i][j-1]) 
            i--; 
        else
            j--; 
    } 
  
    cout << lcs << endl;
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=1e6+3;
int s[maxn];
bool mark[maxn];

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>s[i];
    }
    sort(s+1,s+n+1);
    int ans=0;
    for(int i=1;i<=n;++i){
        if(!mark[s[i]]){
            if(s[i+1]!=s[i]){
                //cout<<i<<' '<<s[i]<<endl;
                ans++;
            }
            for(int j=1;j*s[i]<maxn;++j){
                mark[j*s[i]]=true;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

void	calc_prime(int n, vector<bool> &is_prime)
{
	for (int i = 0; i < n; ++i)
		is_prime.at(i) = true;
	is_prime.at(0) = is_prime.at(1) = false;
	for (int i = 2; i < n; ++i) {
		if (!is_prime.at(i)) continue;
		for (int j = 2 * i; j < n; j += i)
			is_prime.at(j) = false;
	}
}

int	main()
{
	int	n;
	cin >> n;
	int	sqrt_n = sqrt(n);
	vector<bool>	is_prime(sqrt_n + 1);
	calc_prime(sqrt_n + 1, is_prime);
	vector<int>	fact_vec;
	int	quotient = n;
	for (int i = 2; i < sqrt_n + 1; ++i) {
		if (!is_prime.at(i)) continue;
		while (!(quotient % i)) {
			fact_vec.push_back(i);
			quotient /= i;
		}
		if (quotient == 1) break;
	}
	cout << n << ":";
	for (int p : fact_vec)
		cout << " " << p;
	if (quotient != 1) 
		cout << " " << quotient << endl;
	else
		cout << endl;
}





Measured memory_bytes: 3156
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    long long int a[10]={};
    for(int i=0;i<s.size();i++){
        a[i]=s[i]-48;
    }
    for(int i=0;i<s.size();i++){
        long long int b=1;
        long long int c=0;
        for(int j=0;j<i;j++,b*=2);
        for(int k=i,l=0;k<s.size();k++,l++){
            if(l==0){
                c=b;
            }else if(l==1){
                c=c*10+b;
                b*=2;
            }else{
                c=c*10+b;
                b*=2;
            }
        }
        a[i]*=c;
    }
    long long int ans=0;
    for(int i=0;i<s.size();i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
a,b,c= list(map(int, input().strip().split()))
N = int(input().strip())
x=0
y=N
if b<=a:
    for i in range(100):
        b*=2
        x=x+1
        y=y-1
        if b>a:
            break

if y<0:
    if c<=b:
        print("No")
    else:
        print("Yes")
else:
    for i in range(y):
        c*=2
    if c<=b:
        print("No")
    else:
        print("Yes")

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

int main() {
  int n;
  cin >> n;
  map<string, int> d;
  rep(i, n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    d[s] += 1;
  }
  ll ans = 0LL;
  for (auto& p : d) {
    int v = p.second;
    ans += (ll)v * (v-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end(), std::less<char>());
  sort(t.begin(), t.end(), std::greater<char>());
  bool result = s < t;
  cout << (result ? "Yes" : "No");
}

Measured memory_bytes: 256
n = int(input())
s = input()
s = sorted(s)
ans = True
if(len(s)>1 and len(s)%2 == 0):
    for i in range(0,len(s),2):
        if(s[i] != s[i+1]):
            ans = False
else:
    ans = False
if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include<cstdio>

using namespace std;

int  check_num(int in){
  int a=1,i=0;
  while(in>=a){
    ++i;
    a*=10;
  }
  if(i==0){
    return 1;
  }
  return i;
}

int main(){
  char input[32];
  
  while(fgets(input,32,stdin)!=NULL){
    int num1,num2;
    sscanf(input,"%d %d",&num1,&num2);    
    
    printf("%d\n",check_num(num1+num2));
  }
  
   
  return 0;
}

Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;

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

int a,b;
cin>>a>>b;
if(2*b>=a)
cout<<0;
else
cout<<a-2*b;




}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tolower(c) char(c+0x20)
#define toupper(c) char(c-0x20)

const ll MAX_N = 100000;
 
int main(void){
    ll a,b,c,d;
    string s,t,u;
 
    cin >> a;// >> b>> c >> d;
    //cin >> s >> t >> u;
    cout << 800 * a - (a / 15) * 200;

    return 0;
}

Measured memory_bytes: 256