akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>
#include <deque>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

using lint = long long;
constexpr lint inf = (1ll << 60);

int main() {
  /* 
  dp[i] = min{ dp[j] + (h_i - h_j)^2 + C }
        = min{ -2h_j * h_i + (h_j^2 + dp[j]) } + (h_i^2 + C)
  minimize a*h_i + b (a = -2h_j, b = h_j^2 + dp[j]) 
  */
  struct monotonous_convex_hull_trick {
  private:
    struct line {
      lint a, b;
      inline lint val(lint x) const { return a * x + b; }
    };
    bool need(line a, line b, line c) {
      lint x1 = (c.b - b.b) * (a.a - b.a);
      lint x2 = (b.b - a.b) * (b.a - c.a);
      return x1 < x2;
    }
    std::deque<line> lines;
  public:
    // monotonically decreasing
    void insert(lint a, lint b) {
      line l{ a, b };
      unsigned size = lines.size();
      while (size >= 2 && !need(l, lines[size - 1], lines[size - 2])) {
        lines.pop_back();
        --size;
      }
      lines.push_back(l);
    }
    // monotonically increasing
    lint minimum(lint x) {
      unsigned size = lines.size();
      while (size >= 2 && lines[0].val(x) > lines[1].val(x)) {
        lines.pop_front();
        --size;
      }
      return lines[0].val(x);
    }
  } cht;
  int N;
  lint C;
  std::cin >> N >> C;
  std::vector<lint> H(N);
  for (lint &x: H) {
    std::cin >> x;
  }
  std::vector<lint> dp(N, inf);
  dp[0] = 0;
  for (int i: range(0, N - 1)) {
    cht.insert(-2 * H[i], H[i] * H[i] + dp[i]);
    dp[i + 1] = cht.minimum(H[i + 1]) + H[i + 1] * H[i + 1] + C;
  }
  std::cout << dp[N - 1] << '\n';
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> v(N+1,0);
  for(int i=2;i<N+1;i++){
	int num=i;
	//cout << "num:" << num << endl;
	for(int j=2;j<N+1;j++){
	  while(num%j==0){	
		//cout << "num:" << num << " j:"<< j<<endl;
		v[j]++;
		num/=j;	
	  }
	}
  }
  
  vector<int> v2;
  for(int i=0;i<v.size();i++){
	if(v[i]!=0){
	  v2.push_back(v[i]);
	}
	//cout << i << ":" << v[i] << endl;
  }
  
  int ans=0;
  for(int i=0;i<v2.size();i++){
	if(v2[i]>=74){
	  ans++;
	}
	if(v2[i]>=24){
	  v2[i]-=24;
	  for(int j=0;j<v2.size();j++){
		if(v2[j]>=2&&i!=j){
		  ans++;
		}
	  }
	  v2[i]+=24;
	}
	if(v2[i]>=14){
	  v2[i]-=14;
	  for(int j=0;j<v2.size();j++){
		if(v2[j]>=4&&i!=j){
		  ans++;
		}
	  }
	  v2[i]+=14;
	}
	if(v2[i]>=4){
	  v2[i]-=4;
	  for(int j=i+1;j<v2.size();j++){
		if(v2[j]>=4){
		  for(int k=0;k<v2.size();k++){
			if(v2[k]>=2&&i!=k&&j!=k){
			  //cout << "i:" << i << " j:" << j << " k:" << k << endl;
			  ans++;
			}
		  }
		}
	  }
	  v2[i]+=4;
	}
	
  }
		
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

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

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

string s,t,u;int a,b;
signed main(){
  cin>>s>>t>>a>>b>>u;
  if(s==u)a--;
  if(t==u)b--;
  cout << a << " " << b << endl;
}




Measured memory_bytes: 256
n, m, x = map(int, input().split())
l = [None] * n
c = [0] * n
for i in range(n):
    cs, *a = map(int, input().split())
    l[i] = a
    c[i] = cs
ans = float('inf')
for i in range(1 << n):
    t = [0] * m
    cs = 0
    for j in range(n):
        if (i >> j) & 1:
            cs += c[j]
            for k in range(m):
                t[k] += l[j][k]
    for k in t:
        if k < x:
            break
    else:
        ans = min(ans, cs)
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 68520
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;

char s[MAXN]; int n;
vector <pair <int, int>> mod;
void modify(char *s, int n, int x, int y) {
	for (int i = 1; i <= n; i++)
		if (s[i] == x + 'A') s[i] = y + 'A';
		else if (s[i] == y + 'A') s[i] = x + 'A';
}
void init() {
	scanf("%s", s + 1);
	int m = strlen(s + 1);
	int cnt[3] = {0, 0, 0};
	for (int i = 1; i <= m; i++)
		if (s[n] != s[i]) {
			s[++n] = s[i];
			cnt[s[i] - 'A']++;
		}
	s[n + 1] = 0;
	if (cnt[0] > cnt[1]) swap(cnt[0], cnt[1]), modify(s, n, 0, 1), mod.emplace_back(0, 1);
	if (cnt[1] > cnt[2]) swap(cnt[1], cnt[2]), modify(s, n, 1, 2), mod.emplace_back(1, 2);
	if (cnt[0] > cnt[1]) swap(cnt[0], cnt[1]), modify(s, n, 0, 1), mod.emplace_back(0, 1);
	if (cnt[0] == 0) puts(""), exit(0);
}
void sela() {
	int b = 0, c = 0;
	static int pos[MAXN]; int cnt = 0;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'A') pos[++cnt] = i;
	for (int i = 1; i <= cnt; i++) {
		bool occur = false;
		for (int j = pos[i - 1] + 1; j <= pos[i] - 1; j++)
			occur |= s[j] == 'B';
		b += occur;
	}
		bool occur = false;
		for (int j = pos[cnt] + 1; j <= n; j++)
			occur |= s[j] == 'B';
		b += occur;
	for (int i = 1; i <= cnt - 1; i++)
		c += pos[i] == pos[i + 1] - 2 && s[pos[i] + 1] == 'C';
	if (b >= c) return;
	int lft = c - b, tmp = n; n = 0;
	for (int i = 1; i <= tmp; i++)
		if (s[i] == 'A') {
			if (lft != 0 && n >= 2 && s[n] == 'C' && s[n - 1] == 'A') lft--;
			else s[++n] = s[i];
		} else if (s[n] != s[i]) s[++n] = s[i];
	assert(lft == 0);
}
void delc() {
	int delta = 0;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'C') delta++;
		else if (s[i] == 'B') delta--;
	assert(delta >= 0);
	int tmp = n; n = 0; s[tmp + 1] = 0;
	for (int i = 1; i <= tmp; i++)
		if (s[i] == 'C') {
			if (delta != 0 && ((n >= 1 && s[n] != s[i + 1]) || n == 0)) delta--;
			else s[++n] = s[i];
		} else s[++n] = s[i];
	assert(delta == 0);
}
void delb() {
	int a = 0, b = 0, c = 0;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'C') c++;
		else if (s[i] == 'B') b++;
		else a++;
	assert(b == c && b >= a);
	int tmp = n; n = 0; s[tmp + 1] = -1;
	for (int i = 1; i <= tmp; i++)
		if (s[i] == 'A') s[++n] = s[i];
		else if (b > a && n >= 1 && s[n] != 'A' && s[i] != s[n] && s[i + 1] != s[n - 1]) n--, b--, c--;
		else s[++n] = s[i];
	s[n + 1] = 0;
}
int main() {
	init();
	sela();
	delc();
	delb();
	while (!mod.empty()) {
		modify(s, n, mod.back().first, mod.back().second);
		mod.pop_back();
	}
	printf("%s\n", s + 1);
	return 0;
}


