akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> dp(K + 1, false);

    rep(i, K + 1) {
        rep(j, N) {
            ll a = A[j];
            if (i - a >= 0) {
                dp[i] |= !dp[i - a];
            }
        }
    }

    if (dp[K]) {
        cout << "First" << '\n';
    } else {
        cout << "Second" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define NL '\n'
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

//#define LOCAL
vector<string>vec_spltr(string s){s+=',';vector<string>res;while(!s.empty())
res.push_back(s.substr(0, s.find(','))),s=s.substr(s.find(',')+1);return res;}
void dbg_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,
__attribute__((unused))int LINE_NUM){cerr<<endl;}template<typename Head,typename... Tail>
void dbg_out ( vector <string> args, int idx, int LINE_NUM, Head H, Tail... T)
{if(idx>0)cerr<<", ";else cerr << "Line(" << LINE_NUM << ") ";stringstream ss;ss<<H;
cerr<<args[idx]<<" = "<<ss.str();dbg_out(args,idx+1,LINE_NUM, T...);}
#ifdef LOCAL
#define debug(...) dbg_out(vec_spltr(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 6660999
#endif


void absinthe() {
    ll n, m, l, r; cin >> n >> m;
    string s; cin >> s;
    vector<int>end(n+1);
    for(int i = 1; i < n; i++) {
        if(s[i-1] == 'A' && s[i] == 'C') {
            end[i] = 1;
        }
    }
    rep(i, 1, n) end[i] += end[i-1];
   // rep(i, 0, n+1) cerr << end[i] << " "; cerr << NL;
    while(m--){
        cin >> l >> r; l--, r--;
        cout << end[r] - end[l] << NL;
    }
}
 
int main(){
  _fastIO();
  int tx = 1; 
  //cin >> tx;
  while(tx--) absinthe();
} 

Measured memory_bytes: 1488
n = int(input())
sum = 0
s = []
for i in range(n):
    si = int(input())
    sum += si
    s.append(si)
s.sort()
if sum % 10 != 0:
    print(sum)
else:
    for i in range(n):
        if (sum - s[i])%10 !=0:
            print(sum-s[i])
            exit()
        else:
            continue
    print(0)

Measured memory_bytes: 3060
N = int(input())
result = []
for i in range(1, N+1):
    if(i % 3 == 0):
        pass
    elif(i % 5 == 0):
        pass
    elif(i % 3 == 0 and i % 5 == 0):
        pass
    else:
        result.append(i)

print(sum(result))


Measured memory_bytes: 29980
input()
a = list(map(int, input().split()))

def resolve(a):
    if a == [1, 1]:
        return True

    if a.count(1) >= 2:
        return False

    max_num = max(a)
    min_num = min(a)

    if a.count(max_num) < 2:
        return False

    if max_num / 2 > min_num:
        return False

    if max_num & 1:
        # 奇数
        for i in range(max_num // 2 + 1, max_num):
            if i not in a: return False

        if a.count(min_num) > 2:
            return False
    else:
        # 偶数
        for i in range(max_num // 2, max_num):
            if i not in a: return False

        if a.count(min_num) > 1:
            return False
    return True

print("Possible" if resolve(a) else "Impossible")


Measured memory_bytes: 3064
def main():
    S = input()
    T = input()

    if len(S) + 1 != len(T):
        print("No")
        return

    for i in range(0, len(S)):
        if S[i] != T[i]:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9048
n, k, q = map(int, input().split(" "))

a = []
for i in range(q):
    a.append(int(input()))

b = [0 for _ in range(n)]

for i in range(q):
    b[a[i] - 1] += 1

for i in range(n):
    if b[i] > q - k:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 56544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String t = "123";
		String s = sc.next();
		String s2 = sc.next();
		//int n = sc.nextInt();

		sc.close();
		System.out.println(t.replace(s, "").replace(s2, ""));

	}
}



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

#define ll long long int

void init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
}

int main()
{
    init();
    int t,n;
    ll a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    a= a*60 + b;
    b= c*60+d;
    cout<<b-a-e<<endl;
    return 0;
}


/*



*/



Measured memory_bytes: 3612
# coding: utf-8
# Your code here!
s=input()
cnt=0
m=0
tmp="A"
for i in range(4):
    if tmp==s[i]:
        cnt+=1
    else:
        cnt=0
    if m<cnt:
        m=cnt
    tmp=s[i]
