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

int main () {
	
	int n=0, r=0, b=0, i=0;
	string s="";

	cin >> n >> s;

	for (i=0; i<n; i++){
		if (s[i] == 'R') r++;
		else b++;
	}

	if (r>b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b;
   cin >> a >> b;

   bool flg = 0;
   if(a<=8 && b <=8) flg = 1;

   cout << (flg? "Yay!":":(") << endl;


   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    int A[1010], B[1010];
    for(int i = 0; i < n; i++) cin >> A[i] >> B[i];
    ll a = A[0], b = B[0];
    for(int i = 1; i < n; i++){
        ll m = max((a-1)/A[i] + 1, (b-1)/B[i] + 1);
        a = m * A[i];
        b = m * B[i];
    } 
    cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
  std::string s;
  while(std::cin>>s){
    if(std::cin.eof())return 0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='@'){
      for(int j=static_cast<int>(s[i+1]-'0');j;j--){
	std::cout<<s[i+2];
      }
      i+=2;
      continue;
    }
    else{std::cout<<s[i];}
  }
  std::cout<<std::endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, L, Q;
    cin >> N;
    vector<ll> x(N);
    REP(i,N) cin >> x[i];
    x.push_back(LINF);
    cin >> L >> Q;
    vector<vector<int>> to(22, vector<int>(N));
    REP(i,N){
        auto itr = lower_bound(x.begin(), x.end(), L+x[i]);
        if(*itr - x[i] > L) itr--;
        to[0][i] = itr - x.begin();
    }
    REP(i,20) REP(j,N) to[i+1][j] = to[i][to[i][j]];

    while(Q--){
        int a, b;
        cin >> a >> b;
        --a, --b;
        int ans = 0;
        if(a > b) swap(a,b);
        for(int i=20;i>=0;i--) if(to[i][a] < b){
            a = to[i][a];
            ans += 1 << i;
        }
        cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 10608
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N, X, T;
  cin >> N >> X >> T;

  cout << (N + (X - 1)) / X * T << endl;

  return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long k = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		long count = 0;
		if (b - a > 2 && k + 1 - a >= 2) {
			k -= a - 1;
			count = k % 2;
			count += b + (b - a) * (k / 2 - 1);
		} else {
			count = 1 + k;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int k;
string s;

string solve() {
    if (s.size() <= k) return s;
    return s.substr(0, k) + "...";
}

void input() {
    cin >> k >> s;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3132
N, Q = map(int, input().split())
s = '#' + input() + '#'
td = [input().split() for _ in range(Q)]

def check(x, target) :
    for t, d in td :
        if s[x] == t :
            if d == 'L' :
                x -= 1
            else :
                x += 1
        
        if x == target :
            return True
            
    return False

ret = 0
ok, ng = 0, N + 1
while ng - ok > 1 :
    mid = (ok + ng) // 2
    if check(mid, 0) :
        ok = mid
    else :
        ng = mid

ret += ok

ng, ok = 0, N + 1
while ok - ng > 1 :
    mid = (ok + ng) // 2
    if check(mid, N + 1) :
        ok = mid
    else :
        ng = mid
        
ret += N + 1 - ok

print(N - min(ret, N))

Measured memory_bytes: 92716
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] p = new boolean[X * 2];
            for (int i = 2; i < p.length; i++) {
                if (!p[i]) {
                    for (int j = 2; i * j < p.length; j++) {
                        p[i * j] = true;
                    }
                }
            }
            for (int i = X; i < p.length; i++) {
                if (!p[i]) {
                    out.println(i);
                    return;
                }
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 23764
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define mod 1000000007
#define inf 999999999

int main(){
  int a,b;
  cin >> a >> b;
  if(a-b>0) cout << a-1 << endl;
  else cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ld long double
const int mod=1e9 +7;

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

  
 int n,a,b;
 cin>>n>>a>>b;
vector<int>v(n);
 for(int i=0;i<n;i++)
 {
    cin>>v[i];
 }
 int ans=0;

 for(int i=1;i<n;i++)
 {
    ans+=min(b,a*(v[i]-v[i-1]));
 }
  cout<<ans<<"\n";

   
}

 

 
 
 
 
 

Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[100],i,k,x;
	scanf("%d",&n);
	for(i=0;i<n;i++)  scanf("%d",&a[i]);
	sort(a,a+n);
	k=0; i=0; x=0;
	while(i<=n){
		if(n-(k+1)<i){
			break;
		}
		if(a[k]>i) i++;

		if(a[k]<=i){
			k++;
		}
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 2772
N = int(input())
A = list(map(int, input().split()))

K = 0
m = 1000

for i in range(N):
    if i == N-1:
        m += K*A[i]
        break
    for k in range(1,N-i):
        if A[i] < A[i+k]:
            if K > 0:
                m += K*A[i]
            K = m//A[i]
            m = m%A[i]
            break
        else:
            if A[i] > A[i+k]:
                m += K*A[i]
                K = 0
                break
            else:
                continue
print(m)


Measured memory_bytes: 63108
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define inf 0x3f3f3f3f 
int main(){
	ll t , h[100001] , dp[100001] = {0} , k;
    cin >> t >> k;
	for(int i = 0 ; i < t ; ++i) scanf("%lld",h+i);
    for(int i = 1 ; i < t ; ++i){
        ll ans = inf;
        for(int j = 1 ; j <= k && i - j >= 0 ; ++j)
            ans = min(dp[i-j] + abs(h[i] - h[i-j]) , ans);
        dp[i] = ans;
    }
    cout<<dp[t-1];
}

Measured memory_bytes: 5124
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll N;
	
	cin >> N;

	int c[N-1], s[N-1], f[N-1];

	rep(i, N-1)
	{
		cin >> c[i] >> s[i] >> f[i];
	}

	rep(i, N-1)
	{
		int arrival = s[i] + c[i];

		for(int j = i + 1; j < N-1; j++)
		{
			if (arrival % f[j] == 0)
			{
				if (arrival >= s[j])
				{
					arrival = arrival + c[j];
				}
				else
				{
					arrival = s[j] + c[j];
				}
			}
			else
			{
				if (arrival > s[j])
				{
					arrival = (arrival / f[j] + 1) * f[j] + c[j];
				}
				else
				{
					arrival = s[j] + c[j];
				}
			}
		}
		cout << arrival << endl;
	}
	cout << 0 << endl;
	
	return 0;
}


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


int main() {
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int &x:a)
  {
    cin>>x;
  }
  vector<bool> dp(k + 1);
  for(int stones = 0; stones <= k; ++stones) {
      for(int x : a) {
          if(stones >= x && !dp[stones-x]) {
              dp[stones] = true;
          }
      }
  }

  puts(dp[k] ? "First" : "Second");

  /*
  vector<bool> dp(k+1);
  for(int stones=0;stones<=k;stones++)
  {
    for(int x : a)
    {
      if(x<=stones && !dp[stones-x])
      {
        dp[stones] = true;
      }
    }
  }
  if(dp[k])
    cout<<"first";
  else
    cout<<"second";
  /*
  if(helper(a,n,k,0)==0)
  {
    cout<<"first";
  }
  else
  {
    cout<<"second";
  }
*/
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN = 2000;
const int INF = (1<<30);
int A[MAXN + 5];
priority_queue<int, vector<int>, greater<int> >q1, q2;
int main() {
	int N, K, Q, ans = INF;
	scanf("%d%d%d", &N, &K, &Q);
	for(int i=1;i<=N;i++)
		scanf("%d", &A[i]);
	for(int i=1;i<=N;i++) {
		int le = 1;
		for(int j=1;j<=N+1;j++) {
			if( A[j] < A[i] ) {
				int len = j - le;
				for(int k=K;k<=len;k++) {
					q2.push(q1.top());
					q1.pop();
				}
				le = j+1;
				while( !q1.empty() )
					q1.pop();
			}
			else q1.push(A[j]);
		}
		if( q2.size() >= Q ) {
			for(int j=1;j<Q;j++)
				q2.pop();
			ans = min(ans, q2.top() - A[i]);
		}
		while( !q2.empty() )
			q2.pop();
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
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 (a>b) { a=b; return 1; } return 0; }

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(b<a){
        swap(a, b);
    }
    int ans = b - (a + w);
    if(ans < 0){
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
local mod = 1000000007
local mfl = math.floor
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local n, m = io.read("*n", "*n")
local x, y = {}, {}
for i = 1, n do x[i] = io.read("*n") end
for i = 1, m do y[i] = io.read("*n") end

local function solve(t)
  table.sort(t)
  local allsum = 0
  local sum = 0
  for i = 2, #t do
    t[i] = t[i] - t[1]
    sum = badd(sum, t[i])
  end
  t[1] = 0
  allsum = sum
  for i = 2, #t - 1 do
    sum = bsub(sum, bmul(bsub(t[i], t[i - 1]), #t + 1 - i))
    allsum = badd(allsum, sum)
  end
  return allsum
end

print(bmul(solve(x), solve(y)))


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

bool prime(int n) {
	if (n < 2) return false;
	for (int i = 2; i < sqrt(n) + 1; i++) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	vector<int> v = vector<int>(1, 0);
	for (int i = 1; i < 1000000; i++) {
		if (prime(i)) {
			v.push_back(v.back() + 1);
		} else {
			v.push_back(v.back());
		}
	}
	int n;
	while (cin >> n) {
		if (n == 1) {
			cout << 0 << endl;
		} else {
			cout << v[n] + 1 << endl;	
		}
	}
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int W,H;
    cin>>W>>H;
    vector<pair<ll,ll>> r(W+H);
    for (size_t i = 0; i < W; i++)
    {
        ll p;
        cin>>p;
        r[i]={p,0};
    }
    for (size_t i = 0; i < H; i++)
    {
        ll q;
        cin>>q;
        r[i+W]={q,1};
    }
    ll ans = 0;
    ll M = W+H;
    sort(all(r));
    for (size_t i = 0; i < M; i++)
    {
        if(r[i].second==0)
        {
            ans += (H+1)*r[i].first;
            W--;
        }
        else
        {
            ans += (W+1)*r[i].first;
            H--;
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6420
def main():
    N, W =  list(map(int, input().split()))

    dp = [-1] * (W + 1)
    dp[0] = 0

    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] != -1:
                if dp[i + w] < dp[i] + v:
                    dp[i + w] = dp[i] + v

    print(max(dp))

main()


Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  string s;
  cin>>s;
  bool f1=false,f2=false;
  rep(i,3){
    if(s[i]=='A') f1=true;
    if(s[i]=='B') f2=true;
  }
  if(f1&&f2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

int main(int argc, char const* argv[]) {
    int N, M;
    cin >> N >> M;

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    auto threshold = 1.0 * accumulate(A.begin(), A.end(), 0U) / (4 * M);

    // cout << "threshold" << threshold << endl;

    int selected = 0;

    for (int i = 0; i < N; i++) {
        if (A[i] >= threshold) {
            selected++;
        }
    }

    if (selected >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import fractions
a, b = input().split()
a = int(a)
b = int(b)

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))
"""

a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
      ans = ans * a[i] // fractions.gcd(ans, a[i])
      print(ans)
"""


Measured memory_bytes: 5048
n = int(input())
task = []
for i in range(n):
    a, b = map(int, input().split())
    task.append((a,b))
task.sort(key=lambda x:x[1])

res = 0
for j, k in task:
    res += j
    if res > k:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 31872
a = list(map(str, input()))
b = int(input())

for i in range(len(a)):
    if a[i] == 'a':
        continue
    else:
        s = ord(a[i]) - 96
        if 27 - s <= b:
            a[i] = 'a'
            b -= 27 - s

if b != 0:
    a[-1] = chr(((ord(a[-1]) - 97 + b) % 26) + 97)

print(''.join(a))

Measured memory_bytes: 4212
import sys
import fractions

sys.setrecursionlimit(10000000)
input=sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))

def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)

def lcm(a, b):
    return a // fractions.gcd(a, b) * b

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]

print(ans%mod)


Measured memory_bytes: 6108
def solve():
    cnt = -1
    while 1:
        cnt += 1
        H = int(input())
        if H==0:
            break
        puzzle = [list(map(int, input().split())) for _ in range(H)]
        ans = 0
        while True:
            flg = True
            for i, row in enumerate(puzzle):
                if len(set(row))>=4:
                    continue
                streak = [-1, 1]
                for j, c in enumerate(row):
                    if c==-1:
                        streak[0] = -1
                        streak[1] = 1
                        continue
                    if c==streak[0]:
                        streak[1]+=1
                        if streak[1]==3:
                            flg = False
                            ans += c*3
                            puzzle[i][j-2:j+1] = [-1]*3
                        elif streak[1]>=4:
                            ans += c
                            puzzle[i][j] = -1
                    else:
                        streak[0] = c
                        streak[1] = 1
            for i, row in enumerate(puzzle[::-1]):
                if i==H-1:
                    break
                for j, c in enumerate(row):
                    if c==-1:
                        for h in range(H-i-1):
                            if puzzle[(H-i-1)-h-1][j]!=-1:
                                puzzle[-i-1][j] = puzzle[(H-i-1)-h-1][j]
                                puzzle[(H-i-1)-h-1][j] = -1
                                break
            if flg:
                print(ans)
                break

solve()


Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const ll sz = 1e7, inf = 1e9 + 7;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
   /*int a,b,c,d;
   cin>>a>>b>>c>>d;
   int x=a/c+(a%b>=1);
   int y=c/d+(c%d>=1);
   //cerr(x);
   if(x<=y)cout<<"Yes\n";
   else cout<<"No\n";*/
    set<string>st;
	int n;cin>>n;
	for(int i=0;i<n;i++){
		string s;cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<'\n';

	return 0;
}


Measured memory_bytes: 19244
#include<stdio.h>
#include<algorithm>
#include<iostream>

using namespace std;

int main(){

  char image[100][100],Image[200][100];
  int H,W; cin >> H >> W;
  for(int i  = 0;  i<H; i++) {
      for(int  j = 0; j < W; j++) {
        cin >> image[i][j];
    }
  }

  for(int i = 0;  i<2*H; i+=2) {
      for(int  j = 0; j< W; j++) {
        Image[i][j] = image[i/2][j];
        Image[i+1][j] = Image[i][j];
    }
  }

  for(int i  = 0;  i<2*H; i++) {
      for(int  j = 0; j< W; j++) {
        printf("%c",Image[i][j]);
    }
    printf("\n");
  }


return 0;
}


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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, m; std::cin >> n >> m;
  vi cnt(n+1);
  rep(i, m) {
    int l, r; std::cin >> l >> r; --l, --r;
    cnt[l]++, cnt[r+1]--;
  }
  rrep(i, n-1) cnt[i] += cnt[i-1];
  int ans = 0;
  rep(i, n) ans += (cnt[i] == m);
  std::cout << ans << "\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int main(void){
	int n;
	cin>>n;
	ll a[n];
	rep(i,n)cin>>a[i];
	ll cnt=n, ans;
	while(cnt!=1){
		ll min=MAX, id;
		rep(i,n){
			if(a[i]>0 && min>a[i]){
				min=a[i];
				id=i;
			}
		}
		rep(i,n){
			if(i!=id && a[i]!=0){
				a[i]=a[i]%min;
				if(a[i]==0)cnt--;
			}
		}
		ans=min;
	}

	cout<<ans<<endl;

	return 0;

}


Measured memory_bytes: 1024
s = input()
t = input()
S = len(s)
T = len(t)
dp = [[0]*(T+1) for _ in range(S+1)]
revans = ''

for i in range(1, S+1):
    for j in range(1, T+1):
        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])

while dp[i][j] > 0:
    if dp[i-1][j] == dp[i][j]:
        i -= 1
    elif dp[i][j-1] == dp[i][j]:
        j -= 1
    else:
        revans += s[i-1]
        i -= 1
        j -= 1

print(revans[::-1])

Measured memory_bytes: 112220
using System;

namespace ABC_118_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');
            int A = int.Parse(word[0]);
            int B = int.Parse(word[1]);
            for (int i = 1; i <= 20; i++)
            {
                if (A * i == B)
                {
                    Console.WriteLine(A + B);
                    break;
                }
                else if (A * i > B)
                {
                    Console.WriteLine(B - A);
                    break;
                }
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    int ans;
    sort(whole(d));
    ans = d[n/2]-d[n/2-1];
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
using namespace std;

char s[100];

int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	int i;
	for(i=1;i<=len-8;i++){
		printf("%c",s[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 128
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
x = list(map(int, input().split()))

x_p = [0] + [p for p in x if p > 0]#正
x_z = x.count(0)#0
x_n = [(-1) * ng for ng in x if ng < 0]#負
x_n = [0] + sorted(x_n)#0から始まる絶対値

myK = k - x_z#左右に移動して点火するろうそく数

if myK <= 0:
    print(0)
else:
    ans = float('inf')
    for i in range(myK + 1):
        if 0 <= i < len(x_p) and 0 <= myK - i < len(x_n):
            ans = min(ans, x_p[i] + x_n[myK - i] + min(x_p[i], x_n[myK - i]))
    print(ans)

Measured memory_bytes: 14544
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;

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

map<char,vector<ll>>m;

for(ll i=0;i<s.size();i++)
{
	m[s[i]].push_back(i);
}
ll a,b;
bool ok=false;
for(auto x:m )
{
//	cout<<x.second.size()<<" \n";
	for(ll i=x.second.size()-1;i>=0;i--)
	{
		
		for(ll j=0;j<i;j++)
		{
			
		//	cout<<x.second[i]<<" "<<x.second[j]<<"....\n";
			if((x.second[i]-x.second[j]+1)/2<i-j+1)
			{
				ok=true;
				a=x.second[j]+1;
				b=x.second[i]+1;
				break;
			}
			
		}
		if(ok)break;
		
		}
		if(ok)break;	
		
	
	
}

if(ok)cout<<a<<" "<<b;
else
cout<<-1<<" "<<-1;
    
 
   
}

		
	
	
	
	


Measured memory_bytes: 4788
l1 = list(map(int, input().split()))
A = list(map(int, input().split()))

N = l1[0]
x = l1[1]

i = 0
s = 0

A.sort()

while True:
    if x < A[i]:
        break
    if i == N-1:
        if A[i] == x:
            s = s + 1
        break
    x = x - A[i]
    i = i + 1
    s = s + 1


print(s)


Measured memory_bytes: 3064
s=[i for i in input()]
t=len(s)-1
tmp=2**t
ans=0
for i in range(tmp):
    p=bin(i)[2:]
    p="0"*(t-len(p))+p
    x=""
    for j,k in enumerate(s):
        x+=k
        if j!=t and p[j]=="1":
            x+="+"
    ans+=eval(x)
print(ans)

Measured memory_bytes: 3064
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
        bc: [(usize, usize); m],
    }
    let mut v: Vec<(usize, usize)> = bc.into_iter().collect();
    v.sort_by_key(|&a| -(a.1 as i32));
    let mut cards: Vec<usize> = a.into_iter().collect();

    'outer: for &(bi, ci) in &v {
        for _ in 0..bi {
            cards.push(ci);
            if cards.len() > 3 * n {
                break 'outer;
            }
        }
    }

    cards.sort_by_key(|&a| -(a as i32));
    println!("{}", cards.iter().take(n).fold(0, |sum, &a| sum + a));
}


Measured memory_bytes: 11576
S = gets.chomp

if S != S.reverse
  puts 'No'
  exit
end

s1 = S[0...((S.length - 1) / 2)]
s2 = S[((S.length + 1) / 2)...S.length]

puts s1 == s1.reverse && s2 == s2.reverse ? 'Yes' : 'No'

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#define rep(i,m,n) for(int i=m; i<(n); i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll inf=1LL<<60;
double eps=1e-14;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pll> ab(n);
    rep(i,0,n) cin >> ab[i].second >> ab[i].first;
    sort(ab.begin(), ab.end());
    ll tmp=0;
    bool ok = true;
    rep(i,0,n)
    {
        tmp += ab[i].second;
        if(tmp > ab[i].first) ok = false;
    }
    if(ok) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3328
from copy import deepcopy
import numpy as np
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, row in zip(range(h), grid):
            for j, val in zip(range(w), row):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, row)) for row in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

X = [x.strip() for x in open(0).readlines()]
h, w, k = map(int, X[0].split())
grid_origin = Grid(X[1:])
ans = 0
for i in range(2 ** h):
    grid_tmp = deepcopy(grid_origin.grid)
    Y = [k for k in range(h) if (i >> k) & 1]
    for y in Y:
        grid_tmp[y, :] = 'x'
    
    for j in range(2 ** w):
        grid = deepcopy(grid_tmp)
        X = [k for k in range(w) if (j >> k) & 1]
        for x in X:
            grid[:, x] = 'x'
        ans += np.sum(grid == '#') == k
print(ans)

Measured memory_bytes: 27344
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  int N,ans=1;
  cin>>N;
  
  int P[N];
  REP(i,N) cin>>P[i];
  
  int mn=P[0];
  
  for(int i=1; i<N; ++i){
    if(mn>P[i]){
      ans++;
      mn=P[i];
    }
  }
  
  
  co(ans);
}

Measured memory_bytes: 1024
package main
import "fmt"
import "strconv"

func sum_of_digits(i int) int{ //10進法での各桁の和を求める関数
  s := strconv.Itoa(i)
  result := 0
  for j:=0; j<= len(s)-1; j++{
    // fmt.Println(s[j:j+1])
    var k int
    k,_ = strconv.Atoi(s[j:j+1])
    result += k
  }
  return result
}

func main(){
  var(
    N int
    A int
    B int
  )
  fmt.Scan(&N)
  fmt.Scan(&A)
  fmt.Scan(&B)
  // fmt.Println(sum_of_digits(N))
  result := 0
  for i:=1; i<=N; i++{
    num := sum_of_digits(i)
    if num >= A && num<= B{
      result += i
    }
  }
  // fmt.Println(N,A,B)
  fmt.Println(result)

}


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

#define  ll  long long
#define  pii pair<int,int>
#define  pll pair<ll , ll>
#define  debug cout << "this far" << endl;
#define  For(i, n) for(int i = 0; i < (n); ++i)
#define  lsb(x) ((x) & (-x))
#define  PI acos(-1)
#define  line cout << endl;
#define  getbit(n, i) (((n) & (1LL << (i))) != 0)
#define  resetbit(n, i) ((n) & (~(1LL << (i))))
#define  setbit(n, i) ((n) | (1LL << (i)))
#define  togglebit(n, i) ((n) ^ (1LL << (i)))
#define  gap " "
using namespace std;
const int N = 5e3 + 10;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    unsigned long  long ans = 1 ;
    ll n ; cin >> n ;
    double lgres = 0 ;
    ll a[n] ;
    bool anyzero = false;
    for(ll i = 0 ; i < n ;  ++i ) {
        cin >> a[i];
        lgres += log10(a[i]);
        if (a[i] == 0) anyzero = true;
    }
    if(anyzero) return  cout << "0" , 0 ;
    if(lgres > 18) return  puts("-1") , 0 ;
    else {
        for(ll i = 0 ; i < n ; ++i) ans *= a[i] ;
        if(ans > 1000000000000000000LL ) cout <<"-1" ;
        else cout << ans ;
    }



}