Measured memory_bytes: 5248
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct dualsegtree{
	using F=function<T(T,T)>;
	const F lazycalcfn,updatefn;
	int n;
	T lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	dualsegtree(int n_=0,T defvalue=0,
		const F lazycalcfn_=[](T a,T b){return a+b;},
		const F updatefn_=[](T a,T b){return a+b;},
		T lazydefvalue_=0
	):lazydefvalue(lazydefvalue_),
		lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(n,defvalue);
		lazy.assign(n-1,lazydefvalue);
		lazyflag.assign(n-1,false);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i]=v[i];
		lazy.assign(n-1,lazydefvalue);
		lazyflag.assign(n-1,false);
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			if(k<n-1)
			{
				lazy[k]=lazycalcfn(lazy[k],x);
				lazyflag[k]=true;
			}
			else dat[k-n+1]=updatefn(dat[k-n+1],x);
		}
		else
		{
			if(lazyflag[k])
			{
				update(0,n,lazy[k],k*2+1,l,(l+r)/2);
				update(0,n,lazy[k],k*2+2,(l+r)/2,r);
				lazy[k]=lazydefvalue;
				lazyflag[k]=false;
			}
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
		}
	}
	T query(int i)
	{
		T ret=dat[i];
		i+=n-1;
		while(i>0)
		{
			i=(i-1)/2;
			if(lazyflag[i])ret=updatefn(ret,lazy[i]);
		}
		return ret;
	}
};
const long mod=998244353;
int N,K;
int L[10],R[10];
main()
{
	cin>>N>>K;
	for(int i=0;i<K;i++)cin>>L[i]>>R[i];
	dualsegtree<int>P(N,0,[](int a,int b){return (a+b)%mod;},[](int a,int b){return (a+b)%mod;});
	P.update(0,1,1);
	for(int i=0;i<N;i++)
	{
		int now=P.query(i);
		for(int j=0;j<K;j++)
		{
			P.update(i+L[j],i+R[j]+1,now);
		}
	}
	cout<<P.query(N-1)<<endl;
}


