akhauriyash/Code-Regression huggingface dataset:
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;

ll par[N];

ll find(ll x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

void unio(ll a,ll b){
  a=find(a),b=find(b);
  par[a]=b;
}


int main()
{ 

IOS;

ll cnt=0;

ll n;cin>>n;

for(int i=1;i<=n;i++){
  ll x;cin>>x;
  cnt+=(x!=i);
}

if(cnt==2||cnt==0)cout<<"YES";
else cout<<"NO";


return 0;
 
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (T value : vc)
  {
    os << value;
    if (value != vc.back())
      os << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  ui  N{}; std::cin >> N;
  ull K{}; std::cin >> K;

  typedef std::vector<ui> Vector;
  Vector A(N);
  std::map<ui, Vector> idx;
  rep(0, N)
  {
    std::cin >> A[i];
    idx[A[i]].push_back(i); // 出現位置
  }

  ui LOG_K = (ui)log2(K);
  ui LOG_N = (ui)log2(N);
  assert(LOG_K + LOG_N < 58); // 制約チェック

  typedef std::vector<ull> Vector_ull;
  std::vector<Vector_ull> dp(LOG_K + LOG_N + 1, Vector_ull(N));
  for (auto p : idx)
  {
    ui sz = p.second.size();
    p.second.push_back(p.second[0] + N);
    rep(0, sz)
    {
      dp[0][p.second[i]] = p.second[i + 1] - p.second[i] + 1; // 移動距離
    }
  }

  rep(1, dp.size())
  {
    rep_uj(0, N)
    {
      dp[i][j] = std::min(
        std::numeric_limits<ull>::max() / 3,
        dp[i - 1][j] + dp[i - 1][(dp[i - 1][j] + j) % N]);
    }
  }

  ull it{ 0 };
  ull it_max = K * N - 1;
  for(ui i = dp.size() - 1;;)
  {
    if (it + dp[i][it % N] <= it_max)
    {
      it += dp[i][it % N];
    }
    if(!i--)
      break;
  }
  assert(it <= it_max);

  Vector ans;
  ans.reserve(N);

  it %= N;
  std::set<ui> dic;
  while(it < N)
  {
    if (dic.count(A[it]))
    {
      while (true)
      {
        ui last = ans.back();
        ans.pop_back();
        dic.erase(last);
        if (last == A[it])
          break;
      }
    }
    else
    {
      ans.push_back(A[it]);
      dic.insert(A[it]);
    }
    ++it;
  }

  std::cout << ans << "\n";

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 120676
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
ll a[2][2001][2001];
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,num,ans=0;
    cin>>n>>k;
    ll x,y;
    char c;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++){
        cin>>x>>y>>c;
        num=x/k+y/k;
        if(c=='B')num++;
        x%=k;y%=k;
        x++;y++;
        a[num&1][x][y]++;
        a[(num+1)&1][x+k][y]++;
        a[(num+1)&1][x][y+k]++;
        a[num&1][x+k][y+k]++;
    }
    for(int i=1;i<=2*k;i++){
        for(int j=1;j<=2*k;j++){
            for(int m=0;m<2;m++){
                a[m][i][j]+=a[m][i-1][j];
            }
        }
    }
    for(int i=1;i<=2*k;i++){
        for(int j=1;j<=2*k;j++){
            for(int m=0;m<2;m++){
                a[m][i][j]+=a[m][i][j-1];
            }
        }
    }
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            for(int m=0;m<2;m++){
                num=a[m][i+k][j+k]-a[m][i][j+k]-a[m][i+k][j]+a[m][i][j];
                ans=max(num,ans);
            }
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 62848
def gcd(a, b):
    if a == 0: return b
    if b == 0: return a
    if a == b: return a
    if a > b: return gcd(b, a%b)
    return gcd(a, b%a)
def lcm(a, b):
    if a == b == 0:
        return 0
    return abs(a*b)/gcd(a, b)
a, b = map(int, input().split())
print(int(lcm(a, b)))


Measured memory_bytes: 9040
#include <stdio.h>
int main(void){
    int a, b, c, count = 0;
    scanf("%d%d%d", &a, &b, &c);
    while (a <= b)
    {
        if ((c%a) == 0) count++;
        a++;
    }
    
    printf("%d\n", count);
}



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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 2e5 + 100;

int L, N, X[Maxn];
LL Pre[Maxn], Suf[Maxn];
LL ans;

inline void work ()
{
//	for (int i = 1; i <= N; ++i) cout << X[i] << ' ' ; puts("");
	for (int i = 1; i <= N; ++i) Pre[i] = Pre[i - 1] + X[i];
	for (int i = N; i >= 1; --i) Suf[i] = Suf[i + 1] + L - X[i];

	for (int i = 1; i <= N; ++i)
	{
		int pos = (i + N) / 2;
//		cout << i << ' ' << pos << endl;
//		cout << X[i] << ' ' << Pre[pos] - Pre[i - 1] << " " << Suf[pos + 1] << ' ' << L - X[N] << endl;
		int tmp = ((N - i + 1) & 1) ? X[pos] : (L - X[pos + 1]);
		Chkmax (ans, 2ll * (Pre[pos] - Pre[i - 1]) + 2ll * Suf[pos + 1] - tmp);
//		DEBUG (ans);
	}
}

inline void Solve ()
{
	work ();
	for (int i = 1; i <= N; ++i) X[i] = L - X[i];
	reverse (X + 1, X + N + 1);
	work ();

	cout << ans << endl;
}

inline void Input ()
{
	L = read<int>();
	N = read<int>();
	for (int i = 1; i <= N; ++i) X[i] = read<int>();
}

int main()
{

#ifdef hk_cnyali
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}


Measured memory_bytes: 4096
N = int(input())
D = sorted([int(input()) for _ in range(N)])
if len(D) > 1:
    i,prev = 0,None
    while i < (len(D)-1):
        if D[i] == D[i+1]: 
            D.pop(i+1)
        else:
            prev = D[i]
            i +=1
print(len(D))

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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  
  int red=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='R')
      red++;
  }
    int ans=0;
    for(int i=0;i<red;i++){
      if(s.at(i)=='W')
        ans++;
    }
  cout<<ans<<endl;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int A[1010][1010];
