akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{
string s;
cin>>s;
int n=s.size();
rep(i,0,n)
cout<<"x";



}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int mp[1<<16];

int main(){
    rep(i,1<<16)mp[i] = -1;
    vector<pii> stamp;
    int n;
    cin>>n;
    rep(i,n){
        int h,w;
        cin>>h>>w;
        stamp.pb(pii(h,w));
    }
    
    vector<string> vs(4);
    rep(i,4)cin>>vs[i];
    
    
    queue<int> que;
    que.push((1<<16)-1);
    mp[(1<<16)-1] = 0;
    
    while(que.size()){
        int q = que.front();
        que.pop();
        int dist = mp[q];
        
        for(const auto &stm:stamp){
            int h,w;
            tie(h,w) = stm;
            for(int i=-h+1;i<4;i++){
                for(int j=-w+1;j<4;j++){
                    int r=0,g=0,b=0;
                    for(int ii = i;ii<i+h;ii++){
                        ii = max(ii,0);
                        if(ii>=4)break;
                        for(int jj = j;jj<j+w;jj++){
                            jj = max(jj,0);
                            if(jj>=4)break;
                            
                            if( (q>>(ii*4+jj))%2 && vs[ii][jj]=='R' )r++;
                            if( (q>>(ii*4+jj))%2 && vs[ii][jj]=='G' )g++;
                            if( (q>>(ii*4+jj))%2 && vs[ii][jj]=='B' )b++;
                            if( (bool)r + (bool)(g) + (bool)(b)>=2 )goto end_loop;
                        }
                    }
                end_loop:;
                    if( (bool)r + (bool)(g) + (bool)(b)==1 ){
                        int tmp = q;
                        for(int ii = max(0,i);ii<min(4,i+h);ii++){
                            for(int jj = max(0,j);jj<min(4,j+w);jj++){
                                tmp &= ~(1<<(ii*4+jj));
                            }
                        }
                        if(mp[tmp]==-1){
                            int count = 0;
                            rep(ii,4)rep(jj,4)if( (tmp>>(ii*4+jj))%2==0 )count++;
                            if(count==16){
                                cout<<dist+1<<endl;
                                return 0;
                            }
                            
                            que.push(tmp);
                            mp[tmp] = dist+1;
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int x = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o')
			x += 1;
	}
	cout << 700 + x * 100 << "\n";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int N;
    cin >> N;
    vector<int> t(N);
    for(int i = 0; i < N - 1; ++i) {
        int C, S, F;
        cin >> C >> S >> F;
        t[i] = S + C;
        for(int j = 0; j < i; ++j) {
            if(t[j] <= S)
                t[j] = S + C;
            else if (t[j] % F == 0)
                t[j] += C;
            else
                t[j] += (F - t[j] % F) + C;
        }
    }
    for(int i = 0; i < N; ++i)
        cout << t[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
int main() {
    int N, T; cin >> N >> T;
    vector<ll> A(N), diff(N);

    rep(i,N){
        cin >> A[i];
    }

    ll minimum=INF;
    ll diff_max=0LL;
    for(int i=0; i<N; i++){
        diff_max = max(diff_max, A[i]-minimum);
        diff[i] = A[i]-minimum;
        minimum = min(minimum, A[i]);
    }

    int cnt = 0;
    for(int i=0; i<N; i++){
        if(diff[i]==diff_max){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 2424
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//map
int main()
{
    int a,b;
    cin >> a >> b;


    int d = a/b;
    int r = a%b;
    double f = double(a)/double(b);

    printf("%d %d %.8f\n",d,r,f);
    //cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,m;
    cin>>n>>m;
    if(n==1&&m==1)
      cout<<1<<endl;
    else if(n==1||m==1)
      if(n==1)
        cout<<max(0ll,m-2)<<endl;
      else
        cout<<max(0ll,n-2)<<endl;
    else if(n==2||m==2)
      cout<<0<<endl;
    else
      cout<<(n-2)*(m-2)<<endl;
}
return 0;
}

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

#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;


int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll binomialCoeff(int n, int k)
{
    ll res = 1;
    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    while(1)
    {
        while(b<=a)
        {
            b=b*2;
            k--;
        }
        while(c<=b)
        {
            c=c*2;
            k--;
        }
        break;
    }
    //cout<<k; br;
    if(k<0){cout<<"No";}
    else cout<<"Yes";

	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
static const double PI = acos(-1);
#define EPS 0.0000001
double getArea( double c, double A, double B ){
    return c*c*sin(A)*sin(B)/(2*sin(A+B));
}

bool eq( double a, double b ){
    return fabs(a-b)<EPS;
}

void compute(set<double> angle ){
    vector<double> v;
    for ( set<double>::iterator it = angle.begin(); it != angle.end(); it++ ){
	double x = *it;
	if ( v.size() == 0 ) v.push_back(x);
	else if ( fabs(v[v.size()-1]-x) > EPS ) v.push_back(x);
    }

    double r = 0.5/cos(30*PI/180);
    int n = v.size();
    double d = (v[1] - v[0])/2;
    double area = 2*getArea(r, d*PI/180, 30*PI/180);
    printf("%.16lf\n", area*n);
}

void insertP( set<double> &p, double a ){
    if ( a > 360.0 || eq(a, 360)) p.insert(a - 360.0);
    else p.insert(a);
}

main(){
    int n;
    while( cin >> n && n ){
	set<double> p;
	for ( int i = 0; i < 3; i++ ) p.insert(i*120.0);
	double cur = 0.0;
	for ( int t = 1; t < n; t++ ){
	    cur += 360.0/n;
	    for ( int i = 0; i < 3; i++ ) insertP(p, cur+i*120.0);
	}
	compute(p);
    }
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string a,b,c;
    cin >> a >> b;
    c = a+b;
    int x = stoi(c);
    //cout << x << endl;
    FOR(i,4,1000){
        if(i*i==x){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(M)]

cost = [[float('inf')] * N for _ in range(N)]
for i in range(M):
    a, b, c = abc[i][0], abc[i][1], abc[i][2]
    cost[a-1][b-1] = c
    cost[b-1][a-1] = c

from scipy.sparse.csgraph import floyd_warshall
dist = floyd_warshall(cost)

mindist = float('inf')
import itertools
for it in itertools.permutations(r):
    it = list(it)
    d = 0
    for i in range(R - 1):
        d += int(dist[it[i]-1][it[i+1]-1])
    # print(it)
    mindist = min(mindist, d)
print(mindist)


Measured memory_bytes: 31700
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let s = {}
    s["a"] = next().split("")
    s['b'] = next().split("")
    s['c'] = next().split("")
    let turn = "a"
    while(true){
        let curr = s[turn].shift()
        if(curr){
            turn = curr
        } else {
            console.log(turn.toUpperCase())
            return
        }
    }

}
Main()


Measured memory_bytes: 29560
n = int(input())
a = list(map(int, input().split()))
ans = 0
flag = False
while True:
    for i in range(n):
        if a[i]%2 == 1:
            flag = True
            break
        a[i] //= 2
    if flag:
        break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007


int main() {
	int h, w;
	cin >> h >> w;
	vector<string>s(h);
	for (int i = 0; i < h; i++)cin >> s[i];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				int count = 0;
				for (int x = -1; x <= 1; x++) {
					for (int y = -1; y <= 1; y++) {
						if(i+x < h && i+x >= 0 && j+y < w && j+y >= 0 && s[i + x][j + y] == '#')count++;
					}
				}
				cout << count;
			}
			else {
				cout << s[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
	while(1){
		string s;cin>>s;
		if(s==".")break;

		stack<int> st;
		vector<pair<int,int>>moji;
		int cnt=0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='+')cnt++;
			else if(s[i]=='-')cnt--;
			else if(s[i]=='['){
				st.push(moji.size());
			}
			else if(s[i]==']'){
				int l = st.top();st.pop();
				reverse(moji.begin()+l,moji.begin()+moji.size());
			}
			else if(s[i]=='?'){
				moji.push_back(make_pair(0,cnt));
				cnt=0;
			}
			else{
				moji.push_back(make_pair(s[i],cnt));
				cnt=0;
			}
		}

		string ans;
		for(int i=0;i<moji.size();i++){
			int cnt = moji[i].second;
			cnt += 26*4;
			cnt%=26;
			char c = moji[i].first;
			if(c==0)ans.push_back('A');
			else{
				for(int j=0;j<cnt;j++){
					c++;
					if(c>'Z')c='A';
				}
				ans.push_back(c);
			}
		}

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

Measured memory_bytes: 3152
/*Author SHUBH AGRAWAL  */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
    fac[i] = fac[i-1]*i%p; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


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

lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,n2,h,z;
lld w,u;

lld d,p=1000000000;
bool chkpalin(string s)
{
    lld l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]!=s[l-1-i])
        {
            return false;
        }
    }
    return true;
}

void solve()
{
    string s,s1,s2;
    cin>>s;
    l=s.size();
    if(l%2==0)
    {
        cout<<"No";
        return;
    }
    k=1;
    s1=s.substr(0,(l/2));
    s2=s.substr((l/2)+1,(l/2));
   // cout<<s1<<" "<<s2;
    if(chkpalin(s)==false || chkpalin(s1)==false || chkpalin(s2)==false )
    {
        cout<<"No";
        return ;
    }
    cout<<"Yes";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
   //cin>>t;
   for(int i=0;i<t;i++)
    {
     //   cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }
    return 0;
}


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

int n,ans=10000;

int sum(int val){
    int p=0;
    
    while(val){
        p+=val%10;
        val/=10;
    }
    
    return p;
}

int main(){

	cin>>n;
	
	for(int i=1;i<n;i++){
	    ans=min(ans,sum(i)+sum(n-i));
    }
    
    cout<<ans<<endl;

return 0;
}


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

namespace kyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int s1 = 0;
            int s2 = 0;
            s1 = int.Parse(s.Substring(0, 2));
            s2 = int.Parse(s.Substring(2, 2));
            Boolean yy1 = false;
            Boolean mm1 = false;
            Boolean yy2 = false;
            Boolean mm2 = false;
            if (s1 > 12 | s1 == 0)
            {
                yy1 = true;
            }else
            {
                yy1 = true;
                mm1 = true;
            }
            if (s2 > 12 | s2 == 0)
            {
                yy2 = true;
            }
            else
            {
                yy2 = true;
                mm2 = true;
            }
            if (yy1 & mm1 & yy2 & mm2)
            {
                Console.WriteLine("AMBIGUOUS");
            }else if(yy1 & mm2)
            {
                Console.WriteLine("YYMM");
            }else if(mm1 & yy2)
            {
                Console.WriteLine("MMYY");
            }
            else
            {
                Console.WriteLine("NA");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
#define ll long long
int main()
{
    ll n,x = 1;
    for(int cas = 1;cas <= 1;cas++)
    {
        cin >> n;
        x = 1;
        vector<char>ans;
        int k = 10;
        while(x <= n)
        {
            if(n % (x*26)==0)
            {
                n -= x*26;
                ans.push_back('z');
            }
            else
            {
                char c = ((n/x)%(26))-1+'a';
                ans.push_back(c);
                n -= x * (c-'a'+1);
            }
            x = x * 26;
        }
        for(int i=ans.size()-1;i>=0;i--)
        {
            cout << ans[i];
        }
        cout << '\n';
    }



    return 0;
}


Measured memory_bytes: 3588
N = int(input())
A = list(map(int, input().split()))
M = 2 ** N

ans = [0] * M
max_list = [0] * M
for i in range(1, M):
    cand = [i]
    ans_cand = []
    ibin = bin(i)[2:].zfill(N)
    for j in range(N):
        if ibin[j] == '1':
            cand.append(max_list[i - 2 ** (N - j - 1)])
            ans_cand.append(ans[i - 2 ** (N - j - 1)])
    cand_set = sorted(list(set(cand)))
    max1 = 0
    max2 = 0
    for c in cand_set:
        Ac = A[c]
        if Ac >= max1:
            max2 = max1
            max1 = Ac
            max_idx = c
        elif Ac > max2:
            max2 = Ac
    ans_cand.append(max1 + max2)
    ans_cand.append(ans[i - 1])
    max_list[i] = max_idx
    ans[i] = max(ans_cand)
    print(ans[i])


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

int main() {
	int	N, Q;
	cin >> N >> Q;
	vector<priority_queue<int>> vec(N);
	rep(i, Q)
	{
		int a, b;
		cin >> a >> b;
		if (a == 0)
		{
			int	c;
			cin >> c;
			vec.at(b).push(c);
		}
		else if (!vec.at(b).empty())
		{
			if (a == 1)
				cout << vec.at(b).top() << endl;
			else if (a == 2)
				vec.at(b).pop();

		}
	}
}



Measured memory_bytes: 4068
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*3 for _ in range(n+1)]
#dp[i][a] := i日目にaするときの、i日目までの幸福度の最大値
for i in range(1, n+1):
    dp[i][0] = max(dp[i-1][1] + abc[i-1][0],
                   dp[i-1][2] + abc[i-1][0])
    dp[i][1] = max(dp[i-1][0] + abc[i-1][1],
                   dp[i-1][2] + abc[i-1][1])
    dp[i][2] = max(dp[i-1][0] + abc[i-1][2],
                   dp[i-1][1] + abc[i-1][2])
print(max(dp[n]))


Measured memory_bytes: 100780
<?php
$a = (int)trim(fgets(STDIN));
$b = (int)trim(fgets(STDIN));
$c = (int)trim(fgets(STDIN));
$x = (int)trim(fgets(STDIN));
$ans = 0;
for($tmp = 0; $tmp <= $a; $tmp++){
    for($tmp2 = 0; $tmp2 <= $b; $tmp2++){
        for($tmp3 = 0; $tmp3 <= $c; $tmp3++){
            if (500*$tmp+100*$tmp2+50*$tmp3 == $x){
                $ans++;
            }
        }
    }
}
echo ($ans)."\n";
?>

Measured memory_bytes: 4728
from operator import itemgetter

H, W, M = map(int, input().split())
h_count = [[i, 0] for i in range(H)]
w_count = [[i, 0] for i in range(W)]
exist = dict()
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    h_count[h][1] += 1
    w_count[w][1] += 1
    exist[(h, w)] = True

h_count.sort(key=itemgetter(1), reverse=True)
w_count.sort(key=itemgetter(1), reverse=True)
h_max = h_count[0][1]
w_max = w_count[0][1]
res = 0
is_dup = True
for h in h_count:
    if h[1] != h_max or not is_dup:
        break
    for w in w_count:
        if w[1] != w_max or not is_dup:
            break
        val = h[1] + w[1]
        if exist.get((h[0], w[0]), False):
            val -= 1
        else:
            is_dup = False
        res = max(res, val)
print(res)


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {	
	int A,B;
	cin >> A >> B;
	int cnt = 0;
	for (int i = A; i <= B; ++i) {
		int a[5];
		int j=4;
		int t = i;
		while (t) {
			a[j--] = t%10;
			t/=10;
		}
		bool ok = true;
		for (j = 0; j < 3; ++j) {
			if (a[j] != a[4-j])
				ok = false;
		}
		if (ok)
			++cnt;
	}

	cout << cnt << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

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

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
//constexpr ll P = 1e9 + 7;
//constexpr ll P = 998244353;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

struct union_find {
	long long N;					// the number of nodes
	long long M;					// the number of trees
	std::vector<long long> parent;	// parent[i] := the direct parent of i
	std::vector<long long> size;	// size[i] := the number of nodes in the tree containing i

	union_find(long long n) : N(n), M(n) {
		parent.resize(n, -1);
		size.resize(n, 1);
	}

	long long root(long long i) {
		if (parent[i] == -1) return i;
		else return parent[i] = root(parent[i]);
	}

	bool is_united(long long i, long long j) {
		return (root(i) == root(j));
	}

	// true : unite succeeded
	bool unite(long long i, long long j) {
		i = root(i); j = root(j);
		if (i == j) return false;
		if (size[i] < size[j]) std::swap(i, j);
		parent[j] = i;
		size[i] += size[j];
		M--;
		return true;
	}
};

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

	ll n, m;
	cin >> n >> m;
	union_find uf(n);
	while (m--) {
		ll a, b;
		cin >> a >> b;
		uf.unite(a - 1, b - 1);
	}
	ll ans = 0;
	for (auto i : uf.size) ans = max(ans, i);
	cout << ans << endl;
}

Measured memory_bytes: 6364
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//head
int n;
string s;
bool works(int* a1){
	for(int i = 1; i < n -1; i++){
  		if(a1[i] == 0){
  			if(s[i] == 'o'){
  				if(a1[i+1] == -1)
  					a1[i+1] = a1[i-1];
  				else if(a1[i+1] != a1[i-1]) return false;
  			}
  			else{
  				if(a1[i+1] == -1)
  					a1[i+1] = a1[i-1] ^ 1;
  				else if(a1[i+1] != a1[i-1] ^ 1) return false;
  			}
  		}
  		else{
  			if(s[i] == 'o'){
  				if(a1[i+1] == -1)
  					a1[i+1] = a1[i-1] ^ 1;
  				else if(a1[i+1] != a1[i-1] ^ 1) return false;
  			}
  			else{
  				if(a1[i+1] == -1)
  					a1[i+1] = a1[i-1];
  				else if(a1[i+1] != a1[i-1]) return false;
  			}
  		}
  	}
  	return true;
}
void printans(int* a1){
	for(int i = 0; i < n; i++){
		if(a1[i] == 0){
			cout << 'S';
		}
		else{
			cout << 'W';
		}
	}
	cout << "\n";
}
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);

  	cin >> n;
  	cin >> s;
  	int a1[n];
  	int a2[n];
  	int a3[n];
  	int a4[n];
  	memset(a1, -1, sizeof(a1));
  	memset(a2, -1, sizeof(a2));
  	memset(a3, -1, sizeof(a3));
  	memset(a4, -1, sizeof(a4));

  	a1[0] = 0;
  	a1[n-1] = 0;
  	a2[0] = 0;
  	a2[n-1] = 1;
  	a3[0] = 1;
  	a3[n-1] = 0;
  	a4[0] = 1;
  	a4[n-1] = 1;
  	//if(n > 3){
	  	if(s[0] == 'o'){
	  		a1[1] = 0;
	  	}
	  	else{
	  		a1[1] = 1;
	  	}

	  	if(s[n-1] == 'o'){
	  		a1[n-2] = 0;
	  	}
	  	else{
	  		a1[n-2] = 1;
	  	}

  		if(s[0] == 'o'){
  			a2[1] = 1;
  		}
	  	else{
	  		a2[1] = 0;
	  	}

	  	if(s[n-1] == 'o'){
	  		a2[n-2] = 1;
	  	}
	  	else{
	  		a2[n-2] = 0;
	  	}

	  	if(s[0] == 'o'){
	  		a3[1] = 1;
	  	}
	  	else{
	  		a3[1] = 0;
	  	}

	  	if(s[n-1] == 'o'){
	  		a3[n-2] = 1;
	  	}
	  	else{
	  		a3[n-2] = 0;
	  	}

		if(s[0] == 'o'){
			a4[1] = 0;
		}
		else{
			a4[1] = 1;
		}

		if(s[n-1] == 'o'){
			a4[n-2] = 0;
		}
		else{
			a4[n-2] = 1;
		}
  	//}
  	if(works(a1)){
  		printans(a1);
  		return 0;
  	}
  	else if(works(a2)){
  		printans(a2);
  		return 0;
  	}
  	else if(works(a3)){
  		printans(a3); return 0;
  	}
  	else if(works(a4)){
  		printans(a4); return 0;
  	}
  	cout << -1 << "\n";
	return 0;
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
const int iINF=1e9,MOD=1e9+7;
int mh[4]={1,0,-1,0},mw[4]={0,1,0,-1};

bool comp(pair<int,int>a,pair<int,int>b){
    if(a.first == b.first)return a.second<b.second;
    else return a.first<b.first;
}

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    vector<pair<int,int>>ans(n);
    rep(i,n){
        ans[i].first = a[i];
        ans[i].second = i+1;
    }
    sort(all(ans),comp);
    rep(i,n-1){
        cout<<ans[i].second<<" ";
    }
    cout<<ans[n-1].second<<endl;
}



Measured memory_bytes: 2048
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String blank = sc.nextLine();
    String s = sc.nextLine();


    for(int i = 0; i < a; i++){
      if(!('0'<=s.charAt(i)) || !(s.charAt(i)<='9')){
        System.out.println("No");
        System.exit(0);
      }
    }
  

    if(!(s.charAt(a) == '-')){
      System.out.println("No");
      System.exit(0);
    }
  

    if(!(s.length() == a+b+1)){
      System.out.println("No");
      System.exit(0);
    }
  

    for(int i = a+1; i < a + b + 1; i++){
      if(!('0'<=s.charAt(i)) || !(s.charAt(i)<='9')){
        System.out.println("No");
        System.exit(0);
      }
    }

    System.out.println("Yes");
  }
}


Measured memory_bytes: 22480
#include<bits/stdc++.h>
using namespace std;
unordered_map<string,int>mp;
vector<string>ans;
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;++i)
    {
	string s;
	cin>>s;
	++mp[s];
    }
    int mx=0;
    for(auto it:mp)
	if(it.second>mx) ans.clear(),mx=it.second,ans.push_back(it.first);
	else if(it.second==mx) ans.push_back(it.first);
    sort(ans.begin(),ans.end());
    for(auto it:ans) cout<<it<<endl;
}


Measured memory_bytes: 26692
n = int(input())
a_list = list(map(int, input().split()))
ans = 0
wait_for = 1
for a in a_list:
    if a == wait_for:
        wait_for += 1
    else:
        ans += 1
if wait_for == 1:
    print(-1)
else:
    print(ans)

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


VL a;
vector<VVL> memo;
ll rec(int i, int l, int r) {  // [l, r)
    if(memo[i & 1][l][r] != LLONG_MAX) return memo[i & 1][l][r];
    if(r == l) return memo[i & 1][l][r] = 0;
    ll res;
    if((i & 1) == 0) 
        res = max(rec(i + 1, l + 1, r) + a[l], 
                  rec(i + 1, l, r - 1) + a[r - 1]);
    else 
        res = min(rec(i + 1, l + 1, r) - a[l], 
                  rec(i + 1, l, r - 1) - a[r - 1]);
    return memo[i & 1][l][r] = res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    a.resize(n);
    memo.resize(2, VVL(n + 1, VL(n + 1, LLONG_MAX)));
    REP(i, n) cin >> a[i];
    cout << rec(0, 0, n) << ln;
    return 0;
}


Measured memory_bytes: 211840
n = int(input())
h = list(map(int, input().split())) + [0]

ans = 0
cnt = 0

for i in range(1, max(h) + 1)[::-1]:
    cnt = 0
    for j in range(n):
        if h[j] == i:
            h[j] -= 1
            cnt += 1
            if h[j + 1] == i:
                cnt -= 1
    ans += cnt

print(ans)

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

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

    map <string, int> m;

    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        m[s]+=1;
    }

    for (map<string, int>::iterator itr=m.begin(); itr!=m.end(); itr++) {
        ans = max(ans, itr->second);
    }

    for (map<string, int>::iterator itr=m.begin(); itr!=m.end(); itr++) {
        if (itr->second == ans) {
            cout << itr->first << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 25216
def root(parents, i):
    if parents[i] == i:
        return i
    parents[i] = root(parents, parents[i])
    return parents[i]


def main():
    n, k, l = map(int, input().split())
    roads = list(range(n))
    rails = list(range(n))

    for _ in range(k):
        a, b = map(lambda s: int(s) - 1, input().split())
        root_a, root_b = root(roads, a), root(roads, b)
        if root_a != root_b:
            roads[root_a] = root_b

    for _ in range(l):
        a, b = map(lambda s: int(s) - 1, input().split())
        root_a, root_b = root(rails, a), root(rails, b)
        if root_a != root_b:
            rails[root_a] = root_b

    counts = dict()
    for i in range(n):
        pair = (root(roads, i), root(rails, i))
        if not pair in counts:
            counts[pair] = 1
        else:
            counts[pair] += 1

    print(' '.join(
        map(lambda i: str(counts[(root(roads, i), root(rails, i))]), range(n))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 60264
#include<iostream>
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int q;
signed main() {
	double x1, x2, x3, y1, y2, y3;
	cin >> x1 >> y1 >> x2 >> y2 >> q;
	for1(i, q) {
		cin >> x3 >> y3;
		if ((x1 - x2) * (y3 - y1) == (y1 - y2) * (x3 - x1)) {
			if ((x1 - x2) * (x1 - x3) < 0 || (y1 - y2) * (y1 - y3) < 0)cout << "ONLINE_BACK\n";
			else if ((x2 - x1) * (x2 - x3) < 0 || (y2 - y1) * (y2 - y3) < 0)cout << "ONLINE_FRONT\n";
			else cout << "ON_SEGMENT\n";
		}
		else cout << ((x1 - x2) * (y3 - y1) < (y1 - y2) * (x3 - x1) ? "COUNTER_C" : "C") << "LOCKWISE\n";
	}
}


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

int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int main(){
  int k;
  long long int sum = 0;
  cin >> k;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
	sum += gcd(gcd(i,j),l);
      }
    }
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
	int N; cin >> N;
	int A[110];

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

	for(int i=1; i<N; ++i) {
		int v= A[i];
		int j= i-1;

		cout << A[0];
		for(int k=1; k<N; ++k) printf(" %d", A[k]);
		cout << endl;
		
		while(j>=0 && A[j]>v) {
			A[j+1]= A[j];
			j--;
		}
		A[j+1]= v;
	}
	cout << A[0];
		for(int k=1; k<N; ++k) printf(" %d", A[k]);
	cout << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;scanf("%d",&n);
    for (int i=1;i<=n;++i)
        if ((int)(i*1.08)==n) {
            printf("%d\n",i);
            return 0;
        }
    printf(":(\n");
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    S = list(input())

    l = len(S) // 2
    s1 = S[:l]
    s2 = list(reversed(S[l:]))
    
    count = 0
    # print(s1, s2)
    for i in range(l):
        if s1[i] != s2[i]:
            count += 1
    print(count)


if __name__ == '__main__':
    main()

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

struct Card{
  char a;
  int  b;
};

bool compare_as_ints(Card i,Card j){
  return (i.b<j.b);
}

int partition(Card A[],int p,int r){
  Card x = A[r];
  int i = p-1;
  for(int j=p;j<=r-1;j++){
    if(A[j].b <= x.b){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

void quicksort(Card A[],int p,int r){
  if(p<r){
    int q = partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}

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

  Card A[100000],B[100000];

  for(int i=0;i<n;i++){
    cin >> A[i].a >> A[i].b;
    B[i]=A[i];
  }

  quicksort(A,0,n-1);
  stable_sort(B,B+n,compare_as_ints);

  int miss = 0;

  for(int i=0;i<n;i++){
    if(A[i].a!=B[i].a){
      miss++;
    }
  }

  if(miss>0){
    cout << "Not stable" << endl;
  }else{
    cout << "Stable" << endl;
  }

  for(int i=0;i<n;i++){
    cout << A[i].a << ' ' << A[i].b << endl;
  }

  return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<array<ll,4>>> dp(n,vector<array<ll,4>>(m));
    vector<vector<int>> v(n,vector<int>(m,0));
    for (int i = 0;i < k;++i) {
        int r,c,u;
        cin >> r >> c >> u;
        v[r-1][c-1] = u;
    }
    for (int i = 0;i < n;++i) for (int j = 0;j < m;++j) dp[i][j].fill(0);
    for (int i = 0;i < n;++i) for (int j = 0;j < m;++j) {
        if (v[i][j]) for (int l = 3;l > 0;--l) dp[i][j][l] = max(dp[i][j][l],dp[i][j][l-1]+v[i][j]);
        if (i+1 < n) for (int l = 0;l < 4;++l) dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][l]);
        if (j+1 < m) for (int l = 0;l < 4;++l) dp[i][j+1][l] = max(dp[i][j+1][l],dp[i][j][l]);
    }
    ll ans = 0;
    for (int i = 0;i < 4;++i) ans = max(ans,dp[n-1][m-1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 319260
#pragma GCC optimize("O3")
/* #pragma GCC target ("avx2") */
/* #pragma GCC optimize("Ofast") */
/* #pragma GCC optimize("unroll-loops") */
/* #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */
#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;
template <typename T, typename cmp=less<T>>
using ordered_set=tree<T,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;
template<typename K, typename V, typename cmp=less<K>>
using ordered_map=tree<K, V, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
using ll = long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax = 1000*1007;
#define ar array
#define len(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define tT template<typename T
#define tV typename V
#define ins inline string
#ifdef LOCAL
tT>ins to_string(T& t);
ins to_string(string s) {return '"' + s + '"';}
ins to_string(char c){string res="'";res.push_back(c);return res+"'";}
ins to_string(const char* s) {return to_string((string)s);}
ins to_string(char* s) {return to_string((string)s);}
template <size_t N>ins to_string(bitset<N> v) {string res="";for(size_t i = 0; i < N; i++){
res += static_cast<char>('0' + v[i]);}return res;}
ins to_string(bool b) {return (b ? "true" : "false");}
tT,tV>ins to_string(pair<T, V>& p){return "("+ to_string(p.first)+", "+to_string(p.second)+")";}
tT>ins to_string(T& v){string res="{";for(auto& i:v){res+=to_string(i)+',';} return res+'}';}
#define log(...) cerr<< "[" << #__VA_ARGS__ << " : "<< to_string(__VA_ARGS__) << "]"<<endl
#else
#define log(...) 0x30
#endif

inline void solve(const string& s, const string& t, int& n, int& m){
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    /* log("reached"); */
    /* log(dp); */
    log(dp[n][m]);
    string res;
    while(n>0 && m>0){
        if(s[n-1] == t[m-1]){
            res.push_back(s[n-1]);
            --n, --m;
        }
        else{
            if(dp[n-1][m] >= dp[n][m-1]){
                n--;
            }
            else m--;
        }
        log(res);
    }
    reverse(all(res));
    cout<<res<<"\n";
}

inline void test_case(){
    string s;
    string t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    solve(s, t, n, m);
}

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



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

int main(){
  int h,w;
  cin >> h >> w ;
  vector<vector<int>>a(h+1,vector<int>(w+1));
  vector<vector<int>>b(h+1,vector<int>(w+1));
  for(int i=0; i<h; i++){
   for(int j=0; j<w; j++){
     int x;
     cin >> x;
     a[i][j]=x%2;
     b[i][j]=a[i][j];
   }
  }
  
  
  int count = 0;
  for(int i=0; i<h; i++){
   for(int j=0; j<w; j++){
     a[i][j]%=2;
     if(a[i][j]==0) continue;
     if(i==h-1 && j==w-1) break;
     if(i==h-1){
      a[i][j+1]++;
      count++;
     } 
     else if(a[i][j+1]%2==0 || i==h-1){
      a[i+1][j]++;
      count++;
     }
     else{
      a[i][j+1]++;
      count++;
     } 
   }
  }
  
  cout << count << endl;
  
    for(int i=0; i<h; i++){
   for(int j=0; j<w; j++){
     b[i][j]%=2;
     if(b[i][j]==0) continue;
     if(i==h-1 && j==w-1) break;
     if(i==h-1){
      b[i][j+1]++;
      count++;
      cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
     } 
     else if(b[i][j+1]%2==0 || i==h-1){
      b[i+1][j]++;
      count++;
      cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
     }
     else{
      b[i][j+1]++;
      count++;
      cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
     } 
   }
  }
  
  
}


Measured memory_bytes: 4096
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    char s[100000];
    scanf("%s",s);

    for(i=0; i<strlen(s); i++)
    {

        int c=s[i]+n;
        if(c<=90)
        {
            s[i]=c;
        }
        else if(c>90)
        {
            s[i]=c-26;

        }
    }
    printf("%s",s);

    return 0;
}


Measured memory_bytes: 128
while str = STDIN.gets
  
  n = str.split(" ")
  w = n[0].to_i
  h = n[1].to_i
  x = n[2].to_i
  y = n[3].to_i
  r = n[4].to_i

  if ((r <= x) && (x <= w - r)) && (( r <= y) && (y <= h - r)) #????§???¢???????????????????????´???
    puts "Yes"
  else
    puts "No"
end
end

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


int main(void){

	int a,b;
	while(1){
		cin >> a >> b;
		if( a == 0 && b == 0) break;
		else{
			if(a <= b){
				cout << a << " " << b << endl;
			}
			else{
				cout << b << " " << a << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll MAX_H = 300;
constexpr ll MAX_D = MAX_H * MAX_H;

ll H, W, D, Q;
ll board[MAX_H + 2][MAX_H + 2];
unordered_map<ll, p> m;
unordered_map<ll, unordered_map<ll, ll> > d;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> D;
    for (ll h = 1; h <= H; h++) {
        for (ll w = 1; w <= W; w++) {
            cin >> board[h][w];
            m[board[h][w]] = p(h, w);
        }
    }

    for (ll i = 1; i <= D; i++) {
        d[i] = unordered_map<ll, ll>();
    }

    for (ll i = 1; i <= D; i++) {
        ll dist = 0;
        d[i][i] = 0;
        for (ll l = i; l + D <= H * W; l += D) {
            p from  = m[l];
            p to  = m[l + D];
            dist += abs(from.first - to.first) + abs(from.second - to.second);
            d[i][l + D] = dist;
        }
    }

    cin >> Q;
    for (ll q = 0; q < Q; q++) {
        ll l, r;
        cin >> l >> r;
        ll mod = l % D;
        if (!mod) {
            mod = D;
        }
        cout << (d[mod][r] - d[mod][l]) << endl;
    }

    return 0;
}



Measured memory_bytes: 20004
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;

ll mabs(ll a) {
  return a > 0 ? a : -a;
}

int main(void) {
  ll i, j, k, n, m, ans = 0;
  ll pm[8][3] = {
    {1, 1, 1},
    {-1, 1, 1},
    {1, -1, 1},
    {-1, -1, 1},
    {1, 1, -1},
    {-1, 1, -1},
    {1, -1, -1},
    {-1, -1, -1}
  };
  scanf("%lld%lld", &n, &m);
  ll c[n][3];
  for(i = 0; i < n; ++i) {
    scanf("%lld%lld%lld", &c[i][0], &c[i][1], &c[i][2]);
  }
  for(i = 0; i < 8; ++i) {
    vector<ll> vec;
    for(j = 0; j < n; ++j) {
      ll p = 0;
      if((c[j][0] < 0 && i & 1) || (c[j][0] > 0 && !(i & 1))) p += mabs(c[j][0]);
      else p -= mabs(c[j][0]);
      if((c[j][1] < 0 && i & 2) || (c[j][1] > 0 && !(i & 2))) p += mabs(c[j][1]);
      else p -= mabs(c[j][1]);
      if((c[j][2] < 0 && i & 4) || (c[j][2] > 0 && !(i & 4))) p += mabs(c[j][2]);
      else p -= mabs(c[j][2]);
      vec.push_back(p);
    }
    sort(vec.begin(), vec.end(), greater<ll>());
    ll t = 0;
    for(j = 0; j < m; ++j) t += vec[j];
    if(ans < t) ans = t;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main(){
	int n,r,s=0;
	cin>>n>>r;
	while(n)s++,n/=r;
	cout<<s;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX_N 1000000

using namespace std;

int main() {
    bool isPrime[MAX_N];
    fill_n((bool *)isPrime, MAX_N, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i < MAX_N; i++) {
        for (int j = i+i; j < MAX_N; j += i) {
            isPrime[j] = false;
        }
    }

    int a, d, n;
    while (cin >> a >> d >> n, a|d|n) {
        int count = 0;
        int i;
        for (i = 0;; i += d) {
            if (isPrime[a+i])
                count++;
            if (count == n) {
                cout << a+i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int64_t> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  int64_t ans = 0;
  for (int i = 0; i < n - k; i++) {
    ans += h.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792