if m>=2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

#define LEN 100

void lft(char *s);

int main(void){
    char s[LEN], t[LEN];
    int k;
    int len;
    int f = 0;

    scanf("%s %s", s, t);
    len = strlen(s);

    for(k = 0; k <= len; k++){
        if(!(strcmp(s, t))){
            f++;
            break;
        }
        lft(s);
    }

    if ( f ) { puts("Yes"); }
    if ( !f ) { puts("No"); }

    return 0;
}

void lft(char *s){
    char t;
    t = *s;
    for(; *s = *(s+1); s++);
    *s++ = t;
    *s = '\0';
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yes cout << "YES\n"
//#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define fi first
#define se second
#define Max 200005
using namespace std;

int main()
{
    int n;
    cin >> n;
    ll a, b, c;
    ll dp[n][4];

    for(int i = 0; i < n; i++) {
        cin >> a >> b >> c;
        if(!i) {
            dp[0][1] = a, dp[0][2] = b, dp[0][3] = c;
            continue;
        }
        dp[i][1] = max(dp[i - 1][2] + a, dp[i - 1][3] + a);
        dp[i][2] = max(dp[i - 1][1] + b, dp[i - 1][3] + b);
        dp[i][3] = max(dp[i - 1][1] + c, dp[i - 1][2] + c);
    }
    cout << max(dp[n - 1][1], max(dp[n - 1][2],dp[n - 1][3])) << "\n";
    return 0;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
 
void m1(){
  ll a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  if(w >= v) cout << "NO";
  else{
  	if(abs(b-a) <= t * (v - w)) cout << "YES";
    else cout << "NO";
  }
}
 
/*
void m2(){
  int t; cin >> t;
  while(t--) m1();
}
*/
 
int main(){
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

Measured memory_bytes: 3636
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
Nl =[]
for i in range(N):
    Nl.append(i+1)

P_answer = 0
Q_answer = 0
for i, permu in enumerate(itertools.permutations(Nl)):
    if list(permu) == P:
        P_answer = i+1
    if list(permu) == Q:
        Q_answer = i+1

print(abs(P_answer-Q_answer))

Measured memory_bytes: 3188
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	cout << ( a + b ) * h / 2 << endl;
	return 0;
}


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

using namespace std;
 
 
int n, r, p, c;
int card[51], tmp[51];
 
int main(){
    while(cin >> n >> r, n){
        if(n == 0 && r == 0) break;
        for(int i = 0; i < n; i++) card[i] = n-i;
        for(int i = 0; i < r; i++){
            cin >> p >> c;
            p--;
            for(int j = p; j < p+c; j++) tmp[j-p] = card[j];
            for(int j = p-1; j >= 0; j--) card[j+c] = card[j];
            for(int j = 0; j < c; j++) card[j] = tmp[j];
        }
        cout << card[0] << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<15;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

int main(int argc, const char * argv[]) {
  int H, W; cin >> H >> W;
  vector<vector<char>> field(H, vector<char>(W));
  queue<tuple<int, int, int>> Q;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++){
      cin >> field[i][j];
      if (field[i][j] == '#') Q.emplace(0, i, j);
    }
  }
  
  vector<int> dh{1,-1,0,0}, dw{0,0,1,-1};
  int ans = 0;
  int h, w, nh, nw, dist;
  while(not Q.empty()){
    tie(dist, h, w) = Q.front(); Q.pop();
    ans = max(ans, dist);
    for (int i=0; i<4; i++){
      nh = h+dh[i]; nw = w+dw[i];
      if (nh<H && nh>=0 && nw<W && nw>=0){
        if (field[nh][nw] == '.'){
          field[nh][nw] = '#';
          Q.emplace(ans+1, nh, nw);
        }
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 13328
from queue import Queue
import copy

R, C = map(int, input().split(' '))
M = [[s for s in input()] for _ in range(R)]
trial = 0

for i in range(R):
  for j in range(C):
    Sy = i+1
    Sx = j+1
    L = copy.deepcopy(M)
    if L[Sy-1][Sx-1] == '.':
      move = [(0, -1), (0, 1), (1, 0), (-1, 0)]
      q = Queue()
      ans = 0

      q.put([(Sy, Sx)])
      L[Sy-1][Sx-1] = '#'

      while not q.empty():
          pos = q.get()
          valid_pos = []
          for p in pos:
              for m in move:
                  y, x = p[0]+m[0], p[1]+m[1]
                  if 1<= y  <= R and 1<= x <= C:
                    if L[y-1][x-1] == '.':
                      L[y-1][x-1] = '#'
                      valid_pos.append((y, x))
          if len(valid_pos) != 0:
              q.put(valid_pos)
          ans += 1
      trial = max(ans, trial)
    
print(trial-1)

Measured memory_bytes: 4208
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include<utility>
using namespace std;
using ll = long long;

int main()
{
	ll x, y;
	cin >> x >> y;
	ll memo = x, ans = 0;
	while (1) {
		if (memo > y) {
			cout << ans << endl;
			return 0;
		}
		ans++;
		memo *= 2;
	}
}


Measured memory_bytes: 256
N,D = map(int, input().split())
XY = [map(int, input().split()) for _ in range(N)]
X,Y = [list(i) for i in zip(*XY)]

s=0
for i in range (N):
  if X[i]*X[i]+Y[i]*Y[i]<=D*D:
    s=s+1
print(s)

Measured memory_bytes: 116640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int i = in.nextInt(), pocitadlo = 0;
        String answer = "No";

        String s = Integer.toString(i);

        for (int x = 0; x < s.length(); x++) {
            char c = s.charAt(x);

            for (int y = 0; y < s.length(); y++) {
                if(pocitadlo >= 3) break;
                else if ((s.charAt(y) == c) && (pocitadlo <= 2)) pocitadlo++;
                else pocitadlo = 0;
            }

            if (pocitadlo >= 3) {
                answer = "Yes";
                break;
            }

            pocitadlo = 0;
        }

        System.out.print(answer);
    }
}


Measured memory_bytes: 22356
# coding: utf-8
# Your code here!
l=[]
for i in range(3):
    l.append(list(map(int,input().split())))
    std=l[i][0]
    for j in range(3):
        l[i][j]-=std

if l[0]==l[1] and l[0]==l[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>

	struct data{
		char n[9];
		int m;
	}d[100];
int main(){
	int n,m;
	char N[100][9];
	int M[1000];
	int i,j,k;
	char b[1000][9];
	int ans=0;
	int flag = 0;

	while(scanf("%d%d",&n,&m),n+m){
		ans=0;
		flag = 0;
		for(i =0;i<n;i++){
			scanf("%s%d",d[i].n,&d[i].m);
		}
		for(i =0;i<m;i++){
			scanf("%s",b[i]);
		}
	for(k=0;k<n;k++){
		for(i =0;i<m;i++){
			flag = 0;
			for(j=0;j<8;j++){
				if(d[k].n[j] != '*'){
					if(d[k].n[j] == b[i][j]){
						flag = 2;
					}else{
						flag = 1;
					}
				}else{
					flag = 1;
					continue;
				}
				if(flag == 1){
					break;
				}
			}
			if(flag == 2){
				ans += d[k].m;
			}
		}
	}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<cstdio>
using namespace std;
const int N=5005;
const int MOD=1000000007;
int n,m;
long long dp[N][N];
long long sum[N][N];
long long Pw[N],inP[N];
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
void init(int n=5000)
{
	Pw[0]=1;
	for(int i=1;i<=n;i++)
		Pw[i]=Pw[i-1]*2%MOD;
	inP[n]=ksm(Pw[n],MOD-2);
	for(int i=n;i>=1;i--)
		inP[i-1]=inP[i]*2%MOD;
	return;
}
int main()
{
	init();
	scanf("%d%d",&n,&m);
	for(int j=1;j<=m;j++)
		dp[0][j]=1,sum[0][j]=(sum[0][j-1]+dp[0][j]*j%MOD*inP[j]%MOD)%MOD;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=dp[i-1][j]*(j+1)%MOD;
			dp[i][j]=(dp[i][j]+sum[i-1][j-1]*Pw[j-1]%MOD)%MOD;
			sum[i][j]=(sum[i][j-1]+dp[i][j]*j%MOD*inP[j]%MOD)%MOD;
		}
	printf("%lld",dp[n][m]);
	return 0;
}

Measured memory_bytes: 394884
n, k = map(int, input().split())
seq = [bool(int(c)) for c in input()]

ones = []
if seq[0] is False:
    ones.append(0)
zeros = []
state = True
cnt = 0
for i, c in enumerate(seq):
    if i == 0:
        state = c
        cnt = 1
        continue

    if c == state:
        cnt += 1
    else:
        if state:
            ones.append(cnt)
        else:
            zeros.append(cnt)
        cnt = 1
        state = c

if state is True:
    ones.append(cnt)
else:
    ones.append(0)
    zeros.append(cnt)

# print(ones)
# print(zeros)

n_zeros = len(zeros)

k = min(k, n_zeros)

cum_ones = []
for i, num in enumerate(ones):
    if i == 0:
        cum_ones.append(num)
        continue
    cum_ones.append(num + cum_ones[-1])
cum_zeros = []
for i, num in enumerate(zeros):
    if i == 0:
        cum_zeros.append(num)
        continue
    cum_zeros.append(num + cum_zeros[-1])

max_score = 0
for i in range(n_zeros - k + 1):
    score = 0
    score += (cum_ones[i+k] - cum_ones[i-1]) if i > 0 else cum_ones[i+k]
    if k > 0:
        score += (cum_zeros[i+k-1] - cum_zeros[i-1]) if i > 0 else cum_zeros[i+k-1]
    if max_score < score:
        max_score = score

print(max_score)


Measured memory_bytes: 8672
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	return (b==0)?a:gcd(b,a%b);
}
int main()
{
	int n,x;
	cin>>n>>x;
	int a[111111];
	for(int i=1;i<=n;i++)
	   cin>>a[i];
	for(int i=1;i<=n;i++)
	   a[i]-=x;
	n++;
	a[n]=0;
	sort(a+1,a+n+2);
	int ans=a[2]-a[1];
	for(int i=2;i<=n;i++)
	   ans=gcd(ans,a[i+1]-a[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
s = gets.chomp.chars
n = s.size
dp = Array.new(n, 0)
cur = s[0]
1.step(n - 1) do |i|
  dp[i] = dp[i - 1]
  dp[i] += 1 if s[i] != cur
  cur = s[i]
end
puts dp[n - 1]

Measured memory_bytes: 7676
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5+5)

void solve()
{
    ll n,m,x;
    cin>>n>>m>>x;

    ll c[n],arr[n][m];

    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
            cin>>arr[i][j];
    }

    bool check = 1;
    for(int j=0;j<m;j++)
    {
        ll cur = 0;
        for(int i=0;i<n;i++)
            cur += arr[i][j];
        if(cur < x)
            check = 0;
    }

    if(!check)
    {
        cout<<"-1\n";
        return;
    }


    ll ans = inf;
    for(ll i=1;i < (1<<n);i++)
    {
        int ind = 0;
        ll val = i,cc = 0;
        ll tot[m] = {0};
        while(val)
        {
            if(val&1)
            {
                cc += c[ind];
                for(int j=0;j<m;j++)
                    tot[j] += arr[ind][j];
            }
            val>>=1;
            ind++;
        }

        bool flag=1;
        for(int j=0;j<m;j++)
        {
            if(tot[j] < x)
                flag = 0;
        }
        if(flag)
            ans = min(ans,cc);
    }

    cout<<ans;

}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;

    while(tc--)
    {
        solve();
    }
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;cin>>a>>b>>c;
  int rest=a-b;
  (rest<c)?cout<<c-rest<<endl:cout<<0<<endl;
}

Measured memory_bytes: 256
//gauravsinghh
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 1000000000
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
int main(){
    IOS
    //io_set();
    ll a, b;
    cin >> a >> b;
    ll x = a * b;
    x /= __gcd(a, b);
    cout << x << endl;
    return 0;
} 




































































































 

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

#define SIZE 100
#define HALF_SIZE (SIZE / 2)

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

    vector<vector<bool>> field(SIZE, vector<bool>(SIZE, false));
    for (int i = 0; i < HALF_SIZE; i++)
    {
        for (int j = 0; j < HALF_SIZE; j++)
        {
            field[i][j] = true;
        }
    }
    A--;
    B--;

    int h, w;

    h = 0;
    w = 0;
    while (A > 0)
    {
        field[h][w] = false;
        w += 2;
        if (w >= HALF_SIZE)
        {
            h += 2;
            w = 0;
        }
        A--;
    }

    h = 0;
    w = HALF_SIZE + 1;
    while (B > 0)
    {
        field[h][w] = true;
        w += 2;
        if (w >= SIZE)
        {
            h += 2;
            w = HALF_SIZE + 1;
        }
        B--;
    }

    cout << SIZE << " " << SIZE << endl;
    for (int i = 0; i < SIZE; i++)
    {
        for (int j = 0; j < SIZE; j++)
        {
            if (field[i][j])
            {
                cout << '#';
            }
            else
            {
                cout << '.';
            }
        }
        cout << endl;
    }
}


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

int main()
{
	int s,h,m;
	
	cin>>s;
	h = s / 3600;
	s = s % 3600;
	m = s / 60;
	s = s % 60;	
	
	cout<<h<<":"<<m<<":"<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 1164
N = int(input())
A = list(map(int,input().split()))
s = 0
for i in range(N):
    if i % 2 == 0:
        s += A[i]
    else:
        s -= A[i]
ans = [s]
for i in range(N-1):
    ans.append(2*A[i]-ans[-1])
print(*ans)

Measured memory_bytes: 69732
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	string S;
	string T;
	cin >> S;
	cin >> T;
	int a;
	a = 0;
	int b;
	b = 0;
	while (a <3) {
		if (S[a] == T[a]) {
			b++;
		}
		a++;
	}
	cout << b << endl;
}

Measured memory_bytes: 3188
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    VI in(3);
    cin >> in[0] >> in[1] >> in[2];
    SORT(in);
    cout << (in[2]%2==0?0:in[0]*in[1]) << ENDL;
    
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

////////////////////////////////////////////////////////////////

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};


////////////////////////////////////////////////////////////////



bool check(string s){
	string s_inv = s;
	reverse(s_inv.begin(), s_inv.end());
	if(s == s_inv) return true;
	else return false;
}

int main(void) {
	string s;
	cin >> s;

	int N = s.size();
	string s1 = s.substr(0, (N-1)/2);//0番目から(N-1)/2まで抽出
	string s2 = s.substr((N+3)/2 - 1);//(N+3)/2-1番目から最後まで抽出
	bool ans0 = check(s);
	bool ans1 = check(s1);
	bool ans2 = check(s2);

	string ans;
	if(ans0 && ans1 && ans2) ans = "Yes";
	else ans = "No";

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




Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val out = new java.io.PrintWriter(System.out)
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val table = Array.ofDim[Int](m+1)
  Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .foreach(e => {
      e.tail.foreach(table(_) += 1)
    })
  
  val ans = table.count(_ == n)
  out.println(ans)
  out.flush
}

Measured memory_bytes: 25428
N,i,j,k;
long long A[301][301],inf=1e15,z;
main(){
	for(scanf("%d",&N);i++<N;){
		for(j=0;j++<N;){
			scanf("%d",A[i]+j);
		}
		A[i][i]=inf;
	}
	for(;k++<N;){
		for(i=0;i++<N;){
			if(A[i][k]!=inf){
				for(j=0;j++<N;){
					if(A[i][j]!=inf){
						if(A[i][j]>A[i][k]+A[k][j]){
							return!puts("-1");
						}
						if(A[i][j]==A[i][k]+A[k][j]){
							A[i][j]=inf;
						}
					}
				}
			}
		}
	}
	for(i=0;i++<N;){
		for(j=0;j++<N;){
			z+=A[i][j]==inf?0:A[i][j];
		}
	}
	printf("%lld",z/2);
}


Measured memory_bytes: 896
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
int matrix[1010][1010];

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    else if (s == "Rainy") cout << "Sunny" << endl;
    else cout << "Rainy" << endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;

    cin >> s;
    cin >> t;

    vector<vector<int>> appear(26);

    for (int i = 0; i < s.size(); i++) {
        appear[s[i] - 'a'].emplace_back(i + 1);
        appear[s[i] - 'a'].emplace_back(i + s.size() + 1);
    }

    for (int i = 0; i < 26; i++) {
        sort(appear[i].begin(), appear[i].end());
    }

    int last_idx = 0;
    int ans = 0;

    for (int i = 0; i < t.size(); i++) {
        int poss = upper_bound(appear[t[i] - 'a'].begin(), appear[t[i] - 'a'].end(), last_idx) - appear[t[i] - 'a'].begin();
        if (appear[t[i] - 'a'].size() == 0) {
            cout << "-1"
                 << "\n";
            return 0;
        } else {
            if (appear[t[i] - 'a'][poss] >= s.size()) {
                ans++;
            }
            last_idx = appear[t[i] - 'a'][poss];
            if (last_idx >= s.size()) {
                last_idx -= s.size();
            }
        }
    }

    cout << ans * s.size() + last_idx << "\n";
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  double ib = b * 100;
  ll ans = a * (ll)(ib + 0.5) / 100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;
ll gcd(ll a,ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main(){
  int N,K,A[100000];
  cin>>N>>K;
  for (int i(0);i<N;i++) cin>>A[i];
  sort(A,A+N);
  if (A[N-1]<K) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }else{
    ll maxi=gcd(A[0],A[1]); 
		for (int i(2);i<N;i++){
      maxi=gcd(maxi,A[i]);    
    }
    if (K%maxi==0){
      cout << "POSSIBLE" << endl;
      return 0;
    }else{
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int s, w;
    cin >> s >> w;
    if(w >= s)cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


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

using namespace std;

long long xorxor(long long val){
	long long ret=((val+1)/2)%2;
	for (int i=0;i<=59;i++) 
	    if ((val>>i)%2) 
		    ret|=(1^(val%2))<<i;
	return ret;
}

int main() {
	long long a,b;
    cin>>a>>b;
	long long ans=xorxor(b);
	if (a)
		ans^=xorxor(a-1);

	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

bool isSafe(int i, int j, int k, int n){
    return i>=0 && j>=0 && k>=0 && i<n && j<n&&k<n;
}

int main(){
    int n;
    cin>>n;
    int arr[n];
    //now scan the array
    int a=0; int b=0; int c = 0;
    for(int i=0; i<n; i++){
        cin>>arr[i];
        if(arr[i]==1)a++;
        else if(arr[i]==2)b++;
        else c++;
    }
    //given that n<=500
    //create the DP

    double dp[n+1][n+1][n+1];

    memset(dp, 0, sizeof(dp));

    //now loop through the elements
    //i for c, j for b, and k for a
    for(int i=0; i<=c; i++){
        for(int j=0; j<=b+c; j++){
            for(int k=0; k<=a+b+c; k++){
                if(i+j+k>0){
                    double factor = i+j+k;
                    if(isSafe(k-1, j, i, n+1)){
                        dp[k][j][i]+=k*dp[k-1][j][i];
                    }
                    if(isSafe(k+1, j-1, i, n+1)){
                        dp[k][j][i]+=j*dp[k+1][j-1][i];
                    }
                    if(isSafe(k, j+1, i-1, n+1)){
                        dp[k][j][i]+=i*dp[k][j+1][i-1];
                    }
                    dp[k][j][i]+=n;
                    dp[k][j][i]=(double)dp[k][j][i]/(double)(i+j+k);
                }
            }
        }
    }
    printf("%0.14f\n",dp[a][b][c]);
}

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

int a[30],b[30],c[30];
int n;
int main()
{
    cin>>n;
    int ans = 0;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) {cin>>b[i];ans+=b[i];}
    for(int i=1;i<=n-1;i++) cin>>c[i];
    for(int i=1;i<n;i++)
    {
        if(a[i+1]==a[i]+1)
        {
            ans += c[a[i]];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

long long gcd(long long int a, long long int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

long long lcm(long long int a,long long int b) {
    return a / gcd(a, b) * b ;
}

int main(void) {
    long long int t[100];
    int n,i;
    long long int ans=1;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&t[i]);
        ans=lcm(ans, t[i]);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
import collections
N=int(input())
A=list(map(int,input().split()))
l=[]
allsum=0
val=0
c=collections.Counter(A)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l.append([key[i],values[i]])
    allsum=allsum+(values[i]*(values[i]-1))/2
for i in range(N):
    val=c[A[i]]
    print(int(allsum-(val*(val-1)/2)+((val-1)*(val-2)/2)))

Measured memory_bytes: 102860
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair
using namespace std;

typedef long long int64;

class A {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, x, y;
        in >> n >> x;
        int ans = 1;
        int prev = 0;

        for (int i = 0; i < n; ++i) {
            in >> y;
            prev = prev + y;
            if (prev <= x)ans++;
        }
        out << ans << endl;
    }
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    A solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)

def Dfs(G, v, cur=0):
    color[v] = cur % 2
    for next_v in G[v]:
        if color[next_v[0]] != -1:
            continue
        Dfs(G, next_v[0], cur+next_v[1])


n = int(input())
e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n-1)]
g = [[] for i in range(n+1)]

for i in range(1, n):
    g[e[i][0]].append([e[i][1], e[i][2]])
    g[e[i][1]].append([e[i][0], e[i][2]])

color = [-1 for i in range(n+1)]
for v in range(1, n+1):
    if color[v] != -1:
        continue
    Dfs(g, v)

for i in range(1, n+1):
    print(color[i])


Measured memory_bytes: 109840
# instead of AVLTree
class BITbisect():
    def __init__(self, max):
        self.max = max
        self.data = [0]*(self.max+1)
    
    # 0からiまでの区間和
    # 立っているビットを下から処理
    def query_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    # i番目の要素にxを足す
    # 覆ってる区間すべてに足す
    def add(self, i, x):
        while i <= self.max:
            self.data[i] += x
            i += i & -i

    def insert(self, x):
        self.add(x, 1)

    def delete(self, x):
        self.add(x, -1)

    def count(self, x):
        return self.query_sum(x) - self.query_sum(x-1)
    
    def length(self):
        return self.query_sum(self.max)
    
    # 下からc番目(0-indexed)の数
    # O(log(N))
    def search(self, c):
        c += 1
        s = 0
        ind = 0
        l = self.max.bit_length()
        for i in reversed(range(l)):
            if ind + (1<<i) <= self.max:
                if s + self.data[ind+(1<<i)] < c:
                    s += self.data[ind+(1<<i)]
                    ind += (1<<i)
        if ind == self.max:
            return False
        return ind + 1
    
    def bisect_right(self, x):
        return self.query_sum(x)

    def bisect_left(self, x):
        if x == 1:
            return 0
        return self.query_sum(x-1)

    # listみたいに表示
    def display(self):
        print('inside BIT:', end=' ')
        for x in range(1, self.max+1):
            if self.count(x):
                c = self.count(x)
                for _ in range(c):
                    print(x, end=' ')
        print()

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
bit = BITbisect(N)

co_to_ind = [0]*(N+1)
for i in range(N):
    co_to_ind[A[i]] = i+1
    bit.insert(i+1)

ans = 0
for n in range(1, N+1):
    ind = co_to_ind[n]
    seq = bit.bisect_left(ind)
    L = bit.length()
    if seq >= 2:
        l1 = bit.search(seq-1)
        l0 = bit.search(seq-2)
    elif seq == 1:
        l1 = bit.search(seq-1)
        l0 = 0
    else:
        l1 = 0
        l0 = 0
    if L-1 - seq >= 2:
        r1 = bit.search(seq+1)
        r0 = bit.search(seq+2)
    elif L-1 - seq == 1:
        r1 = bit.search(seq+1)
        r0 = N+1
    else:
        r1 = N+1
        r0 = N+1
    #print(n,l0,l1, r1, r0, ((ind-l1)*(r0-r1) + (l1-l0)*(r0-ind)))
    ans += ((ind-l1)*(r0-r1) + (l1-l0)*(r1-ind)) * n
    bit.delete(ind)

print(ans)

Measured memory_bytes: 60832
N = int(input())
P = list(map(int, input().split()))
psorted = sorted(P)

count = 0
for i in range(N):
  if P[i] != psorted[i]:
    count += 1
  if count == 3:
    break
if count == 0:
  print("YES")
elif count == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	static int[][] dp;
	static String s1, s2;

	static int dp(int l1, int l2) {
		if (l1 == s1.length() || l2 == s2.length())
			return 0;
		if (dp[l1][l2] != -1)
			return dp[l1][l2];
		return dp[l1][l2] = s1.charAt(l1) == s2.charAt(l2) ? 1 + dp(l1 + 1, l2 + 1)
				: Math.max(dp(l1, l2 + 1), dp(l1 + 1, l2));
	}

	static StringBuilder trace(int l1, int l2) {
		StringBuilder ans = new StringBuilder();
		while (l1 < s1.length() && l2 < s2.length()) {
			if (s1.charAt(l1) == s2.charAt(l2)) {
				ans.append(s1.charAt(l1++));

				l2++;
			} else {
				if (l1 < s1.length() - 1 && l2 < s2.length() - 1) {
					if (dp[l1][l2 + 1] < dp[l1 + 1][l2]) {
						l1++;
					} else
						l2++;
				} else if (l1 != s1.length() - 1)
					l1++;
				else if (l2 != s2.length() - 1)
					l2++;
				else break;
			}
		}
		return ans;
	}

	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		s1 = sc.next();
		s2 = sc.next();
		dp = new int[s1.length()][s2.length()];
		for (int[] x : dp) {
			Arrays.fill(x, -1);
		}
		dp(0, 0);
		pw.println(trace(0, 0));
		pw.flush();
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}
	}
}


Measured memory_bytes: 77288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
 
int N;
int X;
int x[100001];
 
int main(){
	int min = 1000000001;
	vector<int> min_vec;
	cin >> N >> X;
	for(int i=0;i<N;i++){
		cin >> x[i];
		x[i] = abs(x[i]-X);
		min = x[i]<min ? x[i] : min;
	}
	for(int i=1;i<(min/2)+2;i++){
		if(min%i==0) min_vec.push_back(min/i);
	}
	for(int k=0;k<min_vec.size();k++){
		for(int i=0;i<N;i++){
			if(x[i]%min_vec[k] != 0) break;
			if(i==N-1){
				cout << min_vec[k] << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, m, c, ans, count=0;
    int a[21][21], b[21];
    cin >> n >> m >> c;
    for (int i=0; i<m; ++i) {
        cin >> b[i];
    }
    for(int i=0;i<n;++i) {
        ans=0;
        for (int j=0;j<m;++j) {
            cin >> a[i][j];
            ans += a[i][j] * b[j];
        }
        if (ans+c > 0) count++;
    }
    cout << count << endl;
	return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  
  int ans=0;

  for(int i=0;i<n;i++){
    cout <<"lst "<<i<<endl;
    int a,b;
    cin>>a;
    for(int i=0;i<a;i++) cin>>b;
    ans+=a*(a-1);
  }
  cout <<"ans "<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#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 pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

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 ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll x,n;
    cin >> x >> n;
    vector<bool> f(102,false);
    rep0(i, n){
        ll a;
        cin >> a;
        f[a] = true;
    }
    rep0(i, 102){
        if(!f[max(x - i,0ll)]){
            pf(x - i);
            break;
        }else if(!f[min(x + i,101ll)]){
            pf(x + i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3628
# 二項係数のmod (大量のmod計算が必要なとき)
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r=min(r,n-r)

    return g1[n] * g2[r] * g2[n - r] % mod

mod=998244353
N = 10 ** 6 # 出力の制限
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

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


ans=0

# 同じ色で塗る組数で場合分け
for i in range(k,-1,-1):
    # 同色の組の色の割り当て
    if i==k:
        v1 = m * pow(m - 1, n - i - 1, mod)
    else:
        v1*=m-1
        v1%=mod
    # グループの分け方
    v2=cmb(n-1,i,mod)
    ans+=v1*v2
    ans%=mod

print(ans)

Measured memory_bytes: 168120
def main(A, n, k):
    MOD = int(1e9) + 7
    A.sort()
    ans = 1
    if A[n - 1] == 0 and (k & 1):
        ans = 0
    elif A[n - 1] <= 0 and (k & 1):
        for i in range(n - 1, n - k - 1, -1):
            ans = (ans*A[i]) % MOD
    else:
        i = 0
        j = n - 1
        if k & 1:
            ans = (ans*A[j]) % MOD
            j -= 1
            k -= 1
        k >>= 1
        for itr in range(k):
            left_product = A[i] * A[i + 1]
            right_product = A[j] * A[j - 1]
            if left_product > right_product:
                ans = (ans*left_product) % MOD
                i += 2
            else:
                ans = (ans*right_product) % MOD
                j -= 2

    print(ans % MOD)


if __name__ == "__main__":
    N, K = map(int, input().split(' '))
    A = list(map(int, input().split(' ')))
    main(A, N, K)

Measured memory_bytes: 31776