akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     ff 				first
#define 	ss 				second
#define 	pb 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vvll            vector<vll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(10);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 10)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve() {
    int n;
    cin >> n;
    vpll a(n);

    rep(i, 0, n) cin >> a[i].ff >> a[i].ss;

    int flag = 0;

    rep(i, 0, n-2) {
        int tmp = 1;
        rep(j, 0, 3) {
            if(a[i+j].ff != a[i+j].ss) tmp = 0;
        }
        flag = max(tmp, flag);
    }
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}

int main(){
    boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("alchemy_input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);

    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<iomanip>
#define MAX 100001
#define ll long long int
#define eps 1e-7
using namespace std;

int n;
int a[100500];
int cnt[300500];
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    cnt[a[i]] = i;
  }

  int s = 0;
  for(int i=1;i<=n;i++){
    if(a[a[i]]==i)s++;
  }
  cout<<s/2<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  while (1){
    int e;
    cin >> e;
    if (e == 0){
      break;
    }
    int ans = INF;
    for (int y = 0; y * y <= e; y++){
      for (int z = 0; y * y + z * z * z <= e; z++){
        int x = e - y * y - z * z * z;
        ans = min(ans, x + y + z);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3056
a,b = map(int,input().split())

def prime_factorize(n):
   a = [1]
   while n % 2 == 0:
       a.append(2)
       n //= 2
   f = 3
   while f * f <= n:
       if n % f == 0:
           a.append(f)
           n //= f
       else:
           f += 2
   if n != 1:
       a.append(n)
   return a
   
print(len(set(prime_factorize(a)) & set(prime_factorize(b))))   

Measured memory_bytes: 38536
n,m=list(map(int,input().split()))
s=list(map(int,input().split()))

s.sort()
term=[]
if n-m>=0:
    print(0)
else:
    for i in range(m-1):
        term.append(s[i+1]-s[i])
    
    term.sort()

    for i in range(n-1):
        del term[-1]
    
    print(sum(term))

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

namespace ConsoleApplication1
{
    struct Card { internal int num, vol; }

    class Problem
    {
        readonly int MAX = 1000;
        readonly int m;

        Card[] cards;
        int[,] dp;

        public Problem(int m)
        {
            this.m = m;
            cards = new Card[m];
            dp = new int[m + 1, MAX + 1];
        }

        public void SetCards()
        {
            for (int i = 0; i < m; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                cards[i].num = int.Parse(input[0]);
                cards[i].vol = int.Parse(input[1]);
            }
        }

        public void MakeDP()
        {
            dp[0, 0] = 1;

            for (int i = 0; i < m; i++)
            {
                for (int j = MAX; j >= 0; j--)
                {
                    if (dp[i, j] == 0) continue;

                    for (int k = 0; k <= cards[i].vol; k++)
                    {
                        int sum = j + cards[i].num * k;

                        if (sum > MAX) continue;

                        dp[i + 1, sum] += dp[i, j];
                    }
                }
            }
        }

        public int GetConmination(int n)
        {
            return dp[m, n];
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int m = int.Parse(Console.ReadLine());

                if (m == 0) break;

                Problem p = new Problem(m);
                p.SetCards();
                p.MakeDP();

                int g = int.Parse(Console.ReadLine());

                while (g-- > 0)
                {
                    int n = int.Parse(Console.ReadLine());
                    sb.AppendLine(p.GetConmination(n).ToString());
                }
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9304
#include<iostream>
using namespace std;
int main()
{
	int n,min,s=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		if(i==0)
		{
			s++;
			min=t;
		}
		else 
		{
			if(t<min)
			{
				min=t;
				s++;
			}
		}
	}
	cout<<s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  string s, t;
  cin >> s >> t;
  bool ok = true;
  int n = s.size();
  map<char, char> mp;
  map<char, char> mp2;
  REP(i, 26) { mp['a' + i] = '#'; }
  REP(i, 26) { mp2['a' + i] = '#'; }
  REP(i, n) {
    if (mp[t[i]] == '#') {
      if (mp2[s[i]] != t[i] && mp2[s[i]] != '#') {
        ok = false;
        break;
      }
      mp[t[i]] = s[i];
      mp2[s[i]] = t[i];
    } else {
      if (mp[t[i]] != s[i]) {
        ok = false;
        break;
      }
    }
  }
  print(ok ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=1e5;
const long inf=1e18;
int main(){
	int N; cin>>N;
	long a; long ans = 1;
	rep(i,0,N){
		cin>>a;//cout<<inf / a<<" "<<ans<<endl;
		if(a == 0){ cout<<0<<endl; return 0; }
		else if((inf / a) < ans) ans = 0;
        else ans *= a;
	}cout<<(ans > 0 ? ans : -1)<<endl;
}

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

const int M = 1e9+7;
int N, K;

const int maxn = 5005;

void madd(int& a, int b) {
    a = (a+b) % M;    
}

int ch[maxn][maxn];

int comb(int a, int b) { //# ways to distribute a things among b boxes
    return ch[a+b-1][b-1];
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ch[0][0] = 1;
    for (int i = 1; i < maxn; i++) {
        for (int j = 0; j <= i; j++) {
            ch[i][j] = ch[i-1][j];
            if (j-1 >= 0) madd(ch[i][j],ch[i-1][j-1]);
        }
    }
    cin >> N >> K;
    for (int i = 1; i <= K; i++) {
        int c1 = comb(K-i,i);
        int c2 = comb(N-K-(i-1),i+1);
        cout << ((1LL*c1*c2) % M) << '\n';
    }
}


Measured memory_bytes: 96512
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("input.txt");ofstream coutt("output.txt");

int n,m,k,ans;
int f[200005];

int poww(int a,int b){
    if(b==0)return 1;
    int ans=poww(a,b/2);
    ans=ans*ans%MOD2;
    if(b&1)ans=ans*a%MOD2;
    return ans;
}

int nCr(int n,int r){
    return f[n]*poww(f[n-r],MOD2-2)%MOD2*poww(f[r],MOD2-2)%MOD2;
}

signed main(){
    FASTER;
    f[0]=1;
    for(int i=1;i<=200000;i++)f[i]=(f[i-1]*i)%MOD2;
    cin>>n>>m>>k;
    for(int p=n-k;p<=n;p++){
        ans=(ans+nCr(n-1,p-1)*m%MOD2*poww(m-1,p-1)%MOD2)%MOD2;
    }
    cout<<ans;
}


Measured memory_bytes: 5232
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

if N == 1 and len(A[0]) == 1:
  print(A[0][0] + A[1][0])
else:
  ans = 0
  for i in range(1, len(A[0])):
    if sum(A[0][:i]) + sum(A[1][i-1:i+N-1]) > ans:
      ans = sum(A[0][:i]) + sum(A[1][i-1:i+N-1])
  print(ans)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	static void doit(){
		Scanner scan = new Scanner(System.in);
		Player player[]=new Player[24];
		Player[] f_player=new Player[8];
		Player[] memo=new Player[6];
		for(int i=0;i<24;i++){
			player[i]=new Player(scan.nextInt(),scan.nextDouble());
		}
		Arrays.sort(player,0,8);
		Arrays.sort(player,8,16);
		Arrays.sort(player,16,24);
		int k=0;
		for(int i=0;i<=16;i+=8){
			f_player[k]=player[i];
			f_player[k+1]=player[i+1];
			memo[k]=player[i+2];
			memo[k+1]=player[i+3];
			k+=2;
		}
		Arrays.sort(memo);
		f_player[6]=memo[0];
		f_player[7]=memo[1];
		for(int i=0;i<f_player.length;i++){
			System.out.printf("%d %.2f\n", f_player[i].num,f_player[i].time);
		}
	}
	public static void main(String[] args) {
		new Main().doit();
	}

}
class Player implements Comparable<Player>{
	int num;
	Double time;
	public Player(int num,Double time){
		this.num=num;
		this.time=time;
	}
	@Override
	public int compareTo(Player p){
		return time.compareTo(p.time);
	}	
}

Measured memory_bytes: 28416
{-# LANGUAGE BangPatterns #-}
import           Data.Char

main :: IO ()
main = do
  cs <- getLine
  k <- readLn
  putStrLn $ solve k cs

solve :: Int -> String -> String
solve 0 cs = cs
solve _ "" = ""
solve !k [c] = [change k c]
solve !k (c:cs)
  | cost c <= k = 'a' : solve (k - (cost c)) cs
  | otherwise = c : solve k cs

change :: Int -> Char -> Char
change k c | k >= 26 = change (k `rem` 26) c
change k c = (!!k).dropWhile (/=c) $ cycle['a'..'z']

cost :: Char -> Int
cost c = (123 - ord c) `rem` 26

Measured memory_bytes: 5244
// at coder beginner
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll  maxx=1e10+5;
void solve(){
   ll n;
   cin>>n;
   if(n%2==1){
   cout<<0;return ;}
   n=n/2;

   ll ans1=1;
   ll k=2;
   while(k<=n){
       ans1+=n/k;
       k*=2;
   }
    //cout<<ans1<<"@@@";
   ll kk=5,ans2=0;;
   while(kk<=n){
         ans2+=n/kk;
         kk=kk*5;
   }
   //cout<<ans2<<endl;
   cout<<min(ans1,ans2)<<endl;
    
}
int main(){
    ll t=1;
//cin>>t;
    while(t--){

     solve();
    }
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> citys(N+1);
  for(; M > 0; M--) {
    int a, b;
    cin >> a >> b;
    citys.at(a)++;
    citys.at(b)++;
  }
  
  for(int i = 1; i <= N; i++) {
    cout << citys.at(i) << endl;
  }
}


Measured memory_bytes: 3592
import math
a, b, h, m = map(int, input().split())
theta1 = (60*h + m) / 2.0;
theta2 = 6.0 * m;
theta = abs(theta1 - theta2);
if theta > 180:
    theta = 360 - theta;
    
c = math.cos(theta / 180 * math.acos(-1));
ans = a*a + b*b - 2*a*b*c;
    
ans = math.sqrt(ans);
print(ans);

Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
  int n;
  cin >> n;
  if(n == 0)break;
  int A[1000]={0};
  double ans1=0;
  for(int i=0;i<n;i++){
      cin >> A[i];
      ans1 += A[i];
  }
  ans1 /= n;
  double ans2 = 0;
  for(int i = 0; i< n;i++){
      ans2 += pow(A[i] - ans1, 2);
  }
  ans2 /= n;
  double ans3 = sqrt(ans2);
  cout << fixed << setprecision(15) << ans3 << endl;
  }
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int n;
string s;

ll search(vector<int> &a, vector<int> &b, vector<int> &c) {
    ll cnt = 0;
    for (auto tb : b) {
        // ll ta = upper_bound(all(a), tb) - a.begin();
        ll tc = c.end() - upper_bound(all(c), tb);
        for (int i = 0, size = a.size(); i < size; ++i) {
            if (a[i] > tb)
                break;
            if (binary_search(all(c), tb + (tb - a[i])))
                cnt += max(0LL, tc - 1);
            else
                cnt += tc;
        }
    }
    return cnt;
}

int main() {
    vector<int> r, g, b;
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R')
            r.push_back(i);
        else if (s[i] == 'G')
            g.push_back(i);
        else if (s[i] == 'B')
            b.push_back(i);
    }

    ll sum = 0;
    sum += search(r, g, b);
    sum += search(r, b, g);
    sum += search(g, r, b);
    sum += search(g, b, r);
    sum += search(b, r, g);
    sum += search(b, g, r);
    cout << sum << endl;

    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    ll n, h; cin >> n >> h;
    V<ll> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];

    sort(ALL(a), greater<ll>());
    sort(ALL(b), greater<ll>());

    ll sum = 0, cnt = 0;;
    for(int i = 0; i < n; i++){
        if(b[i] < a[0]) break;
        sum += b[i];
        cnt++;
        if(h <= sum){
            cout << cnt << endl;
            return 0;
        }
    }

    ll ans = cnt;
    ll sub = h - sum;
    if(sub % a[0] == 0) ans += (sub / a[0]);
    else ans += (sub / a[0] + 1);
    cout << ans << endl;

}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int k = in.nextInt();
			int l = in.nextInt();
			UnionFind u1 = new UnionFind(n);
			UnionFind u2 = new UnionFind(n);
			for (int i = 0; i < k; i++) {
				int p = in.nextInt()-1;
				int q = in.nextInt()-1;
				u1.link(p, q);
			}
			for (int i = 0; i < l; i++) {
				int r = in.nextInt()-1;
				int s = in.nextInt()-1;
				u2.link(r, s);
			}
			Map<Long, Integer> roots = new HashMap<Long, Integer>();
			for (int i = 0; i < n; i++) {
				long code = (long)u1.root(i)<< 32 | u2.root(i);
				roots.merge(code, 1, Integer::sum);
			}
			for (int i = 0; i < n; i++) {
				if (i > 0)out.print(" ");
				long code = (long)u1.root(i) << 32 | u2.root(i);
				out.print(roots.get(code));
			}

		}

		public class UnionFind {
			int[] data;

			public UnionFind(int n) {
				data = new int[n];
				Arrays.fill(data, -1);
			}

			boolean link(int x, int y) {
				x = root(x);
				y = root(y);
				if (x != y) {
					if (data[y] < data[x]) {
						data[y] += data[x];
						data[x] = y;
					} else {
						data[x] += data[y];
						data[y] = x;
					}
				}
				return x != y;
			}

			int root(int x) {
				return data[x] < 0 ? x : (data[x] = root(data[x]));
			}
		}
	}


	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 80036
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}



int main() {
    ll n,m; cin>>n>>m;
    vi arr(n,0),brr(n,0);
    ll pen = 0,c = 0;

    rep(i,0,m)
    {
        ll p;
        string s;
        cin>>p>>s;
        if(arr[p-1]!=1)
        {
            if(s=="WA")brr[p-1]++;
            else
            {
                arr[p-1]=1;
                c++;
            }
        }
    }
    rep(i,0,n)
    {
        if(arr[i]==1)pen+=brr[i];
    }
    cout<<c<<" "<<pen<<endl;
   return 0;
}
/*
7
1 2 3 5 4 6 7
*/


Measured memory_bytes: 1792
# include <iostream>
# include <string>
# include <cstdio>

using namespace std;

int main() {
  string s;
  cin >> s;
  char prev = s[0];
  int cnt = 0;
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] == prev) {
      ++cnt;
      prev = (s[i] == '0')? '1' : '0';
    } else {
      prev = s[i];
    }
  }
  //printf("%s", s.c_str());
  printf("%d", cnt);
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static long[] kaijo;
	 static long[] kaiinv;
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        int N = c.length;
	        int[] m= new int[N];
	        for(int i=0;i<N;i++) {
	        	m[i]=c[i]-'a';
	        }
        	int ans=99999;
	        
	        for(int i=0;i<26;i++) {
	        	int[] t = new int[N];
	        	int cnt=0;
	        	for(int j=0;j<N;j++) {
	        		if(m[j]==i) {
	        			t[j]=1;
	        			cnt++;
	        		} else {
	        			t[j]=0;
	        		}
	        	}
//	        	if(cnt==0)continue;
	        	int length=N;
	        	int tmp=0;
	        	while(cnt<N) {
		        	for(int j=0;j<length;j++) {
		        		if(t[j]==0) {
		        			if(j==length-1) {
		        				cnt++;
		        			} else {
		        				if(t[j+1]==1) {
		        					t[j]=1;
		        					cnt++;
		        				}
		        			}
		        		}
		        	}
		        	length--;
		        	tmp++;
	        	}
	        	ans=Math.min(ans, tmp);
	        }
	        System.out.println(ans);
	        
	        
	 }

}