Measured memory_bytes: 4700
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <unordered_map>
#include <queue>
#include <map>
#include <sstream>
#include <set>
#include <cstdlib>
#include <ctime>
#include <unordered_set>
#include <bitset>
#include <chrono>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
//#pragma GCC optimize(3, "Ofast", "inline")
#define MAX_INF 0x3f3f3f3f
template <class T, class C>
void print(C name, T a)
{
	cout << name << ": " << a << endl;
}
template <class T>
T gcd(T a, T b)
{
	return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b, ll p)
{
	ll ans = 1;
	a %= p;
	while (b)
	{
		if (b & 1)
			ans = ans * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return ans;
}
template <typename _Tp>
void read(_Tp &x)
{
	char ch;
	bool flag = 0;
	x = 0;
	while (ch = getchar(), !isdigit(ch))
		if (ch == '-')
			flag = 1;
	while (isdigit(ch))
		x = x * 10 + ch - '0', ch = getchar();
	if (flag)
		x = -x;
}
template <class T>
void print(T x)
{
	if (x < 0)
	{
		x = -x;
		putchar('-');
	}
	if (x > 9)
		print(x / 10);
	putchar(x % 10 + '0');
}
const ll mod = 998244353;
const ll inf = 1e18;
ll add(ll x, ll t)
{
	x %= mod;
	t %= mod;
	return (x + t) % mod;
}
ll del(ll ans, ll x)
{
	ans %= mod;
	ans += mod;
	x %= mod;
	return (ans - x) % mod;
}
ll mul(ll ans, ll x)
{
	ans %= mod;
	x %= mod;
	return (ans * x) % mod;
}
#define fir(i, a, b) for (int i = a; i <= b; i++)
const int maxn = 3000+ 20, N = 2010, M = 3000 + 10;
int p[maxn];
ll c[maxn];
vector<vector<ll>> sum;
ll a[maxn][maxn];
ll dp[maxn][maxn][4];
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	fir(j,1,k)
	{
		int x,y;
		ll w;
		scanf("%d%d%lld",&x,&y,&w);
		a[x][y]=w;
	}
	ll ans=0;
	fir(i,1,n)
	fir(j,1,m)
	{
		fir(u,1,3)
		{
			dp[i][j][u]=max(dp[i][j-1][u-1]+a[i][j],dp[i][j-1][u]);
			fir(k,1,3)
			dp[i][j][u]=max(dp[i][j][u],dp[i-1][j][k]+a[i][j]);
			ans=max(ans,dp[i][j][u]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 356988
#include<cstdio>
int n,m,s[200005],e[200005];

int main()
{
	int ts,te;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&ts,&te);
		if(ts==1) s[te]=1;
		if(te==n) e[ts]=1;
	}
	for(int i=1;i<=n;i++)
	{
		if(s[i]==1&&e[i]==1)
		{
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 1664
x,k,d=map(int,raw_input().split())

def solve(x,k,d):
    x=abs(x)
    if (x>0 and x/d>=k):
        x=x-k*d
        return x
    y=x//d
    x-=y*d
    k-=y
    if k%2==0:
        return abs(x)
    return min(abs(x+d),abs(x-d))
print(solve(x,k,d))


Measured memory_bytes: 84900
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
t=s0()

len_s=len(s)
len_t=len(t)

dp=[[0]*(len_t+1) for _ in range(len_s+1)]
for i in range(len_s):
    for j in range(len_t):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1],dp[i][j]+1)
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

# print(dp)

#reverse
ans = ""
i = len_s
j = len_t
while (i>0  and j>0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1] 
        i -= 1
        j -= 1
print(ans[::-1])

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

using namespace std;

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    for(int i= 0;i <n;i++){
        string x;
        cin >> x;
        mp[x]++;
    }
    int mx = 0;
    for( auto i: mp){
        mx = max(mx, i.second);
    }
    for(auto i: mp){
        if(i.second == mx){
            cout << i.first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <iostream>
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC127();
}

void ABC127(){
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b;
    else if(a>=6)cout<<b/2;
    else cout<<0;
}

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

struct List {
    string name;
    int point;
    int index;
    static bool Name(const List& rLeft, const List& rRight) {
      return rLeft.name != rRight.name ? rLeft.name < rRight.name : rLeft.point > rRight.point;
    }
  };

int main() {
  int n;
  cin >> n;

  vector<List> list(n);
  for(int i=0;i<n;i++) {
    cin >> list[i].name >> list[i].point;
    list[i].index = i+1;
  }
  sort(list.begin(),list.end(), List::Name);
  
  for(int i=0;i<n;i++) {
    cout << list[i].index << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = [list(map(int, input().split(' '))) for i in range(n)]
d = 0
e = 0

for i in range(n):
	for j in range(m):
		d += b[i][j] * a[j]
	if d + c > 0:
		e += 1
	d = 0
print(e)

Measured memory_bytes: 3064
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut k: usize,
        a: [Usize1; n],
    }

    let mut gone1 = HashSet::new();
    gone1.insert(0);
    let mut now = 0;
    loop {
        now = a[now];
        k -= 1;
        if k == 0 {
            println!("{}", now + 1);
            return;
        }
        if gone1.contains(&now) {
            break;
        }
        gone1.insert(now);
    }

    let mut gone2 = HashSet::new();
    gone2.insert(now);
    let mut loop_list = vec![now];
    loop {
        now = a[now];
        k -= 1;
        if k == 0 {
            println!("{}", now + 1);
            return;
        }
        if gone2.contains(&now) {
            break;
        }
        gone2.insert(now);
        loop_list.push(now);
    }
    let goal = k % loop_list.len();
    println!("{}", loop_list[goal] + 1);
}


Measured memory_bytes: 11756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder102
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int endFlag = 0;
            for (int i = 0; i <= 25; i++)
            {
                for (int j = 0; j <= 14; j++)
                {
                    if (i * 4 + j * 7 == X)
                    {
                        endFlag = 1;
                        break;
                    }
                }
                if (endFlag == 1) break;
            }
            if (endFlag == 1) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==0){
        cout<<b/c+1<<endl;
    }
    else{
        cout<<b/c-((a-1)/c)<<endl;
    }
}

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

int n, cnt;
std::unordered_map<std::string, int>mp;
std::vector<std::string>a;
int main() {
	std::cin >> n;
	for(int i = 0; i < n; ++i) {
		std::string s;
		std::cin >> s;
		mp[s]++;
		cnt = std::max(cnt, mp[s]);
	}
	for (auto& p : mp) {
		if (p.second == cnt) {
			a.emplace_back(p.first);
		}
	}
	std::sort(a.begin(), a.end());
	for (auto& s : a) std::cout << s << "\n";
}

Measured memory_bytes: 26692
#include "bits/stdc++.h"
#define allr(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define sp " "
#define double long double
#define pb push_back
#define ff first
#define int long long
#define ss second
#define vi vector<int>
#define mem(ara, a) memset(ara, a, sizeof(ara))

long long inf = 2e18;
long long minf = -inf;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int a , b;
    cin >> a >> b;
    cout<<(a*(a-1)/2)+(b*(b-1)/2);

}






Measured memory_bytes: 256
n,k = map(int,raw_input().split())
a = map(int,raw_input().split())
mod = 10**9 + 7

inv1 = 0
for i in xrange(n-1):
	for j in xrange(i+1,n):
		if a[i] > a[j]:
			inv1 += 1

s = sorted(a)
groups = ((k-1)*k/2)%mod
inv2 = 0
same = 0
for i in xrange(n):
	if i > 0 and s[i] == s[i-1]:
		same += 1
		inv2 += i-same
	else:
		same = 0
		inv2 += i
print (k*inv1+groups*inv2)%mod

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}


int main()
{
	int n;
	cin>>n;
	vi dp(3);
	for(int i=0;i<n;i++)
	{
		vi dp_new(3);
		vi v(3);
		for(int j=0;j<3;j++) cin>>v[j];
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j!=k) dp_new[j]=max(dp[k]+v[j],dp_new[j]);
			}
		}
		dp=dp_new;
	}
	cout<<max({dp[0],dp[1],dp[2]})<<endl;
}

Measured memory_bytes: 256