int B[1010][1010];
int C[1010][1010];
bool used[1010][1010];

int dfs(int i, int j) {
    if (j < 0) return 0;
    if (C[i][j] >= 0) return C[i][j];
    if (used[i][j]) {
        cout << -1 << endl;
        exit(0);
    }
    used[i][j] = true;
    int p = A[i][j], q = B[A[i][j]][i];
    int tmp = max(dfs(i,j-1)+1,dfs(p,q-1)+1);
    return C[i][j] = C[p][q] = tmp;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N;
    cin >> N;
    REP(i,N) {
        REP(j,N-1) {
            cin >> A[i][j];
            A[i][j]--;
            B[i][A[i][j]] = j;
            C[i][j] = -1;
        }
        B[i][i] = -1;
    }
    int ans = 0;
    REP(i,N) REP(j,N-1) if (!used[i][j]) {
        CHMAX(ans,dfs(i,j));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25088
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

ll pow_ (ll x, ll n, ll M){
    ll u = 1;
    if(n > 0){
        u = pow_(x, n/2, M);
        if (n % 2 == 0) u = (u*u) % M;
        else u = (((u * u)% M) * x) % M;
    }
    return u;
};

int main() {
    int x;
    cin >> x;
    vector<int> v;
    for (int j = 1; j <= 31; ++j) {
        for (int i = 2; i <= 9; ++i) {
            ll k = pow_(j, i, (ll)INF*INF);
            if(k > 1000) break;
            v.emplace_back(k);
        }
    }
    sort(v.begin(), v.end(), greater<>());
    cout << *lower_bound(v.begin(), v.end(), x, greater<>()) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define FI first
#define SE second
#define PB(a) push_back(a)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
#define SZ(x) ((int)(x).size())
#define SO(x) sizeof((x)) / sizeof((x)[0])
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline int in() {int x; cin >> x; return x;}
inline lint IN() {lint x; cin >> x; return x;}
inline void co(int a[], int n) {REP(i, n) cout << a[i] << " "; cout << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	string s;	lint k;	cin >> s >> k;
	for (lint i = 0; i < k; i++){
		if (s[i] == '1'){
			if(i+1 == k){
				DEBUG(i);
				cout << 1 << "\n";
				return 0;
			}
		}else{
			//DEBUG(i);
			cout << s[i] << "\n";
			return 0;
		}
	}
	
	//cout << "Hello World" << "\n";
	return 0;
}


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


int main(){

  int n, ans;
  cin >> n;
  ans = n % 1000;
  if (ans == 0){
    cout << 0 << endl;
  }else{
    cout << 1000 - ans << endl;
  }
	return 0;
}


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

using namespace std;
using ll = long long;

void maxi(int &a, int b) {
	a = max(a,b);
}


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	ll X, Y;
	cin >> X >> Y;
	if (max(X-Y, Y-X) <= 1) {
		cout << "Brown" << "\n";	
	} else {
		cout << "Alice" << "\n";
	}
}



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

int main(void){
    
    int n;
    
    cin >> n;
    
    int i,ans=1;
    for(i=1;i<=n;++i){
        int a=i;
        a*=a;
        if(a>ans&&a<=n)ans=a;
        if(a>n)break;
    }
    
    cout << ans;
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buf = make([]byte, 1000)

func inputLine() string{
	sc.Scan()
	return sc.Text()
}

func scanInt() int {
	out, e := strconv.Atoi(inputLine())
	if e != nil {
        panic(e)
    }
	return out
}

func scanIntArray(n int) []int {
	out := make([]int, n)
	for i, v := range(strings.Split(inputLine(), " ")) {
		num, e := strconv.Atoi(v)
		if e != nil {
			panic(e)
		}
		out[i] = num
	}
	return out
}
//  template end

func main() {
	sc.Buffer(buf, 10000)
	xy := scanIntArray(2)
	fmt.Println(xy[0] + xy[1]/2)
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;

vector<ll> a, p;

ll f(ll n, ll x) {
  if (n == 0)
    return x <= 0 ? 0 : 1;
  else if (x <= 1 + a[n - 1])
    return f(n - 1, x - 1);
  else
    return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
}

int main(void) {
  ll N, X; cin >> N >> X;

  a.push_back(1);
  p.push_back(1);

  rep(i, N) {
    a.push_back(a[i] * 2 + 3);
    p.push_back(p[i] * 2 + 1);
  }

  cout << f(N, X) << endl;
  return 0;
}


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

const int64_t SIZE = 55556;

vector<int64_t> sieve() {
  vector<int64_t> prime;
  bool composite[SIZE];
  for (int64_t i = 2; i < SIZE; i++) {
    if (!composite[i]) {
      prime.emplace_back(i);
    }
    for (int64_t j = 0; j < prime.size() && i * prime[j] < SIZE; j++) {
      composite[i * prime[j]] = true;
      if (i % prime[j] == 0) {
        break;
      }
    }
  }
  return prime;
}

int main() {
  int n;
  cin >> n;
  auto primes = sieve();
  for (int i = 0, j = 0; j < n; ++i) {
    if (primes[i] % 5 == 1) {
      cout << primes[i] << ' ';
      ++j;
    }
  }
  return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
#define MOD 1000000007

typedef long long ll;

int col[200001], next[200001], lcol[200001];
ll memo[200001];
int n;

ll BHUVT(int i)
{
	if(i == n+1)
	return 1;
	if(memo[i] != -1)
	return memo[i];
	ll ans = BHUVT(i+1)%MOD;
	if(next[i] && next[i] != i+1)
	ans = ((ans%MOD) + (BHUVT(next[i])%MOD))%MOD;
	memo[i] = ans;
	return ans;	
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	std::cin>>n;
	for(int i=1;i<=n;i++)
	std::cin>>col[i];
	for(int i=1;i<=n;i++)
	{
		if(lcol[col[i]])
		{
			next[lcol[col[i]]] = i;
			lcol[col[i]] = i;
		}	
		else lcol[col[i]] = i;
	}	
	ll ans = BHUVT(1)%MOD;
	std::cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define llong long long
#define pii pair<int,int>
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 2e5;
int len[N+3];
set<pii> a;
int n;

bool check(int s)
{
//	printf("check %d\n",s);
	a.clear();
	for(int i=1; i<=n; i++)
	{
		if(len[i]<=len[i-1])
		{
			set<pii>::riterator iter=a.rbegin();
			while(iter!=a.rend() && (*iter).first>len[i]) {a.erase((++iter).base()); iter = a.rbegin();}
			int tmp = len[i];
			while(iter!=a.rend()&&(*iter).first==tmp&&(*iter).second==s-1)
			{
				a.erase((++iter).base()); tmp--; iter = a.rbegin();
			}
			if(tmp==0) {return false;}
			int x = 1;
			if(iter!=a.rend()&&(*iter).first==tmp) {x = (*iter).second+1; a.erase((++iter).base()); iter = a.rbegin();}
			a.insert(mkpr(tmp,x));
//			printf("i=%d ",i); for(set<pii>::iterator iter=a.begin(); iter!=a.end(); iter++) printf("(%d,%d) ",(*iter).first,(*iter).second); puts("");
		}
	}
	return true;
}

int main()
{
	scanf("%d",&n); bool f = true;
	for(int i=1; i<=n; i++) {scanf("%d",&len[i]); if(len[i]<=len[i-1]) {f = false;}}
	if(f) {puts("1"); return 0;}
	int left = 2,right = n;
	while(left<right)
	{
		int mid = left+(right-left>>1);
		bool ok = check(mid);
		if(ok) right = mid;
		else left = mid+1;
	}
	printf("%d\n",right);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
//using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
using pii=pair<ll,ll>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__);


int main(){
    dcl(n,p);
    int odd=0;
    rep(i,n){dcl(b);odd+=b%2;}
    if(odd) cout<<(1ll<<(n-1))<<endl;
    else cout<<(p?0ll:(1ll<<n))<<endl;
}


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

using namespace std;

int main() {
	int n, d; cin >> n >> d;
	int k = 0;
	while (n--) {
		int x, y; cin >> x >> y;
		if ((long long) x * x + (long long) y * y <= (long long) d * d)
			k++;
	}
	cout << k << '\n';
	return 0;
}


Measured memory_bytes: 3604
//cod2016_qualC_a.cpp
//Sat Oct 20 22:26:12 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;

	int cflag = 101;
	int fflag = 101;
	for (int i=0;i<s.size();i++){
		if (s[i] == 'C' && cflag > i){
			cflag = i;
		}else if (s[i] == 'F'){
			fflag = i;
		}
	}

	if (cflag != 101 && fflag != 101 && cflag < fflag){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

}

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

int n, k;
long long x[100005];

int main()
{
    while(cin >> n >> k)
    {
        for(int i = 0; i < n; i++)
        {
            cin >> x[i];
        }
        long long res = LONG_MAX, cur;
        for(int i = 0; i < n - k + 1;i++)
        {
            if(x[i] <= 0 && x[i + k - 1] >= 0)
            {
                cur = min(abs(x[i]), abs(x[i + k - 1])) + -x[i] + x[i + k - 1];
            }
            else if(x[i] >= 0 && x[i + k - 1] >= 0)
            {
                cur = min(x[i], x[i + k - 1]) + abs(x[i] - x[i + k - 1]);
            }
            else
            {
                long long xi, xik;
                xi = -x[i], xik = -x[i + k - 1];
                cur = min(xi, xik) + abs(xi - xik);
            }
            res = min(res, cur);
        }

        cout << res << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;
  map<string,int>mp;

  rep(i,0,n){
    int a;cin>>a;

    if(a<400)mp["g"]++;
    else if(a<800)mp["br"]++;
    else if(a<1200)mp["gre"]++;
    else if(a<1600)mp["wa"]++;
    else if(a<2000)mp["ble"]++;
    else if(a<2400)mp["yel"]++;
    else if(a<2800)mp["or"]++;
    else if(a<3200)mp["red"]++;
    else mp["kamisama"]++;
  }
  int mi,ma;
  int d=mp.size();
  if(mp["kamisama"]){
    if(d==1){
      mi=1;
      // ma=min(mp["kamisama"],8);
      ma=mp["kamisama"];
    }
    else {
      mi=d-1;
      ma=mi+mp["kamisama"];
    }

  }else {
    mi=d;
    ma=d;
  }

  // int ma=mi+min(mp["kamisama"],8-mi);
  cout<<mi<<" "<<ma<<endl;


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N;
		long K;
		cin >> N >> K;

		vector<int> A( N+1 );
		for( int i = 1; i <= N; ++i ) { cin >> A[i]; }

		vector<bool> vis( N+1 );
		vector<int> step( N+1 );
		int cnt = 0;
		int cur = 1;
		for( ; !vis[cur]; ++cnt ) {
			vis[cur] = true;
			step[cur] = cnt;
			cur = A[cur];
		}

		if( K >= step[cur] ) {
			int loop_n = cnt - step[cur];
			K = step[cur] + (K-step[cur]) % loop_n;
		}

		cur = 1;
		while( K-- ) { cur = A[cur]; }
		cout << cur << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();

		if(a <= b) {
			System.out.println(a);
		}else {
			System.out.println(a - 1);
		}

	}
}

Measured memory_bytes: 21972
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
int INPUT_INT() { int d; cin >> d; return d; } // 入力をpush_back(d)やarray[d]に使う時に無駄な変数を使わない

// ------------------- include, typedef, define END. -------------------

int main(){
	int tickets[5] = { 0, 6000, 4000, 3000, 2000 };
	int t = 0, n = 0;
	FOR(i, 0, 4){
		cin >> t >> n;
		cout << (tickets[t] * n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
  char line[100];
  int h, w;
  int i, j;
  char op;
  while(1){
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d %d", &h, &w);
	if((h==0)&&(w==0))
	  break;
	op='#';
	for(i=0; i<h; ++i){
	  for(j=0; j<w; ++j){
		printf("%c",op);
		if(op=='#')
		  op='.';
		else
		  op='#';
	  }
	  if((i%2)==0){
		op='.';
}else
		op='#';
	  printf("\n");
	}
	printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

int main()
{
    ll A, B, C;
    ll X;
    cin >> A >> B >> C;
    cin >> X;
    int sum = 0;
    for (int i = 0; i <= A; i++) {
        for (int k = 0; k <= B; k++) {
            for (int j = 0; j <= C; j++) {
                if (500 * i + 100 * k + 50 * j == X) {
                    sum++;
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		if(a>b) {
			System.out.println(0);
			return;
		}
		if(n==1) {
			System.out.println(a==b?1:0);
			return;
		}else {
//			int l = a*(n-1)+b;
//			int r = a+b*(n-1);
//			System.out.println(r-l+1);
			System.out.println((long)((b-a)*(n-2)+1));
		}
	}
}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
namespace imzzy{
	#define endl '\n'
	#define ccf std::cout<<"phi**k"<<endl
	#define rgi register int
	#define ll long long
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL);
	#endif
}}using namespace imzzy;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004,maxm=2004;
const int mod=1000000007,inf=1201201201;

signed main()
{P_INIT();
	// freopen("yy.in","r",stdin);
	// freopen("yy.out","w",stdout);
	int a,b; fin>>a>>b;
	if(a<=0&&b>=0) return puts("Zero"),0;
	if(a>0) return puts("Positive"),0;
	puts(((b-a)&1)?"Positive":"Negative");
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
public static void main(String[] args) throws IOException {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(bf.readLine());
	StringBuilder sb = new StringBuilder();
	Deque<Integer> d = new ArrayDeque<Integer>();

	for(int i = 0;i < n;i++) {
		String str = bf.readLine();

		if(str.charAt(0) == 'i') {
			d.push(Integer.parseInt(str.substring(7)));
		}else if(str.charAt(6) == 'L') {
			d.removeLast();
		}else if(str.charAt(6) == 'F') {
			d.removeFirst();
		}else {
			d.remove(Integer.parseInt(str.substring(7)));
		}
	}
    sb.append(d.poll());
    for (Integer num : d) {
        sb.append(" ").append(num);
    }
    System.out.println(sb.toString());
}
}



Measured memory_bytes: 125220
#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;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  string s, t;
  cin >> s >> t;
  REP(i, s.size()) {
    if (s[i] != t[i]) {
      print("No");
      return 0;
    }
  }
  print(t.size() == s.size() + 1 ? "Yes" : "No");
  return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int mod = 1000000000 + 7;
int N, K;
int A[110];
ll dp[110][100010]; 
ll sums[100010];

int main(){

    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = N; i >= 0; i--){
        for(int k = 0; k <= K; k++){
            ll res = 0;
            if(i == N){
                res = (k == 0);
            }
            else{
                // for(int l = 0; l <= min(A[i], k); l++){
                //     res += dp[i + 1][k - l];
                // }
                // [k-0, k-min(A[i],k)]の範囲の値を予め計算しておく
                res = (sums[k+1] - sums[k - min(A[i],k)] + mod) % mod;
            }
            dp[i][k] = res;
        }
        sums[0] = 0;
        sums[1] = dp[i][0];
        for(int j = 1; j <= K; j++){
            sums[j+1] = (sums[j] + dp[i][j]) % mod;
        }
    }
    
    cout << dp[0][K] << endl;

    return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
	cin.tie(0); ios::sync_with_stdio(0);
	
	int a, b;
	cin >> a >> b;
	int ans = 0;
	int falta = 0;
	if(b != 1)
		ans++;
	falta += a;
	while(falta < b){
		ans += 1;
		falta += (a - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
int main(){	
	string s; cin>>s;
	ll n=s.length(),f=0,ff=0,fff=0;
	for(ll i=0;i<n;i++){
		if(s[i]==s[n-i-1]) continue;
		else {
		//cout<<i;
		f=1;
		break;
		}
		}
	if(f==1) cout<<"No\n";
	else{
		ll p=(n-1)/2;
		for(ll j=0;j<p;j++){
			if(s[j]==s[p-j-1]) continue;
			else {
				ff=1;
				//cout<<"st";
				break;
				}
				}
		ll m=(n+3)/2,k=0;
		for(ll j=m;j<n;j++){
		k++;
			if(s[j-1]==s[n-k]) continue;
			else{
				fff=1;
				//cout<<j;
				break;
				}
				}
			//cout<<ff<<" "<<fff;
		if(ff==1 || fff==1) cout<<"No\n";
		else cout<<"Yes\n";
		}
		}
			
	
			
	

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,cnt=0;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  rep(i,n){
    cnt=v[cnt]-1;
    if(cnt==1){
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}
///////////////////////////

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
#define NIL -1
using namespace std;
 
typedef struct{
    int key;
    int right;
    int left;
    int parent;
}node;
 
void insert(vector<node> &T, int i, int *root) {
    int x=*root, y = NIL;
    while(x != NIL){
        y = x;
        T[i].key<T[x].key?x=T[x].left:x=T[x].right;
    }
    T[i].parent = y;
    if(y == NIL) *root = i;
    else if(T[i].key < T[y].key) T[y].left = i;
    else T[y].right = i;
}

void inorder(vector<node> &T, int i){
    if(T[i].left != NIL) 
        inorder(T,T[i].left);
    cout << " " << T[i].key;
    if(T[i].right != NIL)
        inorder(T,T[i].right);
}
 
void preorder(vector<node> &T, int i){
    cout << " " << T[i].key;
    if(T[i].left != NIL)
        preorder(T,T[i].left);
    if(T[i].right != NIL)
        preorder(T,T[i].right);
}
 
int find(vector<node> &T, int i, int k) {
    int result = NIL;
    if(T[i].key == k) return i;
    else if(T[i].key > k) {
        if(T[i].left != NIL)
            result = find(T,T[i].left,k);
    } else if(T[i].key < k) {
        if(T[i].right != NIL)
            result = find(T,T[i].right,k);
    }
    return result;
}

int minimum(vector<node> &T,int a){
    while(T[a].left != NIL) a = T[a].left;
    return a;
}

int successor(vector<node> &T, int z){
    int x = T[z].parent,y;
    if(T[z].right != NIL) return minimum(T,T[z].right);
    while(1) {
        if(x != NIL && T[x].right == z) break;
        y = x;
        x = T[x].parent;
    }
    return x;
}

void erase(vector<node> &T, int *root, int z){
    int x,y;
    T[z].left==NIL||T[z].right==NIL?y = z:y = successor(T,z);
    T[y].left!=NIL?x=T[y].left:x=T[y].right;

    if(x != NIL) T[x].parent = T[y].parent;
    if(T[y].parent == NIL) *root=x;
    else if(y == T[T[y].parent].left) T[T[y].parent].left = x;
    else T[T[y].parent].right = x;

    if(y!=z) T[z].key = T[y].key;
    T[y].parent = NIL;
    T[y].left = NIL;
    T[y].right = NIL;
    T[y].key = 0;
}

int main(void) {
    int judge,n,i,x,root=NIL;
    string od;
    vector<node> T;
    cin >> n;
    T.resize(n);
    rep(i,n) {
        T[i].key = 0;
        T[i].right = NIL;
        T[i].left = NIL;
        T[i].parent = NIL;
    }
    rep(i,n){
        cin >> od;
        if(od == "insert"){
            cin >> T[i].key;
            insert(T,i,&root);
        } else if(od == "print") {
            inorder(T,root);
            cout << endl;
            preorder(T,root);
            cout << endl;
        } else if(od == "find") {
            cin >> x;
            judge = find(T,root,x);
            if(judge != NIL) cout << "yes";
            else cout << "no";
            cout << endl;
        } else if(od == "delete"){
            cin >> x;
            judge = find(T,root,x);
            if(judge != NIL) erase(T,&root,judge);
        }
    }
    return 0;
}

Measured memory_bytes: 8984
# include <iostream>
# include <cstdio>
# include <algorithm>
using namespace std;
const int N = 3e5 + 12;
const int inf = 0x7fffffff;
int a[N],b[N],id[N],n,m,head[N],dt,fa[N];bool vis[N];
long long f[N],s[N];
int find(int x){return fa[x] == x ? x : fa[x] = find(fa[x]);}
struct Edge{int to,nex;}edge[N << 2];
void AddEdge(int u,int v){edge[++dt] = (Edge){v,head[u]};head[u] = dt;}
bool cmp(int x,int y){return a[x] < a[y];}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i = 1;i <= n;i++)scanf("%d %d",&a[i],&b[i]),a[i] = max(a[i] - b[i],0),id[i] = fa[i] = i;
	sort(id + 1,id + n + 1,cmp);int u,v;
	for(int i = 1;i <= m;i++)scanf("%d %d",&u,&v),AddEdge(u,v),AddEdge(v,u);
	for(int t = 1;t <= n;t++)
	{
		u = id[t];vis[u] = true;f[u] = a[u];s[u] = b[u];
		for(int i = head[u];i;i = edge[i].nex)if(vis[edge[i].to])
		{
			v = find(edge[i].to);
			if(u == v)continue;
			fa[v] = u;s[u] += s[v];
			f[u] = min(f[u],max(f[v],a[u] - s[v])); 
		}
	}
	printf("%lld\n",f[id[n]] + s[id[n]]);
}

Measured memory_bytes: 12416
#include<iostream>
#include<cstring>
using namespace std;
char a[10];
bool ff=false;
int main(){
	cin>>a;
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='7'){
			ff=true;
		}
	}
	if(ff){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N%10 == 2 || N%10 == 4 || N%10 == 5 || N%10 == 7 || N%10 == 9)
			System.out.println("hon");
		else if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 7 || N%10 == 8)
			System.out.println("pon");
		else
			System.out.println("bon");
		sc.close();
	}
}


Measured memory_bytes: 35696
import java.util.Scanner;

class Main{
    private static int nS;
    private static int nT;
    private static int[] S;
    private static int[] T;

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	nS = sc.nextInt();	
	S = new int[nS];
	for(int i=0;i<nS;i++){
	    S[i] = sc.nextInt();
	}
       
	nT = sc.nextInt();
	T = new int[nT];
	for(int i=0;i<nT;i++){
	    T[i] = sc.nextInt();
	}
	/*
	for(int i=0;i<nS;i++){
	    if(binary(0,nS,T[i])){
		cnt++;
	    }
	}
	*/
	
	int cnt = 0;
	for(int i=0;i<nT;i++){
	    int right=S.length-1;
	    int left = 0;
	    int center = (right+left)/2;
	    while(left<=right){
		if(S[center]==T[i]){
		    cnt++;
		    break;
		}
		if(S[center]>T[i]){
		    right=center-1;
		}else{
		    left=center+1;
		}
		center = (right+left)/2;
	    }
	}
	System.out.println(cnt);
  
    }

    public static boolean binary(int s,int t, int x){
	if(s==t){
	    if(x==S[s]){
		return true;
	    }else{
		return false;
	    }
	}else{
	    if(x>=S[(s+t)/2]){
		return binary((s+t)/2,t,x);
	    }else{
		return binary(s,(s+t)/2,x);
	    }
	}
    }
}



Measured memory_bytes: 81512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    for(int i = 0; i < n; i++){
        if (i + k == n) break;
        if (a[i] < a[i+k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4840
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin >> n >> k;
  vector<int> a(n) , c(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(a.begin() , a.end());
  sort(c.rbegin() , c.rend());
  auto check = [&](int T) {
    // dg1(T);
    int cnt = k;
    for(int i = 0; i < n; i++) {
      int x = T / c[i];
      // dg1(x);
      if(a[i] > x) {
        cnt -= (a[i] - x);
      }
    }
    // dg1(cnt);
    return cnt >= 0ll;
  };
  int l = 0 , h = 1e13;
  int ans = inf;
  while(l <= h) {
    int mid = (l + h) / 2;
    if(check(mid)) {
      ans = min(ans , mid);
      h = mid - 1;
    }
    else l = mid + 1;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 6336
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    s = SI()
    t = SI()

    from collections import defaultdict
    s_dict = defaultdict(list)
    for i, char in enumerate(s):
        s_dict[char].append(i)

    # s_dict[char] には、 char が s の何番目に入っているかが記載されている。

    from bisect import bisect, bisect_left

    current_position = 0
    s_loops = 0
    first = True
    for char in t:
        li = s_dict[char]
        if not li:
            print(-1)
            return
        # current_position より大きい最小の要素を二分探索で得る。
        if first:
            first=False
            current_position = li[0]
        else:
            pos = bisect_left(li, current_position)
            try:
                if li[pos] == current_position:
                    current_position = li[pos+1]
                else:
                    current_position = li[pos]
            except IndexError:
                # s は次のループに入った。
                s_loops += 1
                current_position = li[0]
        # print(current_position)
    # if len(set(t)) == 1:
    #     add = 1
    # else:
    add = 1
    print(len(s)*s_loops + current_position+add)


main()

Measured memory_bytes: 46320
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
	vl A(100001, 0);
	rep(i, 100001) {
		if (i == 0) {
			A[i] = 1;
		}
		for(ll j = 100; j < 106; j++) {
			if (i >= j && A[i - j])A[i] = 1;
		}
	}

	cin >> n;
	cout << A[n] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
struct edge{
  int p,l,r,f;
  edge(int p,int l,int r,int f):p(p),l(l),r(r),f(f){}
  bool operator<(const edge e)const{
    return p<e.p;
  }
};
vector<P> v;
vector<edge> e;
int n,m,k;
static const int MAX_SIZE = 1 << 17; 
int segMin[2][2 * MAX_SIZE - 1], segAdd[2][2 * MAX_SIZE - 1];
void add(int a, int b, int x, int w, int k = 0, int l = 0, int r = MAX_SIZE){
  if(a<0) a=0;
  if(b>MAX_SIZE) b=MAX_SIZE;
  if (r <= a || b <= l) return; 
  if (a <= l && r <= b){
    segAdd[w][k] += x;
    return;
  }
  add(a, b, x, w, k * 2 + 1, l, (l + r) / 2);
  add(a, b, x, w, k * 2 + 2, (l + r) / 2, r);
  segMin[w][k] = min(segMin[w][k * 2 + 1] + segAdd[w][k * 2 + 1],
		     segMin[w][k * 2 + 2] + segAdd[w][k * 2 + 2]);
}

int getMin(int a, int b, int w, int k = 0, int l = 0, int r = MAX_SIZE){
  if(a<0) a=0;
  if(b>MAX_SIZE) b=MAX_SIZE;
  if (r <= a || b <= l) return (MAX_SIZE);
  if (a <= l && r <= b) return (segMin[w][k] + segAdd[w][k]); 
  int left = getMin(a, b, w, k * 2 + 1, l, (l + r) / 2);
  int right = getMin(a, b, w, k * 2 + 2, (l + r) / 2, r);
  return (min(left, right) + segAdd[w][k]); 
}

bool check(int d){
  memset(segAdd,0,sizeof(segAdd));
  memset(segMin,0,sizeof(segMin));
  int i,j,a,b=0,g=d-1,p,q;
  e.clear();
  for(i=0;i<v.size();i++){
    int x=v[i].first,y=v[i].second;
    e.push_back(edge(x+y-d,n+y-x-d,n+y-x+d,1));
    e.push_back(edge(x+y+d+2,n+y-x-d,n+y-x+d,-1));
    e.push_back(edge(x+y-g,n+y-x-g,n+y-x+g,1));
    e.push_back(edge(x+y+g+2,n+y-x-g,n+y-x+g,-1));
  }
  //for(i=0;i<e.size();i++) cout << i << ":" << e[i].p <<":"<< e[i].l <<":"<< e[i].r <<":"<< e[i].f << endl;
  if(n%2){
    for(i=0;i<n+m;i++) add(i,i+1,MAX_SIZE,i%2);
  }else{
    for(i=0;i<n+m;i++) add(i,i+1,MAX_SIZE,(i+1)%2);
  }
  
  sort(e.begin(),e.end());
  for(i=0;i<e.size();i++){
    j=e[i].p;
    for(a=b;a<min(j,n+m-1);a++){
      if(a<n) p=a;
      else p=2*(n-1)-a;
      if(a<m) q=a;
      else q=2*(m-1)-a;
      int l=max(0,n-p),r=min(n+m-1,n+q);
      //cout << a << ":" << l << ":" << r << ":" << getMin(l,r+1,a%2) << endl;
      if(getMin(l,r+1,a%2)==0) return true;
    }
    while(1){
      if(i==e.size()||j!=e[i].p) break;
      add(e[i].l,e[i].r+1,e[i].f,(j+MAX_SIZE)%2);
      i++;
    }
    b=max(0,j);
    i--;
  }
  for(a=b;a<=n+m-2;a++){
      if(a<n) p=a;
      else p=2*(n-1)-a;
      if(a<m) q=a;
      else q=2*(m-1)-a;
      int l=max(0,n-p),r=min(n+m-1,n+q);
      //cout << a << ":" << l << ":" << r << ":" << getMin(l,r+1,a%2) << endl;
      if(getMin(l,r+1,a%2)==0) return true;
    }
  return false;
}
int main(){
  int i,j,x,y;
  cin>>n>>m>>k;
  for(i=0;i<k;i++){
    cin >> x >> y;
    v.push_back(P(x,y));
  }
  
  int l=0,r=n+m-2,mid;
  while(l+1<r){
    mid=(l+r)/2;
    //ccout << endl << l << ":" << r << ":" << mid << endl;
    if(check(mid)) l=mid;
    else r=mid;
  }
  if(k%n==0&&k/n==m) cout << 0 << endl;
  else cout << l+1 << endl;
  return 0;
}



Measured memory_bytes: 16096