Measured memory_bytes: 5380
import java.util.List;
import java.util.Scanner;

public class Main {
    static long count = 0;

    static boolean has753(long n) {
        boolean has7 = false;
        boolean has5 = false;
        boolean has3 = false;
        while (n > 0) {
            int v = (int) (n % 10);
            switch (v) {
            case 7:
                has7 = true;
                break;
            case 5:
                has5 = true;
                break;
            case 3:
                has3 = true;
                break;
            }
            n = n / 10;
        }
        return has7 && has5 && has3;

    }

    static void put3(long t, long n) {
        t = t * 10 + 3;
        if (t > n)
            return;
        else {
            if (has753(t)) {
                count++;

                putHelper(t, n);
            } else {
                putHelper(t, n);
            }
            return;
        }

    }

    static void put5(long t, long n) {
        t = t * 10 + 5;
        if (t > n)
            return;
        else {
            if (has753(t)) {
                count++;

                putHelper(t, n);
            } else
                putHelper(t, n);
            return;
        }

    }

    static void put7(long t, long n) {
        t = t * 10 + 7;
        if (t > n)
            return;
        else {
            if (has753(t)) {
                count++;

                putHelper(t, n);
            } else
                putHelper(t, n);
            return;
        }

    }

    static void putHelper(long t, long n) {
        put3(t, n);
        put5(t, n);
        put7(t, n);

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        putHelper(0, n);
        System.out.println(count);
    }
}


Measured memory_bytes: 24148
import Data.List      -- isPrefixOf
import Control.Monad  -- replicateM

replace from to str@(c : cs)
  | isPrefixOf from str = to ++ replace from to (drop (length from) str)
  | otherwise           = c : replace from to cs
replace _ _ [] = []

main  = do { n <- readLn ; replicateM n main' }
main' = do
  s <- getLine
  putStrLn . replace "Hoshino" "Hoshina" $ s

Measured memory_bytes: 3920
# -*- coding: utf-8 -*-

n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]

