akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll min3(ll a, ll b, ll c){
    if(a < b){
        if(b < c) return a;
        else{
            if(a < c) return a;
            else return c;
        }
    }else{
        if(b < c) return b;
        else return c;
    }
}

int main(){
    ll h,w; cin >> h >> w;
    ll c[h][w];
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    vvl masu(h+1, vl(w+1,0));
    REP(i,1,h+1){
        REP(j,1,w+1){
            if(c[i-1][j-1] == 1) masu[i][j] = 0;
            else masu[i][j] = masu[i-1][j] + 1;
        }
    }
    ll mx = 0;
    stack<P> st;
    for(ll i=h; i>0; i--){
        for(ll j=w; j>0; j--){
            if(j==w) st.emplace(masu[i][j],w);
            else{
                if(st.empty() || masu[i][j] > masu[i][j+1]){
                    st.emplace(masu[i][j],j);
                }else if(masu[i][j] < masu[i][j+1]){
                    ll index;
                    while(!st.empty()){
                        if(st.top().first < masu[i][j]){
                            st.emplace(masu[i][j],index);
                            break;
                        }
                        auto t = st.top(); st.pop();
                        index = t.second;
                        mx = max(mx, t.first * (t.second - j));
                        //cout << mx << " " << i << j << endl;
                    }
                    if(st.empty()) st.emplace(masu[i][j],index);
                }
            }
        }
        //cout << st.size() << endl;
        while(!st.empty()){
            auto t = st.top(); st.pop();
            mx = max(mx, t.first * t.second);
        }
    }
    cout << mx << endl;
}


Measured memory_bytes: 33424
#C
KN = input().split(' ')
K = int(KN[0]) ; N = int(KN[1])
Ai = input().split(' ')
#Ai = Ai.sort()

AnoSa = []

for k in range(N-1):
    AnoSa.append(int(Ai[k + 1]) - int(Ai[k]))
if K - max(AnoSa) > int(Ai[N-1]) - int(Ai[0]):
    print(int(Ai[N-1]) - int(Ai[0]))
else:
    print(K - max(AnoSa))

Measured memory_bytes: 19052
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int n;
ll k;
vint a;

bool check(ll x) {
    ll res = 0;
    rep(i,n-1) {
        if (a[i] < 0) {
            ll comp;
            if (x >= 0) comp = x/a[i];
            else comp = (-x+(-a[i])-1)/(-a[i]);
            int n = a.end()-lower_bound(a.begin()+i+1,a.end(),comp);
            res += n;
            // cout << res << 'y' << endl;
        }
        if (a[i] == 0) {
            if (x >= 0) res += n-1-i;
            // cout << res << endl;
        }
        if (a[i] > 0) {
            ll comp;
            if (x >= 0) comp = x/a[i];
            else comp = (x+a[i]-1)/a[i];
            int n = upper_bound(a.begin()+i+1,a.end(),comp)-(a.begin()+i+1);
            res += n;
            // cout << res << "c" << endl;
        }
    }
    // cout << res << endl;
    if (res >= k) return true;
    else return false;
}

