akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	int n; cin >> n;
	int s[100100], t[100100];
	vector<pii>v;
	REP(i, n) {
		cin >> s[i] >> t[i];
		v.push_back({ t[i],s[i] });
	}
	sort(v.begin(), v.end());
	int ans = 0;
	int now = 0;
	for (int i = 0; i < n; ++i) {
		if (now < v[i].second) {
			ans++;
			now = v[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4636
package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B := sc.nextInt(), sc.nextInt()

	if A != 1 && B != 1 {
		fmt.Fprintln(wtr, 1)
	} else if A != 2 && B != 2 {
		fmt.Fprintln(wtr, 2)
	} else {
		fmt.Fprintln(wtr, 3)
	}
	wtr.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int ans = 0;
	char now = s[0];
	rep(i, s.size()) {
		if (i == 0)continue;
		if (now == s[i]) {
			now = '1';
			i++;
			if (i >= s.size())break;
		}
		else now = s[i];
		ans++;
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 720
# Nを取得
N = int(input())
# 単語取得
word = list(str(input()) for _ in range(N))
# 結果用の変数
res = 'Yes'
# 重複チェック
if len(word) != len(set(word)):
    print('No')
    exit()
# 前後のチェック用の変数
last = (word[0])[0]
# 前後のチェック
for i, x in enumerate(word):
    if last != x[0]:
        print('No')
        exit()
    last = x[-1]
print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;


// verified by: https://atcoder.jp/contests/abc141/tasks/abc141_e


struct RollingHash {
  using ui64 = uint64_t;
  using ui128 = __uint128_t;
  static const ui64 mod = (1ull<<61) - 1;
  vector<ui64> hash, power;
  ui64 base;

  static inline ui64 add(ui64 a, ui64 b) { if ((a += b) >= mod) a -= mod; return a; }
  static inline ui64 mul(ui64 a, ui64 b) { ui128 c = ui128(a)*b; return add(c>>61, c&mod); }
  static inline ui64 generate_base() {
    mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<ui64> rand(2, mod-2);
    return rand(mt);
  }

  template<typename T>
  RollingHash(const T &s, ui64 b=0) : base(b) {
    if (base == 0) base = generate_base();
    int n = s.size();
    hash.assign(n+1, 0);
    power.assign(n+1, 1);
    rep(i, n) {
      power[i+1] = mul(power[i], base);
      hash[i+1] = add(mul(hash[i], base), s[i]);
    }
  }

  ui64 get(int l, int r) const { return add(hash[r], mod - mul(hash[l], power[r-l])); }

// longest common prefix of s[l1:r1] and s[l2:r2]
  int lcp(int l1, int r1, int l2, int r2) const {
    int len = min(r1-l1, r2-l2);
    int ok = 0, ng = len+1;
    while (ng-ok > 1) {
      int md = (ok+ng)>>1;
      if (get(l1, l1+md) == get(l2, l2+md)) ok = md;
      else ng = md;
    }
    return ok;
  }
  
// longest common prefix of s[l1:r1] and t[l2:r2]
  int lcp(RollingHash &rh, int l1, int r1, int l2, int r2) const {
    int len = min(r1-l1, r2-l2);
    int ok = 0, ng = len+1;
    while (ng-ok > 1) {
      int md = (ok+ng)>>1;
      if (get(l1, l1+md) == rh.get(l2, l2+md)) ok = md;
      else ng = md;
    }
    return ok;
  }
};


int main() {
    int n; cin >> n;
    string s; cin >> s;
    RollingHash rh(s);

    int ans = 0;
    rep(i, n) rep2(j, i+1, n) {
      int lcp = rh.lcp(i, j, j, n);
      ans = max(ans, lcp);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    ll a,b,c;
    cin >> a >> b >> c;

  if(a >= c){
      cout << a-c << " " << b << endl;
  }else if(a < c && b >= c-a){
      cout << '0' << " " << b - (c-a) << endl;

  }else if(a < c && b < c-a){
      cout << '0' << " " << '0' << endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;

using Edge = pair<ll,ll>;  //　1つ目は結んでいるノード、2つ目はその辺の重みを指す
using Graph = vector<vector<Edge> >;  //隣接リスト
using Matrix = vector<vector<ll> >;  //隣接行列

void warshall(const Matrix &G, Matrix &dist){
  dist = G;
  ll n = G.size();
  rep(k,n){
    rep(i,n){
      rep(j,n){
        if(dist[i][k] == INF || dist[k][j] == INF) continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}
 
int main() {
  ll n,m,r;
  cin >> n >> m >> r;
  Matrix G(n,vl(n,INF)),dist;
  vl R(r);
  rep(i,r) cin >> R[i];
  rep(i,m){
    ll a,b,c;
    cin >> a >> b >> c;
    G[a-1][b-1] = c;
    G[b-1][a-1] = c;
  }
  rep(i,n) G[i][i] = 0;
  
  warshall(G,dist);
  
  ll ans = INF;
  sort(ALL(R));
  
  do {
    ll tmp = 0;
    for(int i = 1; i < R.size(); i++){
    tmp += dist[R[i]-1][R[i-1]-1];
    }
    ans = min(ans,tmp);
  } while (next_permutation(ALL(R)));
  
  
  cout << ans;
                             
                             

 return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), ans = 0;
    for(int i=0; i<=n; i+=4){
      for(int j=0; j<=n; j+=7){
        if(i+j==n){
          ans++;
        }
      }
    }
    if(ans>0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

/*
方法1: 全探索+フラッグ
方法2: 割り切れる回数が最も少ない値を見つけ、その値を割り切れる回数を出力
*/

const int INF = 10000000;
int N;
vector<int> A(210);

int main() { 
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int min_divisible = INF;
  for (int i = 0; i < N; i++) {
    int count = 0;
    
    while ((A.at(i) % 2) == 0) {
      A.at(i) /= 2;
      count++;
    }
    
    if (min_divisible > count) min_divisible = count;
  }
  
  cout << min_divisible << endl;
}


Measured memory_bytes: 3640
#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 n, min_p, ans;
    cin >> n;
    ans = 0;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    min_p = p[0];
    rep(i, n){
        if (min_p >= p[i]){
            ans++;
        }
        min_p = min(p[i], min_p);
    }
    cout << ans <<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll c, k;
  cin >> n >> c >> k;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];
  sort(ALL(t));
  int i = 0;
  int ans = 0;
  for(int i = 0; i < n; ++i) {
    int j = i;
    while(t[j+1]-t[i] <= k && (j+1)-i+1 <= c && j < n) ++j;
    i = j;
    ++ans;
  }
  cout << ans << endl;
}

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

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;
typedef pair<double, double> 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<string> &o) {
    string 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;

struct Sushi {
    ll t, d;
    bool first;
};


std::istream &operator>>(std::istream &in, Sushi &o) {
    cin >> o.t >> o.d;
    return in;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<Sushi> sushis(n);

    rep(i, n) cin >> sushis[i];
    sort(sushis.rbegin(), sushis.rend(), [](Sushi &s1, Sushi &s2) {
        return s1.d < s2.d;
    });

    {
        set<ll> t;
        rep(i, n) {
            if (t.find(sushis[i].t) == t.end()) {
                sushis[i].first = true;
                t.insert(sushis[i].t);
            } else {
                sushis[i].first = false;
            }
        }
    }

    vector<Sushi> v = [&] {
        vector<Sushi> res;
        rep(i, k) {
            res.push_back(sushis[i]);
        }
        sort(res.rbegin(), res.rend(), [&](Sushi &s1, Sushi &s2) {
            ll a = s1.d;
            ll b = s2.d;
            if (s1.first) a += INF;
            if (s2.first) b += INF;
            return a < b;

        });
        return res;
    }(); // おいしくないやつが最後
    vector<Sushi> u = [&] {
        vector<Sushi> res;
        rep(i, n) {
            if (i < k) continue;
            if (!sushis[i].first) continue;
            res.push_back(sushis[i]);
        }
        reverse(res.begin(), res.end());
        return res;
    }(); // おいしいやつが最後

    ll prev_dsum = [&] {
        ll sum = 0;
        for (Sushi &s : v) sum += s.d;
        return sum;
    }();
    ll t = [&] {
        set<ll> types;
        for (Sushi &s : v) types.insert(s.t);
        return types.size();
    }();
    ll ma = t * t + prev_dsum;
    while (!u.empty() && v.back().first == false) {
        Sushi pv = v.back();
        Sushi pu = u.back();
        v.pop_back();
        u.pop_back();

        prev_dsum -= pv.d;
        prev_dsum += pu.d;
        t++;

        ll now = t * t + prev_dsum;
        cmax(ma, now);
    }
    cout << ma << endl;

}

Measured memory_bytes: 7772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll t,n,x,rs;
    cin>>n>>x>>t;
    if(n%x==0) rs=n/x*t;
    else rs=(n/x+1)*t;
    cout<<rs;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ic pair <int, char>
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <int> v;

/*int intConvert(string s){
    int n;
    stringstream geek(s);
    geek >> n;
    return n;
}*/

/*string strConvert(int n){
    string s;
    stringstream ss;
    ss << n;
    s=ss.str();
    return s;
}*/


int main(){
    int n;
    map <string, int> mp;
    sf(n);

    while(n--){
        string s,ss;
        cin>>s>>ss;

        if(s=="insert") mp[ss]++;
        else{
            if(mp[ss]>0) pf("yes\n");
            else pf("no\n");
        }
    }

    return 0;
}



Measured memory_bytes: 52536
// --------------
// Tejas Pandey  |
// 08 - 12 - 19  |
// KGP MIRROR'19 |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		ll a[n];
		for(int i = 0;i < n;i++)
			cin >> a[n - 1 - i];
		int pref[60];
		memset(pref,0,sizeof(pref));
		ll ans = 0;
		for(int i = 0;i < n;i++){
			for(int j = 59;j > -1;j--){
				ll cur = (1LL<<j);
				if(a[i]&cur){
					ans += (((i - pref[j])%mod*(cur%mod))%mod);
					ans %= mod;
					pref[j]++;
				}
				else
					ans += (((pref[j]%mod)*(cur%mod))%mod),
					ans %= mod;
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;

int main() {
  int N;
  cin>>N;
  int count=0;
  int BN=0;
  int BA=0;
  int NA=0;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    for(int k=0;k<s.size()-1;k++){
      if(s[k]=='A'&&s[k+1]=='B') count++;
    }
    if(s[0]=='B' && s[s.size()-1]=='A') BA++;
    if(s[0]=='B' && s[s.size()-1]!='A') BN++;
    if(s[0]!='B' && s[s.size()-1]=='A') NA++;
  }

  
  if(BA>0){
    count+=BA-1;
  }
  
  if(NA>0&&BA!=0){
    count++;
      NA--;
  }

  if(BN>0&&BA!=0){
    count++;
      BN--;
  }
  
  if(NA>=BN)count+=BN;
  else count+=NA;

  
  
  
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int talls[10], max, banme;
	for(int i = 0; i < 10; i++) scanf("%d", &talls[i]);
	for(int i = 0; i < 3; i++){
		max = 0;
		for(int j = 0; j < 10; j++){
			if(max < talls[j]){
				max = talls[j];
				banme = j;
			}
		}
		printf("%d\n", max);
		talls[banme] = 0;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

bool threeDoubles(vector<vector<int>>& input) {
    vector<int> positions;

    for (int i = 0; i < (int)input.size(); i++) {
        if (input[i][0] == input[i][1]) {
            positions.push_back(i);
        }
    }

    if ((int)positions.size() < 3) return false;
    for (int i = 0; i < (int)positions.size(); i++) {
        if (i + 2 < (int)positions.size()) {
            int diff1 = positions[i + 1] - positions[i];
            int diff2 = positions[i + 2] - positions[i + 1];
            if (diff1 == 1 && diff2 == 1) return true;
        }
    }
    return false;
}

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

    vector<vector<int>> input;
    for (int i = 0; i < n; i++) {
        vector<int> v;
        int a, b;
        cin >> a >> b;
        v.push_back(a);
        v.push_back(b);
        input.push_back(v);
    }

    if (threeDoubles(input))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3632
x1,y1,x2,y2,n,*a=`dd`.split.map &:to_i
xf=yf=1
x1>x2&&(x1,x2,xf=x2,x1,-1)
y1>y2&&(y1,y2,yf=y2,y1,-1)
v=a.each_slice(2).select{|x,y|x1<=x&&x<=x2&&y1<=y&&y<=y2}.map{|x,y|[x*xf,y*yf]}.sort
D=[F=1e9]*s=v.size
v.each{|x,y|D[D.bsearch_index{|e|e>=y}]=y}
n=D.bsearch_index{|e|e>=F}||s
p 100.0*(x2-x1+y2-y1)-20*n+5*(n+(n>[x2-x1,y2-y1].min ? 1:0))*Math::PI

Measured memory_bytes: 40972
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = LLONG_MAX;

/*
<url:https://abc075.contest.atcoder.jp/tasks/abc075_d>
問題文============================================================
 2次元座標上に N 個の点があります。
 i(1≦i≦N) 番目の点の座標は (xi,yi) です。
 長方形の内部に N 点のうち K 個以上の点を含みつつ、それぞれの辺がX軸かY軸に平行な長方形を考えます。
 このとき、長方形の辺上の点は長方形の内部に含みます。
 それらの長方形の中で、最小の面積となるような長方形の面積を求めてください。
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    vector<pll> ps(N);
    vector<ll> X(N),Y(N);
    for(int i = 0; i < N;i++){
        cin >> ps[i].first >> ps[i].second;
        X[i] = ps[i].first; Y[i] = ps[i].second;
    }
    sort(X.begin(),X.end()); sort(Y.begin(),Y.end());
    
    ll ans = LINF;
    for(int xi = 0; xi < N; xi++){
        for(int xj = xi + 1; xj < N; xj++){
            for(int yi = 0; yi < N; yi++){
                for(int yj = 0; yj < N; yj++){
                    
                    int cnt = 0;
                    
                    ll minx = X[xi], miny = Y[yi];
                    ll maxx = X[xj], maxy = Y[yj];
                    for(int k = 0; k < N;k++){
                        if(minx <= ps[k].first &&
                           ps[k].first <= maxx &&
                           miny <= ps[k].second &&
                           ps[k].second <= maxy)
                            cnt++;
                    }
                    if(cnt >= K){
                        ans = min(ans,(maxx-minx)*(maxy-miny));
                    }
                }
            }
        }
    }

    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}




int main(){
    int M, D; cin >> M >> D;
    int cnt = 0;
    FORS(d, 22, D){
        int d1 = d % 10, d10 = d / 10;
        if(d1 >= 2 && d10 >= 2 && d1*d10 <= M)
            ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


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

constexpr long MOD = 1000000007;

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}

long com(long n, long r) {
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * mpow(y, MOD - 2) % MOD;
}

int main() {
  int X, Y;
  cin >> X >> Y;
  if ((X + Y) % 3) return cout << 0 << "\n", 0;
  int n = (X + Y) / 3;
  int r = Y - n;
  if (r < 0) return cout << 0 << "\n", 0;
  cout << com(n, r) << "\n";
}

Measured memory_bytes: 256
from itertools import accumulate
N = int(input())
s = input()
w = map(lambda x: 1 if x == 'W' else 0, s)
e = list(map(lambda x: 1 if x == 'E' else 0, s))
e.reverse()
w = list(accumulate(w))
e = list(accumulate(e))
e.reverse()
# print(w)
# print(e)
ans = []
for i in range(N):
    num = 0
    if 0 < i: num += w[i - 1]
    if i < N - 1: num += e[i + 1]
    ans.append(num)
# print(ans)
print(min(ans))

Measured memory_bytes: 38944
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int L,R; cin>>L>>R;
    long long int a,b,minimum=9999999999999999;
    for(long long int i=L;i<R;i++){
        for(long long int j=i+1;j<=R;j++){
            long long int kake=i*j;
            minimum = min(kake % 2019, minimum);
            if(minimum==0){
                cout<<minimum;
                return 0;
            }
        }
    }
    cout<<minimum;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
INF = 1000000001
nw, sw, ne, se = (INF, -INF), (INF, INF), (-INF, -INF), (-INF, INF)
for _ in range(n):
    x, y = [int(x) for x in input().split()]
    if y - x > nw[1] - nw[0]:
        nw = x, y
    if y - x < se[1] - se[0]:
        se = x, y
    if y + x > ne[1] + ne[0]:
        ne = x, y
    if y + x < sw[1] + sw[0]:
        sw = x, y

print(max(abs(ne[0] - sw[0]) + abs(ne[1] - sw[1]),
          abs(nw[0] - se[0]) + abs(nw[1] - se[1])))


Measured memory_bytes: 9240
#include <iostream>
  using namespace std;
 long long  n;
 int  main()
 {   int a[100];
     cin>>n;int l=1;
     for(int i=5;i<55555;i++)
      {  int m=0;
          for(int j=2;j<i;j++)
          {
              if(i%j!=0)
              {
                  m++;
              }
          }
          if(i%10==1&&m==i-2)
          {
               a[l]=i;
               l++;
               m=0;
          }
          if(l>n)
            break;

      }
      for(int i=1;i<=n;i++)
      {
          if(i!=n)
           cout<<a[i]<<" ";
           else
            cout<<a[i]<<endl;
      }

     return 0;
 }


Measured memory_bytes: 256
import java.util.Scanner;

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

    int w, h, x, y, r;
      w = sc.nextInt();
      h = sc.nextInt();
      x = sc.nextInt();
      y = sc.nextInt();
      r = sc.nextInt();

    boolean X, Y;

      if( r<=x && x<=w-r){
        X = true;
      }else{
        X = false;
      }

      if( r<=y && y<=h-r){
        Y = true;
      }else{
        Y = false;
      }

        if( X && Y ){
          System.out.println( "Yes" );
        }else{
          System.out.println( "No" );
        }

    } 
}


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

const int N = 1e3+3, M = 5e3+2;
vector <int> g[N];
int X[N], ok = 1;
int dp[N];
// 0 = black

void dfs(int v){
	int sum = 0, yes = 0;
	for (auto it: g[v]) {
		dfs(it), sum += dp[it] + X[it];
		if (X[it] == 0 || dp[it] == 0) yes = 1;
	}
	bool tmp1[M], tmp2[M];
	memset(tmp1, 0, sizeof(tmp1));
	tmp1[0] = 1;
	for (int it: g[v]){
		memset(tmp2, 0, sizeof(tmp2));
		for (int i = M - 1; i >= 0; i--){
			if (tmp1[i]){
				if (i + dp[it] < M) tmp2[i+dp[it]] = 1;
				if (i + X[it] < M) tmp2[i+X[it]] = 1;
			}
		}
		for (int i = 0; i < M; i++) tmp1[i] = tmp2[i];
	}
	// if (yes || g[v].size() == 0) tmp1[0] = 1;
	// else tmp1[0] = 0;

	for (int i = X[v]; i >= 0; i--){
		if (tmp1[i]) {
			dp[v] = sum - i;
			if (dp[v] < 0) abort();
			return;
		}
	}
	ok = 0;
}


int main(){
	int n; cin >> n;
	for (int i = 2; i <= n; i++){
		int x; scanf("%d",&x);
		g[x].push_back(i);
	}
	for (int i= 1; i <= n; i++) scanf("%d",&X[i]);
	dfs(1);
	puts(ok?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 4480
#include<stdio.h>
#include<stdlib.h>
#define SWAP(a,b) ((a)^=(b)^=(a)^=(b))
typedef long long ll;
int map[105][105];
int col[10005];
int main(void)
{
	int H, W, N;
	scanf("%d %d %d", &H, &W, &N);
	for (int i = 0; i < N; i++)
		scanf("%d", &col[i]);
	int i, j, m, s = 1, a = 0, b = W - 1;
	i = j = m = 0;
	while (m < N)
	{
		for (int k = 0; k < col[m]; k++) {
			map[i][j] = m + 1;
			if (j == b)
				SWAP(a, b), s = -s, i++;
			else
				j += s;
		}
		m++;
	}
	for (int i = 0; i < H; putchar('\n'),i++)
		for (int j = 0; j < W; j++)
			printf("%d ", map[i][j]);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	int X = sc.nextInt();

        
	if (A <= X && X<= A+B) {
	    System.out.println("YES");
	}
	else {
	    System.out.println("NO");
	}

    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
	int N, D;
	int cnt;

	cnt = 0;
	cin >> N >> D;

	for (int i = 0; i < N; i++)
	{
		long long int X, Y;
		cin >> X >> Y;

		double distance = sqrt( (X*X) + (Y*Y) );

		if( distance <= (double)D )
		{
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3676
#include<stdio.h>
#include<stdlib.h>

typedef long long int llu;

#define MAX(a, b) ((a < b) ? b : a);

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

    llu *dp = (llu*)calloc(W+1,sizeof(llu));

    int w, v;
    while (N--) {
        scanf("%d%d", &w, &v);
        for (int j = W; j >= w; --j) {
            dp[j] = MAX( dp[j-w] + v , dp[j] );
        }
    }

    printf("%llu\n", dp[W]);
}

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

int main()
{
    int a, b;
    string c;
    cin >> a >> c >> b;
    if (c == "+")
    {
        cout << a + b << endl;
    }
    else if (c == "-")
    {
        cout << a - b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for(int i = 0; i < n; i++){
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + l[i];
        }
        if((sum - l[n-1]) > l[n-1]){
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int,input().split()))
A = [A[i]-(i+1) for i in range(N)]
A.sort()
b = (A[N//2-1]+A[N//2])//2 if N%2==0 else A[N//2]
print(sum([abs(a-b) for a in A]))

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

using namespace std;

using i64=long long;

int main() {
    char S[16];
    scanf("%s", S);

    i64 len=strlen(S);
    i64 ub=1<<(len-1);
    i64 res=0;
    for (int i=0; i<ub; ++i) {
        i64 cur=0;
        for (int j=0; j<len; ++j) {
            (cur *= 10) += S[j]-'0';

            if (1<<j & i) {
                res += cur;
                cur = 0;
            }
        }
        res += cur;
    }

    return !printf("%lld\n", res);
}


Measured memory_bytes: 128
#include <stdio.h>

int isPrime(int n) {
  int i;
  if (n == 2) return 1;
  else if (n == 3) return 1;
  if (n % 2 == 0) return 0;
  for (i = 3; i * i <= n; i += 2)
    if (n % i == 0) return 0;
  return 1;
}

int main(void) {
  int prime[10001] = {0};
  int twinPrime[2];
  int i, n;
  for (i = 2; i <= 10000; i++)
    if (isPrime(i))
      prime[i]++;

  while (1) {
    scanf("%d", &n);
    if (n == 0) break;

    for (i = 5; i <= n; i++) {
      if (prime[i] && prime[i-2]) {
	twinPrime[0] = i - 2;
	twinPrime[1] = i;
      }
    }

    printf("%d %d\n", twinPrime[0], twinPrime[1]);
  }
  return 0;
}

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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

const int mod = 1e9 + 7;

int main()
{
    ll m; cin >> m;
    cout << 24 + 24 - m << endl;
    return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((b > c)  && (c > a)){
        cout << "Yes" << endl;
    }else if((a > c)&&(c > b)){
       cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

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

    string s;
    cin >> s;

    int wcnt = 0;
    rep(i, 0, s.size()) {
        if (s[i] == '.') {
            wcnt++;
        }
    }

    int bcnt = 0;

    // all black
    int ans = wcnt;
    // b and w
    rep(i, 0, s.size()) {
        if (s[i] == '.') {
            wcnt--;
        } else {
            bcnt++;
        }

        ans = min(bcnt + wcnt, ans);
    }

    // all white;
    ans = min(bcnt, ans);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    char o[200]={};
    char e[200]={};
    scanf("%s",o);
    scanf("%s",e);
    for(int i = 0;i< strlen(o)+strlen(e) ;i++){
        if(o[i] != '\0') {
            printf("%c", o[i]);
        }
        if(e[i]!='\0'){
            printf("%c", e[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println("100 100");
		for (int i=0;i<50;i++) {
			String str = "";;
			for (int j=0;j<100;j++) {
				if (a>1 && i%2==0 && j%2==0) {
					str = str+".";
					a--;
				} else {
					str = str+"#";
				}
			}
			System.out.println(str);
		}
		for (int i=0;i<50;i++) {
			String str = "";;
			for (int j=0;j<100;j++) {
				if (b>1 && i%2==1 && j%2==1) {
					str = str+"#";
					b--;
				} else {
					str = str+".";
				}
			}
			System.out.println(str);
		}
	}

}


Measured memory_bytes: 28884
K = int(input())

N = 50
q = K//N
r = K%N

ans = [q+i for i in range(N)]

for i in range(r):
    ans[i] += N
    for j in range(i+1, N):
        ans[j] -= 1
        
for i in range(N):
    ans[i] = str(ans[i])
    
print(N)
print(" ".join(ans))

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

using namespace std;

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

	int DataSetNum = 0;
	int HouseNum = 0;//家の数
	int GeneNum = 0;//発電機の数
	int* HousePos;//家の位置
	int* CableLength;//送電線長さ
	int AllCableLength = 0;//全線距離

	cin >> DataSetNum;//データセット数取得
	for (int datanum = 0; datanum < DataSetNum; ++datanum){
		//各データ入力
		cin >> HouseNum;
		cin >> GeneNum;
		if (HouseNum <= GeneNum){//家より発電機が多ければ距離0
			int dummy = 0;//データ読み捨て
			for (int i = 0; i < HouseNum; ++i){
				cin >> dummy;
			}
			cout << 0 << endl;
			continue;
		}
		HousePos = new int[HouseNum];
		for (int i = 0; i < HouseNum; ++i){
			cin >> HousePos[i];
		}
		CableLength = new int[HouseNum - 1];
		for (int i = 0; i < HouseNum - 1; ++i){
			CableLength[i] = HousePos[i + 1] - HousePos[i];
		}
		AllCableLength = HousePos[HouseNum - 1] - HousePos[0];//全線距離

		//距離ソート
		sort(&CableLength[0], &CableLength[0]+HouseNum-1);
		//長いほうから削る
		for (int i = 0; i < GeneNum - 1; ++i){
			AllCableLength -= CableLength[HouseNum - i - 2];
			CableLength[HouseNum - i - 2] = 0;
		}
		//出力
		cout << AllCableLength << endl;

		delete[] CableLength;
		delete[] HousePos;
	}

	return 0;
}

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

vector<vector<int>> G(8);
int cntPath = 0;
int N, M;

void bfs(int cnt, int pos, vector<int> checked){
  
  if(cnt == N - 1){
    for(int j = 0; j < N; j++){
      if(checked.at(j) == 0) return;
    }
    cntPath++;
    return;
  }
  cnt++;
  for(int i = 0; i < G.at(pos).size(); i++){
    vector<int> ch = checked;
    ch.at(G.at(pos).at(i)) = 1;
    bfs(cnt, G.at(pos).at(i), ch);
  }
  return;
}


int main(){
  
  cin >> N >> M;
  int i;
  
  for(i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    G.at(a - 1).push_back(b - 1);
    G.at(b - 1).push_back(a - 1);
  }
  
  vector<int> ZeroVec(N, 0);
  ZeroVec.at(0) = 1;
  bfs(0, 0, ZeroVec);
  cout << cntPath << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    vector<char> a(26, -1);

    for(int i = 0; i < s.size(); i++){
        if(a[s[i]-'a'] == -1){
            a[s[i]-'a'] = t[i];
        }else if(a[s[i]-'a'] != t[i]){
            cout << "No" << endl;
            exit(0);
        }
    }
    for(int i = 0; i < 26-1; i++){
        if(a[i] != -1){
            for(int j = i+1; j < 26; j++){
                if(a[i] == a[j]){
                    cout << "No" << endl;
                    exit(0);
                }
            }
        }
    }
    
    cout << "Yes" << endl;

}

Measured memory_bytes: 4164
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;




long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

bool c;
int N,C,H,R,G, M,K,W,a[10],ltl[26],g,k,X,ans,con,iti[100000];
string S,s,SB,SA,SS,b;

int main() {
	cin >> N;
	cin >> K;
	C = 1;
	for (int i = 0; i < N; i++) {
		if (C > K) {
			C += K;
		}
		else {
			C += C;
		}
	}


cout <<C<<endl;
	return 0;
}




Measured memory_bytes: 256
using System;

namespace AtCoderBeginnerContest142_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            if (N % 2 == 0)
            {
                Console.WriteLine(0.5);
            }
            else
            {
                Console.WriteLine(((N + 1) / 2.0)/(double)N);
            }
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(){
     int a,b;
     cin>>a>>b;
     if(a<b){
        cout<<"a < b"<<endl;
     }
     if(a==b){
         cout<<"a == b"<<endl; 
     }
     if(a>b){
       cout<<"a > b"<<endl;
     }
     return 0;
}


Measured memory_bytes: 3092
/**
 *    author:  FromDihPout
 *    created: 2020-05-26
**/

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    map<string, int> freq;
    int max_freq = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        freq[s]++;
        max_freq = max(max_freq, freq[s]);
    }
    
    vector<string> most_vote;
    for (auto i : freq) {
        if (i.second == max_freq) {
            most_vote.push_back(i.first);
        }
    }
    sort(most_vote.begin(), most_vote.end());
    
    for (string s : most_vote) {
        cout << s << '\n';
    }
    return 0;
}

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

int main(){
    int K,S;
    cin>>K>>S;
    int ans=0;
    for(int X=0;X<=K&&X<=S;X++){
        int L = S-X;
        if(L>2*K) continue;
        if(L<=K){
            ans+=L+1;
        }else{
            ans+=2*K-L+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
K = int(input())
A = list(map(int, input().split()))

if A[-1] > 2:
    print(-1)
    exit()



hi = 2
lo = 2

for i in reversed(range(K)):



    new_hi = hi // A[i] * A[i] + (A[i] - 1)

    if lo // A[i] > 0 and lo % A[i] > 0:
        new_lo = (lo // A[i] + 1) * A[i]
    elif lo // A[i] > 0 and lo % A[i] == 0:
        new_lo = lo
    elif lo // A[i] == 0:
        new_lo = A[i]

    if new_hi < hi or new_lo < lo or new_hi < new_lo:
        print(-1)
        exit()


    

    hi = new_hi
    lo = new_lo


print(lo, hi)

Measured memory_bytes: 14432
S=input()
key="keyence"

if S.find(key)!=-1:
    print("YES")
    exit()


count=0
for i in range(7):
    s=S[i]
    if s==key[count]:
        count+=1
    else:
        break

for i in range(-1,-8,-1):
    s=S[i]
    if s==key[i]:
        count+=1
    else:
        break
if count>=7:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61848
//C - Colorful Leaderboard: 
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, x, ans;
    vector<int> colors(9, 0);
    cin >> n;
    vector<int> ratings(n);
    loop(i, 0, n) {
        cin >> x;
        if(x < 400) colors[0]++;
        else if(x < 800) colors[1]++;
        else if(x < 1200) colors[2]++;
        else if(x < 1600) colors[3]++;
        else if(x < 2000) colors[4]++;
        else if(x < 2400) colors[5]++;
        else if(x < 2800) colors[6]++;
        else if(x < 3200) colors[7]++;
        else colors[8]++;
    }
    ans = 0;
    loop(i, 0, 8) if(colors[i] > 0) ans++;
    if(ans == 0) cout << 1 << " " << colors[8] << "\n";
    else cout << ans << " " << ans + colors[8] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3],sum=0;
	for(int i=0;i<3;i++){
		cin>>a[i];
	}
	sort(a,a+3);
	for(int i=0;i<2;i++){
		sum+=a[i+1]-a[i];
		//cout<<a[i]<<" "<<sum<<' ';
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
def lcs(s, t):
    '''s,tは文字列をリスト化したもの'''
    n = len(s)
    m = len(t)
    s.append('$')
    t.append('%')
    dp = [[0 for _j in range(m + 2)] for _i in range(n + 2)]
    dp[0][0] = 0
    for i in range(n+1):
        for j in range(m+1):
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]))
    # return dp[n][m]
    '''復元する'''
    length = dp[n][m]
    ans = ['']*(length+1)
    while(length > 0):
        if(s[n] == t[m]):
            ans[length] = s[n]
            n-=1
            m-=1
            length-=1
        elif(dp[n+1][m+1] == dp[n][m+1]):
            n-=1
        else:
            m-=1
    return ''.join(ans[1:])
# END CUT HERE

def ALDS1_10_C():
    q = ii()
    for _ in range(q):
        s = li()
        t = li()
        print(lcs(s, t))

def EDPC_F():
    s = li()
    t = li()
    print(lcs(s,t))


if __name__ == '__main__':
    # ALDS1_10_C()
    EDPC_F()

Measured memory_bytes: 122460
N, M = map(int, input().split())
A = sorted(map(int, input().split()))
BC = sorted([ list(map(int, input().split())) for _ in range(M)], key=lambda x:x[1], reverse=True)

s = 0
i = 0
B = 0
for a in A:
  if B == 0:
    if i < len(BC):
      B, C = BC[i]
      i += 1

  if B > 0 and C > a:
    s += C
    B -= 1
  else:
    s += a

print(s)


Measured memory_bytes: 34740
from collections import deque
s=deque(input());q=int(input());rev=0
for i in range(q):
    p=list(map(str,input().split()))
    if p[0]=="1":rev^=1
    else:
        z,f,c=p
        if f=="1":
            if rev:s.append(c)
            else:s.appendleft(c)
        else:
            if rev:s.appendleft(c)
            else:s.append(c)
s=list(s)[::1-2*rev]
print("".join(s))

Measured memory_bytes: 10740