stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)

#define all(x) (x).begin(),(x).end()

using namespace std;

const int INF=1145141919,MOD=1e9+7;

const long long LINF=8931145141919364364,LMOD=998244353;

inline long long mod(long long n,long long m){return(n%m+m)%m;}

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



// unsigned long long modpow(long long a,long long n){

//     long long x=1;

//     while(n>0){

//         //nの2進数表記の右端が1

//         if(n&1){

//             x=x*a;

//         }

//         a=a*a;

//         n>>=1; //nを右に1bitずらす

//     }

//     return x;

// }

int main(){

    long long n,p; cin>>n>>p;

    if(n==1){

        cout<<p<<endl;

        return 0;

    }

    long long MAX=1;

    for(long long i=2;;i++){

        if(pow(i,n)>1e13) break;

        MAX=i+1;

    }

    long long ans=1;

    for(long long i=2;i<=MAX;i++){

        long long tmp=pow(i,n);

        if(p%tmp==0){

            ans=i;

        }else if(p<=tmp){

            break;

        }

    }

    cout<<ans<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.78308676457637x):
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)

#define all(x) (x).begin(),(x).end()

using namespace std;

const int INF=1145141919,MOD=1e9+7;

const long long LINF=8931145141919364364,LMOD=998244353;

inline long long mod(long long n,long long m){return(n%m+m)%m;}

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



map<long long,int> mp;

vector<long long> prime_factorization(long long n){

    vector<long long> v;

    if(n==1) v.push_back(1);

    long long i=2;

    while(n>1){

        if(n<i*i){

            v.push_back(i);

            mp[n]++;

            return v;

        }

        if(n%i==0){

            n/=i;

            v.push_back(i);

            mp[i]++;

        }else{

            i++;

        }

    }

    return v;

}

