akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

template <class T> int digits_number(T x) {
    string str = to_string(x);
    return (int)str.size();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    while (cin >> a >> b) {
        print(digits_number(a + b));
    }

    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
using namespace std;
typedef long long ll;
ll n,s[45];
int main(void){
    cin>>n;
    s[0]=1;
    s[1]=1;
    for(int i=2;i<=44;i++){
        s[i]=s[i-1]+s[i-2];
    }
    cout<<s[n]<<endl;
}



Measured memory_bytes: 3100
//
// Created by Abhishek Bansal on 9/02/2020.
//
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void mostFrequent(const int arr[], int n, ll &ans){
    int max_count = 1, res = arr[0], curr_count = 1;
    for (int i = 1; i < n; i++) {
        if (arr[i] == arr[i - 1])
            curr_count++;
        else {
            if (curr_count > max_count) {
                max_count = curr_count;
                res = arr[i - 1];
            }
            curr_count = 1;
        }
    }
   if (curr_count > max_count)    {
        max_count = curr_count;
        res = arr[n - 1];
    }
   ans += max_count;
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

    int H, W, m;cin >> H >> W >> m;
    int h[m], w[m];map<pair<int, int>, int> map;
    for(int i=0;i<m;i++) {
        cin >> h[i] >> w[i];
        map[{h[i], w[i]}]++;
    }
    sort(h, h+m);sort(w, w+m);ll cnt1 =0, cnt2=0;
    mostFrequent(h, m, cnt1); mostFrequent(w, m, cnt2);
    vector<int> v1, v2;
    for(int i=0;i<m;i++) {
        int temp =0, x = h[i];
        for(int j=i;j<m;j++) {
            if (h[j]==x) {temp++;i++;}
            else break;
        }i--;
        if (cnt1 == temp) v1.push_back(h[i]);
    }
    for(int i=0;i<m;i++) {
        int temp =0, x = w[i];
        for(int j=i;j<m;j++) {
            if (w[j]==x) {temp++;i++;}
            else break;
        }i--;
        if (cnt2 == temp) v2.push_back(x);
    }
    ll ans = cnt1 + cnt2;
    for(int i: v1) {
        for(int j: v2) {
            if (map[{i, j}] == 0) {cout << ans;return 0;}
        }
    }
    cout << ans - 1;
    return 0;
}

Measured memory_bytes: 28516
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define ALL(x) begin(x), end(x)

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for (auto i = 0; i != N; ++i) {
    cin >> x[i];
  }
  for (auto i = 0; i != M; ++i) {
    cin >> y[i];
  }
  x.push_back(X);
  y.push_back(Y);

  bool pred = *max_element(ALL(x)) < *min_element(ALL(y));
  cout << (pred ? "No War" : "War") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll P = 1e9+7;
const int Nmax = 400;
int N, C, A[Nmax], B[Nmax];
ll s[Nmax+1][Nmax+1];
ll dp[Nmax+1][Nmax+1];

ll mpow(int a, int x, ll p){
	if(x<1) return 1;
	if(x%2) return mpow(a, x-1, p)*a%p;
	ll t = mpow(a, x/2, p);
	return t*t%p;
}

int main(){
	cin >> N >> C;
	for(int i=0; i<N; i++) cin >> A[i];
	for(int i=0; i<N; i++) cin >> B[i];

	for(int i=1; i<=400; i++){
		s[i][0] = i;
	}
	for(int j=1; j<=C; j++){
		for(int i=1; i<=400; i++){
			s[i][j] = (s[i-1][j]+mpow(i, j, P))%P;
		}
	}

	for(int j=0; j<=C; j++){
		dp[0][j] = (P+s[B[0]][j]-s[A[0]-1][j])%P;
	}
	//cout << dp[0][C] << endl;

	for(int i=1; i<N; i++){
		for(int j=0; j<=C; j++){
			for(int k=0; k<=j; k++){
				dp[i][j] += dp[i-1][j-k]*(P+s[B[i]][k]-s[A[i]-1][k]);
				dp[i][j] %= P;
				//cout << i << " " << j << " " << k << " " << s[B[i]][k]-s[A[i]-1][k] << endl;
			}
			//cout << dp[i][j] << endl;
		}
	}

	cout << dp[N-1][C] << endl;

	return 0;
}


Measured memory_bytes: 2816
#include<stdio.h>
int main(){
    char s[100000];
    int n;
    scanf("%s", &s);
    int sum = 0;
    int a=0;
    int b=0;
    for(int i=0; i<100000;i++){
        if(s[i]=='0')a++;
        else if(s[i]=='1')b++;
        else break;
    }
    if(a<b){
        printf("%d\n", a*2);
    }else{
        printf("%d\n", b*2);
    }
    return 0;
}

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

using namespace std;

int main() {
    long long A, B;
    int K;
    cin >> A >> B >> K;
    if ((B - A + 1) > K && (B - A + 1) >  K * 2) {
        for (int i = 0; i < K; i++) {
            cout << A + i << endl;
        }
        for (int i = 0; i < K; i++) {
            cout << B + i - K + 1 << endl;
        }
    }

    else {
        for (int i = 0; i < B - A + 1; i++) {
            cout << A + i << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N;
	int Y;
	cin >> N >> Y;
	int res10000 = -1, res5000 = -1, res1000 = -1;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N-i; j++) {
			int k = N - i - j;
			if (i * 10000 + j * 5000 + k * 1000 == Y) {
				res10000 = i;
				res5000 = j;
				res1000 = k;
			}
		}
	}

	cout << res10000 <<" "<< res5000 <<" "<< res1000 <<" "<< endl;
	return 0;
}

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

int main(){
    string str;

    cin >> str;
    int cnt=0;
    int flag=1;

    for(int i=0; i<3; i++){

        if(str[i] == 'R' && flag == 1){
            cnt++;
        }


        if(i == 2){
            if(str[2] == 'R' && cnt==0){
                cnt++;
            }
            break;
        } 

        if(str[i+1] == 'S'){
            flag=0;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

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

  map<ll, int> m;
  
  int n;
  cin >> n;
  rep(i, 0, n){
    ll a;
    cin >> a;
    m[a]++;
  }

  ll sq = -1;
  vector<ll> v;
  for(auto p: m){
    if( p.second >= 2 )
      v.push_back(p.first);
    if( p.second >= 4 )
      sq = max(sq, p.first);
  }

  if( v.size() < 2 ){ // No rectangle possible
    if( sq != -1 ) // But square possible
      cout << sq*sq << endl;
    else
      cout << 0 << endl;
  }else{
    n = v.size();
    ll reca = v[n-1]*v[n-2];

    if( reca > sq*sq )
      cout << reca << endl;
    else
      cout << sq*sq << endl;
  }
  

  return 0;
}


Measured memory_bytes: 6528
def myAnswer(N:int,S:list) -> int:
   ans = 0
   for i in range(1,N):
      left = set(S[:i])
      right = set(S[i:])
      counter = 0
      for l in left:
         if(l in right):
            counter += 1
      ans = max(ans,counter)

   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   S = list(input())
   print(myAnswer(N,S[:]))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int a[26]={0};
    for(int i=0;i<s.size();i++)
    {
        a[s[i]-'a']++;
    }
    bool d=true;
    for(int i=0;i<26;i++)
    {
        if(a[i]%2==1)
        {
            d=false;
            break;
        }
    }
    if(d==true)
    cout<<"Yes";
    else
    cout<<"No";
	return 0;
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int c, n, m;
	cin >> c >> n >> m;
	vi s(n), p(n);
	REP(i, n)cin >> s[i] >> p[i];
	vi dp(c + 1,0);
	REP(i, n) {
		RREP(j, c + 1) {
			if (j + s[i] <= c) {
				chmax(dp[j + s[i]], dp[j] + p[i]);
			}
		}
	}
	REP(i, m) {
		cout << dp[c / (i + 1)]*(i+1) << endl;
	}
}


Measured memory_bytes: 3312
import java.io.PrintWriter
import kotlin.math.min

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, m, x) = readIntegerList()
    val costList = Array(n) { readIntegerList() }
    var ans = Int.MAX_VALUE
    for (i in 0 until (1 shl n)) {
        val xs = IntArray(m)
        var cost = 0
        for (j in 0 until n) {
            if (((i shr j) and 1) == 1) {
                cost += costList[j][0]
                for (k in 0 until m) {
                    xs[k] += costList[j][k + 1]
                }
            }

            if (xs.filter { it < x }.isEmpty()) {
                ans = min(ans, cost)
            }
        }
    }
    if (ans == Int.MAX_VALUE) {
        println(-1)
    } else {
        println(ans)
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 54884
#include<iostream>
#define N 1000000
#define MOD 1000000007
using namespace std;
typedef long long LL;
LL f[N+1];
LL solve()
{
	LL n; cin >> n;

	f[0] = 1;
	f[1] = n;
	f[2] = (n*n)%MOD;
	
	LL running_sum = (n*n+n+1)%MOD;
	for(LL k = 3; k <= n; k++)
	{
		f[k] = (running_sum-f[k-2]+(n*n-n-k+2))%MOD;
		running_sum += f[k], running_sum %= MOD;
	}
	return (f[n]+MOD)%MOD;
}
int main()
{
	cout<<solve()<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
#define Mod 1000000007
using namespace std;
inline ll read(){
	ll x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
ll ksm(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1)res=1ll*res*x%Mod;
		x=1ll*x*x%Mod;y>>=1;
	}return res;
}
ll a[maxn],n,fac[maxn],inv[maxn];
inline void init(){
	fac[0]=1;
	for(ll i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%Mod;
	for(ll i=1;i<=n;i++)inv[i]=(inv[i-1]+ksm(i,Mod-2))%Mod;
}
int main(){
	n=read();init();
	for(ll i=1;i<=n;i++)a[i]=read();
	ll ans=0;
	for(ll i=1;i<=n;i++)ans=(ans+a[i]*(inv[i]+inv[n-i+1]-1)%Mod)%Mod;
	printf("%d\n",ans*fac[n]%Mod);return 0;
}

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

using namespace std;

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));

#define debug(x) std::cout << #x << ": " << x << endl
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
//#define int ll

int T;
const int maxn = 2e5+7;
int n; ll M;
ll dp[maxn]; //way that u is black,rooted at 1 at first
vector<int> G[maxn];
vector<ll> pre[maxn];
vector<ll> suf[maxn]; //so that dont need to calc inv
//int p[maxn];
//int s[maxn], t[maxn], dfn;
//vector<ll> vals;

ll dfs1(int u, int f) //first dp
{
	//debug(u);
	ll &ret = dp[u];
	ret = 1;
	//vals.clear();
	vector<ll> vals;
	for(int v:G[u])
	{
		if(v == f) {vals.pb(1); continue;}
		ll dpv = (dfs1(v, u)+1)%M;
		ret *= dpv;
		ret %= M;
		vals.pb(dpv);
	}
	int sz = G[u].size();
	//debug(sz);
	pre[u].resize(sz); //RE
	suf[u].resize(sz);
	rep(i, 0, sz)
	{
		pre[u][i] = i ? (pre[u][i-1]*vals[i]%M) : vals[i];
		suf[u][sz-1-i] = i ? (suf[u][sz-i]*vals[sz-1-i]%M) : vals[sz-1-i];
	}
	return ret;
}


//     fval(1/0)
//     |
//     1
// |   |   |
// u  1/0 1/0
void dfs2(int u, int f, ll f_val) //eular tree tour concept
{
	//debug(u);
	ll &ret = dp[u];
	ret = ret*f_val%M;
	rep(i, 0, G[u].size())
	{
		int v = G[u][i];
		if(v == f) continue;
		ll brother_way = ((i ? pre[u][i-1] : 1) * (i+1 < G[u].size() ? suf[u][i+1] : 1)) %M;
		ll f_is_1 = brother_way * f_val % M;
		dfs2(v, u, f_is_1 + 1);
	}

}



void solve()
{
	cin >> n >> M;
	int a, b;
	rep(i, 0, n-1) //1-indexed
	{
		cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}
	//dfn = 0;
	dfs1(1, 0);
	//cout << "HIHI" << endl;
	dfs2(1, 0, 1);

	rep(i, 1, n+1) cout << dp[i] << endl;

  return;
}


signed main()
{
  //fastIO();
	T = 1;
	//cin >> T; //this
  while(T--) solve();
  return 0;
}
/*
stuck:
	* do observations and see properties
	* binary search? DP? DS? flow?
	* be organized

before upload:
	* int overflow, array bounds
	* special cases (min, max, special)
*/


Measured memory_bytes: 33280
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int maxn = 2e5 + 7;

char s[maxn];

int main() {
	scanf("%s",s);
	int ans = 0;
	int len = strlen(s);
	rep(i,0,len-1) {
		ans = (ans + (s[i] - '0')) % 9;
	}
	if(!ans) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    string s;
    int k;
    cin >> k >> s;
    cout << s.substr(0, k) + (s.size() > k ? "..." : "") << '\n';
    return 0;
}

Measured memory_bytes: 3628
ABCD = input()

for i in range(2 ** 3):
    ans = int(ABCD[0])
    pm = []
    for j in range(3):
        if (i >> j) & 1:
            ans += int(ABCD[j+1])
            pm.append("+")
        else:
            ans -= int(ABCD[j+1])
            pm.append("-")
    if ans == 7:
        print("{}{}{}{}{}{}{}=7".format(ABCD[0], pm[0], ABCD[1], pm[1], ABCD[2], pm[2], ABCD[3]))
        break

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

int main() {

    int a, b;
    cin >> a >> b;
    int rank_num[5];

    int i;
    int ans=0;
    for(i=a; i<=b; i++){

        rank_num[0] = i/10000;
        rank_num[1] = (i - rank_num[0]*10000)/1000;
        rank_num[2] = (i - rank_num[0]*10000 - rank_num[1]*1000 )/100;
        rank_num[3] = (i - rank_num[0]*10000 - rank_num[1]*1000 - rank_num[2]*100)/10;
        rank_num[4] = (i - rank_num[0]*10000 - rank_num[1]*1000 - rank_num[2]*100 - rank_num[3]*10);
        
        if( rank_num[0] == rank_num[4]){
            if( rank_num[1] == rank_num[3]){
                ans++;
            }
        }
    }

cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x[100010];
int main(){
	long long a,b,c,i,n,m=0;
	cin>>n;
	cin>>a>>b;
	for(i=1;i<=n;i++){
		cin>>x[i];
	}
	for(i=1;i<n;i++){
		c=(x[i+1]-x[i])*a;
		if(c<b) m+=c;
		else m+=b;
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a[1 << 20];

    cin >> n;

    REP(i, (1 << n))
    cin >> a[i];

    P p[1 << 20];

    p[0] = {0, 0};

    for (int i = 1; i < (1 << n); i++)
    {
        vector<pair<int, int>> v;

        v.push_back({a[i], i});

        for (int j = 0; j < 20; j++)
        {
            if (i & (1 << j))
            {
                int f = p[i - (1 << j)].first;
                int s = p[i - (1 << j)].second;

                v.push_back({a[f], f});
                v.push_back({a[s], s});
            }
        }

        SORT(v);

        v.erase(unique(v.begin(), v.end()), v.end());

        p[i].first = v[v.size() - 1].second;
        p[i].second = v[v.size() - 2].second;
    }

    ll res[1 << 20];

    res[0] = 0;

    for (int i = 1; i < (1 << n); i++)
        res[i] = a[p[i].first] + a[p[i].second];

    for (int i = 1; i < (1 << n); i++)
        res[i] = max(res[i], res[i - 1]);

    for (int i = 1; i < (1 << n); i++)
        cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 17792
#include <iostream>

int main() {
  // 入力
  int date;
  std::cin >> date;

  // 出力文字列の判定
  std::string event;
  if (date == 25) {
    event = "Christmas";
  } else if (date == 24) {
    event = "Christmas Eve";
  } else if (date == 23) {
    event = "Christmas Eve Eve";
  } else {
    event = "Christmas Eve Eve Eve";
  }

  // 出力
  std::cout << event << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k;
vector<int>h,m;
int dp(int i){
	if(i<0) return 0;
	if(m[i]!=-1) return m[i];
	m[i]=INT_MAX;
	int u=1;
	while(u)
	{
		if(i>=u)
		m[i]=min(m[i],dp(i-u)+abs(h[i]-h[i-u]));
		u++;
		if(u==k+1) break;
	}
	//m[i]=min(dp(i-1)+abs(h[i]-h[i-1]),dp(i-2)+abs(h[i]-h[i-2]));
	return m[i];
}
int main(){
	int n,i;
	scanf("%d%d",&n,&k);
	h.resize(n);
	m.resize(n);
	for(i=0;i<n;i++) scanf("%d",&h[i]);
	fill(m.begin(),m.end(),-1);
	m[0]=0;
	m[1]=abs(h[1]-h[0]);
	cout<<dp(n-1)<<endl;
}

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

int main()
{
    long long int num[3];
    cin >> num[0] >> num[1] >> num[2];
    if (num[0] % 2 == 0 || num[1] % 2 == 0 || num[2] % 2 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        if (num[1] * num[2] < num[0] * num[2] && num[1] * num[2] < num[1] * num[0])
            cout << num[1] * num[2] << endl;
        else if (num[0] * num[2] < num[1] * num[2] && num[0] * num[2] < num[1] * num[0])
            cout << num[0] * num[2] << endl;
        else
            cout << num[1] * num[0] << endl;
    }
    return 0;
}

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

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

	int c1, c2, c3;
	while(cin >> c1 >> c2 >> c3) {
		bool exist[11] = { 0 };
		exist[c1] = exist[c2] = exist[c3] = true;

		int cnt = 0;
		for(int i = 1; i <= 10; i++) {
			if(!exist[i] && c1 + c2 + i <= 20) cnt++;
		}

		if(cnt >= 4) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

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

#define int long long

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

int N, M, K;
int x[100000], a[100000];
int diff[99999], perm[100][99999];
int ans[99999], finaly[99999];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < N - 1; i++) {
        diff[i] = x[i + 1] - x[i];
        perm[0][i] = i;
        ans[i] = i;
    }
    cin >> M >> K;
    for (int i = 0; i < M; i++) {
        cin >> a[i];
        swap(perm[0][a[i] - 2], perm[0][a[i] - 1]);
    }
    for (int i = 1; i < 100; i++) {
        for (int j = 0; j < N - 1; j++) {
            perm[i][j] = perm[i - 1][perm[i - 1][j]];
        }
    }
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < 63; j++) {
            if (((K >> j) & 1) == 1) {
                ans[i] = perm[j][ans[i]];
            }
        }
    }
    int a = x[0];
    for (int i = 0; i < N - 1; i++) {
        cout << a << endl;
        a += diff[ans[i]];
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 82560
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main=do
    n<-readLn::IO Int
    as<-unfoldr(B.readInt.B.dropWhile(==' '))<$>B.getLine
    print $ sol 0 as
sol n [] = n+1
sol n [x] = n+1
sol n (a:b:as)
    | a == b = sol n (b:as)
    | a < b  = solf n (<) (b:as)
    | otherwise = solf n (>) (b:as)
solf n _ [] = n+1
solf n _ [x] = n+1
solf n f (a:b:as)
    | a == b = solf n f (b:as)
    | f a b  = solf n f (b:as)
    | otherwise = sol (n+1) (b:as)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============modpow============================
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================

int main()
{
  ll mod = 998244353;
  ll N;
  cin >> N;
  vector<ll> D(N, 0);
  ll M = 0;
  for (ll i = 0; i < N; ++i) {
    ll d;
    cin >> d;
    if (i == 0) {
      if (d != 0) {
        cout << 0 << "\n";
        return 0;
      }
    }
    D.at(d) += 1;
    M = max(d, M);
  }
  if (D.at(0) > 1) {
    cout << 0 << "\n";
    return 0;
  }
  ll ans = 1;
  for (ll i = 0; i < M; ++i) {
    ans = (ans * modpow(D.at(i), D.at(i + 1), mod)) % mod;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <iostream>

int main(void)
{
    int a, b, c, d, e, k;
    std::cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k)
    {
        std::cout << ":(" << std::endl;
    }
    else
    {
        std::cout << "Yay!" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

bool is_even(string &s) {
	int sz = s.size();
	for (int i = 0, j = sz / 2; j < sz; ++j, ++i) {
		if (s[i] != s[j]) {
			return false;
		}
	}

	return true;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	s.pop_back();
	s.pop_back();

	while (!is_even(s)) {
		s.pop_back();
		s.pop_back();
	}

	cout << s.size() << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(r<=x&&x<=w-r&&r<=y&&y<=h-r){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2692
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
#include <cassert>
 
using namespace std;

int main(){

	long long x,y;
	cin>>x>>y;

	long long z=x;
	int res=1;
	while(z*2LL<=y) z*=2LL,res++;
	cout<<res<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 12345
int dp[tam],v[tam];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    forr(i,0,n)
        cin>>v[i];
    dp[0]=1;
    forr(i,0,n)
    {
        for(int j=tam-1;j>=0;j--)
        {
            if (dp[j])
                dp[j+v[i]]=1;
        }
    }
    int maxx=0;
    forr(j,0,tam)
    {
        if (dp[j]==0 || j%10==0)continue;

        maxx=j;
    }
    cout<<maxx<<endl;
}
// PLUS ULTRA!ac

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0};
const int dy[] = {0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int INF = 1e9;
const int MAX = 55;

string board[MAX];
int dp[MAX][MAX][MAX][MAX];
bool can[MAX][MAX][MAX][MAX];
vector<pii> pnts[33];
int H, W;

int dfs(int y1, int x1, int y2, int x2) {
	int& ret = dp[y1][x1][y2][x2];
	if (ret != -1) return ret;
	if (y1 == y2 && x1 == x2) return ret = 0;
	ret = -INF;
	char c = board[y1][x1];
	if (c == '#') return ret;
	// ??????????????????????????????
	if (y1 + 1 <= y2 && board[y1 + 1][x1] != '#') {
		ret = max(ret, dfs(y1 + 1, x1, y2, x2));
	}
	if (x1 + 1 <= x2 && board[y1][x1 + 1] != '#') {
		ret = max(ret, dfs(y1, x1 + 1, y2, x2));
	}
	if ('a' <= c && c <= 'z') {
		// ???????????????????????§??????
		int index = c - 'a';
		for (auto p : pnts[index]) {
			int ny = p.first, nx = p.second;
			if (ny > y2 || nx > x2) continue;
			if (abs(ny - y1) + abs(nx - x1) == 1) {
				ret = max(ret, 1 + dfs(ny, nx, y2, x2));
			}
			else {
				for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) {
					int ny1 = y1 + dy[i], nx1 = x1 + dx[i];
					if (ny1 > y2 || nx1 > x2) continue;
					int bny = ny - dy[j], bnx = nx - dx[j];
					if (bny < y1 || bnx < x1) continue;
					if (!can[ny1][nx1][bny][bnx]) continue;
					ret = max(ret, 1 + dfs(ny1, nx1, bny, bnx) + dfs(ny, nx, y2, x2));
				}
			}
		}
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> H >> W) {
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++)
			cin >> board[i];
		for (int i = 0; i < 30; i++)
			pnts[i].clear();
		for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
			char c = board[i][j];
			if ('A' <= c && c <= 'Z') {
				pnts[c - 'A'].emplace_back(i, j);
			}
		}
		memset(can, false, sizeof(can));
		for (int y = H - 1; y >= 0; y--) for (int x = W - 1; x >= 0; x--) {
			if (board[y][x] == '#') continue;
			can[y][x][y][x] = true;
			if (y + 1 < H && board[y + 1][x] != '#') {
				for (int y1 = y + 1; y1 < H; y1++) for (int x1 = x; x1 < W; x1++) {
					can[y][x][y1][x1] |= can[y + 1][x][y1][x1];
				}
			}
			if (x + 1 < W && board[y][x + 1] != '#') {
				for (int y1 = y; y1 < H; y1++) for (int x1 = x + 1; x1 < W; x1++) {
					can[y][x][y1][x1] |= can[y][x + 1][y1][x1];
				}
			}
		}
		memset(dp, -1, sizeof(dp));
		int ans = dfs(0, 0, H - 1, W - 1);
		if (ans < 0) ans = -1;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 47880
#include <iostream>
using namespace std;
int main(void){
    int n,m,a,b,c,d,t;
    cin >>n>>m>>a>>b;
    int x[n],y[m];
    c=-100;
    for(int i=0;i<n;i++){
        cin >>x[i];
        if(c<x[i]) c=x[i];
    }
    d=100;
    for(int i=0;i<m;i++){
        cin >> y[i];
        if(d>y[i]) d=y[i];
    }
    t=1;
    if(c>=d) t=0;
    if(a>=d) t=0;
    if(b<=c) t=0;
    if(t==0){
        cout <<"War"<<endl;
    }else{
        cout<<"No War"<<endl;
    }
}
    

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;

vi hen[114514];
int check[114514];
int ans[114514];
int depth[114514]={0};
int main(){
	int n,m;
	cin>>n>>m;
	
	rep(i,n+m-1){
		int a,b;
		cin>>a>>b;--a;--b;
		hen[a].pb(b);
		check[b]++;
	}
	int oya=0;
	rep(i,n){
		if(check[i]==0)oya=i;
	}
	//cout<<oya<<endl;
	rep(i,n)ans[i]=-1;
	//ans[oya]=0;
	queue<int> qu;
	qu.push(oya);
	depth[oya]=0;
	while(!qu.empty()){
		int now = qu.front();
		qu.pop();
		rep(i,hen[now].size()){
			int nex=hen[now][i];
			if(check[nex]==1){
				ans[nex]=now;
				depth[nex]=depth[now]+1;
				qu.push(nex);
			}else{
				check[nex]--;
				
			}
		}
	}
	rep(i,n){
		cout<<ans[i]+1<<endl;
	}
}

Measured memory_bytes: 7808
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n) cin >> h[i];
    sort(all(h), greater<int>());
    int mn = INF;
    for(int i = 0; i + k <= n; i++) {
        int val = h[i] - h[i+k-1];
        mn = min(val, mn);
    }
    cout << mn << endl;
}


Measured memory_bytes: 768
// comment
// 가장 큰게 리프였다는 사실을 알았으면 해볼만 했을지도..
// 가장 작은 값을 기준으로 트리를 만들면 밑으로 갈수록 점점 증가한다라는 사실을 인지하는 능력?

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

int N, Ix[MAX_N];
ll Ds[MAX_N];
int S[MAX_N];

int findD(ll d) {
	int ix = lower_bound(Ds+1, Ds+N+1, d) - Ds;
	if(Ds[ix] == d) return ix;
	return -1;
}

int Vis[MAX_N];
vector<int> Ed[MAX_N];

int main() {
	cin >> N;
	vector<pli> temp;
	for(int i=1; i<=N; i++) {
		scanf("%lld", &Ds[i]);
		temp.emplace_back(Ds[i], i);
	}
	sort(Ds+1, Ds+N+1);
	sort(ALL(temp));
	for(int i=0; i<N; i++) Ix[i+1] = temp[i].two;
	for(int i=1; i<=N; i++) S[i] = 1;
	
	vector<pi> Ans;
	//for(int i=1; i<=N; i++) printf("%lld ", Ds[i]); puts("");
	for(int i=N; i>=2; i--) {
		ll pd = Ds[i] + 2*S[i] - N;
		int ix = findD(pd);
		//printf("%lld [%lld + 2*%d - %d] %d\n", pd, Ds[i], S[i], N, ix);
		if(ix == -1 || ix == i) return puts("-1") < 0;
		S[ix] += S[i];
		Ans.emplace_back(Ix[ix], Ix[i]);
		Ed[Ix[ix]].push_back(Ix[i]);
		Ed[Ix[i]].push_back(Ix[ix]);
	}

	ll real = 0;
	queue<int> Q;
	int root = Ix[1];
	Vis[root] = 1; Q.push(root);
	while(!Q.empty()) {
		int v = Q.front(); Q.pop();
		for(int w: Ed[v]) if(Vis[w] == 0) {
			Vis[w] = Vis[v] + 1;
			Q.push(w);
		}
	}
	int all = 0;
	for(int i=1; i<=N; i++) if(Vis[i] != 0) {
		all++;
		real += Vis[i] - 1;
	}
	if(all != N || real != Ds[1]) return puts("-1") < 0;


	for(auto p: Ans) {
		int x, y; tie(x, y) = p;
		printf("%d %d\n", x, y);
	}
	return 0;
}


Measured memory_bytes: 13168
#include<iostream>
#include<string>

int main(){

    std::string s;
    std::cin >> s;

    if(s[2] == s[3] && s[4] == s[5]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define br cout << "\n";
#define pb push_back
#define ll long long 
#define ff first 
#define ss second
#define all(x) x.begin(),x.end()
#define in(a , idx , n ) for (int i = idx ; i < n ; ++i)cin >>a[i];
using namespace std;
const int MOD = 1000*1000*1000 + 7 ; 
const int MAXN = 1000*100 +10 ;
const ll INF = 1e18 ; 
void solve(){
	string s , t ;
	cin >> s >> t ;
	s="1"+ s ;  
	t ="2"+t; 
	int sl = s.length() , st = t.length() ;
	int dp[sl+1][st+1];
	for(int i = 0 ; i < sl ; ++i )
		for(int j = 0 ; j < st ; ++j )
			dp[i][j] = 0 ;
			
	int  ans = 0 , dx =-1 , dy =-1; 	
	for (int i = 1 ; i < sl ; ++i )
	{	for(int j  = 1;  j < st ; ++j )
		{	
			if (s[i] != t[j])
			{
				dp[i][j] = max(dp[i-1][j] , dp[i][j-1]) ;	
				continue;
			}
			dp[i][j] = dp[i-1][j-1] + (s[i]==t[j]) ;  
			
			if(dp[i][j]  > ans ){ans = dp[i][j]; dx = i ; dy = j ;}
		}
	}
	// cout <<ans << " " <<  dx <<" "<<dy , br 
	string res ; 

	while(dx >= 1 and dy >= 1 )
	{
			if(s[dx] == t[dy])
			{
				res += s[dx] ;
				dx--;
				dy--; 
			}
			else
			{
				if ( dp[dx-1][dy] >= dp[dx][dy-1])dx--;
				else dy--; 
			}	
	}

	reverse(all(res));
	cout << res , br 
	// for(int i = 0 ; i < sl ; ++i )
	// {	for(int j = 0 ;  j < st ; ++j )
			// cout << dp[i][j]<<" " ;
		// br 
	// }

}
int main (){ 
	int t = 1  ;
	// cin >> t ;
	while (t--){
		solve() ; 
	}
    
return 0 ; 
}


Measured memory_bytes: 38840
#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main(int32_t argc, char const *argv[])
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a >= c){
		a-=c;
		cout << a << " " << b << endl;exit(0);
	}
	else{
		c -= a;
		b -= c;
		a = 0;
		b = max(b,0ll);

		cout << a << " " << b << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int K,N;
  cin>>K>>N;
  int A[N],max=0,count=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(i!=0)
      count=A[i]-A[i-1];
    if(count>max)
      max=count;
  }
  if(max<K-A[N-1]+A[0])
    max=K-A[N-1]+A[0];

  cout<<K-max<<endl;

  return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict
from collections import Counter

# nを素因数分解
# 各素因数を数え上げる場合はcounterを使うとよい
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
    
d = defaultdict(lambda: 0)

if N == 1:
    print(1)
else:
    for i in range(2, N+1):
        a = prime_factorize(i)
        c = Counter(a)
        for k, v in c.items():
            d[k] += v

    count = 1
    for v in d.values():
        count *= (v + 1)
        count %= int(1e9+7)
    print(count)

Measured memory_bytes: 43112
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<ll> cnt[8];
    rep0(i, n){
        ll x[3];
        cin >> x[0] >> x[1] >> x[2];
        rep0(j, 8){
            ll sum = 0;
            rep0(k, 3){
                if(j >> k & 1){
                    sum -= x[k];
                }else{
                    sum += x[k];
                }
            }
            cnt[j].push(sum);
        }
    }
    ll ans = 0;
    rep0(i, 8){
        ll c = 0;
        rep0(j, m){
            c += cnt[i].top();
            cnt[i].pop();
        }
        ans = max(ans,c);
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 384
#include <math.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

using ll = long long;

struct UnionFind {
    vector<int> p;
    vector<int> size;

    UnionFind(int n): p(n), size(n, 1) {
        for (int i = 0; i < n; i++) { p[i] = i; }
    }

    int find(int x) {
        if (p[x] == x) { return x; }

        return p[x] = find(p[x]);
    }

    void unite(int x, int y) {
        x = find(x); y = find(y);

        if (x == y) { return; }

        if (size[x] < size[y]) { swap(x, y); }

        p[y] = x;
        size[x] += size[y];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

struct Edge { int u, v; };

int N, M, ans;
vector<Edge> v;

int main() {
    cin >> N >> M;
    v = vector<Edge>(M);

    for (int i = 0; i < M; i++) {
        cin >> v[i].u >> v[i].v;
    }

    for (int i = 0; i < M; i++) {
        UnionFind uf = UnionFind(N + 1);

        for (int j = 0; j < M; j++) {
            if (j != i) { uf.unite(v[j].u, v[j].v); }
        }

        for (int j = 1; j <= N; j++) {
            if (!uf.same(1, j)) { ans++; break; }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
#wv.sort()
dp=[[0]*(w+1) for _ in range(n)]
for i in range(1,w+1):
    if i<wv[0][0]:
        dp[0][i]=0
    else:
        dp[0][i]=wv[0][1]
for i in range(1,n):
    for j in range(1,w+1):
        if wv[i][0]>j:
            dp[i][j]=dp[i-1][j]
        else:
            wleft=j-wv[i][0]
            dp[i][j]=max(wv[i][1]+dp[i-1][wleft],dp[i-1][j])
print(dp[-1][-1])

Measured memory_bytes: 119916
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
   ll x;
   cin >> x;
   bool ok = 0;
   for(long i=-200; i<=200; i++)
   {
    for(long j=-200; j<=200; j++)
    {
       if(i*i*i*i*i - j*j*j*j*j == x)
        {ok=1; cout << i << " " << j << endl;break;}
    }
    if(ok) break;
   }
}

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


Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
N = int(input())
a = []
for _ in range(N): a.append(int(input()))
if a[0] != 0:
  print(-1)
  exit(0)
for i in range(N - 1):
  if a[i + 1] > a[i] and (a[i + 1] - a[i] > 1):
    print(-1)
    exit(0)
res = 0
s = 0
x = 1
for i in range(1, N):
  if a[i] == x:
    s += 1
  else:
    if x > 0: res += (s - 1) * x + 1
    if x > a[i] and a[i] > 1:
      res += a[i] - 1
    s = 1
    x = a[i]
  #print(i, res)
if x > 0: res += (s - 1) * x + 1
print(res)

Measured memory_bytes: 50780
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B = I()
print((A+B)%24)

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define FOR_EX(i, a, b) for (int i = a; i < b; i++)
#define FOR_IN(i, a, b) for (int i = a; i <= b; i++)

#define ALL(a) a.begin(), a.end()

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int n;
    cin >> n;
    int a[n];
    FOR_EX(i, 0, n) {
        cin >> a[i];
    }
    // Only works if split by exactly half
    // long long t = 0;
    // FOR_EX(i, 0, n / 2) {
    //     int left = a[i];
    //     int right = a[n - i - 1];
    //     t += (right - left);
    // }
    // cout << (n % 2 == 0 ? abs(t) : abs(abs(t) - a[n / 2])) << endl;
    int i = 0, j = n - 1;
    long long left = 0;
    long long right = 0;
    while (i <= j) {
        if (left < right) {
            left += a[i++];
        } else {
            right += a[j--];
        }
    }
    cout << abs(left - right) << endl;
}


Measured memory_bytes: 1024