xyh.sort(key=lambda x: x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        x = xyh[0][0]
        y = xyh[0][1]
        h = xyh[0][2]
        ans = [cx, cy, h + abs(x - cx) + abs(y - cy)]
        for i in range(1, n):
            x = xyh[i][0]
            y = xyh[i][1]
            h = xyh[i][2]
            if h != max(ans[2] - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            print(*ans)


Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;

long long int fact(long long int k) {
	long long int sum = 1;
	for (long long int i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long int power(int a, int b) {
	long long int  ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}


int main()
{
	long long int n, cnt = 0;
		
	string s;

	cin >> n;
	cin >> s;

	vector<bool> check_1(10);
	vector<bool> check_2(100);
	vector<bool> check_3(1000);

	for (int ptr = 0; ptr < n; ptr++) {
		for(int i = 0; i < 10; i++){
			if (check_1[i]) {
				for (int j = 0; j < 10; j++){
					if (check_2[i * 10 + j]) {
						if (!check_3[i * 100 + j * 10 + ctoi(s[ptr])]) {
							check_3[i * 100 + j * 10 + ctoi(s[ptr])] = true;
							cnt++;
						}
					}
				}
				if (!check_2[i * 10 + ctoi(s[ptr])]) {
					check_2[i * 10 + ctoi(s[ptr])] = true;
				}
			}
		}
		if (!check_1[ctoi(s[ptr])]) {
			check_1[ctoi(s[ptr])] = true;
		}
	}



	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll ans, N;
ll A[105000], B[105000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N + 1; i++) cin >> A[i];
    for(int i = 1; i <= N; i++) cin >> B[i];
    ll rest = 0;
    for(int i = 1; i <= N; i++) {
        ans += min(A[i], rest);
        A[i] -= min(A[i], rest);
        ll now = min(A[i], B[i]);
        ans += now;
        B[i] -= now;
        now = min(B[i], A[i+1]);
        ans += now;
        A[i+1] -= now;
        rest = B[i] - now;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
#define mod  1000000007
#define mp make_pair
#define pb push_back
#define sd second
#define mod  1000000007
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++) 
ll i,j,k;
void solve(){
 ll h,a; cin >>h >> a;
  vl v(a); ll sum =0;
  for(i = 0; i < a; i++) cin >> v[i],sum = sum + v[i];
 cout<< (sum >= h ? "Yes" :  "No") << endl; 


     return ; 
} 
    signed main(){
   
    //CASET
    solve();
    
   
    return 0;
  }

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    int count = 0;
    for(int i=0; i<n; i++){
        ll aa;
        cin >> aa;
        a[i] = abs(aa);
        if(aa<0){
            count++;
        }
    }
    sort(a.begin(), a.end());
    ll ans=0;
    for(int i=0; i<n; i++){
        ans+=a[i];
    }
    if(count%2 == 1){
        ans -= 2*a[0];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
def pad(n):
  s = str(n)
  while len(s) < 6:
    s = '0' + s
  return s

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

ans = [''] * (M+1)

ds = []
for i in range(M):
  P, Y = map(int, input().split())
  ds.append((Y, P, i))
ds.sort()

pn = [0] * (N+1)

for y, p, i in ds:
  pn[p] += 1
  ans[i] = pad(p) + pad(pn[p])
print("\n".join(ans))






Measured memory_bytes: 32592
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;
int main(void){
    int n, m, a, b, c;
    long long s=0, t=0;
    vector<P> v;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> a;
        v.push_back(P(a, 1));
    }
    for(int i=0;i<m;i++){
        cin >> b >> c;
        v.push_back(P(c, b));
    }
    sort(v.begin(), v.end(), greater<P>());
    for(int i=0;i<n;i++){
        long long x = v[i].first, y = v[i].second;
        if(t+y<n){
            s += x*y;
            t+=y;
        }else{
            s += x*(n-t);
            cout << s << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    double x;
    string u;
    double ans = 0;
    for(int i=0; i<n; i++){
        cin >> x >> u;
        if(u=="JPY"){
            ans+=x;
        }else{
            ans+=380000.0*x;
        }
    }
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApplication58
{
    class Program
    {
        static void Main()
        {
            List<int> s = new List<int>();
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) break;
                int b = int.Parse(a);
                if (b != 0) s.Add(b);
                else
                {
                    Console.WriteLine(s[s.Count-1]);
                    for(int d = s.Count-1; d > 0; d--)
                    {
                        s[d] = s[d-1];
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=300009;
ll dp[3009][3009];
string a,b;
ll  call(ll  i, ll  j)
{
    if(i==a.size() or j==b.size()) return 0;
    ll  &ret=dp[i][j];
    if(ret!=-1) return ret;
    if(a[i]==b[j]) return ret=1+call(i+1,j+1);
    return ret= max(call(i+1,j),call(i,j+1));
}
void path(int i, int j)
{
    if(i==a.size() or j==b.size()) return ;
    if(a[i]==b[j])
    {
        cout<<a[i];
        path(i+1,j+1);
    }
    else if(call(i+1,j)>=call(i,j+1))
    {
        path(i+1,j);
    }
    else path(i,j+1);
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin>>a>>b;
    call(0,0);
    path(0,0);
}


Measured memory_bytes: 71424
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;
const int MAXN = 402;
const int MOD = 1e9+7;
int _w;

int n, m, a[MAXN], b[MAXN];
int f[MAXN][MAXN][MAXN];
int g[MAXN][MAXN][MAXN];
bool ok[MAXN][MAXN];

void solve0() {
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= n; ++j ) {
			bool flag = 1;
			for( int k = 1; k <= i && flag; ++k )
				if( a[k] == b[j] ) flag = 0;
			for( int k = 1; k <= j && flag; ++k )
				if( b[k] == a[i] ) flag = 0;
			ok[i][j] = flag;
		}
}

int vis[MAXN];
void solve1() {
	int tmp = 0;
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= n; ++j )
			if( ok[i][j] ) {
				int cnt = 0;
				++tmp;
				for( int k = 1; k <= i; ++k ) vis[a[k]] = tmp;
				for( int k = 1; k <= j; ++k ) vis[b[k]] = tmp;
				for( int k = 1; k <= n; ++k )
					if( vis[k] == tmp ) ++cnt;
				for( int k = 1; k <= m; ++k )
					f[i][j][k] = n - (m-k)*3 - cnt;
			}
}

void solve2() {
	for( int i = 0; i <= n; ++i )
		for( int j = 0; j <= n; ++j )
			g[0][i][j] = 1;
	for( int k = 1; k <= m; ++k ) {
		for( int i = 1; i <= n; ++i )
			for( int j = 1; j <= n; ++j )
				if( ok[i][j] )
					g[k][i][j] = int((ll)g[k-1][i-1][j-1] * f[i][j][k] % MOD);
		for( int i = 1; i <= n; ++i )
			for( int j = 1; j <= n; ++j )
				g[k][i][j] = (g[k][i][j] + g[k][i][j-1]) % MOD;
		for( int i = 1; i <= n; ++i )
			for( int j = 1; j <= n; ++j )
				g[k][i][j] = (g[k][i][j] + g[k][i-1][j]) % MOD;
	}
}

void solve3() {
	memset(f, 0, sizeof f);
	f[0][0][0] = 1;
	for( int i = 0; i <= m; ++i )
		for( int j = 0; j <= m; ++j )
			for( int k = max(i, j); k <= m; ++k ) {
				int &now = f[i][j][k];
				if( i < m )
					f[i+1][j][k] = int((f[i+1][j][k] + ll(k-i) * now) % MOD);
				if( j < m )
					f[i][j+1][k] = int((f[i][j+1][k] + ll(k-j) * now) % MOD);
				if( k < m )
					f[i][j][k+1] = (f[i][j][k+1] + now) % MOD;
			}
	printf( "%lld\n", (ll)f[m][m][m] * g[m][n][n] % MOD );
}

int main() {
	_w = scanf( "%d", &n );
	m = n/3;
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", b+i );
	solve0(), solve1(), solve2(), solve3();
	return 0;
}


Measured memory_bytes: 342016
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string input = Console.ReadLine();
		var result = false;
		
		char c1 = input[0];
		char c2 = new char();
		
		foreach(var c in input){
			if(c1 != c){
				c2 = c;
			}
		}
		result = input.Count(c=>c==c1)==2 && input.Count(c=>c==c2)==2;
		
		// 出力
		var ret = "No";
		if(result){
			ret ="Yes";
		}
		Console.WriteLine(ret);
	}
}

Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] a = sc.nextIntArray(n);
    int max = 0;
    for (int ai: a) {
      if (ai % 2 == 1) continue;
      int val = ai;
      int count = 0;
      while (val > 0 && val % 2 == 0) {
        count++;
        val /= 2;
      }
      max += count;
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 36036
#include<iostream>
using namespace std;
int main() {
int a, sum = 0;
for (int i = 0; i < 4; i++) {
cin >> a;
sum += a;
}
cout << sum / 60 << endl << sum % 60 << endl;
}
/*#include<iostream>
using namespace std;
int main() {
int min1 = 2000, min2 = 2000, a;
for (int i = 0; i < 3; i++) {
cin >> a;
if (min1 > a)min1 = a;
}
for (int i = 0; i < 2; i++) {
cin >> a;
if (min2 > a)min2 = a;
}
cout << min1 + min2-50 << endl;
}*/
/*#include<iostream>
using namespace std;
int main() {
int a[5], b[2] = {1}, sum = 0;
for (int i = 0; i < 5; i++) {
cin >> a[i];
}
while (a[1] > a[3]*b[0]) {
b[0]++;
//cout << "bakatoy" << endl;
}
while (a[2] > a[4]*b[1]) {
b[1]++;
//cout << "bakatoy" << endl;
}
if (b[0] > b[1]) {
cout << a[0]-b[0] << endl;
}
else {
cout << a[0]-b[1] << endl;
}
}*/
/*#include<iostream>
using namespace std;
int main() {
	int a, sum=0;
	for (int i = 0; i<5; i++) {
		cin >> a;
		if (a < 40)a = 40;
		sum += a;
	}
	cout << sum / 5 << endl;
}*/

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int W, H;
long long P[1000000 + 10], Q[1000000 + 10];

int main()
{
	scanf("%d%d", &W, &H);
	for (int i = 0; i < W; i ++)
	{
		int t;
		scanf("%d", &t);
		P[i] = t;
	}
	for (int i = 0; i < H; i ++)
	{
		int t;
		scanf("%d", &t);
		Q[i] = t;
	}
	sort(P, P + W);
	sort(Q, Q + H);

	{
	long long XNW = W + 1, XNH = H + 1;
	int i = 0, j = 0;
	long long Ans = 0;
	while (! (XNW == 1 && XNH == 1))
	{
		if (j == H || (i != W && P[i] < Q[j]))
		{
			Ans += XNH * P[i];
			i ++;
			XNW --;
		}
		else
		{
			Ans += XNW * Q[j];
			j ++;
			XNH --;
		}
	}
	cout << Ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.
LLI dp[404][404];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LI n,i,j,k;cin>>n;
      LI a[n];fo(i,0,n) cin>>a[i];
      LLI sum[n+1];sum[0]=0;
      fo(i,1,n+1) sum[i]=sum[i-1]+a[i-1];
      rfo(i,n-1,-1){
        fo(j,i,n){
          dp[i][j]=1e18;
          if(i==j) dp[i][j]=0;
          fo(k,i,j){
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j+1]-sum[i]);
          }
        }
      }
      cout<<dp[0][n-1];
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int d[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	vector<int> a(m);
	for(int i = 0; i < m; i++){
		cin>>a[i];
	}
	sort(a.rbegin(), a.rend());
	vector<int> dp(n + 1, -1e6);
	dp[0] = 0;
	for(int i = 1; i <= n; i++){
		for(auto x : a){
			if(d[x] <= i)dp[i] = max(dp[i], dp[i - d[x]] + 1);
		}
	}
	string ans = "";
	int ind = n;
	while(true){
		bool flg = false;
		for(auto x : a){
			if(d[x] <= ind && dp[ind] == dp[ind - d[x]] + 1){
				ans += char(x + '0');
				ind -= d[x];
				flg = true;
				break;
			}
		}
		if(!flg)break;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int n,m;
    cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    cin>>m;
    vector<string> t(m);
    rep(i,m)cin>>t[i];
    vector<int> b(n),r(n);
    int get[n];
    rep(i,n){
        rep(j,n){
            if(s[i]==s[j])b[i]++;
        }
        rep(k,m){
            if(s[i]==t[k])r[i]++;
        }
        get[i]=b[i]-r[i];
    }
    sort(get,get+n,greater<int>());
    if(get[0]>=0)cout<<get[0]<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
def main():
    ns = input()
    k = int(input())

    l = len(ns)

    dp = [[0, 0] for _ in range(k+1)]
    dp[0][0] = 1

    for i in range(l):
        c = int(ns[i])

        dp_n = [[0, 0] for _ in range(k+1)]

        for j in range(k + 1):
            if c == 0:
                dp_n[j][0] += dp[j][0]
            else:
                dp_n[j][1] += dp[j][0]
                if j+1 <= k:
                    dp_n[j+1][1] += dp[j][0] * (c - 1)
                    dp_n[j+1][0] += dp[j][0]

            dp_n[j][1] += dp[j][1]
            if j+1 <= k:
                dp_n[j+1][1] += dp[j][1] * 9

        dp = dp_n

    print(dp[k][0] + dp[k][1])


main()


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




















 
int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> s(n + 1), t(m + 1);
    for(ll i = 1; i <= n; i++) cin >> s[i];
    for(ll i = 1; i <= m; i++) cin >> t[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(m + 1)), sum(n + 1, vector<ll>(m + 1));
    for(ll i = 0; i <= n; i++) dp[i][0] = 1;
    for(ll j = 0; j <= m; j++) dp[0][j] = 1;
    for(ll i = 1; i <= n ;i++){
        for(ll j = 1; j <= m; j++){
            if(s[i] == t[j]){
                sum[i][j] = dp[i - 1][j - 1];
            }
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + sum[i][j] + MOD) % MOD;
        }
    }
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 62976
import sys

s=input()
n=len(s)

for i in range(1,n):
    if s[i]==s[i-1]:
        print(i,i+1)
        sys.exit()

for i in range(2,n):
    if s[i]==s[i-2]:
        print(i-1,i+1)
        sys.exit()

print(-1,-1)

Measured memory_bytes: 39408
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  int x[n];
  for(int i = 0; i < n; i++) {
    cin >> x[i];
  }

  int sum = 0;
  for(int i = 0; i < n; i++) {
    sum += 2*min(x[i],k-x[i]);
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1000000007;
const llint big=(llint)(2.19e15)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	llint n,i,j;cin>>n;
	llint ans=0;
	string ma="MARCH";
	llint ar[5]={0};
	for(i=0;i<n;i++){
		string str;cin>>str;
		for(j=0;j<5;j++){
			if(str[0]==ma[j]){ar[j]++;}
		}
	}
	//10通りの列挙
	ans+=ar[0]*ar[1]*ar[2];
	ans+=ar[0]*ar[1]*ar[3];
	ans+=ar[0]*ar[1]*ar[4];
	ans+=ar[0]*ar[2]*ar[3];
	ans+=ar[0]*ar[2]*ar[4];
	ans+=ar[0]*ar[3]*ar[4];
	ans+=ar[1]*ar[2]*ar[3];
	ans+=ar[1]*ar[2]*ar[4];
	ans+=ar[1]*ar[3]*ar[4];
	ans+=ar[2]*ar[3]*ar[4];
	cout<<ans<<endl;
	RE;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

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

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

long long N, M, A[1 << 19];
long long ret = 1;

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) {
		ret = lcm(ret, A[i]);
		ret = min(ret, 2LL * M + 1);
	}
	if (ret > 2LL * M) {
		cout << "0" << endl;
		return 0;
	}

	bool flag = true;
	for (int i = 1; i <= N; i++) {
		if ((ret / A[i]) % 2LL == 0) flag = false;
	}
	if (flag == false) {
		cout << "0" << endl;
		return 0;
	}

	long long K = (2LL * M) / ret;
	cout << (K + 1LL) / 2LL << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;cin >> x;
	for(ll i = x; i < 1000000; i++){
		bool ok = true;
		for(ll j = 2; j * j <= i; j++){
			if(i % j == 0) ok = false;
		}
		if(ok){
			cout << i << endl;
			break;
		}
	}
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, X, T; cin >> N >> X >> T;
	print(((N + X - 1) / X) * T);
}

Measured memory_bytes: 3656
//verma_ankit484

#include<bits/stdc++.h>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll mod = (ll) 1e9+7;

using namespace std;

string str;
ll n;

ll dp[100003][15];

ll rec(ll idx, ll r) {
  if(dp[idx][r] != -1) return dp[idx][r];
  if(idx == n) {
    if(r == 5) return dp[idx][r] = 1;
    return dp[idx][r] = 0;
  }
  ll ans = 0;
  if(str[idx] == '?') {
    for(ll i = 0; i <= 9; i++) {
      ll p = (r*10)+i;
      p %= 13;
      ans += rec(idx+1, p);
      ans %= mod;
    }
  }
  else {
    ll p = (r*10)+str[idx]-'0';
    p %= 13;
    ans += rec(idx+1, p);
    ans %= mod;
  }
  return dp[idx][r] = ans;
}

int main()
{
  IOS
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  memset(dp, -1, sizeof(dp));
  cin >> str;
  n = str.length();
  cout << rec(0, 0) << endl;
  return 0;
}


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

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


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

int i, rs;
int MOD = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(0);

  int n;
  cin >> n;
  for(rs = i = 1; i <= n; ++i) rs = (1LL * rs * i) % MOD;

  cout << rs << '\n';

  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

const int MAXN=2e5+8;
int cur;
vector<int> edges[MAXN];
bool done[MAXN];

void dfs(int c)
{
    done[c]=1;
    ++cur;
    for (int i : edges[c])
        if (!done[i])
            dfs(i);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m,u,v,ans=1;
    cin>>n>>m;
    for (int i=0;i<m;++i)
    {
        cin>>u>>v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    for (int i=1;i<=n;++i)
        if (!done[i])
        {
            cur=0;
            dfs(i);
            ans=max(ans,cur);
        }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 20920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(){
    int a,b,c,d;
    char token[1000];
    fgets(token, sizeof(token), stdin);
    a=atoi(strtok(token," "));b=atoi(strtok(NULL, " "));
    c=atoi(strtok(NULL, " "));d=atoi(strtok(NULL, " "));
    while (a>0&&c>0) {
        c-=b;a-=d;
    }
    if (a<=0&&c>0) printf("No");
    else if(a>0&&c<=0) printf("Yes");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    int dp[n+2][m+2];
    string c = "";
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
            else if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1; 
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    //cout << dp[n][m] << endl;
    int i=n;
    int j=m;
    while(i>0&&j>0)
    {
        if(dp[i][j]==dp[i-1][j])
        {
            i--;
        }
        else if(dp[i][j]==dp[i][j-1])
        {
            j--;
        }
        else
        {
            c+=s[i-1];
            i--;j--;
        }
    }
    reverse(c.begin(),c.end());
    cout << c << endl;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll d,n; cin>>d>>n;
  ll ans=1;
  if(d>0){
    ll tmp=1;
    rep(i,d) tmp*=100;
    ans=tmp;
  }
  if(n!=100) ans*=n;
  else ans*=101;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let base : u64 = 10;
    let scan = stdin();
    let mut line = String::new();

    let _ = scan.read_line(&mut line);

    let mut iter = line.split_whitespace();
    let x : u64 = iter.next().expect("Iteration Error?").trim().parse().expect("Number pls...");
    let y : u64 = iter.next().expect("Iteration Error?").trim().parse().expect("Number pls...");

    if x == y {
        println!("{}", -1);
        return;
    }

    let mut i : u64 = 1;
    loop {
        let mul : u64 = x * i;
        i += 1;

        if mul >= base.pow(18) {
            println!("{}", -1);
            return;
        }
        
        if i > 3 {
            println!("{}", -1);
            return;
        }

        if mul % y != 0 {
            println!("{}", mul);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

using namespace std;

int main(){

  string str;
  cin >> str;

  rep(i,4){
    cout << str[i]; 
  }
  cout << " ";
  for(int i=4;i<12;i++){
    cout << str[i];
  }
  cout << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[sc.nextInt()]++;
		}

		for (int i = 0; i < n; i++) {
			if (n % 2 == 0) {
				if (i % 2 == 1&& a[i] != 2) {
					System.out.println(0);
					return;
				}
			} else {
				if (i == 0 && a[i] != 1) {
					System.out.println(0);
					return;
				} else if (i != 0 && i % 2 == 0 && a[i] != 2) {
					System.out.println(0);
					return;
				}
			}
		}

		System.out.println(pow(2, n/2));
	}

	static long pow(int a, int b) {
		long res = 1;
		for(int i = 0;i < b;i++){
			res = (res*a)%mod;
		}
		return res;
	}
}

Measured memory_bytes: 46080
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			ans = max(ans, abs(A[i]-A[j]))
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int bingo[3][3] = {};

	bool check[5][5] = {};

	int dxy[9] = { -1,1,1,-1,-1,0,1,0,-1 };


	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> bingo[i][j];
		}
	}

	int n;
	cin >> n;
	for (int k = 0; k < n; k++) {
		int a;
		cin >> a;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a == bingo[i][j])
					check[i + 1][j + 1] = true;
			}
		}
	}

	bool answer = false;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 8; k++) {
				bool f = true;
				f &= check[i + 1 + dxy[k]][j + 1 + dxy[k + 1]];
				f &= check[i + 1][j + 1];
				f &= check[i + 1 - dxy[k]][j + 1 - dxy[k + 1]];
				answer |= f;
			}
		}
	}

	if (answer) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputStr = Console.ReadLine();
            var chars = new List<char>();

            foreach (var c in inputStr)
            {
                chars.Add(c);
            }

            chars.ToArray();

            if (chars[2] == chars[3] && chars[4] == chars[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092