Measured memory_bytes: 21588
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}

signed main() {
  int N = in();
  int M = in();
  if (M / 2 <= N) {
    cout << M / 2 << endl;
  } else {
    cout << (2 * N + M) / 4 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a[3];
    rep(i,0,3)
    cin>>a[i];
    if(min(a[0],a[1])<a[2] and a[2]<max(a[0],a[1]))
    	cout<<"Yes\n";
    else
    	cout<<"No\n";
}


Measured memory_bytes: 256
#include<set>
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 200000
#define ba a[i]-'a'
#define bb b[i]-'a'
char a[MAXN+5],b[MAXN+5];
int len;
set <int> x[30],y[30];
int main(){
  scanf("%s%s",a,b);
  len=strlen(a);
  for(int i=0;i<len;i++){
    x[ba].insert(bb);
    y[bb].insert(ba);
  }
  for(int i=0;i<26;i++)
    if(x[i].size()>1||y[i].size()>1){
      printf("No");
      return 0;
    }
 	printf("Yes");
  return 0;
}

Measured memory_bytes: 640
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll K; cin >> K;
    if (K%2 == 0 || K%5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    ll cnt = 1;
    ll tmp = 7;
    while (tmp%K != 0) {
        tmp = (tmp%K * 10) + 7;
        cnt++;
    }
    cout << cnt << endl;

}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int c1,c5,c10,c50,c100,c500;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    int coin;
    coin = c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
    if((coin/1000)>0){cout << 1 << endl;}
    else{cout << 0 << endl;}
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<stdlib.h>
int main(){
  int D;
  scanf("%d",&D);
  if(D==25)
    printf("Christmas");
  else if(D==24)
    printf("Christmas Eve");
  else if(D==23)
    printf("Christmas Eve Eve");
  else if(D==22)
    printf("Christmas Eve Eve Eve");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <stdio.h>
#include<vector>
using namespace std;
int dfs(int n, int level){
    //printf("%d %d\n", n, level);
    if(n<0) return 0;
    if (level == 0 && n<0) return 0;
    if(level == 0 && n == 0) return 1;
    if(level > 0){
        int sum = 0;
        for(int i=0; i<=9; i++){
            if(i<=n)
                sum += dfs(n-i, level-1);
        }
        return sum;
    }
    return 0;
}
int main(){
    int n;
    while(scanf("%d\n", &n)!=EOF){
        printf("%d\n", dfs(n, 4));
    }
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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 n,m;

int main() {
  cin >> n >> m;
  int x[m];
  rep(i,m)cin >> x[i];
  sort(x,x+m);
  int ans=x[m-1]-x[0];
  if(n>=m){cout << 0;return 0;}
  vector<int> l(m-1);
  rep(i,m-1)l[i]=x[i+1]-x[i];
  sort(rALL(l));
  int sum=0;
  rep(i,n-1)sum+=l[i];
  cout << ans-sum;
}

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

int main(){
    int A,B;
    cin >> A >> B;
    int ans = 6;
    ans -= A+B;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var n = lines.shift();

var dic = {};
for (var i = 0; i < n; i++) {
	var command = lines[i].split(' ');
	if (command[0] == 'insert')
		dic[command[1]] = true;
	else {
		if (dic[command[1]]) {
			console.log('yes');
		} else {
			console.log('no');
		}
	}
}

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

int main()
{
    int h, w;
    cin >> h >> w;

    for (int i = 0; i < w + 2; i++) cout << "#"; cout << endl;

    string s;
    for (int i = 0; i < h; i++) {
        cin >> s;
        cout << "#" << s << "#" << endl;
    }

    for (int i = 0; i < w + 2; i++) cout << "#"; cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
int n,m,k,a,b,fa[100000],r[100000],ch[100000];
ll find(ll x){
    if(fa[x]==x)return x;
    return fa[x]=find(fa[x]);
}
/*
int find(int x){
    if(find(x)==x)return x;
    return fa[x]=find(fa[x]);
}
*/
void uni(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y){
        
        return ;
    }
    if(r[x]<r[y])swap(x,y);
    fa[y]=x;
    r[x]+=r[y];
}


int main(void){

    cin>>n>>m>>k;
    for(int i=0;i<100000;i++){
        r[i]=1;
        fa[i]=i;
    }
    //uni(5,3);
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        b--;
        uni(a,b);
        ch[a]++;
        ch[b]++;
    }
    for(int i=0;i<k;i++){
        cin>>a>>b;
        a--;
        b--;
        if(find(a)==find(b)){
            ch[a]++;
            ch[b]++;
        }
    }
    for(int i=0;i<n;i++){
        cout<<r[find(i)]-ch[i]-1;
        cout<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=100000007;
int comb[1001][1001];

signed main(){
    comb[0][0]=1;
    for(int i=1;i<=1000;i++){
        comb[i][0]=comb[i][i]=1;
        for(int j=1;j<i;j++){
            comb[i][j]=(comb[i-1][j]+comb[i-1][j-1])%mod;
        }
    }


    int r,c,a1,a2,b1,b2;cin>>r>>c>>a1>>a2>>b1>>b2;
    int wc=min(abs(a1-b1),r-abs(a1-b1));
    int hc=min(abs(a2-b2),c-abs(a2-b2));

    int ans=comb[wc+hc][hc];
    if(abs(a1-b1)==r-abs(a1-b1))ans=ans*2%mod;
    if(abs(a2-b2)==c-abs(a2-b2))ans=ans*2%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8268
def main():
    n = int(input())
    a = input()
    b = input()
    c = input()

    cnt = 0
    for i in range(n):
        if a[i] == b[i] == c[i]:
            pass
        elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
            cnt += 1
        else:
            cnt += 2

    print(cnt)


if __name__ == '__main__':
    main()


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
const ll INF = LLONG_MAX / 10;

typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight = 1)
        : src(src), dst(dst), weight(weight) {}
};
bool operator<(const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
               e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool BellmanFord(const Graph &g, int s, vector<Weight> &dist,
                 vector<int> &prev) {
    int n = (int)g.size();
    dist.assign(n, INF);
    dist[s] = 0;
    prev.assign(n, -2);
    bool negative_cycle = false;
    for(int k = 0; k <= 2 * n; k++)
        for(int i = 0; i < n; i++)
            for(Edge e : g[i]) {
                if(dist[e.src] == -INF) {
                    dist[e.dst] = -INF;
                    continue;
                }
                if(dist[e.src] != INF && dist[e.dst] > dist[e.src] + e.weight) {
                    dist[e.dst] = dist[e.src] + e.weight;
                    prev[e.dst] = e.src;
                    if(k == n - 1) {
                        dist[e.dst] = -INF;
                        negative_cycle = true;
                    }
                }
            }
    return !negative_cycle;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, P;
    cin >> N >> M >> P;
    Graph G(N);
    for(int i = 0; i < M; i++) {
        ll A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        G[A].emplace_back(A, B, P - C);
    }
    vector<Weight> dist;
    vector<int> prev;
    BellmanFord(G, 0, dist, prev);
    ll ans = dist[N - 1] > 0 ? 0 : -dist[N - 1];
    if(ans == INF)
        ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
while(cin>>n){
for(int i=1;i<=50000;i++){
    if(int(i*1.08)==n){
        cout<<i<<endl;
        return 0;
    }
}
cout<<":("<<endl;}
return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String answer = "";	
		
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			int[] shuffleBegin = new int[shuffleTimes]; //?????£?????????????§????
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			answer = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					answer = answer + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					answer = answer + targetChar[j];
				}
				
			targetChar = answer.toCharArray();
			}
			System.out.println(answer);		
		}
	}
}

Measured memory_bytes: 46212
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>
#include <stdlib.h>

#define FOR(i, l, r) for (i = (l); i < r; i++ )

using namespace std;
typedef long long ll;

#define MAX_N (500010)

struct Node{
    int key;
    Node *p_p;
    Node *p_l;
    Node *p_r;
};

int m;

Node *T = NULL;


void insert(int k) {
    Node *p_y = NULL;		// parent of x
    Node *p_x = T;
    Node *p_z = (Node *)malloc(sizeof(Node));
    
    p_z->key = k;
    p_z->p_p = p_z->p_l = p_z->p_r = NULL;

    while ( p_x != NULL ) {
	p_y = p_x;
	if ( k < p_x->key ) {
	    p_x = p_x->p_l;
	}
	else {
	    p_x = p_x->p_r;
	}
    }

    p_z->p_p = p_y;		// parent of z is y.
    
    if ( p_y == NULL ) {		// T is NULL.
	T = p_z;
    }
    else if ( k < p_y->key ) {	// z is left child of y.
	p_y->p_l = p_z;

    }
    else {			// z is right child of y.
	p_y->p_r = p_z;
    }

    return;
}

void preorder( vector<int> *p_v, Node *p_x ) {
    if ( p_x == NULL ) return;
    else {
	p_v[0].push_back(p_x->key);
	preorder(p_v, p_x->p_l);
	preorder(p_v, p_x->p_r);	
    }
    
    return;
}

void inorder( vector<int> *p_v, Node *p_x ) {
    if ( p_x == NULL ) return;
    else {
	inorder(p_v, p_x->p_l);
	p_v[0].push_back(p_x->key);	
	inorder(p_v, p_x->p_r);	
    }
    
    return;
}

Node* find( Node *p_x, int k ) {
    if ( p_x == NULL || (k == p_x->key) ) return p_x;
    else if ( k < p_x->key ) {
	return find( p_x->p_l, k );
    }
    else {
	return find( p_x->p_r, k );
    }
}

int main()
{
    scanf("%d", &m);
    for ( int i = 0; i < m; i++ ) {
	char str[100];
	scanf("%s", str);
	if ( str[0] == 'i' ) {	// insert
	    int k;
	    scanf("%d", &k);
	    insert(k);
	}
	else if ( str[0] == 'f' ) { // find
	    Node *p_x;
	    int k;
	    scanf("%d", &k);
	    p_x = find(T, k);
	    printf("%s\n", (p_x != NULL) ? "yes" : "no" );
	}
	else {			// print
	    vector<int> pre;
	    vector<int> in;
	    preorder( &pre, T );
	    inorder( &in, T );

	    for ( int i = 0; i < in.size(); i++ ) {
		printf(" %d", in[i]);
	    }
	    printf("\n");
	    for ( int i = 0; i < pre.size(); i++ ) {
		printf(" %d", pre[i]);
	    }
	    printf("\n");	    
	}
    }
    
    return 0;
}

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

int main() {
    // 入力
   int64_t a,b,k;
   cin>>a>>b>>k;
   
   if(a<k){
       cout<<"0 ";
       if(b>=(k-a)){
           cout<<b-k+a<<endl;
       }
       else{
           cout<<0<<endl;
       }
   }else if(a==k){
        cout<<"0 "<<b<<endl;
   }else{
       cout<<a-k<<" "<<b<<endl;
   }

 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a[4]{};
    for(int i = 0; i < 2; i++){
        int x;
        cin >> x;
        a[x] = 1;
    }
    for(int i = 1; i <= 3; i++) if(a[i] == 0) cout << i;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  priority_queue<int> pq;
  rep(i, n) {
    int d;
    cin >> d;
    pq.push(d);
  }
  rep(i, n/2-1) pq.pop();
  int maxk = pq.top();
  pq.pop();
  int mink = pq.top();
  int ans = maxk - mink;
  cout << ans << endl;
}

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

int main(){
    int s;
    cin >> s;
    int x, y;
    x = s / 100;
    y = s % 100;
    string ans1, ans2;
    if (x == 0 || x > 12){
        ans1 = "YY";
    }
    else {
        ans1 = "MM";
    }
    if (y == 0 || y > 12){
        ans2 = "YY";
    }
    else {
        ans2 = "MM";
    }

    string ans;
    if (ans1 + ans2 == "YYYY"){
        ans = "NA";
    }
    else if (ans1 + ans2 == "MMMM"){
        ans = "AMBIGUOUS";
    }
    else{
        ans = ans1 + ans2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int i1;
  char s[3];
  char t[3];
  
  scanf("%s", s);
  scanf("%s", t);
  
  for(i1=0;i1<3;i1++){
    if(s[i1]!=t[2-i1]){
      printf("NO");
      return 0;
  } }
  
  printf("YES");
  return 0;
}

Measured memory_bytes: 128
from collections import Counter

S = list(input())
c = Counter(S)

A = c.get("a", 0)
B = c.get("b", 0)
C = c.get("c", 0)

if max(A, B, C) - min(A, B, C) >= 2:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 4340
public class Main{
    public static void main(String args[]) throws Exception {
 
        String out;
        int result = 0;
 
        for (int i = 1; i < 10; i++) {
 
            for (int j = 1; j < 10; j++) {
                 
                result = i*j;
 
                out = i + "x" + j + "=" + result;
 
                System.out.println(out);
 
            }
 
        }
 
    }
 
}

Measured memory_bytes: 15012
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int a[100001];
int main() {
    int n, k, s, t, C;
    cin >> n >> k;
    map<int, deque<pair<int, int>>> c;
    FOR(i, n) {
        cin >> s >> t >> C;
        s--, t--, C--;
        c[C].push_back({ t,s });
    }
    for (auto &g : c) {
        deque<pair<int, int>> d;
        SORT(g.second);
        while(!g.second.empty()){
            bool changed = 0;
            FOR1(j, g.second.size()) {
                if (g.second.front().first == g.second[j].second) {
                    g.second[j].second = g.second.front().second;
                    changed = 1;
                    break;
                }
            }
            if (!changed)d.push_back(g.second.front());
            g.second.pop_front();
        }
        g.second = d;
    }
    for (auto g : c)for (auto p : g.second)a[p.second]++, a[p.first + 1]--;
    FOR1(i, 100000)a[i] += a[i - 1];
    int ans = 0;
    FOR(i, 100000)chmax(ans, a[i]);
    cout << ans << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}


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

string s,t;
cin >> s >> t;

// dp[i+1][j+1]:= s[i]までとt[j]までの最長共通部分列の長さ
vvi dp(s.size()+1,vi(t.size()+1,0));

for(int i = 0; i < s.size(); ++i) {
    for(int j = 0; j < t.size(); ++j) {
        if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
        chmax(dp[i+1][j+1], dp[i+1][j]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
    }
}

// 復元
string ans = "";
int i = s.size(); int j = t.size();
while(i > 0 && j > 0) {
    if(dp[i-1][j] == dp[i][j]) --i;
    else if(dp[i][j-1] == dp[i][j]) --j;
    else {
        ans = s[i-1] + ans;
        --i;--j;
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 35584
import sys

c=0
for s in sys.stdin:
  a,b = map(int,s.split())
  if a==b==0: break
  x=[]
  for i in range(a,b+1):
    if i%4==0:
      if i%100 ==0:
        if i%400==0: f=1
        else: f=0
      else: f=1
    else: f=0
    if f==1: x.append(i)
    
  if c: print
  if x==[]: print "NA"
  else:
    for e in x: print e
  c=1

Measured memory_bytes: 4312
N = int(input())
A = list(map(int, input().split()))
d = [0]*(N+1)
for a in A:
  d[a] += 1
X = 0
for a in set(A):
  X += d[a]*(d[a]-1)//2
for a in A:
  print(X-(d[a]-1))

Measured memory_bytes: 84044
o=input()
e=input()
ans=[]
cnt=0

for i in range(2*len(e)):
    if  i%2==0:
        ans.append(o[i//2])
    else:
        ans.append(e[i//2])

if len(o)!=len(e):
    ans.append(o[-1])

print(*ans, sep='')

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

int main(void){

    int N,K; cin>>N>>K;
    vector<int> vec(N+1);
    for (int i = 0; i < N; ++i) {
        int tmp; cin>>tmp;
        vec[tmp]++;
    }
    sort(vec.rbegin(),vec.rend());
    int sum=0;

    for (int i = K; i <= N; ++i) {
        sum+=vec[i];
    }
    cout<<sum<<endl;


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

int main() {
    int n;
    
    cin >> n ;
    vector<int> a(n);
    vector<int> b(n,0);
    
    rep(i,n) cin>>a[i];
    
    rep(i, n) b[a[i]-1] = i+1;
    
    rep(i, n) cout<<b[i]<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1664
//
// Created on 2020/03/22.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


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

    ans=0;
    ans += n * (n-1);
    ans += m * (m-1);
    ans /= 2;

    cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from collections import defaultdict

def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N = int(input())
C = [-1]
for i in range(N):
    c = int(input())
    if c != C[-1]:
        C.append(c)
C = C[1:]
N = len(C)
DP = [1]*N

ixs = defaultdict(lambda: [-1])
ixs[C[0]].append(0)

for i, c in enumerate(C[1:], start=1):
    l = ixs[c][bisect_left(ixs[c], i) - 1]
    if l != -1:
        DP[i] = (DP[i-1] + DP[l])%MOD
    else:
        DP[i] = (DP[i-1])%MOD
    ixs[c].append(i)
print(DP[-1])

Measured memory_bytes: 57600
function Main(input) {
    var args = input.trim().split(' ').map(Number);
    var nums = args[1] * 2
    var ans = 0;
    if(nums <= args[0]) {
      ans = args[0] - nums;
    }
    console.log(ans);
 }
 
/* var input = `12 11`;
Main(input);
 */ 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22836
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
        x: i32,
        y: i32,
    }

    let mut anss = vec![0; n as usize - 1];
    for i in 1..n {
        for j in i+1..n+1 {
            let mut d = j - i;
            d = min(d, (x-i).abs()+(y-j).abs()+1);
            d = min(d, (y-i).abs()+(x-j).abs()+1);
            anss[(d-1) as usize] += 1;
        }
    }

    for ans in anss {
        println!("{}", ans);
    }
}



Measured memory_bytes: 4352