akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int N;
int r[24], x[24], y[24], c[24];
vector<int> ue;

short dp[1 << 24];
int xx(int x) { return x * x; }
short _dp(int k) {
	if (k == 0) return 0;
	if (dp[k] >= 0) return dp[k];

	vector<int> w;
	for (int i = 0; i < N; ++i) {
		if ( (k & (1 << i)) && (k & ue[i]) == 0 ) w.push_back(i);
	}
	short ret = 0;
	for (int i = 0; i < w.size(); ++i) {
		for (int j = i+1; j < w.size(); ++j) {
			if (c[w[i]] == c[w[j]]) {
				ret = max<short>(ret, _dp(k ^ (1 << w[i]) ^ (1 << w[j]))+2);
			}
		}
	}
	return dp[k] = ret;
}
int main() {
	while (cin >> N, N) {
		for (int i = 0; i < N; ++i) {
			cin >> x[i] >> y[i] >> r[i] >> c[i];
		}

		bool f[24][24] = {0};
		for (int i = 0; i < N; ++i) {
			for (int j = i+1; j < N; ++j) {
				if (xx(x[i]-x[j]) + xx(y[i]-y[j]) < xx(r[i]+r[j])) {
					f[j][i] = true;
				}
			}
		}

		ue.clear();
		ue.resize(N);
		for (int i = 0; i < N; ++i) {
			int b = 0;
			for (int j = 0; j < N; ++j) {
				if (f[i][j]) b |= (1 << j);
			}
			ue[i] = b;
		}

		fill(&dp[0], &dp[0]+(1<<24), -1);
		cout << (int)_dp((1 << N) - 1) << endl;
	}
}

Measured memory_bytes: 33988
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <stack>
#define N_MAX 500000
#define INFTY 2000000000//Sの要素の最大値が10^9なのでそれより大きく設定
using namespace std;
//常に心してかかれ
//簡単なことを簡単にできるように練習する
//びっくりするくらいつまらないことで詰まってることも多い

int n;
int S[N_MAX+1];
int n_cmpr=0;

//すでに整列済みの二つの数列からそれらを合わせた数列を整列させる関数
void merge(int A[],int left,int mid,int right){int n1,n2;
	
	n1 = mid -left;
	n2 = right - mid;
	//n2-n1=right-left

	int L[N_MAX];//n1
	int R[N_MAX];//n2

	for(int i=0;i<n1;i++){
		L[i] = A[left + i];
	}

	for(int i=0;i<n2;i++){
		R[i] = A[mid + i];
	}

	L[n1] = INFTY;
	R[n2] = INFTY;

	int i_L=0;
	int i_R=0;
	for(int k=left;k < right;k++){//整列後の数列のk番目の値を決める
		if(L[i_L] <= R[i_R]){
			A[k] = L[i_L];//昇順なので小さい方が採用される
			i_L++;
		}else{
			A[k] = R[i_R];//昇順なので小さい方が採用される
			i_R++;
		}
		n_cmpr++;
	}
}

