akhauriyash/Code-Regression huggingface dataset:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = int(input())
a = list(map(int,input().split()))
t = int(input())
u = list(map(int,input().split()))
cnt = 0
for i in range(len(u)):
    for j in range(len(a)):
        if a[j] == u[i]:
            cnt += 1
            break
print(cnt)


Measured memory_bytes: 7164
use std::vec::Vec;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {_day:String}
    let mut day = _day.chars().collect::<Vec<char>>();
    day[3] = '8';
    for i in &day {
        print!("{}", i);
    }
    println!()
}


Measured memory_bytes: 4352
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	string s;
	set<string> substr;
	int i, k, m, n;
	cin >> s;
	cin >> m;
	n = min((int)s.size(), m);
	for (k = 1; k <= n; k++) {
		for (i = 0; i + k <= s.size(); i++) {
			substr.insert(s.substr(i, k));
		}
	}
	i = 1;
	for (string str : substr) {
		if (i == m) {
			cout << str << endl;
			break;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 1664
n,k = map(int, input().split())
a =  list(map(int, input().split()))
b,c = 0,0
num,wa = 10**9 +7,k * (k-1) //2
for i in range(n-1):
    for j in range(i+1,n):
        if a[i] != a[j]:
            c += 1
            if a[i] > a[j]:
                b += 1
ans = c * wa % num
ans += b * k
print(ans % num)


Measured memory_bytes: 3188
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int N;
vector<int> G[100000];

int dfs(int v){
    if(SZ(G[v])==0)
        return 0;
    else{
        vector<int> r;
        REP(i,SZ(G[v]))
            r.pb(1+dfs(G[v][i]));
        sort(ALL(r));
        REP(i,SZ(r))
            r[i]+=SZ(r)-1-i;
        sort(ALL(r));
        return r[SZ(r)-1];
    }
}

int main(void){
    cin>>N;
    REP(i,N-1){
        int a;
        cin>>a;
        a--;
        G[a].pb(i+1);
    }
    cout<<dfs(0)<<endl;
     return 0;
}

Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int h,w,k;
    cin >> h >> w >> k;
    vs s(h);
    rep(i,h)cin >> s[i];
    int ans = INF;
    rep(bit, 1LL << (h-1)){
        vi v;//分割場所
        vi ind(h,0);
        rep(i,h){
            ind[i] = v.size();
            if(bit & (1<<i))v.push_back(i);
        }
        int cnt = 0;
        vi num(v.size()+1,0);
        int before = 0;
        rep(i,w)rep(j,h)if(s[j][i] == '1'){
            num[ind[j]]++;
            if(num[ind[j]] > k){//iの左で縦に切る
                if(before == i)goto END;
                before = i;
                cnt++;
                rep(x,v.size()+1)num[x] = 0;
                i--;
                break;
            }
        }
        ans = min(ans, cnt + (int)v.size());
        END:;
        //cout << bit << " " << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
while 1:
 H, W = map(int,raw_input().split())
 if H + W == 0: break
 for h in range(H):
  if h % 2 == 0:
   if W % 2 == 0:
    print ('#.'*(W//2))
   else:
    print ('#.'*(W//2)+'#')
  else:
   if W % 2 == 0:
    print ('.#'*(W//2))
   else:
    print ('.#'*(W//2)+'.')
 print ''

Measured memory_bytes: 6436
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    String S =sc.next();
    String SS[] =S.split("",0);
    int N =SS.length;
    long ans =0;
    int t;
    for(int i=0;i<N;i++){
      t=Integer.parseInt(SS[i]);
      ans =ans+t;
      ans =ans%9;}
    if(ans ==0){System.out.println("Yes");}
    else{System.out.println("No");}
  }
}

Measured memory_bytes: 54216
import numpy as np
X,N=map(int,input().split())
L = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    for n in np.array(range(N+1)):
        for l in L:
            s = X - n
            if (s == l):
                break
        else:
            print(s)
            break

        for l in L:
            s = X + n
            if (int(s) == l):
                break
        else:
            print(s)
            break

Measured memory_bytes: 27120
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a,b;cin>>a>>b;
    int hd[1000];
    hd['H']=1;
    hd['D']=0;
    if(hd[a]^hd[b]) cout<<'D'<<endl;
    else cout<<'H'<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      
      int n=sc.nextInt();
      int W=sc.nextInt();
      long wei[] = new long[n+1];
      long val[] = new long[n+1];
      for(int i=1;i<=n;i++)
      {
          wei[i]=sc.nextLong();
          val[i]=sc.nextLong();
      }
      
      long dp[][]=new long[n+1][W+1];
      for(int i=0;i<=n;i++)
      {
          for(int j=0;j<=W;j++)
          {
              if(i==0 || j==0)
              {
                  dp[i][j]=0;
              }
              else
              {
                  if(wei[i]<=j)
                  {
                      dp[i][j]=Math.max(dp[i-1][j],val[i]+dp[i-1][j-(int)wei[i]]);
                  }
                  else
                  {
                      dp[i][j]=dp[i-1][j];
                  }
              }
              //w.print(dp[i][j]+" ");
          }
          //w.println();
      }
      w.println(dp[n][W]);
      w.close();
    }
}

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

int main()
{
    int i, j, k, n, x, y, z, p;

    cin >> n;

    int ans[n+1];

    memset(ans, 0, sizeof(ans));

    for(i=1; i<=100; i+=1)
    {
        for(j=1; j<=100; j+=1)
        {
            for(k=1; k<=100; k+=1)
            {
                x=i;
                y=j;
                z=k;

                p=x*x+ y*y+ z*z+ x*y+ x*z+ y*z;

                if(p<=n)
                    ans[p]+=1;
            }
        }
    }

    for(i=1; i<=n; i+=1)
        cout << ans[i] << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int g[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
  int w;
  vector<int> sum;
  
  while(cin >> w) {
    sum.clear();
    for(int i = 9 ; i >= 0 ; i--) {
      if(g[i] <= w) {
	w -= g[i];
	sum.push_back(g[i]);
      }
    }
    sort(sum.begin(), sum.end());
    for(int i = 0 ; i < sum.size() ; i++) {
      if(i != sum.size()-1) cout << sum[i] << ' ';
      else cout << sum[i] << endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 = 1e9;
const ll MOD = 1e9 + 7;


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

    vector<vector<int>> v(m, vector<int>());
    rep(i, m){
        int k; cin >> k;
        rep(j, k){
            int x; cin >> x;
            v[i].push_back(x-1);
        }
    }

    vector<int> p(m);
    rep(i, m) cin >> p[i];

    int ans = 0;
    for(int bit=0; bit<(1<<n); bit++){
        int sum = 0;
        rep(i, m){
            int cnt = 0;
            rep(j, v[i].size()){
                if((1<<v[i][j]) & bit) cnt++;
            }
            if(cnt%2 == p[i]) sum++;
        }
        ans += (sum == m);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    (H, W) = [int(i) for i in input().split()]
    
    if H == W == 0:
        break
    for hc in range(H):
        if hc == 0 or hc == H - 1:
            print('#' * W)
        else:
            print('#' + '.' * (W-2) + '#')
    print()


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  int all = 1;
  int ng = 1;
  int a;
  REP(i, N) {
    cin >> a;
    all *= 3;
    if (a % 2 == 0) {
      ng *= 2;
    } else {
      ng *= 1;
    }
  }
  cout << all - ng << endl;

  return 0;
}


Measured memory_bytes: 256
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

const int N = 1e5 + 100, T = 2e3 + 100, OO = 1e12 + 10, M = 1e9 + 7, P = 49157, sq = 360, lg = 20;
typedef pair <int, int> pii;
vector <int> v;
int a[N];

int32_t main() {
	use_fast;
	int n, ans = 0;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		v.pb(a[i]);
	}
	sort(v.begin(), v.end());
	for(int i = 1; i <= n; i++) {
		int x = upper_bound(v.begin(), v.end(), a[i]) - v.begin();
		if(x % 2 != i % 2)
			ans++;
	}
	cout << ans / 2 << endl;
	return 0;
} 	
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 1912
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> A_(N);
    queue<int> A;
    rep(i,0,N) {
        int a;
        cin >> a;
        A_[i] = a;
        A.push(a);
    }

    bool pc = true, sc = true;
    vector<bool> appeared(1000001,false);
    rep(i,0,N) {
        for (auto v : prime_factorize(A_[i])) {
            if (appeared[v.first]) {
                pc = false;
            } else {
                appeared[v.first] = true;
            }
        }
    }
    while (A.size()>1) {
        int a = A.front();
        A.pop();
        int b = A.front();
        A.pop();
        int tmp = __gcd(a,b);
        A.push(tmp);
    }
    if (A.front() != 1) sc = false;

    if (pc) cout << "pairwise coprime" << endl;
    else if (sc) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 11372
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC079.B
{
    class Program
    {
        static void Main ()
        {
            const int MaxN = 86;
            var L = new long[MaxN + 1];
            L[0] = 2;
            L[1] = 1;
            int n = int.Parse (Console.ReadLine ());
            int i = 2;
            while (L[n] == 0)
            {
                L[i] = L[i - 1] + L[i - 2];
                i++;
            }
            Console.WriteLine (L[n]);
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <map>
using namespace std;

int main() {
    int n, vi;
    cin >> n;
    map<int, int> even, odd;
    for (int i = 1; i <= n; i++) {
        cin >> vi;
        if (i & 1) {
            if (odd.find(vi) != odd.end()) {
                odd[vi]++;
            } else {
                odd[vi] = 1;
            }
        } else {
            if (even.find(vi) != even.end()) {
                even[vi]++;
            } else {
                even[vi] = 1;
            }
        }
    }

    int ans_odd = 0, ans_even = 0, key_odd_first, key_even_first;
    for (auto oddi : odd) {
        if (oddi.second > ans_odd) {
            ans_odd = oddi.second;
            key_odd_first = oddi.first;
        }
    }
    for (auto eveni : even) {
        if (eveni.second > ans_even) {
            ans_even = eveni.second;
            key_even_first = eveni.first;
        }
    }

    int key_odd_second = 0, key_even_second = 0;
    ans_odd = 0;
    ans_even = 0;
    for (auto oddi : odd) {
        if (oddi.first != key_odd_first && oddi.second > ans_odd) {
            ans_odd = oddi.second;
            key_odd_second = oddi.first;
        }
    }
    for (auto eveni : even) {
        if (eveni.first != key_even_first && eveni.second > ans_even) {
            ans_even = eveni.second;
            key_even_second = eveni.first;
        }
    }

    ans_odd = n / 2 - odd[key_odd_first];
    ans_even = n / 2 - even[key_even_first];

    if (key_odd_first == key_even_first) {
        if (key_odd_second == 0) {
            ans_odd = n / 2;
        } else {
            if (odd[key_odd_second] >= even[key_even_second]) {
                ans_odd = n / 2 - odd[key_odd_second];
            } else {
                ans_even = n / 2 - even[key_even_second];
            }
        }
    }

    cout << ans_odd + ans_even << endl;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main()
{
    int x=0;
    int y=0;
    string arr1;
    cin>>arr1;
    for(int i=0;i<100000;i++)
    {
        for(int i2=97;i2<=122;i2++)
        {
            if(arr1[x]==i2)
            {
                cout<<arr1[x];
                x=x+2;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(void)
{
    char s[3],c[3];
	int i,n;
	scanf("%s %s",s,c);
	n=1;
	for(i=0;i<3;i++){
	    if(s[i]!=c[2-i]){
			n=0;
			break;
		}
	}
	if(n==1) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll dp[2001] = {},ans[4001] = {},i,j,n;
    for(i=0;i<=1000;i++){
        for(j=0;j<=1000;j++) dp[i+j]++;
    }
    for(i=0;i<=4000;i++){
        for(j=max(i-2000,0LL);j<=min(i,2000LL);j++) ans[i] += dp[j]*dp[i-j];
    }
    while(cin >> n) cout << ans[n] << "\n";
}


Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int wari[3][2] = {
  {500,850},
  {300,550},
  {200,380},
};
int main(void){
  int n;
  while(cin>>n,n){
  
    int money = 1e9;
    n /= 100;
    rep(i,26){
      rep(j,17){
	rep(k,11){
	  if (2 * i + 3 * j + 5 * k == n) { 
	    money = min(money,  
			i / 5 * 1520 + i % 5 * 380 +
			j / 4 * 1870 + j % 4 * 550 +
			k / 3 * 2244 + k % 3 * 850);
	  }
	}
      }
    }
    
    cout<<money<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cmath>
int n,m,l,p[100],t[100],v[100];
double time[100][51],poss[100][51],c[2][51],ans,sum[100][51];
int main(){
        scanf("%d%d%d",&n,&m,&l);
        c[0][0]=1;
        for (int i=1;i<=m;i++){
                c[i%2][0]=c[i%2][i]=1;
		for (int j=1;j<i;j++) c[i%2][j]=c[(i+1)%2][j-1]+c[(i+1)%2][j];
        }
        for (int i=0;i<n;i++){
                scanf("%d%d%d",&p[i],&t[i],&v[i]);
                time[i][0]=(double)l/v[i];
                for (int j=1;j<=m;j++) time[i][j]=time[i][j-1]+t[i];
                for (int j=0;j<=m;j++) poss[i][j]=c[m%2][j]*pow((double)p[i]/100,j)*pow(1-(double)p[i]/100,m-j);
		sum[i][m]=poss[i][m];
		for (int j=m-1;j>=0;j--) sum[i][j]=sum[i][j+1]+poss[i][j];
        }
	for (int i=0;i<n;i++){
		ans=0;
		for (int j=0;j<=m;j++){
			double cur=1,cur_t=time[i][j];
			for (int k=0;k<n;k++) if (i!=k){
				int l=0,r=m,mid,res;
				while (l<=r){
					mid=l+r>>1;
					if (time[k][mid]>cur_t){
						res=mid;
						r=mid-1;
					}	
					else l=mid+1; 
				}
				if (time[k][res]>cur_t) cur*=sum[k][res];
				else cur=0;
			}
			ans+=cur*poss[i][j];
		}
		printf("%f\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1264
nkq = gets.chomp.split
n = nkq[0].to_i
k = nkq[1].to_i
q = nkq[2].to_i

ans = Array.new(n+1, 0)
q.times do
    a = gets.to_i
    ans[a] += 1
end

n.times do |i|
    if q - k < ans[i+1]
        puts "Yes"
    else
        puts "No"
    end
end

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

using namespace std;
typedef long long int ll;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    printf("%c%c%c\n", toupper(s1[0]), toupper(s2[0]), toupper(s3[0]));
    return 0;
}

Measured memory_bytes: 256
x = int(input())

for i1 in range(x//105, -1, -1):
  x2 = x - 105*i1
  for i2 in range(x2//104, -1, -1):
    x3 = x2 - 104*i2
    for i3 in range(x3//103, -1, -1):
      x4 = x3 - 103*i3
      for i4 in range(x4//102, -1, -1):
        x5 = x4 - 102*i4
        for i5 in range(x5//101, -1, -1):
          x6 = x5 -101*i5
          for i6 in range(x6//100, -1, -1):
            if x5 - 100*i6 == 0:
              print(1)
              exit()
print(0)

Measured memory_bytes: 9172
/* ex_3-2. nknm */

#include <stdio.h>

int main(void){

    //鉛筆の本数を入力
    int pencils;

    scanf("%d", &pencils);

    //条件により異なる出力
    if (pencils % 10 == 3){
        printf("bon\n");
    }else if(pencils % 10 == 0 || pencils % 10 == 1 || pencils % 10 == 6 || pencils % 10 == 8){
        printf("pon\n");
    }else{
        printf("hon\n");
    }
    return 0;
}

Measured memory_bytes: 1600
N, A, B = map(int, input().split())
X = [int(_) for _ in input().split()]
F = 0
for i in range(1, N):
    if A * (X[i] - X[i-1]) >= B:
        F += B
    else:
        F += A * (X[i] - X[i-1])
print(F)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


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

    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    map<ll, ll> m;
    rep(i, n) m[numbers[i]] = i;

    set<int> used;
    ll ans = 0;
    for (int i = n; i >= 1; i--) {
        int j = m[i];
        int r1 = [&] {
            auto it = used.lower_bound(j);
            if (it == used.end()) return n;
            return *it;
        }();

        int r2 = [&] {
            auto it = used.lower_bound(j);
            if (it == used.end()) return n;
            it++;
            if (it == used.end()) return n;
            return *it;
        }();

        int l1 = [&] {
            auto it = used.lower_bound(j);
            if (it == used.begin()) return -1;
            it--;
            return *it;
        }();

        int l2 = [&] {
            auto it = used.lower_bound(j);
            if (it == used.begin()) return -1;
            it--;
            if (it == used.begin()) return -1;
            it--;
            return *it;
        }();

        ll k1 = (l1 - l2) * (r1 - j);
        ll k2 = (r2 - r1) * (j - l1);

        ll now = i * k1 + i * k2;

        ans += now;

        used.insert(j);

    }
    cout << ans << endl;
}


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

using namespace std;

using i64 = int64_t;

int main()
{
    string S;

    cin >> S;

    string tmp1, tmp2;
    bool ret = true;
    int result;

    tmp1 = S.substr(0, (S.size() - 1) / 2);
    tmp2 = S.substr((S.size() + 1) / 2, (S.size() - 1) / 2);

    reverse(tmp2.begin(), tmp2.end());
    if (tmp1 != tmp2) {
        ret = false;
        goto fin;
    }
    reverse(tmp2.begin(), tmp2.end());

    for (int i = 0; i < tmp1.size() / 2; i++) {
        if (tmp1[i] != tmp1[tmp1.size() - 1 - i]) {
            ret = false;
            goto fin;
        }
    }

    for (int i = 0; i < tmp2.size() / 2; i++) {
        if (tmp2[i] != tmp2[tmp2.size() - 1 - i]) {
            ret = false;
            goto fin;
        }
    }

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


Measured memory_bytes: 256
x, n = gets.strip.split(" ").map(&:to_i)
p = gets.strip.split(" ").map(&:to_i)

ans = nil
p.sort!

0.upto(101) do |i|
    if p.size > 0 && p.first == i 
        p.shift
        next
    end

    a = (x - i).abs
    if ans.nil? || (a < (x - ans).abs)
        ans = i
    end
end

puts ans


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

const int INF = 1001001001;
int co = 0;

void merge(vector<pair<char, int> > &a, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	vector<pair<char, int> > l(n1+1), r(n2+1);
	rep(i, n1) l.at(i) = a.at(left+i);
	rep(i, n2) r.at(i) = a.at(mid+i);
	l.at(n1).second = r.at(n2).second = INF;
	int i = 0, j = 0;
	for(int k = left; k < right; k++){
		co++;
		if(l.at(i).second <= r.at(j).second){
			a.at(k) = l.at(i);
			i++;
		}else{
			a.at(k) = r.at(j);
			j++;
		}
	}
}

void mergeSort(vector<pair<char, int> > &a, int left, int right){
	if(left + 1 < right){
		int mid = (left+right)/2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}

int partition(vector<pair<char, int> > &a, int p, int r){
	r--;
	int x = a.at(r).second;
	int i = p;
	for(int j = p; j < r; j++){
		if(a.at(j).second <= x){
			swap(a.at(i), a.at(j));
			i++;
		}
	}
	swap(a.at(i), a.at(r));
	
	return i;
}

void quicksort(vector<pair<char, int> > &a, int p, int r){
	if(p < r){
		int q = partition(a, p, r);
		quicksort(a, p, q);
		quicksort(a, q+1, r);
	}
}

int main(){
	int n;
	cin >> n;
	vector<pair<char, int> > a(n);
	vector<pair<char, int> > ma;
	rep(snip_i, n) cin >> a.at(snip_i).first >> a.at(snip_i).second;
	ma = a;
	quicksort(a, 0, n);
	mergeSort(ma, 0, n);
	bool stable = true;
	rep(i, n){
		if(a.at(i) != ma.at(i)){
			stable = false;
			break;
		}
	}
	if(stable == true) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	rep(i, n){
		cout << a.at(i).first << " " << a.at(i).second << endl;
	}
	return 0;
}


Measured memory_bytes: 5180
let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =
  if r = 0 then acc
  else
    let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in
    ( if sq_acc_minus_z' <= 0 then
        floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'
      else
        floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)
let floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)

let () = Scanf.scanf "%d %d" @@ fun n m ->
  Printf.printf "%d\n" @@
  if n = 1 then m
  else Array.fold_left (List.fold_left max) 1 @@
    Array.init (floor_sqrt m) @@ fun i ->
      if 0 < m mod (i + 1)
      then []
      else (if m / (i + 1) < n then [] else [i + 1]) @ (if (i + 1) < n then [] else [m / (i + 1)])



Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  string s;
  cin >> s;
  map<char, int> mp;
  for (char c: s) {
    mp[c]++;
  }
  bool flg = true;
  for (char c: s) {
    flg &= mp[c] % 2 == 0;
  }
  if (flg) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    rep(i,n)rep(j,i){
        int t = abs(a[i]-a[j]);
        if(t%(n-1)==0){
            cout << a[i] << " " << a[j] << endl;
            return 0;
        }
    }

}



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

using namespace std;

#define INF 1000000000

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

    int a[m], b[m], c[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }

    int dist[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }

    for (int i = 0; i < m; i++) {
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
    }

    // Warshall Froyd
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (dist[a[i]][b[i]] < c[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    while(1){
        int N;
        scanf("%d",&N);
        if(N==0)break;
        int a[1145];
        rep(i,N){
            scanf("%d",&a[i]);
        }
        sort(a,a+N);
        int ans=1145141919;
        rep(i,N-1){
            ans=min(ans,a[i+1]-a[i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 2808
#include<stdio.h>
int main()
{
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	x=a+b+c;
	if(x>=22){
		printf("bust\n");
	}
	if(x<=21){
		printf("win\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<char>st;
    string s;
    cin >> s;
    rep(i,n){
        if(st.size() == 0)st.push_back(s[i]);
        else if(st.back() == s[i]){
            continue;
        }else{
            st.push_back(s[i]);
        }
    }
    show(st);
    cout << st.size() << endl;
}


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


#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define M                 1000007
#define PI 3.14159265358979323846

int solve()
{
    string s,t;
    cin>>s>>t;
    int szs=sz(s),ans=0;
    for(int i=0;i<szs;i++)
    {
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

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

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
        int n[3];
        int ans=0;
        cin>>n[0]>>n[1]>>n[2];
        sort(n,n+3);
        ans+=(n[2]-n[1])/2+(n[2]-n[0])/2;
        n[0]+=((n[2]-n[0])/2)*2;
        n[1]+=((n[2]-n[1])/2)*2;
        if(n[0]!=n[2]&&n[1]!=n[2]) ans++;
        else if(n[0]!=n[2]||n[1]!=n[2]) ans+=2;
        cout<<ans<<endl;
        return 0;
}

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

using namespace std;



int main()
{
    long long a,b,p;

    cin >> a >>  b;

    long long k;

    k=min(a,b);

    p=abs(a-b);



    if(p%2!=0)
    {
        cout << "IMPOSSIBLE";
    }
    else
    {
        p=p/2;

        cout << k+p;
    }


    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	int a[N];
	a[0] = 0;
	for(int i = 1; i < n; i++) {
		if(s[i] != s[i - 1]) {
			a[i] = a[i - 1] + 1;
		}
		else {
			a[i] = a[i - 1];
		}
	}

	int r = 0;
	int ans = 0;
	for(int l = 0; l < n; l++) {
		int lim;
		if(s[l] == '0') {
			lim = 2 * k - 1;
		}
		else {
			lim = 2 * k;
		}
		while(r + 1 < n && a[r + 1] - a[l] <= lim) {
			r++;
		}
		ans = max(ans, r - l + 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
using namespace std;

long long int d[200000000] = {};

void kansu( long long int n, long long int m, long long int s ) {

  if ( n == 0 ) {

    d[ s ]++;
    return;

  }

  for ( long long int i = 1; i <= m; i++ ) {
    kansu( n - 1, m, s + i );
  }

  return;

}

int main() {

  while( true ) {

    long long int n, m, k;
    cin >> n >> m >> k;
    if ( n == 0 ) break;

    long long int a = 1;
    for ( long long int i = 0; i < n; i++ ) {
      a *= m;
    }

    long long int ans = 0;

    for ( long long int i = 0; i <= n * m; i++ ) {
      d[i] = 0;
    }

    kansu( n, m, 0 );

    for ( long long int i = 1; i <= n * m; i++ ) {

      ans += d[ i ] * max( 1LL, i - k );

    }

    cout << setprecision(10) << 1.00 * ans / a << endl;

  }

  return 0;

}

Measured memory_bytes: 1308
#include "bits/stdc++.h"

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
	int x = 1;
	while (b) {
		if (b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a) { return power(a, mod - 2);}

#undef int
int main() {
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int h,w,n,x,y; cin>>h>>w>>n;
	int min_row[h+1];
	for(int i=0;i<h;i++) min_row[i]=w;
	min_row[h]=0;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		x--; y--;
		min_row[x]=min(min_row[x],y);
	}
	int cur_col=0,ans=h;
	for(int i=1;i<=h;i++){
		if(min_row[i]<=cur_col){
			ans=i;
			break;
		}else if (min_row[i] == cur_col+1){
			cur_col = cur_col;
		} else {
			cur_col += 1;
		}
	}
	cout<<ans<<endl;

	return 0;
}




Measured memory_bytes: 1792
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int N, M;
	std::cin >> N >> M;

	if (N == M)
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc154c()
}

fun abc154c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val set = mutableSetOf<Long>()

    for (a in aList) {
        if (!set.add(a)) return println("NO")
    }

    return println("YES")
}


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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short

#define pb push_back

#define fst first
#define snd second
#define mp make_pair

#define MOD 1000000007
#define all(v) (v).begin(),(v).end()
#define frl(i,n) for(long long i=0;i<n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cerr << #x << " = " << x << "\n"
#define displayvec(vec) cerr<<#vec<<": "; for(auto vd : vec) cerr<<vd<<" "; cerr<<"\n"

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for(auto &i : v) cin>>i;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  for(auto &i : v) cout<<i<<" ";
  return os;
}

vector< ll > lis(vector< ll > &v){
    ll n = v.size();
    if(n == 0) return vector< ll > ();
    vector< ll > arr, temp(n + 1, LLONG_MAX);
    vector< ll > mark(n);

    for(ll i = 0; i < n; ++i){
        ll index = lower_bound(temp.begin(), temp.end(), v[i]) - temp.begin();
        mark[i] = index;
        temp[index] = v[i];
    }

    ll findex;
    for(findex = 0; temp[findex + 1] != LLONG_MAX; ++findex);

    for(ll i = n-1; i >= 0; --i){
        if(mark[i] == findex){
            arr.emplace_back(v[i]);
            --findex;
        }
    }
    reverse(arr.begin(), arr.end());
    return arr;
}

string lcs(string s, string t){
    string str;
    ll n = s.length(), m = t.length();
    vector< ll > arr[128];
    vector< ll > find_lis;
    //find_lis.reserve(n*m);

    for(ll i = 0; i < m; ++i){
        arr[static_cast< int >(t[i])].emplace_back(i);
    }
    for(auto &i : s){
        for(vector< ll > :: reverse_iterator itr = arr[static_cast< int >(i)].rbegin(); itr != arr[static_cast< int >(i)].rend(); ++itr){
            find_lis.emplace_back(*itr);
        }
    }

    const vector< ll > found_lis = lis(find_lis);
    for(auto i : found_lis){
        str.push_back(t[i]);
    }
    return str;
}

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin>>s>>t;
    cout<<lcs(s, t)<<"\n";
    return 0;
}


Measured memory_bytes: 214112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct edge{int to;ll cap;int rev;};
struct Dinic{
private:
    int n;
    vector<vector<edge>> v;
    vector<int> dist,iter;
public:
    Dinic(int sz):n(sz),v(sz),dist(sz),iter(sz){}
    
    void addedge(int from,int to,ll cap){
        int x=v[to].size(),y=v[from].size();
        v[from].push_back({to,cap,x});
        v[to].push_back({from,0,y});
    }
    
    void bfs(int s){
        fill(dist.begin(),dist.end(),-1);
        queue<int> q;
        dist[s]=0;
        q.push(s);
        while(q.size()){
            int x=q.front();q.pop();
            rep(i,v[x].size()){
                edge &e=v[x][i];
                if(e.cap>0&&dist[e.to]<0){
                    dist[e.to]=dist[x]+1;
                    q.push(e.to);
                }
            }
        }
    }
    
    ll dfs(int x,int t,ll f){
        if(x==t)return f;
        for(int& i=iter[x];i<(int)v[x].size();++i){
            edge& e=v[x][i];
            if(e.cap>0&&dist[x]<dist[e.to]){
                ll d=dfs(e.to,t,min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    v[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    ll max_flow(int s,int t){
        ll flow=0;
        while(1){
            bfs(s);
            if(dist[t]<0)return flow;
            fill(iter.begin(),iter.end(),0);
            ll f;
            while((f=dfs(s,t,1LL<<62))>0)flow+=f;
        }
    }
};
int main(){
    int n;
    cin>>n;
    int p[n], q[n];
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];
    vector<int> a(n,-1), b(n,-1);
    int id1 = 0, id2 = 0;
    rep(j,n){
        int i = j;
        if(a[i]!=-1)continue;
        a[i]=id1;
        while(a[p[i]]==-1){
            a[p[i]]=id1;
            i=p[i];
        }
        ++id1;
    }
    rep(j,n){
        int i = j;
        if(b[i]!=-1)continue;
        b[i]=id2;
        while(b[q[i]]==-1){
            b[q[i]]=id2;
            i=q[i];
        }
        ++id2;
    }
    Dinic dn(id1+id2+2);
    int s = id1+id2, t = id1+id2+1;
    rep(i,n){
        //dn.addedge(a[i],t,1);
        //dn.addedge(s,id1+b[i],1);
        if(i==q[i]){
            dn.addedge(id1+b[i], t, inf);
        }
        if(i==p[i]){
            dn.addedge(s,a[i], inf);
        }
        dn.addedge(a[i],id1+b[i],1);
        if(p[i]==q[i]){
            dn.addedge(id1+b[i], a[i], 1);
        }
    }
    cout<<n-dn.max_flow(s, t)<<endl;
    return 0;
}

Measured memory_bytes: 16224
#include <iostream>
#include<vector>
#include<utility>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int D;
    cin>>D;
    vector<int>c(27);
    rrep(i,26)cin>>c[i];
    vector<vector<int>>s(D+1,vector<int>(27));
    rrep(d,D){
        rrep(i,26)cin>>s[d][i];
    }
    vector<int>last(27);
    vector<int>C(D+1);
    vector<int>t(D+1);
    vector<int>v(D+1);
    rrep(d,D){
        cin>>t[d];
        last[t[d]] = d;
        rrep(i,26){
            C[d] += c[i]*(d-last[i]);
        }
        v[d] = v[d-1]+s[d][t[d]]-C[d];
    }
    rrep(d,D){
        cout<<v[d]<<endl;
    }

    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(a+b,min(b+c,c+a)) << endl;
}


Measured memory_bytes: 256
N = gets.to_i
R = N.times.map{gets.split}

R.map! do |r|
  r[1] = r[1].to_i
  r
end

temp = R.sort_by{|r| r[0]}
temp = temp.group_by{|r| r[0]}

temp.map do |k,v|
  v.sort_by! { |r| r[1] }.to_a.reverse!
end

temp.each do |k,v|
  v.each do |r|
    puts R.index { |t| t[1] == r[1] } + 1
  end
end




Measured memory_bytes: 1788
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int x;
	cin >> x ;	
	
	int lim = sqrt(x)+1;
	
	int ans = 0;
	rep(i,2,x){
		int j = 3;
		while( pow(i,j) <= x ){
			j++;
		}
		
		int num = (int)pow(i,j-1);
		if( ans < num && num <= x ){
			ans = num;
		}
	}

	if(!ans)
		ans = 1;
	cout << ans << endl;
	ret 0;
}

Measured memory_bytes: 384