int main() {
    cin >> n >> k;
    a.resize(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    // check(6);
    ll l = -inf_l-1;
    ll r = inf_l+1;
    while (r-l > 1) {
        ll mid = (l+r)/2;
        // cout << "mid" << mid << endl;
        if (check(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m, len;
  scanf("%d%d%d", &n, &m, &len);
  map<ii, int> cnt;
  while (len--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    for (int i = -1; i <= 1; ++i) {
      for (int j = -1; j <= 1; ++j) {
        int nx = x + i, ny = y + j;
        if (nx < 1 || nx >= n - 1 || ny < 1 || ny >= m - 1) continue;
        cnt[{nx, ny}]++;
      }
    }
  }
  vector<int64> ret(10);
  for (auto& it : cnt) {
    ret[it.second]++;
  }
  ret[0] = (int64)(n - 2) * (m - 2);
  for (int i = 1; i < 10; ++i) ret[0] -= ret[i];
  for (int i = 0; i < 10; ++i) {
    printf("%lld\n", ret[i]);
  }
  return 0;
}


Measured memory_bytes: 56448
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans = (100 * a + 10 * b + c) % 4;
  if (ans == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

int solve(int a, int b){
    if(a >= 10 || b >= 10){
        return -1;
    }else{
        return a * b;
    }
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int a, b;
    cin >> a >> b;
    cout << solve(a, b) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *h = new int[n + 1];
  int *dp = new int[n + 1];
  dp[1] = 0;
  dp[0] = -1;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  dp[2] = abs(h[1] - h[2]);
  for (int i = 3; i <= n; i++) {
    dp[i] =
        min(abs(h[i - 1] - h[i]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
  }

  cout << dp[n] << endl;
}

Measured memory_bytes: 4412
#include <stdio.h>
#include <limits.h>

int n;
int x[100];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&x[i]);
    int min=INT_MAX;
    for(int i=1;i<=100;i++)
    {
        int tmp=0;
        for(int j=0;j<n;j++)
        {
            tmp+=(x[j]-i)*(x[j]-i);
        }
        if(tmp<min) min=tmp;
    }
    printf("%d\n",min);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int A = cin.nextint;
        int B = cin.nextint;
        WriteLine($"{Math.Min(A, B)} {Math.Max(0, A + B - N)}");
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 100005, MAX_M = 200010;
// code
//#define int long long

int x[MAXN];
int sps[MAXN][20];
int n, q, l;
void Solve() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i];
    cin >> l >> q;
    int jump = n;
    for (int i = n; i >= 1; i--){
		while(x[jump] - x[i] > l) jump--;
		sps[i][0] = jump;
    }
    for (int d = 1; d <= 19; d++){
        for (int i = 1; i + (1 << d) <= n; i++)
            sps[i][d] = sps[ sps[i][d-1] ][d-1];
    }
    while (q--){
        int a, b, ans = 0;
        cin >> a >> b;
        if (a > b) swap(a, b);
        for (int d = 19; d >= 0; d--){
            if (sps[a][d] < b && sps[a][d]){
                a = sps[a][d];
                ans += (1 << d);
            }
        }
        ans ++;
        cout << ans << endl;
    }
}

signed main(){
    FAST_IO;
    int TC = 1; 
	//cin >> TC;
    while(TC--) Solve();
    return 0;
}


Measured memory_bytes: 11788
#include <iostream>
#include <cstdint>
#include <cmath>

using namespace std;

int main(){
    uint64_t a;
    double c;
    cin >> a >> c;
    uint64_t b = static_cast<int64_t>(round(c * 100));
    cout << (a*b)/100 << '\n';
}


Measured memory_bytes: 3768
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int tmp;
        if (a>b) {
            tmp = a;
            a = b;
            b = tmp;
        }
        if (b>c) {
            tmp = b;
            b = c;
            c = tmp;
        }
        if (a>b) {
            tmp = b;
            b = a;
            a = tmp;
        }
        System.out.println(a+" "+b+" "+ c);
    }
}


Measured memory_bytes: 26152
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	vector<int>arr(n);
	int sum = 0;
	int dp[n+2];
	for(int i=0;i<n;i++){cin>>arr[i];}
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	dp[2] = (dp[1]+abs(arr[2]-arr[1]));
	for(int i=0;i<n;i++){
		dp[i+1] = min(dp[i+1],dp[i]+abs(arr[i]-arr[i+1]));
		dp[i+2] = abs(dp[i] + abs(arr[i+2] - arr[i]));
	}
	cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
using namespace std;
typedef long long LL;
typedef map<LL,LL> LLm;
typedef LLm::iterator LLit;
LL h,w,n;
LLm m;
LLit it;
LL ans[10];
LL dx[9]={-2,-2,-2,-1,-1,-1,0,0,0};
LL dy[9]={-2,-1,0,-2,-1,0,-2,-1,0};
void slove(LL x,LL y){
    LL a,b;
    LL temp;
    for(int i=0;i<9;++i){
        a=x+dx[i];
        b=y+dy[i];
        if(a<1 || b<1 || a>h-2 || b>w-2)   continue;
		temp=(w-2)*(a-1)+b;
        temp=(h-2)*(b-1)+a;//对每个小矩形进行编号
		//左上角的位置就只能在(h-2)*(w-2)的矩形区域内
		//每一行有w-2个元素 a-1
        m[temp]++;
    }
}
int main(){
    LL x,y;
    cin>>h>>w>>n;
    for(LL i=0;i<n;++i){
        cin>>x>>y;
        slove(x,y);
    }
    ans[0]=(h-2)*(w-2);//总数
    LL temp;
    for(it=m.begin();it!=m.end();++it){
        temp=it->second;
        ans[temp]++;
        ans[0]--;
    }
    for(LL i=0;i<=9;++i)
        cout<<ans[i]<<endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

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

  ll n, k;
  cin >> n >> k;
  vector < ll > a(n), f(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> f[i];

  sort(a.begin(), a.end());
  sort(f.begin(), f.end());

  ll lo = 0, hi = 1e12;
  ll ans = LLONG_MAX;
  while(lo <= hi){
    ll mid = (hi - lo) / 2 + lo;
    ll cnt = 0;
    for(int i = 0; i < n; i++){
      cnt += max((ll)0, a[i] - (mid / f[n - i - 1]));
    }
    if(cnt <= k){
      hi = mid - 1;
      ans = min(ans, mid);
    }
    else lo = mid + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n,m;
    cin>>n;
    if(n>-1&&n<1200)
    {

        cout<<"ABC"<<endl;
    }
    else if(n>1199&&n<2800)
    {

        cout<<"ARC"<<endl;
    }
    else if(n>2799&&n<4209)
    {
        cout<<"AGC"<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
using namespace std;

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

int main() {

	int N;
	cin >> N;
	string S;
	cin >> S;

	if (N % 2 != 0) { cout << "No" << endl; return 0; }
	REP(i, N / 2) {
		if (S[i] != S[N / 2 + i]) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) // gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
using namespace std;

int main(){          
    ll n , sum = 0 , sum1  = 0 , temp1 , maxi = -1e18 , i;
    cin>>n;
    
    ll a[n+1] , b[n+1];
    p_q < ll > q;
    priority_queue<ll, vector<ll>,greater<ll> > q1;
    
    ll temp = 3*n;
    vi v(temp);
    
    rep(i,0,temp)
        cin>>v[i];
    
    rep(i,0,n){
        sum = sum + v[i];
        q1.push(v[i]);
    }
    a[0] = sum;
    
    rep(i,n,2*n){
        sum = sum + v[i];
        //cout<<sum<<"\n";
        q1.push(v[i]);
        temp1 =  q1.top();
        //cout<<temp1<<" ";
        q1.pop();
        sum = sum - temp1;
        a[(i+1) - n] = sum; 
    }
    //cout<<"\n";
   // rep(i,0,n+1){
    //    cout<<a[i]<<" ";
    //}
    cout<<"\n";
    for (i=temp - 1;i >= 2*n ;i--){
        sum1 = sum1 + v[i];
        q.push(v[i]);
    }
    b[0] = sum1;
    
    for (i=2*n - 1;i>=n;i--){
        sum1 = sum1 + v[i];
        q.push(v[i]);
        temp1 = q.top();
        q.pop();
        sum1 =  sum1 - temp1;
        b[(2*n - i)] = sum1; 
    }
  //  rep(i,0,n+1)
    //    cout<<b[i]<<" ";
    //cout<<"\n";
    
    rep(i,0,n+1){
        if ((a[i] - b[n-i]) > maxi)
            maxi = a[i] - b[n-i];
    }
    cout<<maxi;
    
        
    
    
}
  


Measured memory_bytes: 5876
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int cnt = 0;
    string s;
    cin >> s;
    rep(i, n) {
        if(s[i] == '1') cnt++;
    }

    if(cnt == 0 or cnt == 1){
        if(cnt == 0) {
            rep(i, n) {
                cout << 1 << endl;
            }
            return 0;
        } else {
            if(s[n-1] == '1') {
                rep(i, n-1) {
                    cout << 2 << endl;
                }
                cout << 0 << endl;
            } else {
                rep(i, n-1) {
                    if(s[i] == '1') cout << 0 << endl;
                    else cout << 1 << endl;
                }
                cout << 2 << endl;
            }
            return 0;
        }
    }

    vi sum(2);
    rep(i, n) {
        sum[0] *= 2;
        sum[1] *= 2;
        sum[0] %= (cnt+1);
        sum[1] %= (cnt-1);
        if(s[i] == '1') {
            sum[0] += 1;
            sum[1] += 1;
        }
    }

    rep(i, n) {
        int x = 0;
        if(s[i] == '1') {
            x = 1;
        }
        ll ss = sum[x];
        function<int(int)> pow = [&](int t) {
            if (!t) return 1;
            int a = pow(t>>1);
            a = ll(a)*a%(cnt+1-x*2);
            if (t&1) a *= 2;
            a %= (cnt+1-x*2);
            return a;
        };
        if(x) {
            ss -= pow(n-i-1);
            ss = (ss+(cnt+1-x*2))%(cnt+1-x*2);
            int res = 1;
            while(ss) {
                ss %= __builtin_popcountll(ss);
                res++;
            }
            cout << res << '\n';
        } else {
            ss += pow(n-i-1);
            ss = (ss+(cnt+1-x*2))%(cnt+1-x*2);
            int res = 1;
            while(ss) {
                ss %= __builtin_popcountll(ss);
                res++;
            }
            cout << res << '\n';
        }
    }
}

Measured memory_bytes: 3776
#include<iostream>
#include<vector>

template<class Container>
auto print(const Container&c) {

	auto it = std::begin(c);
	auto end_ = std::end(c);

	if (it != end_) {
		std::cout << (*it);
	}

	++it;
	for (; it != end_; ++it) {
		std::cout << " " << (*it);
	}std::cout << "\n";
	
}

int main() {

	int N{};
	std::cin >> N;
	std::vector<int> v;
	
	for (int i{ 0 }; i < N; i++) {
		int tmp{};
		std::cin >> tmp;
		v.emplace_back(tmp);
	}

//	print(v);

	int c{0};
	for (int i{ 0 }; i < N; i++) {
		int mini = i;
		for (int j{ i }; j < N; j++) {
			
			if (v[j] < v[mini]) {
				mini = j;//index of minimum value
//				std::cout << "i, j = " << i << " " << j << "\n";
			}
		}
		if (i == mini)continue;// It is no-mean to swap it and itself.
//		std::cout << "swapped:" << v[i] << " and " << v[mini] << "\n";
		std::swap(v[i], v[mini]);//swap to index i and minimum
		c++;
	}

//	std::cout << v[0];
	print(v);
	std::cout << c << "\n";
	
	int n;
	std::cin >> n;
}


Measured memory_bytes: 3160
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    long long int h,w;
    cin >> h >> w;
    if(h == 1 || w == 1)cout << 1;
    else cout << (h*w+1)/2 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 9 && b <= 9)
	{
		cout << a * b << endl;
	}
	else
	{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            var pr = new PrimeList(55555);
            var L = pr.GetPrimeList();

            int index = 1;
            for(var i = 0; i < N; i++)
            {
                while (true)
                {
                    if (L[index] % 5 == 1)
                    {
                        Console.Write($"{L[index]} ");
                        index++;
                        break;
                    }
                    index++;
                }
            }

            Console.WriteLine();



            
            
            //Console.Out.Flush();
        }

        
    }

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

    public class PrimeList
    {
        private bool[] isprime;
        private List<int> primelist;

        public PrimeList(int n)
        {
            if (n < 2) { return; }
            primelist = new List<int>();
            isprime = new bool[n + 1];
            for (var i = 0; i <= n; i++)
            {
                isprime[i] = i != 0 && i != 1;
            }

            for (var i = 2; i <= n; i++)
            {
                if (!isprime[i]) { continue; }
                primelist.Add(i);

                int c = i;
                while (c + i <= n)
                {
                    c += i;
                    isprime[c] = false;
                }
            }
        }

        public bool IsPrime(int n)
        {
            return isprime[n];
        }

        public List<int> GetPrimeList()
        {
            return primelist;
        }

    }
}


Measured memory_bytes: 13136
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 500003;
int n, fen[26][N];
string s;

void upd(int c, int x, int y) {
    for (; x <= n; x |= (x + 1)) {
        fen[c][x] += y;
    }
}

int get(int c, int x) {
    int res = 0;
    for (; x >= 0; x = (x & (x + 1)) - 1) {
        res += fen[c][x];
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    int q;
    cin >> n >> s >> q;
    for (int i = 1; i <= n; i++) {
        upd(s[i - 1] - 'a', i, 1);
    }
    while (q--) {
        int tp;
        cin >> tp;
        if (tp == 1) {
            int pos;
            char c;
            cin >> pos >> c;
            upd(s[pos - 1] - 'a', pos, -1);
            s[pos - 1] = c;
            upd(s[pos - 1] - 'a', pos, 1);
        }   else {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                if (get(i, r) - get(i, l - 1)) {
                    ans++;
                }
            }
            cout << ans << '\n';
        }
    }
}


Measured memory_bytes: 51740
from collections import deque

n = int(input())
a = []
for i in range(n):
    ai = list(map(int, input().split()))
    a.append([tuple(sorted((i, aij - 1))) for aij in ai])

idx = [0] * (n + 1)
pool = set()
q = deque([ai[0] for ai in a])
day = 1
s = set()

while q:
    # print('-' * 30)
    # print('pool:', pool)
    # print('s:', s)
    # print('q:', q)
    p = q.popleft()
    if p not in pool:
        pool.add(p)
    else:
        pool.remove(p)
        x, y = p
        idx[x] += 1
        idx[y] += 1

        if x in s or y in s:
            day += 1
            s = {x, y}
        else:
            s.add(x)
            s.add(y)

        if idx[x] < n - 1:
            q.append(a[x][idx[x]])
        if idx[y] < n - 1:
            q.append(a[y][idx[y]])

# print('=' * 20)
if pool:
    print(-1)
else:
    print(day)

Measured memory_bytes: 99532
import sys
input = sys.stdin.readline

def main():
    N, Z, W = map(int, input().split())
    A = list(map(int, input().split()))
    INF = 10**12

    ans = 0
    for i in range(N-1):
        s = INF
        for j in range(i+1, N):
            if j < N-1:
                s = min(s, abs(A[j]-A[N-1]))
            else:
                s = min(s, abs(A[j]-A[i]))
        ans = max(s, ans)

    ans = max(ans, abs(A[N-1]-W))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

bool solve(){
    ll N;
    cin >> N;
    map<ll, ll> ma;
    ll a;
    for(ll i = 0; i < N; i++){
        cin >> a;
        ma[a]++;
    }
    if(ma.size() == 1){
        if(a == N - 1 || a <= N / 2) return 1;
        else return 0;
    }else if(ma.size() > 2){
        return 0;
    }
    vector<P> v;
    for(auto p : ma) v.push_back(p);
    sort(v.begin(), v.end());
    if(v[0].first != v[1].first - 1) return 0;
    if(v[1].second < 2) return 0;
    if(v[0].second + 1 <= v[0].first + 1 && v[0].first + 1 <= v[0].second + v[1].second / 2) return 1;
    else return 0;
}

int main(){
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 6528
N,W = map(int,input().split())
L = list(list(map(int,input().split())) for i in range(N))

dp = [[0 for x in range(W+1)] for y in range(N+1)]

for i in range(N) :
    weight_i,value_i = L[i]
    for weight in range(W+1) :
        if weight-weight_i >= 0 :
            dp[i+1][weight] = max(dp[i][weight-weight_i]+value_i, dp[i][weight])
        else :
            dp[i+1][weight] = dp[i][weight]

ans = dp[N][W]
print(ans)


Measured memory_bytes: 172040
h,w=map(int,input().split())
point=[0]*w
a=[]
for _ in range(h):
    x=input()
    if x.count("#")!=0:
        a.append(x)
        for i in range(w):
            if x[i]=="#":
                point[i]+=1
for k in range(len(a)):
    s=a[k]
    ans=""
    for j in range(w):
        if point[j]!=0:
            ans+=s[j]
    print(ans)


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;
        
/* 
const ll MAX_MEM = 25e7;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    string t;
    cin >> t;
    int n = 0, s = 0, e = 0, w = 0;
    for (auto &c : t)
    {
        if (c == 'N')
            ++n;
        if (c == 'E')
            ++e;
        if (c == 'S')
            ++s;
        if (c == 'W')
            ++w;
    }
    n = !!n;
    e = !!e;
    w = !!w;
    s = !!s;
    cout << (e == w && s == n ? "Yes" : "No");
    return 0;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str; cin >> str;
    long long sum = 0;
    for(int i = 0; i < str.size(); i++)
    {
        sum += str[i]-'0';
    }
    if(sum%9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
penki = input().rstrip().split(' ')
penki.sort(key=int,reverse=False)

K = 0

for i in range(3):
    temp = penki[i]
    if i == 0:
        K += 1
    elif i > 0 and penki[i-1] == temp:
        pass
    else:
        K += 1

print(K)




Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

const int maxn = 1e+6 + 5;
char a[maxn];
void solve()
{
    int s;
    cin >> s;
    
    a[s] = 1;
    int cnt = 1;
    while(true)
    {
        cnt++;
        if(s % 2 == 0)
        {
            s = s / 2;
        }
        else
        {
            s  = 3 * s + 1;
        }
        
        if(a[s] == 1)
        {
            break;
        }
        a[s] = 1;
    }
    cout <<  cnt;
}
    

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in", "r", stdin);freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out", "w", stdout);
    
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
/**
 *      ABC 100 C
 *      author  : kyomukyomupurin
 *      created : 2018/08/24
**/

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

int CountEven(int x){
    int count = 0;
    while (x % 2 == 0){
        x /= 2;
        ++count;
    }
    return count;
}

int main(){
   int n; cin >> n;
   int sum = 0;

   for (int i = 0; i < n; ++i) {
       int x; cin >> x;
       sum += CountEven(x);
   }

    cout << sum << endl;

    return 0;

}


Measured memory_bytes: 256
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


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

    if(A==2||B==2){
        std::cout<<"No";
    }else{
        std::cout<<"Yes";
    }

return 0;
}



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

int main(){
  string w;
  int len[40];
  int tanku[]={5,7,5,7,7};
  int n,sum=0;
  for(;;){
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>w;
      len[i]=w.size();
      sum+=len[i];
    }
    for(int i=0,jud=0;i<n;i++){
      if(sum<27) break;
      for(int j=i,k=0,m=0;j<n;j++){
	if(m+len[j]>tanku[k]) break;
	else if(m+len[j]==tanku[k]){
	  k++; m=0;
	}
	else m+=len[j];
	if(k==5){
	  cout<<i+1<<endl; jud=1; break;
	}
      }
      if(jud) break;
    }
  }
}


Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(U == S){
    A = A-1;
  }
  else{
    B = B-1;
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
// Daniel Grzegorzewski15
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 5*(int)1e5 + 3;
const int SQ = 700;

int n, q, wyn, c[N], cnt[N], res[N];
vector<pair<PII, int>> que;

bool cmp(pair<PII, int> x, pair<PII, int> y) {
  if (x.ST.ST/SQ != y.ST.ST/SQ)
    return x.ST.ST < y.ST.ST;
  return x.ST.ST/SQ % 2 ? x.ST.ND > y.ST.ND : x.ST.ND < y.ST.ND;
}

int main() {
  init_ios();
  cin >> n >> q;
  for (int i = 1; i <= n; ++i)
    cin >> c[i];
  for (int i = 1; i <= q; ++i) {
    int l, r;
    cin >> l >> r;
    que.PB({{l, r}, i});
  }
  sort(que.begin(), que.end(), cmp);
  int l = 1, r = 1;
  wyn = cnt[c[l]] = 1;
  for (auto el: que) {
    int le = el.ST.ST;
    int ri = el.ST.ND;
    int id = el.ND;
    while (le < l) {
      --l;
      ++cnt[c[l]];
      if (cnt[c[l]] == 1)
        ++wyn;
    }
    while (r < ri) {
      ++r;
      ++cnt[c[r]];
      if (cnt[c[r]] == 1)
        ++wyn;
    }
    while (l < le) {
      --cnt[c[l]];
      if (cnt[c[l]] == 0)
        --wyn;
      ++l;
    }
    while (ri < r) {
      --cnt[c[r]];
      if (cnt[c[r]] == 0)
        --wyn;
      --r;
    }
    res[id] = wyn;
  }
  for (int i = 1; i <= q; ++i)
    cout<<res[i]<<"\n";
}

Measured memory_bytes: 15620
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
from functools import partial, reduce
from operator import mul
prod = partial(reduce, mul)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, A, B = LI()
    X = LI()
    ans = 0
    for x, y in zip(X, X[1:]):
        if (y - x) * A < B:
            ans += (y - x) * A
        else:
            ans += B
    return ans

print(main())

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

int main()
{
    int N;
    cin >> N;
    vector<pair<ll, ll>> ab;
    for(int i = 0;i < N;i++){
        ll A, B;
        cin >> A >> B;
        ab.emplace_back(A, B);
    }
    sort(ab.begin(), ab.end());
    vector<ll> sum(N + 1), v(N + 1);
    for(int i = 0;i < N;i++){
        sum[i + 1] = sum[i] + ab[i].second;
        v[i] = sum[i] - ab[i].first;
    }
    ll res = 0, mi = v[0];
    for(int i = 0;i < N;i++){
        mi = min(mi, v[i]);
        res = max(res, sum[i + 1] - ab[i].first - mi);
    }
    cout << res << endl;
    return 0;
}



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

int n;

int (*p)[3];
int (*q)[3];


int element(int (*k)[3],int i,int j)
{
	return *(*(k+i)+j);
}

int routes(int i,int c)
{	
	
	int cost0,cost1,cost2;
	
	if(c!=0)
	{
		if(i==n-1)cost0=element(p,i,0);
		else
		{
			if(element(q,i,0)!=-1)cost0=element(q,i,0);
			else {cost0=element(p,i,0)+routes(i+1,0);*(*(q+i)+0)=cost0;}
		}
		

	}
	else cost0=0;

	if(c!=1)
		{	if(i==n-1)cost1=element(p,i,1);
			else
			{
				if(element(q,i,1)!=-1)cost1=element(q,i,1);
				else{cost1=element(p,i,1)+routes(i+1,1);*(*(q+i)+1)=cost1;}
			}
			
		}
		else cost1=0;

	if(c!=2)
		{	
			if(i==n-1)cost2=element(p,i,2);
			else
			{
				if(element(q,i,2)!=-1)cost2=element(q,i,2);
				else {cost2=element(p,i,2)+routes(i+1,2);*(*(q+i)+2)=cost2;}
			}
			
		}
		else cost2=0;
	
	return max(max(cost1,cost2),cost0);
}


	
	
	
	
	

int main()
{

cin>>n;

int arr[n][3];
int arr2[n][3];
	
for(int i=0;i<n;i++)for(int j=0;j<3;j++){cin>>arr[i][j];arr2[i][j]=-1;}

p=arr;
q=arr2;

cout<<routes(0,-1);


}


Measured memory_bytes: 10580
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

vector<int> edge[100005];

long long N,M;
int A,B;

/*==================================================*/
/*==================================================*/

int color[100005];
long long cnt[2];

int check(int node, int nowcol){
    color[node] = nowcol;
    cnt[nowcol]++;

    long long ret = 1;
    REP(i,0,edge[node].size()){
        if(color[edge[node][i]] == -1){
            ret += check(edge[node][i], (nowcol+1)%2);
        }
        if(color[edge[node][i]] == nowcol){
            ret -= 1000000000000000000;
        }
    }
    return ret;
}

int main() {
    cin>>N>>M;
    REP(i,0,M){
        cin>>A>>B;
        A--; B--;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }

    REP(i,0,N) color[i] = -1;

    long long ans = 0;
    if(check(0, 0) == N){
        //cout<<"T"<<endl;
        ans = cnt[0]*cnt[1] - M;
    }else{
        //cout<<"F"<<endl;
        ans = N*(N-1)/2 - M;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 7680
/*
    Code by CNH_Tourist
*/
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")

using namespace std;

/*----------------Define----------------*/
#define inp "TestCode.inp"
#define out "TestCode.out"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileInOut freopen(inp,"r",stdin);freopen(out,"w",stdout);
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define pi acos(-1)
#define pii pair<int,int>
#define ppiii pair< pair <int,int> ,int>
#define INF 1000000
#define endl '\n'
#define ll long long
#define pq priority_queue
const ll mod=1e9+7;
int test=1;
/*--------------------------------------*/

string s,t;
int dp[3030][3030];


int main()
{
    FAST
    //FileInOut
    cin>>s>>t;
    int n=s.length(),m=t.length();
    s='0'+s;
    t='1'+t;
    for(int i=1;i<=max(n,m);i++)
        dp[i][0]=dp[0][i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i]==t[j])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    string ans="";
    int l=n,r=m;
    while(l>0 && r>0)
    {
        //cout<<l<<" "<<r<<" "<<ans<<endl;
        if(s[l]==t[r])
        {
            ans=s[l]+ans;
            l--;r--;
        }
        else
        {
            if(dp[l-1][r]>=dp[l][r-1])
                l--;
            else
                r--;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 35840
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int n = 0, qtd[21], inns = 0;

    scanf("%d", &n);

    for (int j = 0; j < n; j++) {
        scanf("%d", &qtd[j]);
    }
    inns = n;

    while(n) {
        for (int i = n-1; i >= 0; i--) {
            if (qtd[n-1] < qtd[i]) {
                inns--;
                break;
            }
        }
        n--;
    }
    printf("%d\n", inns);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int cnt = 0;
    while (A >= B) {
        B *= 2;
        cnt++;
    }
    while (B >= C) {
        C *= 2;
        cnt++;
    }

    // cout << cnt << endl;
    if (cnt <= K) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int len = s.length()>=n ? n : s.length();
  for(int i = 0 ; i < len ; i++)cout<<s[i];
  if(n>=s.length())
    return 0;
  cout<<"..."<<endl;
}



Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>

int cnt=0;

void merge(int A[], int left, int mid, int right){
	int n1, n2, i, j, k;
	int *L, *R;
	n1 = mid - left;
	n2 = right - mid;
	L = (int *)malloc( sizeof( int ) * n1+100 );
	R = (int *)malloc( sizeof( int ) * n2+100 );
//	int L[n1+1], R[n2+1];

	for(i=0; i<n1; i++){
		L[i] = A[left+i];
	}
	for(i=0; i<n2; i++){
		R[i] = A[mid+i];
	}
	L[n1] = 10000000000000000;
	R[n2] = 10000000000000000;
	i = 0;
	j = 0;
	for(k=left; k<right; k++){		
		if(L[i]<=R[j]){
			A[k] = L[i];
			i++;
		}else{
			A[k] = R[j];
			j++;
		}
		cnt++;
	}

	free( L );
	free( R );
}


void mergesort(int A[], int left, int right){
	int mid;
	if(left+1<right){
		mid = (left + right)/2;
		mergesort(A, left, mid);
		mergesort(A, mid, right);
		merge(A, left, mid, right);
	}
}



int main(){

	int A[500000];
	int left, mid, right, n, i;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}

	left = 0;
	right = n;
	mergesort(A, left, right);

	for(i=0; i<n; i++){
		if(i!=0){
			printf(" ");
		}
		printf("%d", A[i]);
	}

	printf("\n%d\n", cnt);

	return 0;
}

Measured memory_bytes: 4480
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int t1 = H1 * 60 + M1;
    int t2 = H2 * 60 + M2;

    ll ans = t2 - K - t1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652