void mergeSort(int A[],int left,int right){
	int mid;
	if(left+1 < right){
		mid = (left + right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	scanf("%d",&n);

	//確認用
	//printf("%d\n",n);
	
	for(int i=0;i<n;i++){
		scanf("%d",&S[i]);

		//確認用
		//printf("%d ",S[i]);
	}

	mergeSort(S,0,n);

	printf("%d",S[0]);//Presentation error対策
	for(int i=1;i<n;i++){
		printf(" %d",S[i]);
	}
	printf("\n");
	printf("%d\n",n_cmpr);

	return 0;
}

Measured memory_bytes: 6072
import qualified Data.Vector.Unboxed as VU
import Control.Monad
import Data.List

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  hs <- fmap VU.fromList $ fmap sort $ replicateM n readLn :: IO (VU.Vector Int)
  xs <- forM [k-1..n-1] $ \i -> return $ (hs VU.! i) - (hs VU.! (i-k+1))
  print $ minimum xs 


Measured memory_bytes: 71548
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
bingo = "No"

for i in range(N):
    for a in range(3):
        for b in range(3):
            if(B[i]==A[a][b]):
                A[a][b] = 0
for i in range(3):
    if(A[i]==[0,0,0]):
        bingo = "Yes"
    if(A[0][i]==0 and A[1][i]==0 and A[2][i]==0):
        bingo = "Yes"
if(A[0][0]==0 and A[1][1]==0 and A[2][2]==0):
        bingo = "Yes"
if(A[0][2]==0 and A[1][1]==0 and A[2][0]==0):
        bingo = "Yes"

print(bingo)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int h , w;
    int i , j;
    
    while(1){
    scanf("%d %d",&h,&w);
     if(h==0 && w==0) break;
     else
        for(i=0;i<h;i++){
            for(j=1;j<=w;j++){ 
                if(i%2 == 0){
                    if(j%2 == 0){
                    printf("."); 
                    } else{
                    printf("#"); 
                    }
                } else{
                    if(j%2 == 0){
                    printf("#"); 
                    } else{
                    printf("."); 
                    }
                }
            }
            printf("\n");
        }
            printf("\n");
    }
return 0;
}


Measured memory_bytes: 2036
<?php
    list($X,$Y) = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    $flg =0;
    //2本足の総数を$a匹とする
    for($a=0;$a<=$X;$a++){
        if(2*$a + 4*($X-$a) == $Y){
            echo "Yes\n";
            $flg = 1;
        }
    }
    if($flg == 0){
        echo "No\n";
    }
?>

Measured memory_bytes: 16216
#include <bits/stdc++.h>
#define tr(container, it) \
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(), c.end()
#define sum(v) accumulate(all(v),0LL)
#define rep(i,s,n) for (int i=s; i<n; i++)
#define lli long long int
#define MOD 1000000007
#define pii pair <int,int> 
#define pll pair <lli, lli>
#define endl '\n'
#define debugv(c) for(auto hnvx : c) cout << hnvx <<" "; cout << endl;
#define debug(c) cout<<#c<<" := "<<c<<endl;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int h[n];
    rep(i,0,n) cin>>h[i];
    int ans[n];
    ans[0]=0;
    ans[1]=abs(h[1]-h[0]);
    rep(i,2,n) ans[i]=min(abs(h[i]-h[i-1])+ans[i-1],abs(h[i]-h[i-2])+ans[i-2]);
    //rep(i,0,n) cout<<ans[i]<<" "; cout<<endl;
    cout<<ans[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
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; }

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

const int INF = 1001001001;

int main(){
    string S;
    cin >> S;
    if (S=="SUN") cout << 7 << endl;
    else if (S=="MON") cout << 6 << endl;
    else if (S=="TUE") cout << 5 << endl;
    else if (S=="WED") cout << 4 << endl;
    else if (S=="THU") cout << 3 << endl;
    else if (S=="FRI") cout << 2 << endl;
    else if (S=="SAT") cout << 1 << endl;

}


Measured memory_bytes: 256
//
// Created by PIIMUU on 8/29/2020.
//
#include <bits/stdc++.h>
using namespace std;

int main() {
    int d, s, t;
    cin >> d >> s >> t;
    double T = 1.0 * d / s;
    if (T <= t) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double vol = a * a * b;
    double res, ang;
    if (vol <= x*2){
        res = 2 * (vol - x) / (a*a);
        ang = 90 - asin(a / sqrt((res*res + a*a))) * 180 / M_PI;
    } else{
        res = 2 * x / (a*b);
        ang = 90 - asin(res / sqrt((res*res + b*b))) * 180 / M_PI;
    }
    printf("%.12f", ang);
}

Measured memory_bytes: 4000
N = int(input())
a = list(map(int, input().split()))
four = 0
two = 0
for i in range(N):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
zero = N - two - four
if zero == four + 1:
    if two == 0:
        print("Yes")
    else:
        print("No")
elif zero > four:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14252
#include <cstdio>
#include <cstring>

using namespace std;

char s[100001];

int main() {
    int n, i;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i + 1 < n; i++) {
        if (s[i] == s[i + 1]) {
            printf("%d %d\n", i + 1, i + 2);
            return 0;
        }
    }
    
    for (i = 0; i + 2 < n; i++) {
        if (s[i] == s[i + 2]) {
            printf("%d %d\n", i + 1, i + 3);
            return 0;
        }
    }
    
    puts("-1 -1");
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] p=new int[n],q=new int[n];
        int[] facts={1,1,2,6,24,120,720,5040,40320};
        boolean[] usedp=new boolean[n];
        boolean[] usedq=new boolean[n];
        int pin=0;
        int qin=0;
        for(int i=0;i<n;i++)p[i]=sc.nextInt();
        for(int i=0;i<n;i++)q[i]=sc.nextInt();
        int countp;
        int countq;
        for(int i=0;i<n;i++){
            countp=0;
            countq=0;
            for(int j=0;j<n;j++){
                if(!usedp[j]&&j!=p[i]-1){
                    countp++;
                }else if(j==p[i]-1){
                    break;
                }
            }
            for(int j=0;j<n;j++){
                if(!usedq[j]&&j!=q[i]-1){
                    countq++;
                }else if(j==q[i]-1){
                    break;
                }
            }
            usedp[p[i]-1]=true;
            usedq[q[i]-1]=true;
            pin+=facts[n-i-1]*countp;
            
            qin+=facts[n-i-1]*countq;
        }
        System.out.println(Math.abs(pin-qin));
 
    }


}