int main(){

    long long n,p; cin>>n>>p;

    if(n==1){

        cout<<p<<endl;

        return 0;

    }

    vector<long long> v=prime_factorization(p);

    long long ans=1;

    for(auto i:mp){

        ans*=pow(i.first,i.second/n);

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

using namespace std;



int dp[501][501];

bool field[501][501];



int main() {

    for(int N; cin >> N, N; ) {

        fill(dp[0], dp[501], 0);

        fill(field[0], field[501], 0);

        int W, H; cin >> W >> H;

        while(N--) {

            int X, Y; cin >> X >> Y;

            field[Y][X] = true;

        }

        for(int x = 1; x <= W; x++) {

            for(int y = 1; y <= H; y++) {

                dp[y][x] = dp[y - 1][x] + dp[y][x - 1] - dp[y - 1][x - 1] + field[y][x];

            }

        }

        int S, T; cin >> S >> T;

        int res = 0;

        for(int x = S; x <= W; x++) {

            for(int y = T; y <= H; y++) {

                res = max(res, dp[y][x] - dp[y - T][x] - dp[y][x - S] + dp[y - T][x - S]);

            }

        }

        cout << res << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 2.6315300724467643x):
#include <iostream>

#include <algorithm>

#include <cstring>

using namespace std;

int main() {

  while(true) {

    int N; cin >> N;

    if(N == 0) break;

    int W, H; cin >> W >> H;

    int F[W][H];

    memset(F, 0, sizeof(F));

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

      int x, y; cin >> x >> y;

      x--, y--;

      F[x][y] = 1;

    }

    int S, T; cin >> S >> T;

    int G[W+1][H+1];

    memset(G, 0, sizeof(G));

    for(int y = 1; y <= H; ++y) {

      for(int x = 1; x <= W; ++x) {

        G[x][y] = G[x-1][y] + G[x][y-1] - G[x-1][y-1] + F[x-1][y-1];

        // cerr << "G(" << y << "," << x << ") = " << G[x][y] << endl;

      }

    }

    int ans = 0;

    for(int y = T; y <= H; ++y) {

      for(int x = S; x <= W; ++x) {

        ans = max(ans, G[x][y] - G[x-S][y] - G[x][y-T] + G[x-S][y-T]);

      }

    }

    cout << ans << endl;

  }

}
// Slower C++ solution:
#include <iostream>

#include <fstream>

#include <stdio.h>

#include <math.h>

#include <time.h>

#include <string>

#include <tuple>

#include <vector>

#include <map>

#include <unordered_map>

#include <list>

#include <set>

#include <stack>

#include <queue>

#include <cstdlib>

#include <algorithm>

#include <random>

#include <cassert>

using namespace std;

#define LL long long

#define MP(a, b) make_pair(a, b)

#define POWER9 1000000000

#define MOD POWER9+1

#undef INT_MIN

#undef INT_MAX

#define INT_MIN -2147483647

#define INT_MAX 2147483647

#define LL_MIN (LL)-9223372036854775807

#define LL_MAX (LL)9223372036854775807

#define PI 3.14159265359



string S,T;

string dp[2][3001];



string max(string A, string B, string C){

	if(A.size() >= B.size() && A.size() >= C.size()) return A;

	if(B.size() >= C.size()) return B;

	return C;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



	cin >> S >> T;

    for(int i=0; i<=1; i++) dp[i][T.size()] = "";

    for(int j=0; j<=T.size(); j++) dp[S.size()%2][j] = "";

    for(int i=S.size()-1; i>=0; i--){

        for(int j=T.size()-1; j>=0; j--){

            dp[i%2][j] = max(dp[(i+1)%2][j], dp[i%2][j+1], S[i]==T[j] ? S[i]+dp[(i+1)%2][j+1] : "");

        }

    }

    cout << dp[0][0] << endl;



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2073581449353092x):
#include <iostream>

#include <fstream>

#include <stdio.h>

#include <math.h>

#include <time.h>

#include <string>

#include <tuple>

#include <vector>

#include <map>

#include <unordered_map>

#include <list>

#include <set>

#include <stack>

#include <queue>

#include <cstdlib>

#include <algorithm>

#include <random>

#include <cassert>

using namespace std;

#define LL long long

#define MP(a, b) make_pair(a, b)

#define POWER9 1000000000

#define MOD POWER9+1

#undef INT_MIN

#undef INT_MAX

#define INT_MIN -2147483647

#define INT_MAX 2147483647

#define LL_MIN (LL)-9223372036854775807

#define LL_MAX (LL)9223372036854775807

#define PI 3.14159265359



string S,T;

int dp[3001][3001];



int max(int a, int b, int c){ return max(a, max(b, c)); }



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



	cin >> S >> T;

    for(int i=0; i<=S.size(); i++) dp[i][T.size()] = 0;

    for(int j=0; j<=T.size(); j++) dp[S.size()][j] = 0;

    for(int i=S.size()-1; i>=0; i--){

        for(int j=T.size()-1; j>=0; j--){

            dp[i][j] = max(dp[i+1][j], dp[i][j+1], S[i]==T[j] ? dp[i+1][j+1]+1 : 0);

        }

    }



    int i = 0;

    int j = 0;

    while(dp[i][j] > 0){

        if(S[i] == T[j] && dp[i][j] == dp[i+1][j+1]+1){

            cout << S[i];

            i++; j++;

        }

        else if(dp[i][j] == dp[i+1][j]) i++;

        else j++;

    }

    cout << endl;



	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.4209474853056328x):
#include <iostream>

#include <bits/stdc++.h>

#include <string>

using namespace std;



int main() {

  string palavra1, palavra2;



  cin>>palavra1>>palavra2;



  int lcsDP[palavra1.length()+1][palavra2.length()+1];



  for (int i=0; i<=palavra1.length(); i++){ 

    for (int j=0; j<=palavra2.length(); j++){ 

      if (i == 0 || j == 0) 

        lcsDP[i][j] = 0; 

      else if (palavra1[i-1] == palavra2[j-1]) 

        lcsDP[i][j] = lcsDP[i-1][j-1] + 1; 

      else

        lcsDP[i][j] = max(lcsDP[i-1][j], lcsDP[i][j-1]); 

    } 

  }





  int i = palavra1.length(), j = palavra2.length(); 

  int ultimo = lcsDP[i][j]; 



  char lcsString[ultimo+1]; 

  lcsString[ultimo] = '\0'; 

  while (i > 0 && j > 0){ 

    if (palavra1[i-1] == palavra2[j-1]){ 

      lcsString[ultimo-1] = palavra1[i-1];

      i--; 

      j--; 

      ultimo--;

    } else if (lcsDP[i-1][j] > lcsDP[i][j-1]){

      i--; 

    }else{

      j--; 

    }

  } 

  

  

  cout<<lcsString<<endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.4160827678680972x):
#include<bits/stdc++.h>

using namespace std;



void LCS_bottomup(string x,string y,int n,int m)

{

    int a[n+1][m+1]={0};

    for(int i=0;i<=n;i++)

    {

        for(int j=0;j<=m;j++)

        {

            if(i==0||j==0) a[i][j]=0;

            else if(x[i-1]==y[j-1]) a[i][j]=a[i-1][j-1]+1;

            else a[i][j]=max(a[i-1][j],a[i][j-1]);

        }

    }

    int idx=a[n][m];

    char ans[idx+1];

    ans[idx]='\0';

    int i=n,j=m;

    while(i>0&&j>0)

    {

        if(x[i-1]==y[j-1])

        {

            ans[idx-1]=x[i-1];

            idx--;

            i--;

            j--;

        }

        else if(a[i-1][j]>a[i][j-1])i--;

        else j--;

    }

    cout<<ans;

}



int main()

{

    string x,y;

    cin>>x>>y;

    int i=x.size();

    int j=y.size();

    LCS_bottomup(x,y,i,j);

    //for(int i=0;i<ans.size();i++)cout<<ans[i];

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.4287225658059801x):
#include<iostream>

#include<string.h>

#include<stdlib.h>

using namespace std;

char X[3002];

char Y[3002];



void lcs( char *X, char *Y, int m, int n )

{

int L[m+1][n+1];





for (int i=0;i<=m;i++)

{

	for (int j=0;j<=n;j++)

	{

	if (i==0||j==0)

		L[i][j] = 0;

	else if (X[i-1] == Y[j-1])

		L[i][j]=L[i-1][j-1]+1;

	else

		L[i][j]=max(L[i-1][j],L[i][j-1]);

	}

}





int index = L[m][n];



char lcs[index+1];

lcs[index] = '\0';





int i=m,j=n;

while (i>0&&j>0)

{



	if (X[i-1]==Y[j-1])

	{

		lcs[index-1]=X[i-1];

		i--; j--; index--;

	}



	else if (L[i-1][j]>L[i][j-1])

		i--;

	else

		j--;

}





cout << lcs;

}





int main()

{

cin>>X;

cin>>Y;

int m = strlen(X);

int n = strlen(Y);

lcs(X, Y, m, n);

return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.4033404188894554x):
#include <bits/stdc++.h>

using namespace std;



#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);

#define ll long long

#define pb push_back

#define F first

#define S second

#define endl '\n'

#define mod 1e9 + 7

const ll maxN = 3000 + 5;

const int INF = 0x3f3f3f3f;



string s, t;

int dp[maxN][maxN];

vector <char> stringy;



void printSub(int x, int y){

    while (x && y) {

        if (s[x-1] == t[y-1]) {

            stringy.pb(s[x-1]);

            x--; y--;

        }

        else {

            if (dp[x][y-1] >= dp[x-1][y])

                y--;

            else if (dp[x][y-1] < dp[x-1][y])

                x--;

        }

    }

    for (int i=stringy.size()-1; i>=0; i--)

        cout << stringy[i];

}



int main() {

	Omar45

    cin >> s >> t;

    int N = s.size();

    int M = t.size();

    for (int i=0; i<=N; i++)

        dp[i][0] = 0;

    for (int i=0; i<=M; i++)

        dp[0][i] = 0;

    for (int i=1; i<=N; i++){

        for (int j=1; j<=M; j++){

            if (s[i-1]==t[j-1])

                dp[i][j] = dp[i-1][j-1]+1;

            else

                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

        }

    }

    printSub(N,M);

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.3946731882924939x):
#include <bits/stdc++.h>

#include <bitset>

using namespace std;

#define ll long long

#define mod 1000000007



ll arr[3005][3005] = {};

ll n,m;

void test(){

    for(ll i=1; i<=n; i++){

        for(ll ii=1; ii<=m; ii++){

            cout << arr[i][ii] << " ";

        }

        cout << endl;

    }

}



int main()

{

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





    string s1,s2; cin >> s1 >> s2;

    string out = "";

    n = s1.length(); m = s2.length();



    for(ll i=1; i<=s1.length(); i++){

        for(ll ii=1; ii<=s2.length(); ii++){

            if(s1[i-1] == s2[ii-1]){

                arr[i][ii] = arr[i-1][ii-1] + 1;

            }else{

                arr[i][ii] = max(arr[i-1][ii], arr[i][ii-1]);

            }

        }

    }





    ll i = n, ii = m;



    while(i && ii){

        if(arr[i-1][ii-1] < arr[i][ii] && arr[i-1][ii] < arr[i][ii] && arr[i][ii-1] < arr[i][ii]){



            out += s1[i-1];

            i--;

            ii--;

            continue;

        }else{

            if(arr[i-1][ii] > arr[i][ii-1]){

                i--;

            }else{

                ii--;

            }

        }

    }







    for(ll i=out.length()-1; i>=0; i--) cout << out[i];









    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.3951639594579737x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int dp[3005][3005];

int main()

{

  ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);

    string s,ss;

    cin>>s>>ss;

    for(int i=0;i<=s.size();i++)

    {

        for(int j=0;j<=ss.size();j++)

        {

            if(i==0||j==0)

                continue;

               else if(s[i-1]==ss[j-1])

                {

                    dp[i][j]=1+dp[i-1][j-1];

                }

                else

                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);

        }

    }

    string ans;

    int i=s.size(),j=ss.size();

    while(i&&j)

    {

           if(s[i-1]==ss[j-1])

           {

            ans+=s[i-1];

               i--;

               j--;

           }

           else if(dp[i-1][j]>dp[i][j-1])

            i--;

           else

            j--;



    }

    for(int i=ans.size()-1;i>=0;i--)

        cout<<ans[i];



    return 0;

}