akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define N 100100
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(x, a, b) for(int x=a; x<=b; x++)
#define drp(x, a, b) for(int x=a; x>=b; x--)
int deg[N], d[N], n, vis[N], a[N], tot, num[N], l[N], ans=1, fac[N], inv[N];
vector<pair<int, int> > fu;
queue<int> q;
int power(int a, int k){
	int ret=1;
	while(k)
	{
		if(k&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod; k>>=1;
	}
	return ret;
}
int C(int n, int m){
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int pr(int n){
	return 1ll*fac[2*n]*inv[n]%mod*power((mod+1)>>1, n)%mod;
}
void init(){
	fac[0]=1;
	rep(i, 1, n) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=power(fac[n], mod-2);
	drp(i, n, 1) inv[i-1]=1ll*inv[i]*i%mod;
}

int st[N<<1];
void renew(int &x, const int y){
	x += y;
	if(x < 0) x += mod;
	if(x >= mod) x -= mod;
}
int getdp(){
	int fr = 0;
	rep(i, 1, tot) st[i + tot] = st[i];
	rep(i, 1, tot) if(l[st[i]]){
		fr = i;
		break;
	}
	reverse(st + fr + 1, st + fr + tot);
	int a = fr + l[st[fr]] - 1, b = a + 1, c = 1;
	rep(i, fr + 1, fr + tot - 1)if(l[st[i]]){
		int na = i + l[st[i]] - 1, nb = na + 1, cc = 0;
		if(a < i) renew(cc, c);
		if(b < i) renew(cc, c);
		a = na;
		b = nb;
		c = cc;
	}
	int ans = 0;
	if(a < fr + tot) renew(ans, c);
	if(b < fr + tot) renew(ans, c);
	return ans;
}

int main(){
	scanf("%d", &n);
	init();
	rep(i, 1, n)
	{
		scanf("%d", a+i);
		deg[a[i]]++;
	}
	rep(i, 1, n) if(deg[i]>2) return puts("0"), 0;
	rep(i, 1, n) d[i]=deg[i];
	rep(i, 1, n) if(!d[i]) q.push(i);
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		vis[u]=1;
		if(--d[a[u]]==0) q.push(a[u]);
	}
	rep(i, 1, n) if(vis[i] && deg[i]>1) return puts("0"), 0;
	rep(i, 1, n) if(vis[i] && !deg[i])
	{
		int x=i, cnt=0;
		for(; vis[x]; x=a[x]) cnt++;
		l[x]=cnt;
	}
	rep(i, 1, n) if(!vis[i])
	{
		int x=i, fl=0, ass=1; tot=0;
		for(; !vis[x]; x=a[x]) st[++tot]=x, fl|=bool(l[x]), vis[x]=1;
		if(!fl) num[tot]++;
		else
		{/*
			int p=0; fu.clear();
			if(l[i]) fu.pb(mp(l[i], 0));
			for(p++, x=a[i]; x!=i; x=a[x]) if(l[x]) fu.pb(mp(l[x], p));
			fu.pb(mp(fu[0].fi, fu[0].se+tot));
			int sz=fu.size();
			rep(i, 1, sz-1)
			{
				if(fu[i].fi>fu[i].se-fu[i-1].se) ass=0;
				if(fu[i].fi<fu[i].se-fu[i-1].se) ass=2ll*ass%mod;
			}*/
			ass=getdp();
		}
		ans=1ll*ans*ass%mod;
	}
	rep(i, 1, n) if(num[i])
	{
		int m=num[i], ass=0;
		rep(j, 0, m/2)
		{
			int tmp=1ll*C(m, 2*j)*pr(j)%mod*power(i, j)%mod;
			if(i>1 && (i&1)) tmp=1ll*tmp*power(2, m-2*j)%mod;
			ass=(ass+tmp)%mod;
		}
		ans=1ll*ans*ass%mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(void){
  long long n, m;
  cin >> n >> m;
  long long sum;
  if (n == 1 ^ m == 1){
    sum = max(n, m)-2;
  }
  else{
    sum = (n-2)*(m-2);
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	for(int i = 1; i <= 9; i++) {
		for(int j = 1; j <= 9; j++) {
			if(i *j == n) {
				cout << "Yes";
				return;
			}
		}
	}
	cout << "No";
	

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3596
// УЛЬЯНА НОВОЯТЛОВА САМАЯ ЛУЧШАЯ В МИРЕ!!!

#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <stack>
#include <algorithm>
#include <random>
#include <bitset>

using namespace std;

typedef long long ll;


void dfs(int x, vector<int> &been, vector<ll> &s, set<int> &e) {
    s[x] |= (1LL << x);
    been[x] = 1;
    for (int i : e) {
        if (been[x % i] == 0) {
            dfs(x % i, been, s, e);
        }
        
        s[x] |= s[x % i];
    }
}

bool try_(int n, vector<int> &a, vector<int> &b, set<int> &e) {
    vector<ll> share(51);
    vector<int> been(51);
    
    for (int i = 0; i <= 50; ++i) {
        if (been[i] == 0) {
            dfs(i, been, share, e);
        }
    }
    
    
    bool flag = true;
    for (int i = 0; i < n; ++i) {
        if ((share[a[i]] & (1LL << b[i])) == 0) {
            flag = false;
        }
    }
    
    return flag;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    
    cin >> n;
    
    vector<int> a(n), b(n);
    
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }

    set<int> e;
    for (int i = 1; i <= 50; ++i) {
        e.insert(i);
    }

    if (!try_(n, a, b, e)) {
        cout << -1 << endl;
        return 0;
    }
    e.erase(50);
    
    ll ans = 0;
    int nows = 49;
    while (nows >= 0) {
        e.erase(nows);
        if (!try_(n, a, b, e)) {
            ans += (1LL << (nows));
            e.insert(nows);

            //cout << nows << endl;
        }
        nows--;
    }
    cout << ans << endl;
    return 0;
}



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

#define ll long long int

using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> A(n), B(n);
    for (auto & a : A) cin >> a;
    copy(A.begin(), A.end(), B.begin());

    sort(B.begin(), B.end());
    ll m1 = B[n/2-1];
    ll m2 = B[n/2];

    for (auto a : A) {
        if (a <= m1) {
            cout << m2 << endl;
        } else {
            cout << m1 << endl;
        }
    }

    
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define int long long
#define pb push_back
#define getMat(v, n, m, val) vector<vector<int>> v(n,vector<int>(m, val))
#define lb lower_bound
#define up upper_bound
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define size(v) (int)v.size()
using namespace std;
const int mod = 1e9+7;

int32_t main(){
    fastio;
    
    const int mxN = 1e6+1;
    int spf[mxN];
    vector<int> is_prime(mxN, true);
    for(int i=2; i<mxN; i++){
        if(is_prime[i]){
            spf[i] = i;
            for(int j=i*i; j<mxN; j+=i){
                if(is_prime[j]){
                    spf[j] = i;
                    is_prime[j] = false;
                }
            }
        }
    }

    //for(int i=0; i<mxN; i++) cout << i << " " << is_prime[i] << endl;
    int n; cin >> n;
    int ans = 0;
    for(int c=1; c<n; c++){
        int val = n-c;
        unordered_map<int,int> mp;
        while(val != 1){
            mp[spf[val]]++;
            val /= spf[val];
        }
        int prod = 1;
        for(auto x: mp) prod *= (x.second+1);
        ans += prod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18712
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const long long MAX_V = 1000 * 110;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, w; cin >> n >> w;
    int val[n + 1], weight[n + 1];
    for(int i = 0; i < n; i++)  cin >> weight[i] >> val[i];
    vector<vector<int>> dp(n + 1, vector<int>(MAX_V + 1, INF));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= MAX_V; j++)
        {
            if(j - val[i] < 0)
            {
                dp[i + 1][j] = dp[i][j];
            }
            else 
            {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - val[i]] + weight[i]);
            }
        }
    }
    int ans;
    for(int v = 0; v <= MAX_V; v++)
    {
        if(dp[n][v] <= w) ans = v;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 44288
import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


def main():
    # N = int(input())
    # A = list(map(int, input().split()))
    N, *A = map(int, open(0).read().split())
            
    x = 1
    for a in A:
        x *= a //  fractions.gcd(x, a)
        
    b = sum(x//a for a in A)
    print(b%MOD)
    
if __name__== "__main__":
    main()


Measured memory_bytes: 6108
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x,y = y,x%y
    return x

N,X = map(int,input().split())
Y = [abs(X-int(i)) for i in input().split()]
ans = Y[0]
for i in range(N-1):
    ans = p(ans,Y[i+1])
print(ans)

Measured memory_bytes: 14216
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 200100;
int n;
int c[maxn];
long long dp[maxn] = {0};
long long s[maxn] = {0}, nxt[maxn] = {0};
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> c[i];
	dp[0] = 1;
	for(int i = 1; i <= n; i ++)
	{
		int x = c[i];
		dp[i] = dp[i - 1];
		if(x == c[i - 1])
			continue;
		if(nxt[x] != 0)
			(dp[i] += s[x]) %= mod;
		(s[x] += dp[i - 1]) %= mod;
		nxt[x] = i;
		//cout << i << " " << dp[i] << endl;
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 5760
n, m = map(int, input().split())
g = [[] for i in range(n)]

for _ in range(m):
   a, b = map(int, input().split())
   a -= 1
   b -= 1
   g[a].append(b)
   g[b].append(a)

def dfs(v):
   if (len(v) == n):
      return 1

   ans = 0
   for u in set(g[v[-1]]) - set(v):
      ans += dfs(v + [u])

   return ans

print(dfs([0]))


Measured memory_bytes: 3064
n,m=map(int,input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
l=[1]*n
out_=[0]*n
in_=[0]*n
c=1

check=0
for i in range(m):
    if check==0:
        if xy[i][0]==1:
            in_[xy[i][1]-1]+=1
            check=1
        else:
            if xy[i][1]==1:
                in_[xy[i][1]-1]+=1
                check=1
        l[xy[i][0]-1]-=1
        l[xy[i][1]-1]+=1
    else:
        l[xy[i][0]-1]-=1
        l[xy[i][1]-1]+=1
        if l[xy[i][0]-1]==0 and in_[xy[i][0]-1]!=0:
            in_[xy[i][0]-1]=0
            in_[xy[i][1]-1]+=1
        elif l[xy[i][0]-1]!=0 and in_[xy[i][0]-1]!=0:
            in_[xy[i][1]-1]+=1
ans=0
for i in range(n):
    if in_[i]!=0:
        ans+=1
print(ans)

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

#define ll long long
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define see(x) cout<<(#x)<<" -> "<<(x)<<"\n"
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fr1(i,b,a) for(int i=b;i>=a;i--)

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
long double infd=1.0/0.0;
const double pi=2*acos(0.0);
const int MOD=1e9+7;

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        ll n;
        cin>>n;
        if(n&1){
            cout<<0;
            return 0;
        }
        ll ans=n/10;
        ll x=50;
        while(n/x>0){
            ans+=n/x;
            x*=5;
        }
        cout<<ans;
    }
    return 0;
}


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

int main(){
  ll a,b,res,c,k,sum=0; cin>>a>>b>>c>>k;
  ll ans = k-a;
  if(ans<0){
  res=k;
  }
	else if(ans==0){
   	res = a;
    }
  else{
  	sum+=a;
    ans = ans - b;
    if(ans==0){
      res=sum;
    }
    else{
    	sum = sum+(ans*-1);
      res=sum;
    }
  }
  cout<<res;
  return 0;
}


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

void solve()
{
  ll n,k;
    cin>>n>>k;
   vector<ll>a(n);
    for(ll &x:a)
        cin>>x;
    sort(a.begin(),a.end());
    ll ans=0;
    for(ll i=0;i<k;i++)
        ans+=a[i];
    cout<<ans<<endl;
}


int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		if (N % 2 == 0) {
			System.out.println(N);
		} else {
			System.out.println(2 * N);
		}
	}
}

Measured memory_bytes: 21844
N, Q = map(int, input().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())

s = [0] * N
for i in range(N-1):
    if S[i:i+2] == 'AC':
        s[i+1] = s[i] + 1
    else:
        s[i+1] = s[i]

for i in range(Q):
    print(s[r[i]-1] - s[l[i]-1])
    

Measured memory_bytes: 14128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int a,b;
	int t=1,n;
	cin>>a>>b;
	n=b;
	while(n!=0){
		if(n/10>0){
			t++;
		}
		n=n/10;
	}
	int q=1;
	for(int i=1;i<=t;i++){
		q=q*10;
	}
	int c=0,flag=0;
	c=a*q+b;
	for(int i=0;i<=100000;i++){
		if(i*i==c){
			flag=1;
			break;
		}
	}
	if(flag==1){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  if(A!=B && B==C){
    printf("%d\n",A);
  }else if(B!=C && C==A){
    printf("%d\n",B);
  }else if(C!=A && A==B){
    printf("%d\n",C);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int mod = 998244353;

int main(){
	int a[35]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	scanf("%d",&n);
	cout << a[n] << endl; 
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
input = sys.stdin.readline
ymo = input()

a = int(ymo[0:2])
b = int(ymo[2:4])

ans = ""
#00
if a == 0 and b ==0:
    ans = "NA"

#YYMMのみ
elif (a > 12 or a == 0) and 0 < b < 13:
    ans = "YYMM"

#MMYYのみ
elif 0 < a < 13 and (b > 12 or b == 0):
    ans = "MMYY"

#どっちも
elif a <13 and b < 13:
    ans = "AMBIGUOUS"

else :
    ans = "NA"

print(ans)

Measured memory_bytes: 38256
#include <stdio.h>
#include <math.h>

int main(void){
    int n;
    scanf("%d", &n);
    
    int ans=n/1.08;
    
    if(floor(ans*1.08)==n){
        printf("%d\n", ans);
    }else if(floor((ans+1)*1.08)==n){
        printf("%d\n", ans+1);
    }else{
        printf(":(\n");
    }
    return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,c,k,ans,sign,sum;
int timer[100010];
int main()
{
	cin>>n>>c>>k;
	for(int i=1; i<=n; i++)
		scanf("%d",&timer[i]);
	sort(timer+1,timer+1+n);
	sum=1;
	ans=1;
	sign=timer[1]+k;
	for(int i=2; i<=n; i++)
		if(sign<timer[i]||sum==c)
		{
			ans++;
			sum=1;
			sign=timer[i]+k;
		}
		else sum++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
def inpl(): return list(map(int, input().split()))

#### START
S = input()

flag = True
if S[0] != "A":
  flag = False
if S[2:-1].count("C") != 1:
  flag = False
if sum([s.islower() for s in S]) != len(S)-2:
  flag = False

if flag:
  print("AC")
else:
  print("WA")

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

int main() {
    int N, K;
    std::cin >> N >> K;

    int H[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> H[i];
    }

    std::sort(H, H + N, std::greater<int>());

    uint64_t cnt = 0;
    for (int i = K; i < N; ++i) {
        cnt += H[i];
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, t;
    cin>>n>>t;
    vl as(n);
    cin>>as;

    ll l = LINF, r = -LINF;
    ll m = -LINF;
    map<ll, ll> mp;
    rep(i, n) {
        if (chmax(r, as[i])) m = r - l;
        if (chmin(l, as[i])) {
            mp[m]++;
            r = as[i];
            m = -LINF;
        }
    }
    mp[m]++;
    ll ans;
    for (auto d : mp) {
        ans = d.second;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
n = int(input())
mod = 10**9 + 7
contain_zero = 0
contain_nine = 0
not_contain_zero_and_nine = 0
all_per = pow(10,n,mod)
if n < 2:
    print(0)
else:
    contain_zero = all_per - pow(9,n,mod)
    contain_nine = all_per - pow(9,n,mod)
    not_contain_zero_and_nine = pow(8,n,mod)
    print((-(all_per - not_contain_zero_and_nine -contain_nine - contain_zero))%mod)
    


Measured memory_bytes: 61484
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N;

	cin >> N;
	vector<int> A(N), B(N), C(N);

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

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		auto up = lower_bound(A.begin(), A.end(), B[i]);
		auto low = upper_bound(C.begin(), C.end(), B[i]);

		ans += (up - A.begin()) * (N - (low - C.begin()));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int k=scn.nextInt();
		String s=scn.next();
		if(s.length()<=k)
			System.out.println(s);
		else 
			System.out.println(s.substring(0, k)+"...");
	}

}


Measured memory_bytes: 38500
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using vi = vector<int>;
template <class T>
using Grid = vector<vector<T>>;

vector<pair<int, int>> prime_fact(int n) {
    vector<pair<int, int>> v;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0)
            continue;
        int cnt = 0;
        while (n % i == 0) {
            cnt++;
            n /= i;
        }
        v.emplace_back(i, cnt);
    }
    if (n != 1)
        v.emplace_back(n, 1);
    return v;
}

int main() {
    int N;
    cin >> N;
    int mod = 1000000007;
    vector<ll> e(N + 1);
    rep2(i, N) {
        const auto &v = prime_fact(i);
        for (auto x : v)
            e[x.first] += x.second;
    }
    ll ans = 1;
    rep(i, N + 1) {
        ans *= e[i] + 1;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>

int main(void){


  int length = 0;


  int height = 0;


  int area = 0;


  int cir = 0;


  scanf("%d %d",&length,&height);


  area = length * height;


  cir = length*2 + height*2;


  printf("%d %d\n",area,cir);


  return 0;


}

Measured memory_bytes: 596
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n,m,x;
vector<ll>c;
vector<vector<ll>>a;
ll dfs(int k,vector<int>v){
    ll res=LINF;
    if(k==n){
        vector<ll> sum(m,0);
        rep(i,v.size()){
            rep(j,m){
                sum[j]+=a[v[i]][j];
            }
        }
        rep(i,m){
            if(sum[i]<x)return LINF;
        }
        ll ans=0;
        rep(i,v.size()){
            ans+=c[v[i]];
        }
        return ans;
    }
    chmin(res,dfs(k+1,v));
    v.push_back(k);
    chmin(res,dfs(k+1,v));
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m>>x;
    a.resize(n);
    c.resize(n);
    rep(i,n){
        cin>>c[i];
        a[i].resize(m);
        rep(j,m){
            cin>>a[i][j];
        }
    }
    vector<int> v;
    ll ans=dfs(0,v);
    if(ans==LINF)cout<<-1<<"\n";
    else cout<<ans<<"\n";
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    ll k;
    cin >> k;
    vector<ll> save = {1,2,3,4,5,6,7,8,9};
    vector<ll> result = save;
    if(k <= 9){
        cout << save[k-1] << endl;
        return 0;
    }
    ll cur = 9;
    while(cur < k){
        vector<ll> listing;
        for(ll i: save){
            if(i % 10 != 0){
                listing.push_back(i*10+i%10-1);
                cur++;
            }
            listing.push_back(i*10+i%10);
            cur++;
            if(i % 10 != 9){
                listing.push_back(i*10+i%10+1);
                cur++;
            }
        }
        result.insert(result.end(), listing.begin(), listing.end());
        save = listing;
    }
    cout << result[k-1] << endl;
    return 0;
}


Measured memory_bytes: 4284
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i, n) for(int i = 0;i < (int)(n); i++)

using namespace std;


int main() {
    int n,k;
    vector<int> l;
    cin >> n >> k;
    l.resize(n);
    rep(i,n){
        cin >> l[i];
    }
    sort(l.begin(),l.end(),std::greater<int>());
    int sum = 0;
    rep(i,k){
        sum += l[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int A, B, C,juice;
	scanf("%d %d %d", &A,&B,&C);
	juice = B / A;
	if (juice >= C) {
		printf("%d\n",C);
	}
	else {
		printf("%d\n", juice);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

int main() {
    stack<char> st;
    string S;
    cin >> S;
    int result = 0;
    int size = S.size();
    rep(i, size) {
        char c = S[i];
        // DEBUG(i);
        if (st.empty() || st.top() == c) {
            st.push(c);
        } else {
            // DEBUG(st.top());
            // DEBUG(c);
            st.pop();
            result += 2;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(1000000000)
LET=('3','5','7')
n=int(input())

def dfs(s):
  cnt = 0
  if len(s) >0 and int(s) > n:
    return cnt
  if s.count('3') > 0 and s.count('5')>0 and s.count('7')>0:
    cnt += 1
  for l in LET:
    cnt += dfs(s+l)
  return cnt

print(dfs(''))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a,b;
    cin >> a >> b;
    a%=3;
    b%=3;
    if(a==0||b==0||a+b==3){
        put("Possible");
    }else{
        put("Impossible");
    }
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    int A,B,C,D;
    
    cin>>A>>B>>C>>D;
    
    int AB=A+B;
    int CD=C+D;
    
    if(AB>CD) cout<<"Left"<<endl;
    else if(AB<CD) cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
}



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

int main() {
  int num,strnum;
  cin >> num;
  string x;
  cin >> x;
  strnum = x.length();
  if (num >= strnum) {
    cout << x << endl;
  }
  else{
    cout << x.erase(num)+"..." << endl;
  }

}


Measured memory_bytes: 3632
/*13 16 112 can not */
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

void slove(int pr, int ne, int sum){
	int ans = 0;
	reps(i, 1, sum + 100){//???????????? +100??????????????????????¨??????§??????????????§????????????
		reps(j, 1, sum + 100){//????????????
			int pre1 = i * (100 + pr) / 100;
			int pre2 = j * (100 + pr) / 100;
			int presum = pre1 + pre2;//double??§?????´???????¨??????????????¨??????????
			if(sum == presum){
				int tmp1 = i * (100 + ne) / 100;
				int tmp2 = j * (100 + ne) / 100;
				ans = max(ans, tmp1 + tmp2);
			}
		}
	}
	printf("%d\n", ans);
	return;
}

int main(void){
	int x, y;
	int s;
	rep(i, 10000){
		scanf("%d %d %d", &x, &y, &s);
		if(x == 0 && y == 0 && s == 0) break;
		slove(x, y, s);
	}
	return 0;
}

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

f=True
c=0
o=0
ans="No"
for i in range(N):
    if a[i]%2!=0:
        f=False
        o+=1
    if a[i]%4==0:
        c+=1

if f:
    ans="Yes"
if c>=o or c>=N//2:
    ans="Yes"

print(ans)

Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N (1<<18)

using namespace std;
typedef long long ll;

int n,q;
int dat[1<<19];
ll INF;

void init(){
	INF=1;
	for(int i=0;i<31;i++)INF*=2;
	INF--;
	for(int i=0;i<1<<19;i++)dat[i]=INF;
}

void update(int k,int x){
	k+=N-1;
	dat[k]=x;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1],dat[k*2+2]);
	}
}

int find(int a,int b,int k=0,int l=0,int r=N){
	if(r<=a || b<=l)return INF;
	if(a<=l && r<=b)return dat[k];
	
	int vl=find(a,b,k*2+1,l,(l+r)/2);
	int vr=find(a,b,k*2+2,(l+r)/2,r);
	return min(vl,vr);
}

int main(void){
	init();
	scanf("%d%d",&n,&q);
	for(int i=0;i<q;i++){
		int com,x,y;
		scanf("%d%d%d",&com,&x,&y);
		if(com==0)update(x,y);
		else printf("%d\n",find(x,y+1));
	}
	return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
vector<vector<ll>> R(550000, vector<ll>(0));//to
vector<ll> Dist(550000, 0);//day
bool visit[550000];
bool calc[550000];

ll id[5050][5050];
 
ll toId(ll i, ll j) {
    if (i > j) swap(i, j);
    return id[i][j];
}
ll dfs(ll u){
    if(visit[u]){
        if(!calc[u])return -1;
        return Dist[u];
    }
    visit[u]=true;
    Dist[u]=1;
    for(ll e: R[u]){
        ll before=dfs(e);
        if(before==-1){return -1;
        }
        Dist[u]=max(Dist[u], before+1);
    }
    calc[u]=true;
    return Dist[u];
}

int main(){
    ll N;
    cin>>N;
    vector<vector<ll>> A(N, vector<ll>(N-1));
    for(ll i=0; i<N; i++){
        for(ll j=0; j<N-1; j++){
            cin>>A[i][j];
            A[i][j] --;
        }
    }
  	 ll V = 0;
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            if (i >= j) continue;
            id[i][j] = V++;
        }
    }
    for(ll i=0; i<N; i++){
        for(ll j=0; j<N-2; j++){
           	R[toId(i, A[i][j + 1])].push_back(toId(i, A[i][j]));
        }
    }
    ll Max=0;
    for(ll i=0; i<N*(N-1)/2; i++){//henkou
        ll d=dfs(i);
        if(d==-1){
          cout<<-1<<endl;
          return 0;
        }
        Max=max(Max, d);
    }
    cout<<Max<<endl;
  	return 0;
}

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

int main() {
    int n;
    scanf("%d", &n);
    if (n == 1) {
        printf("Yes");
        return 0;
    }
    vector<int> h(n);
    rep(i, n) {
        scanf("%d", &h[i]);
    }
    if (n == 2) {
        if (h[0] - h[1] <= 2) {
            printf("Yes");
        } else {
            printf("No");
        }
        return 0;
    }
    h[0]--;
    bool flg = true;
    for (int i = 1; i < n; i++) {
        if (h[i] > h[i - 1]) {
            h[i]--;
        } else if (h[i] < h[i - 1]) {
            flg = false;
            break;
        }
    }
    if (flg) {
        printf("Yes");
    } else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <iostream>
//#include <vector>
using namespace std;
 
int main() {
    int N = 0;
    cin >> N;
    int c0=0, c1=0, c2=0, c3=0;
    string s;
    for(int n1=0; n1<N; n1++){
        cin >> s;
        if(s == "AC"){
            c0 += 1;
        }
        else if (s == "WA")
        {
            c1 += 1;
        }
        else if (s == "TLE")
        {
            c2 += 1;
        }
        else if (s == "RE")
        {
            c3 += 1;
        }
    }
    printf("AC x %d\n", c0);
    printf("WA x %d\n", c1);
    printf("TLE x %d\n", c2);
    printf("RE x %d", c3);
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,m;cin>>n>>m;
  int seki = (abs(n-m) <= 1)?!abs(n-m)+1:0;
  ll tmp = 1;
  for(int i = 2;i <= n;++i){
    tmp *= i;
    tmp %= INF;
  }
  ll tmp2 = 1;
  for(int i = 2;i <= m;++i){
    tmp2 *= i;
    tmp2 %= INF;
  }
  ll ans = (((tmp * tmp2)%INF)*seki)%INF;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)

int main(){
	while(true){
		int gl;
		cin>>gl;			if(!gl) return 0;
		bool mss[21][21];	//sokoni gem ga aru
		REP(x,21) REP(y,21) mss[x][y]=false;
		REP(gi,gl){
			int gx,gy;
			cin>>gx>>gy;
			mss[gx][gy]=true;
		}

		int ol;
		cin>>ol;
		int px=10,py=10;
		mss[px][py]=false;
		REP(oi,ol){
			char vc; int kl;
			cin>>vc>>kl;
			if(vc=='N') REP(k,kl) mss[px][++py]=false;
			if(vc=='S') REP(k,kl) mss[px][--py]=false;
			if(vc=='E') REP(k,kl) mss[++px][py]=false;
			if(vc=='W') REP(k,kl) mss[--px][py]=false;
		}

		bool re=false;
		REP(x,21) REP(y,21) re = re || mss[x][y];

		cout << (re?"No":"Yes") << endl;
	}
}

Measured memory_bytes: 1148
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 300000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real()* b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real()* b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int imos[200000];
int main() {
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		imos[a]++;
		imos[b + 1]--;
	}
	long long ans = 0;
	for (int i = 1; i <= n+1; ++i) {
		imos[i] += imos[i - 1];
		if (imos[i] == m) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	int c;
	if(s[0]!='A') {
		cout<<"WA"<<endl;
		return 0;
	}
	if(s[1]=='C') {
		cout<<"WA"<<endl;
		return 0;
	}
	if(s[s.length()-1]=='C') {
		cout<<"WA"<<endl;
		return 0;
	}
	for(int i=1;i<s.length();i++) {
		if(s[i]=='C') c++;
		else if(s[i]>='A'&&s[i]<='Z') {
			cout<<"WA"<<endl;
			return 0;
		}
	}
	if(c!=1) {
		cout<<"WA"<<endl;
		return 0;
	}
	cout<<"AC"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    char[] s = scanner.next().toCharArray();
    char[] t = scanner.next().toCharArray();

    int slen = s.length;
    int tlen = t.length;
    int[][] dp = new int[slen + 1][tlen + 1];
    for (int i = 1; i <= slen; i++) {
      for (int j = 1; j <= tlen; j++) {
        if (s[i - 1] == t[j - 1]) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
        }
      }
    }

    StringBuilder sb = new StringBuilder();
    int i = slen;
    int j = tlen;
    while (i > 0 && j > 0) {
      if (dp[i][j] == dp[i - 1][j - 1] + 1 && s[i - 1] == t[j - 1]) {
        sb.append(s[i - 1]);
        i--;
        j--;
      } else if (dp[i][j] == dp[i - 1][j]) {
        i--;
      } else if (dp[i][j] == dp[i][j - 1]) {
        j--;
      } else {
        throw new IllegalStateException();
      }
    }
    System.out.println(sb.reverse().toString());
  }
}


Measured memory_bytes: 81868
#include <iostream>
#define llint unsigned long long
#define B 1000000007
#define C 9973

using namespace std;

llint N;
char s[305][305], t[305][305];
llint shash[305][305], thash[305][305];

llint BN, CN;

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> s[i][j];
			t[j][i] = s[i][j];
		}
	}
	
	BN = CN = 1;
	for(int i = 0; i < N; i++){
		BN *= B, CN *= C;
	}
	
	llint h[305], hh;
	for(int j = 0; j < N; j++){
		
		if(j == 0){
			for(int i = 0; i < N; i++){
				h[i] = 0;
				for(int jj = 0; jj < N; jj++){
					h[i] = h[i] * B + s[i][jj];
				}
			}
		}
		else{
			for(int i = 0; i < N; i++){
				h[i] = h[i] * B + s[i][j-1] - s[i][j-1] * BN;
			}
		}
		
		hh = 0;
		for(int i = 0; i < N; i++){
			hh = hh * C + h[i];
		}
		shash[0][j] = hh;
		for(int i = 1; i < N; i++){
			hh = hh * C + h[i-1] - h[i-1] * CN;
			shash[i][j] = hh;
		}
	}
	
	for(int j = 0; j < N; j++){
		
		if(j == 0){
			for(int i = 0; i < N; i++){
				h[i] = 0;
				for(int jj = 0; jj < N; jj++){
					h[i] = h[i] * B + t[i][jj];
				}
			}
		}else{
			for(int i = 0; i < N; i++){
				h[i] = h[i] * B + t[i][j-1] - t[i][j-1] * BN;
			}
		}
		
		hh = 0;
		for(int i = 0; i < N; i++){
			hh = hh * C + h[i];
		}
		thash[j][0] = hh;
		for(int i = 1; i < N; i++){
			hh = hh * C + h[i-1] - h[i-1] * CN;
			thash[j][i] = hh;
		}
	}
	
	llint ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(shash[i][j] == thash[i][j]) ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

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

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  char x, y ;
  cin >> x >> y ;
  
  if(x>y){
    cout<<">"<<endl ;
  }
  else if(x==y){
    cout << "="<<endl ;
  }
  else{
    cout <<"<"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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


using namespace std;


using ll = long long;
mt19937 mt(736);


template<class T>
T &remin(T &x, const T &y)
{
	return x = min(x, y);
}


ll foo(const vector<ll> &arr, int l, int r, ll cl, ll cr)
{
	static map<tuple<int, int, ll, ll>, ll> dp;

	assert(l + 1 <= r);

	if (l + 1 == r)
		return 0;

	auto q = make_tuple(l, r, cl, cr);

	if (!dp.count(q))
	{
		dp[q] = numeric_limits<ll>::max();

		for (int i = l + 1; i < r; i++)
			remin(dp[q], foo(arr, l, i, cl, cl + cr) + (cl + cr) * arr[i] + foo(arr, i, r, cl + cr, cr));
	}

	return dp[q];
}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<ll> arr(n);

	for (auto &it : arr)
		cin >> it;

	cout << arr.front() + foo(arr, 0, n - 1, 1, 1) + arr.back() << endl;
}


void gen(ostream &cout = std::cout)
{
	const int n = 18;

	uniform_int_distribution<int> uid(0, (int) 1e9);

	cout << n << endl;

	for (int i = 0; i < n; i++)
		cout << uid(mt) << ' ';
	cout << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");
	stringstream ss;

	gen (ss);

	solve(ss);

	cout << setprecision(4);
	cout << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


Measured memory_bytes: 20736
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>

using namespace std;

#define FOR( i, k, n ) for ( int i = ( k ); i < ( int )( n ); ++i )
#define REP( i, n ) FOR( i, 0, n )

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

#define MAX_S 8

class cMCXI {
public :
	cMCXI() { mi = mx = mc = mm = 0; }
	~cMCXI(){};
	void SetStr( string );
	void SetNum( int );
	string GetStr();
	int GetNum() { return mi + mx * 10 + mc * 100 + mm * 1000; }
private :
	int mi, mx, mc, mm;
};

bool IsNum( char );

int main()
{
	int n;
	cin >> n;
	while( n-- ) {
		string str1, str2;
		cin >> str1 >> str2;
		cMCXI mcxi1, mcxi2, summcxi;
		mcxi1.SetStr( str1 );  mcxi2.SetStr( str2 );
		int num1 = mcxi1.GetNum(), num2 = mcxi2.GetNum();
		summcxi.SetNum( num1 + num2 );
		cout << summcxi.GetStr() << endl;
	}
	return 0;
}

void cMCXI::SetStr( string str ) {
	int num = -1;
	REP( i, str.size() ) {
		int ch = str[ i ];
		if( IsNum( ch ) ) { 
			num = ch - '0';
			continue;
		}
		if( num == -1 ) num = 1;
		switch( ch ) {
		case 'm' : mm = num; break;
		case 'c' : mc = num; break;
		case 'x' : mx = num; break;
		case 'i' : mi = num; break;
		}
		num = -1;
	}
}

string cMCXI::GetStr() {
	string res;
	if( mm > 1 ) res += ( char )( mm + '0' );
	if( mm > 0 ) res += 'm';
	if( mc > 1 ) res += ( char )( mc + '0' );
	if( mc > 0 ) res += 'c';
	if( mx > 1 ) res += ( char )( mx + '0' );
	if( mx > 0 ) res += 'x';
	if( mi > 1 ) res += ( char )( mi + '0' );
	if( mi > 0 ) res += 'i';
	return res;
}

void cMCXI::SetNum( int num ) {
	mi = num % 10;  num /= 10;
	mx = num % 10;  num /= 10;
	mc = num % 10;  num /= 10;
	mm = num % 10;  num /= 10;
}

bool IsNum( char ch ) {
	return ( '0' <= ch && ch <= '9' );
}

Measured memory_bytes: 1204
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 
    # c in '753'はc = {7, 5, 3}と見て、それぞれの文字になるのでall(s.count(c))で全てが0より大きければいい
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char a[100001];
int main()
{
	int k,i=0,j=0;
	scanf("%s",a+1);
	for(k=1;k<=strlen(a+1);k++)
	{
		if(a[k]=='C')i=k;
		if(a[k]=='F')j=k;
		if(j>i&&j!=0&&i!=0){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,k,p,r,d[52]={0};
  for(i=0;i*2<=50;i++){
    for(j=0;i*2+j*3<=50;j++){
      for(k=0;i*2+j*3+k*5<=50;k++){
	p=380*i+550*j+850*k;
	p-=380*(i/5)+330*(j/4)+306*(k/3);
	r=i*2+j*3+k*5;
	if(d[r]==0||d[r]>p)d[r]=p;
      }
    }
  }
  while(scanf("%d",&r),r)printf("%d\n",d[r/100]);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>

using namespace std;

long long INF = 1LL << 60;
long long dp[110][100100] = {0};
long long weight[110], value[110];

int main(){
    int N;
    long long W;
    cin >> N >> W;
    for(int i = 0;i < N;i++){
        cin >> weight[i] >> value[i];
    }
    for(int i = 0;i < N; i++){
        for(int j = 0;j <= W; j++){
            if(j - weight[i] >= 0){
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);
            }
            dp[i + 1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<deque>
#include<string>
#include<stack>
using namespace std;

map<int, int>m;
signed main() {
	int a; cin >> a;
	for (int i = 0; i < a; i++) {
		int b; cin >> b;
		m[b]++;
	}
	int b; cin >> b;
	for (int c = 0; c < b; c++) {
		int d; cin >> d;
		if (m[d]) {
			m[d]--;
		}
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int k,i,s,x;
  for(;scanf("%d",&k),k;)
    {
      for(i=s=0;i<k*(k-1)/2;i++)
	scanf("%d",&x),s+=x;
      printf("%d\n",s/(k-1));
    }
}

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

long long ans = 1E18;
int a, b, c, x, y;

int main()
{
    scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
    for (int i = 0; i <= max(x, y); i++)
        ans = min(ans, 2LL * c * i + 1LL * a * max(0, x - i) + 1LL * b * max(0, y - i));
    printf("%lld", ans);
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main {
  val w = List(1,2,4,8,16,32,64,128,256,512)
  def main(args:Array[String]) =
    println(stdin.getLines.map(_.toInt).map { i=>w.filter(y=>(y & i)>0).mkString(" ") }.mkString("\n"))
}

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

int main(){
	string S;
    int N,K;
    
	cin >> N >> K;
	cin >> S;
    
    S.at(K - 1) = S.at(K - 1) + 32;
    
    cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
n, k  = map(int, input().split())
l = list(map(int, input().split()))
s = sum(l)
#print(l)

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  divisors.sort()
  return divisors

d = make_divisors(s)
#print(d)

ans = 0
for i in d:
  m = [0]*n
  for j in range(n):
    m[j] = l[j]%i
  m.sort()
  #print(m)
  sm = sum(m)
  sl = 0
  for p in range(n):
    sl += m[p]
    sr  = sm-sl
    if sl <= k and (n-p-1)*i-sr <= k and sl == (n-p-1)*i-sr:
      ans = i
      break
print(ans)
    

Measured memory_bytes: 41964