Measured memory_bytes: 21332
class StronglyConnectedComponents():
    def __init__(self, n):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.rev = [[] for _ in range(n)]

    def add_edge(self, fr, to):
        self.graph[fr].append(to)
        self.rev[to].append(fr)

    def scc_id(self):
        group = [0] * self.n
        order = []
        for s in range(self.n):
            if group[s]: continue
            stack = [s]
            group[s] = -1
            while stack:
                node = stack.pop()
                for adj in self.graph[node]:
                    if group[adj]: continue
                    group[adj] = -1
                    stack.append(node)
                    stack.append(adj)
                    break
                else:
                    order.append(node)
        cnt = 0
        for s in order[::-1]:
            if group[s] != -1: continue
            stack = [s]
            group[s] = cnt
            while stack:
                node = stack.pop()
                for adj in self.rev[node]:
                    if group[adj] != -1: continue
                    group[adj] = cnt
                    stack.append(adj)
            cnt += 1
        return group, cnt

    def scc(self):
        group, cnt = self.scc_id()
        res = [[] for _ in range(cnt)]
        for i in range(self.n):
            res[group[i]].append(i)
        return res

import sys
input = sys.stdin.buffer.readline

N, M = map(int, input().split())

scc = StronglyConnectedComponents(N)

for _ in range(M):
    a, b = map(int, input().split())
    scc.add_edge(a, b)

res = scc.scc()
print(len(res))

for r in res:
    print(len(r), *r)

Measured memory_bytes: 221900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
ll k;
ll ans = INFF;
void dfs(int cnt, ll now) {
	if(cnt == n) {
		chmin(ans, now); return ;
	}
	dfs(cnt + 1, now * 2);
	dfs(cnt + 1, now + k);
}

int main(void) {
	cin >> n >> k;
	dfs(0, 1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include<string>
#include<algorithm>
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin>>n;
  char s[20];
  cin>>s;
  (n<3200)?(cout<<"red"<<'\n'):(cout<<s<<'\n');
  
  
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

int n,k[100];
string str="abcdefghijklmnopqrstuvwxyz"
           "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
signed main()
{   
    cin.tie(0);
    ios::sync_with_stdio(false);

    str+=str;
    while(cin>>n,n)
    {   
        REP(i,n) cin>>k[i];
        string s; cin>>s;
        
        REP(i,s.size()){
            int j=0;
            while(s[i]!=str[j]) j++;
            cout<<str[j+52-k[i%n]];
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3184
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
//--------------------------------------------



//--------------------------------------------





//============================================
int main() {
    ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen ("INPUT.txt" , "r" , stdin);
       freopen ("OUTPUT.txt", "w" , stdout);
    #endif

	//THE WATER WAS DEEP, I DROWNED AND THEN CAME FLOATING UP,DEAD!!

       
  	string st;
  	cin>>st;
  	if(st.back() == 's')
  	cout<<st<<"es";
  	else
  	cout<<st<<'s';      









return 0;
} 

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

int main() {
    int N;
    cin >> N;
    vector <int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    set <int> vec1(vec.begin(), vec.end());
    cout << vec1.size() << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mod=1e9+7;
int m,n,yy[100005],sy[100005],cnt,ans;
unordered_map<int,int> mp;
int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
	cin>>m;
	for(int i=1;i<=m;++i) cin>>yy[i];
	sy[0]=2e9;
	for(int i=1;i<=m;++i)
	{
		if(yy[i]<=sy[cnt]) sy[++cnt]=yy[i];
		else
		{
			int l=0,r=cnt,mid,e;
			while(l<=r)
			{
				mid=(l+r)>>1;
				if(sy[mid]<yy[i]) r=mid-1;
				else { l=mid+1; e=mid; } 
			}
			sy[e+1]=yy[i];
		}
	}
	//for(int i=1;i<=cnt;++i) ans+=mp[sy[i]];
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
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;}

int dp[1010][5050];

signed main(){
	int N,M;
	cin>>N>>M;
	vector<int>a(M),b(M);
	vector<int>c(M,0);
	REP(i,M){
		cin>>a[i]>>b[i];
		REP(j,b[i]){
			int t;
			cin>>t;
			t--;
			c[i] |= 1ll << t;
		}
	}
	REP(i,1010)REP(j,5050)dp[i][j]=INF;
	dp[0][0] = 0;
	REP(i,M){
		REP(j,1ll<<N){
			CHMIN(dp[i+1][j],dp[i][j]);
			CHMIN(dp[i+1][j|c[i]],dp[i][j]+a[i]);
		}
	}
	if(dp[M][(1ll<<N)-1] == INF)cout << -1 << endl;
	else cout << dp[M][(1ll<<N)-1] << endl;
}

Measured memory_bytes: 40064
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
#define fore(e, u, v) for (int p = e.g[u], v = e[p].y; p; v = e[p = e[p].nxt].y)
typedef long long LL;
const int maxN = 100006;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

void NIE() { puts("Impossible"); exit(0); }

int n, m;
int val[maxN];
int v[maxN], tot;
LL res = 0;

struct Vec {
	int g[maxN], te;
	struct edge {int y, nxt;} e[maxN << 1];
	inline void push(int x, int y) { e[++te] = (edge){y, g[x]}; g[x] = te; }
	inline void link(int x, int y) { push(x, y), push(y, x); }
	inline edge& operator [] (int x) { return e[x]; }
}e;

bool vis[maxN];
int tmp[maxN], tt;

void dfs(int x) {
	vis[x] = true;
	tmp[++tt] = val[x];
	fore (e, x, y) if (!vis[y]) {
		dfs(y);
	}
}

int main() {

	n = ri(), m = ri();
	if (m == n-1) { puts("0"); return 0; }
	rep (i, 1, n) val[i] = ri();
	rep (i, 1, m) {
		int x = ri() + 1, y = ri() + 1;
		e.link(x, y);
	}
	m = 2*(n-1-m);
	rep (i, 1, n) if (!vis[i]) { 
		tt = 0;
		dfs(i);
		sort(tmp+1, tmp+tt+1);
		res += tmp[1];
		--m;
		rep (i, 2, tt) v[++tot] = tmp[i];
	}
	sort(v+1, v+tot+1);
	if (tot < m) NIE();
	else rep (i, 1, m) res += v[i];
	printf("%lld\n", res);

	return 0;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#define For(i,j,k) for(ll i=j;i<=k;++i)
#define Dow(i,j,k) for(ll i=k;i>=j;--i)
#define ll long long
#define inf 1e17
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9')	{if(c=='-')	f=-1;c=getchar();}
	while(c<='9'&&c>='0')	t=t*10LL+c-48LL,c=getchar();
	return t*f;
}
ll n,ans,x;
inline ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
int main()
{
	n=read();
	ans=1;
	For(i,1,n)
	{
		x=read();
		ans=ans/gcd(x,ans)*x;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000
int A[MAX + 1],H;
void maxHeapify(int i){
  int r , l , largest;
  int temp;
  l =2 * i;
  r = 2 * i + 1;
  if(l <= H && A[l] > A[i]){
    largest = l;
  }
  else {
    largest = i;
  }
  if(r <= H && A[r]>A[largest]){
    largest = r;
  }
  if(largest != i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    return maxHeapify(largest);

  }
}
void buildMaxHeap(){
  int i;
  for(i = H / 2 ; i >= 1 ;i--){
    maxHeapify(i);
  }
}
int main(){
  int i;
  scanf("%d",&H);
  for(i = 1;i <= H; i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
  for(i = 1;i <= H; i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int a,b;
  in(a,b);
  if(a>9||b>9)out(-1);
  else out(a*b);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using namespace std;

int main()
{
    long long N, K;
    cin >> N >> K;

    long long ans;
    if(N % K < abs(N % K - K)){
        ans = (N % K);
    }
    else{
        ans = abs(N % K -K);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,Y=map(int,input().split())
for x in range(N+1):
    for y in range(N+1-x):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 9096
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[10];
			
			for(int i=0;i<n;i++){
				a[sc.nextInt()]++;
			}
						
			for(int i=0;i<10;i++){
				if(a[i]==0)System.out.print("-");
				for(int j=0;j<a[i];j++)System.out.print("*");
				System.out.println();
			}	
		}
	
	}	
}

Measured memory_bytes: 54084
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A <= C && C <= B) cout << "Yes" << endl;
  else cout << "No" << endl;
} 
  

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

int main(){
	// sengen
	int a,b;
	// nyuryoku
	cin >> a >> b;
	// keisan
	if(a*b%2 == 0){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 3640
#include <iostream>
#include <utility>
#include <cmath>
using namespace std;
bool check(int* cube){
    for(int i = 1; i < 9; i++){
        if(cube[i] != cube[0]){
            return false;
        }
    }
    for(int i = 10; i < 12; i++){
        if(cube[i] != cube[9] || cube[i + 3] != cube[12]){
            return false;
        }
    }
    return true;
}

void turn(int* cube, int i){
    switch(i){
        case 0:
        for(int i = 0; i <= 6; i += 3){
            swap(cube[i], cube[23 + i]);
        }
        swap(cube[20], cube[9]);
        swap(cube[15], cube[17]);
        break;
        
        case 1:
        for(int i = 0; i < 3; i++){
            swap(cube[i], cube[27 + i]);
        }
        swap(cube[14], cube[15]);
        swap(cube[20], cube[18]);
        break;
        
        case 2:
        for(int i = 2; i <= 8; i += 3){
            swap(cube[i], cube[19 + i]);
        }
        swap(cube[18], cube[11]);
        swap(cube[14], cube[12]);
        break;
        
        case 3:
        for(int i = 6; i <= 8; i++){
            swap(cube[i], cube[15 + i]);
        }
        swap(cube[17], cube[12]);
        swap(cube[9], cube[11]);
        break;
        default:break;
    }
}

int minimumTurn = 9;

void calc(int* cube, int currentTurnCount, int prevTurn){
    currentTurnCount++;
    if(currentTurnCount >= minimumTurn){
        return;
    }
    for(int i = 0; i < 4; i++){
        if(i == prevTurn){
            continue;
        }
        int tempCube[30];
        for(int j = 0; j < 30; j++){
            tempCube[j] = cube[j];
        }
        turn(cube, i);
        if(check(cube)){
            minimumTurn = min(minimumTurn, currentTurnCount);
            return;
        }
        calc(cube, currentTurnCount, i);
        for(int j = 0; j < 30; j++){
            cube[j] = tempCube[j];
        }
    }
}

int main(){

    int n = 1;
    cin >> n;
    for(int k = 0; k < n; k++){
        int cube[30];
        for(int i = 0; i < 30; i++){
            cin >> cube[i];
        }
        minimumTurn = 9;
        if(!check(cube)){
            calc(cube, 0, -1);
        }else{
            minimumTurn = 0;
        }
        cout << minimumTurn << endl;
    }
    return 0;
}

Measured memory_bytes: 3128
ticket = [int(i) for i in input()]
sum_list = [[] for i in range(len(ticket))]
sum_list[0] = [ticket[0]]
sign_list = [[] for i in range(len(ticket))]
sign_list[0] = [""]

for i in range(len(ticket)-1):
    for j in range(len(sum_list[i])):
        sum_list[i+1].append(sum_list[i][j] + ticket[i+1])
        sign_list[i+1].append(sign_list[i][j] + "+")
        sum_list[i+1].append(sum_list[i][j] - ticket[i+1])
        sign_list[i+1].append(sign_list[i][j] + "-")

for i in range(2**len(ticket)):
    if sum_list[len(ticket)-1][i] == 7:
        sign = sign_list[len(ticket)-1][i]
        break

for i in range(len(ticket)-1):
    print(str(ticket[i]) + sign[i], end="")
print(str(ticket[-1]) + "=7")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, m;
    cin >> n >> m;
    vec a(m), b(m);
    vec c[1050] = {};
    rep(i, m) {
        cin >> a[i] >> b[i];
        c[i].resize(b[i]);
        rep(j, b[i]) {
            int x;
            cin >> x;
            x--;
            c[i][j] = x;
        }
    }

    vec key(m);
    rep(i, m) {
        int k = 0;

        rep(j, b[i]) k |= (1 << c[i][j]);

        key[i] = k;
    }

    bool f = true;
    int key_f = 0;
    rep(i, m) {
        key_f = key_f | key[i];
    }
    rep(i, n) if (!((key_f >> i) & 1)) f = false;

    if (!f) {
        cout << -1 << endl;
        exit(0);
    }

    int dp[8000];
    rep(i, 8000) dp[i] = INF;
    dp[0] = 0;

    int mx = 0;
    rep(i, n) mx |= (1 << i);

    rep(i, m) {
        rep(flag, 1 << n) {
            dp[flag | key[i]] = min(dp[flag | key[i]], dp[flag] + a[i]);
        }
    }

    cout << dp[mx] << endl;
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long long         ll;
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef vector<ll>		  vll;


const ll OO = 1e16;

const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
int n;
ll a[100];
int main(){
	fast();
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i < 100; i++){
		a[i] = a[i - 1] + a[i - 2];
	}
	cin >> n;
	cout << a[n] << endl;

	return 0;
}
//mosta7il_

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<limits>
#include<bitset>
#include<unordered_map>
#include<functional>
using namespace std;

#define rep(i,s,n) for(int i=s;i<n;i++)
#define dow(i,n,s) for(int i=n-1;i>=s;i--)
#define all(a) a.begin(),a.end()
#define Sort(a) sort(all(a))
#define Qsort(a,size) qsort(a,size,sizeof(*a),compare_int)
//#define DEBUG
//#define DEBUG2
typedef pair<int,int> II;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
bool compare_by_second(II a,II b) { return a.second != b.second ? a.second < b.second : a.first < b.first; }
bool compare_int(const void *a,const void *b) { return *(int *)a - *(int *)b; }

const int INF = 1e+9;
const int MAX_N = 15;
const int MAX_M = 15;

int N,M;
int pos[MAX_N];
vector<II> from_to;
int ans;
vector<II> zero_ans,one_ans;
int zero_count = 0,zero_ans_count = 0,one_ans_count = 0;
int zero_min = 0,one_min = 0;

void solve();

int main() {
  cin>>N>>M;
  from_to.resize(N);
  rep(i,0,N) {
    cin>>pos[i];
    if(pos[i] == 0) zero_count++;
    from_to[i].first = i;
  }
  rep(i,0,M) {
    cin>>ans;
    rep(j,0,ans) {
      if(i%2==0) zero_ans_count++;
      else one_ans_count++;
      zero_ans.push_back(II(i%2==0?0:1,zero_ans.size()));
      one_ans.push_back(II(i%2==0?1:0,one_ans.size()));
    }
  }

#ifdef DEBUG
  rep(i,0,zero_ans.size()) cout<<zero_ans[i].first<<" , "<<zero_ans[i].second<<endl;
  cout<<endl;
  rep(i,0,one_ans.size()) cout<<one_ans[i].first<<" , "<<one_ans[i].second<<endl;
  cout<<endl;
#endif

  solve();

  return 0;
}

void solve() {

  if(zero_count == zero_ans_count) {
    rep(i,0,from_to.size()) {
      rep(j,0,zero_ans.size()) {
        if(pos[from_to[i].first] == zero_ans[j].first) {
          from_to[i].second = zero_ans[j].second;
          zero_ans.erase(zero_ans.begin()+j);
          break;
        }
      }
    }

  #ifdef DEBUG2
    rep(i,0,from_to.size()) cout<<from_to[i].first<<" , "<<from_to[i].second<<endl;
    cout<<endl;
  #endif

    rep(i,0,from_to.size()-1) {
      rep(j,i+1,from_to.size()) {
        if(from_to[i].second > from_to[j].second) zero_min++;
      }
    }
  }else { zero_min = INF; }

  if(zero_count == one_ans_count) {
    rep(i,0,from_to.size()) {
      rep(j,0,one_ans.size()) {
        if(pos[from_to[i].first] == one_ans[j].first) {
          from_to[i].second = one_ans[j].second;
          one_ans.erase(one_ans.begin()+j);
          break;
        }
      }
    }

  #ifdef DEBUG2
    rep(i,0,from_to.size()) cout<<from_to[i].first<<" , "<<from_to[i].second<<endl;
    cout<<endl;
  #endif

    rep(i,0,from_to.size()-1) {
      rep(j,i+1,from_to.size()) {
        if(from_to[i].second > from_to[j].second) one_min++;
      }
    }
  }else { one_min = INF; }

  cout<<min(zero_min,one_min)<<endl;
  return ;
}



Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication15
{
    //ONLINE JUDGE (ITP1_9_A)


    class Program
    {
        static void Main(string[] args)
        {

            string str1 = Console.ReadLine();
            string w = str1.ToLower();

            int count = 0;

            while (true)
            {
                string str2 = Console.ReadLine();

                if (str2 == "END_OF_TEXT")
                {
                    break;
                }

                string t = str2.ToLower();
                string[] tArray = t.Split(' ');

                
                for (int i = 0; i < tArray.Length; ++i)
                {
                    if (tArray[i] == w)
                    {
                        ++count;
                    }
                }
               
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 5580
aaa = [int(input()) for i in range(5)]

i = list()
b = 0
for a in aaa:
  n = 0
  n = 10 - int(str(a)[-1])
  if n % 10 != 0:i.append(n)
    
if len(i) == 0:
  h = 0
else:
  h = max(i)
print(sum(aaa) + sum(i) - h)

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

int SumDigit(int N){
  int sum = 0;
  while(N > 0){
    sum += N % 10;
    N = (N - N % 10) / 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int sum = SumDigit(N);
  if (N % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  


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

int main() {
  ll X, K, D;
  cin >> X >> K >> D;

  ll ans;
  X = abs(X);
  if (X / D <= K) // X <= K * D
  {
    K -= X / D;
    X -= X / D * D;
    if (K % 2 == 0)
    {
      ans = X;
    }
    else
    {
      ans = D - X;
    }
  }
  else
  {
    // K * D < X. K * D never overflows
    ans = X - K * D;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ll powmod(ll a,ll b,ll mod) {
//     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;
// }

void solve(){
  int n;
  cin>>n;
  if(n%1000){
    cout<<1000-n%1000<<endl;
  }else{
    cout<<0<<endl;
  }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    #endif
    int tc=1;
    // cin>>tc;
    while(tc--)solve();
}


Measured memory_bytes: 3636
#include <stdio.h>

int N, Q;
char S[114514];
int l[114514], r[114514];

int hayamisaori[114514];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &Q) != 2) return 1;
	if (scanf("%114513s", S) != 1) return 1;
	for (i = 0; i < Q; i++) {
		if (scanf("%d%d", &l[i], &r[i]) != 2) return 1;
	}
	hayamisaori[0] = 0;
	for (i = 1; i < N; i++) {
		hayamisaori[i] = hayamisaori[i - 1] + (S[i - 1] == 'A' && S[i] == 'C');
	}
	for (i = 0; i < Q; i++) {
		printf("%d\n", hayamisaori[r[i] - 1] - hayamisaori[l[i] - 1]);
	}
	return 0;
}


Measured memory_bytes: 2048
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	if (n % 1000)cout << 1000 - n % 1000 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;cin >> n;
  int t = n;
  int h = 0; 
 
  while(t>0){
    h += t % 10;
    t /= 10;
  }
  if(n % h == 0){
     cout << "Yes"; 
  }else{
  	cout << "No";

  }
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  //INPUT
  llint N;
  cin >> N;
  llint buf;
  vector<pair<llint, llint> > p(N);
  rep(i,0,N) {
    cin >> p[i].first;
    p[i].second = i;
  }


  //SOLVE
  llint ans=0;
  sort(p.begin(),p.end());


  //OUTPUT
  rep(i,0,N) {
    cout << (p[i].second+1);
    if (i <= N-2) {
      cout << " ";
    } else {
      cout << endl;
    }
  }


  return 0;
}


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

int main(){
    vector<int> v;
    for(int i = 0; i < 3; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    cout << (v[0] + v[1] == v[2] ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,y=100000000000,m,w;
    	string s,t;
    	cin>>s>>t;
    	n=s.size();
    	k=t.size();
		ll dp[n+1][k+1];
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=k;j++)
			{
				if(i==0||j==0)
				dp[i][j]=0;
				else if (s[i-1]==t[j-1])
					dp[i][j]=1+dp[i-1][j-1];
				else
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
			string ans="";
			while(n>0&&k>0)
			{
				if(dp[n][k]==dp[n-1][k])
				n--;
			else	if(dp[n][k]==dp[n][k-1])
				k--;
			else	if(dp[n][k]==1+dp[n-1][k-1])
				{
					ans.pb(s[n-1]);
					n--;
					k--;
				}
			}
			reverse(ans.begin(),ans.end());
		cout<<ans;
	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

Measured memory_bytes: 74000
N,K = map(int,input().split()) #K = super attack!!
Monsters = [_ for _ in map(int,input().split())]
res = 0
#一番体力の多いモンスターから、Kで殺していく。あとは一足すだけ。
Monsters.sort(reverse = True) #多い順
res += sum(Monsters[K:N+1])
print(res)

Measured memory_bytes: 26180
N,K = map(int,input().split())
L = list(map(str,input().split()))

flag = 0
while flag == 0 :
    counter = 0
    for c in str(N) :
        if c not in L :
            counter += 1
        else :
            break
    if counter == len(list(str(N))) :
        flag = 1
    else :
        N += 1
print(N)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

int N, M, P;
int a[5001], b[5001], c[5001];
ll cost[5001], cost_[5001];
bool fok[5001], bok[5001];








int main(){
  cin >> N >> M >> P;
  vector<vector<int> > fAdjList(N);
  vector<vector<int> > bAdjList(N);
  for(int i=0;i<M;i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    fAdjList[a[i]].pb(b[i]);
    bAdjList[b[i]].pb(a[i]);
  }
  
  // ベルマンフォード
  for(int i=0;i<N;i++){
    cost[i] = INT_MAX;
  }
  cost[0] = 0;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cost[b[j]] = min(cost[b[j]], cost[a[j]] + (P - c[j]));
    }
  }
  for(int i=0;i<N;i++) cost_[i] = cost[i];
  
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cost[b[j]] = min(cost[b[j]], cost[a[j]] + (P - c[j]));
    }
  }
    
  // 各頂点が，始点と終点から到達可能かどうかを調べる
  queue<int> q; q.push(0); fok[0] = true;
  while(!q.empty()){
	int now = q.front(); q.pop();
    for(auto i : fAdjList[now]){
      if (!fok[i]){
        fok[i] = true; q.push(i);
      }
    }
  }
  queue<int>().swap(q); // clear
  q.push(N-1); bok[N-1] = true;
  while(!q.empty()){
	int now = q.front(); q.pop();
    for(auto i : bAdjList[now]){
      if (!bok[i]){
        bok[i] = true; q.push(i);
      }
    }
  }
  
  for(int i=0;i<N;i++){
    if (fok[i] && bok[i] && cost[i] != cost_[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << max(0LL, -cost[N-1]) << endl;
  
  
  return 0;
}
  


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N; cin >> N;

	int ans = 0;
	FOR(i,1,N/2+1){
		if(N - i != i) ans++;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>

using namespace std;

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

typedef long long LL;
#define int long long
const int maxn = 1e5 + 10, maxm = maxn << 1;
int mod, to[maxm], nxt[maxm], head[maxn], e, f[maxn], g[maxn], ans[maxn], p[maxn];
vector<int> vec[maxn];

void add(int x, int y) 
{
	to[++e] = y; nxt[e] = head[x]; head[x] = e;
	to[++e] = x; nxt[e] = head[y]; head[y] = e;
}

void dfs(int u, int fa)
{
	f[u] = 1;
	int tot = 0;
	for(int i = head[u]; i; i = nxt[i])
	{
		int v = to[i];
		if(v == fa) continue;
		dfs(v, u);
		f[u] = (LL)f[u] * (f[v] + 1) % mod;
		p[v] = tot++; vec[u].push_back(f[v]);
	}
}

void dp(int u, int fa)
{
	vec[u].push_back(g[u] + 1);
	for(int i = (int)vec[u].size() - 2; i >= 0; --i)
		vec[u][i] = (LL)(vec[u][i] + 1) * vec[u][i + 1] % mod;
	int now = 1; ans[u] = (LL)(g[u] + 1) * f[u] % mod;
	for(int i = head[u]; i; i = nxt[i])
	{
		int v = to[i];
		if(v == fa) continue;
		g[v] = ((LL)now * vec[u][p[v] + 1] % mod);
		dp(v, u);
		now = (LL)now * (f[v] + 1) % mod;
	}
}

main()
{

	int n = read(); mod = read();
	for(int i = 2; i <= n; ++i) add(read(), read());
	dfs(1, 0);
	dp(1, 0);
	for(int i = 1; i <= n; ++i) printf("%lld\n", ans[i]);

	return 0;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int N,D;
  cin >>N>>D;
  int X[N][D];
  rep(i,N) rep(j,D) cin >> X[i][j];
  int ans = 0;
  rep(i,N){
    for(int j=i+1;j<N;j++){
      float dist = 0;
      rep(k,D)dist += pow(X[i][k]-X[j][k],2);
      dist = sqrt(dist);
      if(floor(dist) == dist) ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)	cin>>a[i];
	sort(a.begin(), a.end(), greater<int>());
	ll ans=a[0];int req = n-2;
	for(int i=1;i<n && req;i++) {
		int cur=min(req, 2);
		req-=cur;
		ans+=cur*a[i];
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3940
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for _ in range(N)]

ans=inf=float('inf')
def dfs(idx,tt,l):
    global ans
    for i in range(idx,N):
        ntt=tt+C[i][0]
        nl=[l[j]+C[i][j+1] for j in range(M)]
        ok=True
        for x in nl:
            if x<X:
              ok=False
              break
        if ok:
            ans=min(ans,ntt)
        else:
	        dfs(i+1,ntt,nl)
        
dfs(0,0,[0]*M)

print(ans if ans<inf else -1)


Measured memory_bytes: 74480