akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;
#define EPS 1e-4
typedef long long ll;

struct Point{
    double x,y;
	int f,a,t;
    Point(){}
	Point(double _x,double _y){
		x=_x; y=_y;
	}
    Point(double _x,double _y,int _f,int _a,int _t){
        x=_x; y=_y; f=_f; a=_a; t=_t;
    }
    Point operator +(const Point p)const{
        return Point(x+p.x,y+p.y);
    }
    Point operator -(const Point p)const{
        return Point(x-p.x,y-p.y);
    }
    Point operator *(const double d)const{
        return Point(x*d,y*d);
    }
    bool operator <(const Point &p)const{
        if(x==p.x) return y<p.y;
        return x<p.x;
    }
	bool operator ==(const Point &p)const{
		return abs(x-p.x)<EPS && abs(y-p.y)<EPS;
	}
    double norm(){
        return x*x+y*y;
    }
	bool input(){
		if(cin>>x>>y) return true;
		return false;
	}
};

int main(){
	int N;
	cin>>N;
	Point last(-1,-1,32500,-1,-1);
	double ansd[2] = {-1,-1};
	int ansf[2] = {-1,-1};
	for(int i=0;i<N;i++){
		Point p;
		cin>>p.f>>p.a>>p.t>>p.x>>p.y;
		if(last.t==p.t && last.a!=p.a){
			if(sqrt((last-p).norm())>ansd[p.t] ||
			   (abs(sqrt((last-p).norm())-ansd[p.t])<EPS && p.f-last.f<ansf[p.t])){
				ansd[p.t] = sqrt((last-p).norm()); ansf[p.t] = p.f-last.f;
			}
		}
		last = p;
	}
	for(int i=0;i<2;i++){
		if(ansd[i]<0) puts("-1 -1");
		else printf("%lf %lf\n",ansd[i],((double)ansf[i])/60.0);
	}
	return 0;
}

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

int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	cout << min(max(x,y)*2*c,min(a*x+b*y,x>y?y*2*c+(x-y)*a:x*2*c+(y-x)*b))<<endl;
}

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

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    
    if(n - 1){
        int a, b;
        cin >> a >> b;
        cout << (a + b) << "\n";

    }else{
        cout << "Hello World\n";
    }

    return 0;
}

Measured memory_bytes: 256
using System;
namespace B
{
    public class EmptyClass
    {
        static void Main(string[] args)
        {

            int[] nk = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int[] h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            long[] dp = new long[nk[0]];
            dp[0] = 0;
            for (int i = 1; i < nk[0]; i++)
            {
                dp[i] = long.MaxValue;
                for (int j = 1; j <= Math.Min(nk[0],nk[1]); j++)
                {
                    if (i - j < 0) break;
                    ChangeMin(ref dp[i], dp[i - j] + Math.Abs(h[i] - h[i - j]));
                }
            }

            Console.WriteLine(dp[nk[0] - 1]);
        }

        static bool ChangeMin(ref long a, long b)
        {
            if (a > b)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


Measured memory_bytes: 17632
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    S = input()
    n = len(S) + 1

    s = 0
    x = 0
    while x != n-1:
        if S[x] == ">":
            x+= 1
        else:
            break
    s += x*(x+1)//2

    if x == n-1:
        print(s)
        exit()


    a = 0
    b = 0
    f = 0
    for i in range(x, n-1):
        if S[i] == ">":
            f = 1
            b += 1
        elif f == 0:
            a += 1
        else:
            if a == b:
                s += a*a
            elif a > b:
                s += a*(a+1)//2 + b*(b-1)//2
            else:
                s += a*(a-1)//2 + b*(b+1)//2
            f = 0
            a = 1
            b = 0



    if S[n-2] == ">":
        if a == b:
            s += a*a
        elif a > b:
            s += a*(a+1)//2 + b*(b-1)//2
        else:
            s += a*(a-1)//2 + b*(b+1)//2
    else:
        s += a*(a+1)//2




    print(s)





if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

using V = vector<int>;
using Q = queue<int>;
using Graph = vector<vector<int>>;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define YesNo(x) cout<<(x?"Yes":"No")<<endl
#define YESNO(x) cout<<(x?"YES":"NO")<<endl
#define yesno(x) cout<<(x?"yes":"no")<<endl
#define yay(x) cout<<(x?"yay":":(")<<endl

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
	in(x);
	out(x == 1 ? 0 :  1);
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    string ans;
    for (int i = 0;i < s.size();i++){
        if (i % 2 == 0){
            ans += s[i];
        }
    }
    cout << ans << endl;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int ans = 2020;
  if(m - n >= 2018) {
    ans = 0;
  }
  else{
    rep(i, m - n){
      for(int j = i + 1; j < m - n + 1; j++){
        ans = min(ans, (((n + i) % 2019) * ((n + j) % 2019) % 2019));
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    vl a(3);
    rep(i,3)cin>>a[i];

    if(a[0]%2||a[1]%2||a[2]%2){
        cout<<0<<endl;
        return;
    }

    if(a[0]==a[1]&&a[1]==a[2]){
        cout<<-1<<endl;
        return;
    }

    ll ans=0;
    while(a[0]%2==0&&a[1]%2==0&&a[2]%2==0){
        ++ans;
        vl na(3);
        rep(i,3)na[i]=a[i]/2+a[(i+1)%3]/2;
        a=na;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
i,m;main(h,s,S){for(S=60;++i%2?scanf("%d%d%d",&h,&m,&s),h=(120-h*S-m)*S-s,m=~m:1;h*=3)printf("%02d:%02d:%02d\n",h/S/S,h/S%S,h%S);}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;


signed main() {
  i64 n;
  cin >> n;
  vector<i64> A(n);
  cin >> A;
  vector<i64> S;
  for (i64 a: A) {
    auto i = upper_bound(S.begin(), S.end(), -a);
    if (i == S.end()) {
      S.push_back(-a);
    } else {
      *i = -a;
    }
  }
  cout << S.size() << endl;
}


Measured memory_bytes: 2168
#include<stdio.h>
int main(void){
    int n,i,j,count=1,total=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        j=i;
        while(j/10!=0){
            count++;
            j=j/10;
        }
        if(count%2==1){
            total++;
        }
        count=1;
    }
    printf("%d",total);
}

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

using namespace std;

int main()
{
    int a,b,c,d,i,cnd;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1){
        c=c-b;
        if(c<=0){
            cnd=1;break;
        }
        a=a-d;
        if(a<=0){
            cnd=2;break;
        }
    }
    if(cnd==1) printf("Yes\n");
    else printf("No\n");
}


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

int main(){
int n;
  cin>>n;
  vector<long long> L(n+1);
  L[0]=2;
  L[1]=1;
  for(int i=2;i<=n;i++){
    L[i]=L[i-2]+L[i-1];
  }
  cout<<L[n]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int N, R;
  cin >> N >> R;
  
  if(N < 10){
    cout << R + 100*(10-N);
  }else{
    cout << R;
  }
}

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

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

    int minimum = 0;
    int minimum_idx = 1;

    int maximum = 0;
    int maximum_idx = 1;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        if (minimum > a[i])
        {
            minimum = a[i];
            minimum_idx = i + 1;
        }
        if (maximum < a[i])
        {
            maximum = a[i];
            maximum_idx = i + 1;
        }
    }

    cout << 2 * N - 1 << endl;
    if (maximum + minimum > 0)
    {
        for (int i = 1; i <= N; i++)
        {
            cout << maximum_idx << " " << i << endl;
        }
        for (int i = 1; i + 1 <= N; i++)
        {
            cout << i << " " << i + 1 << endl;
        }
    }
    else
    {
        for (int i = 1; i <= N; i++)
        {
            cout << minimum_idx << " " << i << endl;
        }
        for (int i = N; i - 1 >= 1; i--)
        {
            cout << i << " " << i - 1 << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
 
struct UnionFind{
  vector< int > data;
  UnionFind(int sz){
    data.resize(sz, -1);
  }
  int Find(int a){
    return(data[a] < 0 ? a : data[a] = Find(data[a]));
  }
  void Union(int a, int b){
    a = Find(a), b = Find(b);
    if(a == b) return;
    if(data[a] < data[b]) swap( a, b);
    data[b] += data[a];
    data[a] = b;
  }
};
 
struct edge {
  int to, cost;
};
struct edge2 {
  int u, v, cost;
  bool operator<(const edge2& e) const {
    return cost < e.cost;
  }
};
typedef vector< vector< edge > > Graph;
typedef pair< int, int > Pi;
const int INF = 1 << 30;
int N, M, K, Q, F[100000];
Graph graph;
vector< edge2 > weighted;
set< int > buffer[100000];
stack< int > st;
int ret[100000];
 
void Dijkstra(Graph& g, vector< int >& min_cost){
  min_cost.assign( g.size(), INF);
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  for(int i = 0; i < K; i++){
    que.push( make_pair( 0, F[i]));
    min_cost[F[i]] = 0;
  }
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.first > min_cost[p.second]) continue;
    for(int i = 0; i < g[p.second].size(); i++){
      edge& e = g[p.second][i];
      if(p.first + e.cost >= min_cost[e.to]) continue;
      que.push( make_pair( p.first + e.cost, e.to));
      min_cost[e.to] = p.first + e.cost;
    }
  }
}
 
 
int main(){
  scanf("%d %d %d %d", &N, &M, &K, &Q);
  graph.resize(N);
  UnionFind uftree(N);
 
  for(int i = 0; i < M; i++){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    --a, --b;
    graph[a].push_back((edge){b, c});
    graph[b].push_back((edge){a, c});
    weighted.push_back((edge2){a, b});
  }
 
  for(int i = 0; i < K; i++){
    scanf("%d", &F[i]);
    --F[i];
  }
  for(int i = 0; i < Q; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    buffer[a].insert(i);
    buffer[b].insert(i);
  }
 
  vector< int > min_cost;
  Dijkstra( graph, min_cost);
   
  for(int i = 0; i < M; i++){
    weighted[i].cost = min( min_cost[weighted[i].u], min_cost[weighted[i].v]);
  }
  sort( weighted.rbegin(), weighted.rend());
 
  for(int i = 0; i < M; i++){
    int u = uftree.Find(weighted[i].u), v = uftree.Find(weighted[i].v);
    if(u == v) continue;
    uftree.Union( u, v);
    int unioned = uftree.Find(weighted[i].u);
    set< int > *oo = &buffer[u], *pp = &buffer[v];
    if(u != unioned) swap( oo, pp);
    for(set< int >::iterator it = pp -> begin(); it != pp -> end(); it++){
      if(oo -> find(*it) != oo -> end()) ret[*it] = weighted[i].cost;
      else st.push(*it);
    }
    for( ;!st.empty(); oo -> insert(st.top()), st.pop());
  }
   
  for(int i = 0; i < Q; i++){
    printf("%d\n", ret[i]);
  }
}

Measured memory_bytes: 59080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=1e5+7;
const ll modn=1000000007;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
int a[3];
int main()
{
    while(scanf("%d%d%d",&a[0],&a[1],&a[2])==3)
    {
        sort(a,a+3);
        if(a[0]==5&&a[1]==5&&a[2]==7) puts("YES");
        else puts("NO");
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    string s = Console.ReadLine();
    int l = s.Length;
    int ans = l;
    for(int i=l-2; i>0; i-=2){
      if(s.Substring(0,i/2-1) == s.Substring(i/2,i/2-1)){
        ans = i;
        break;
      }
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


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

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;

#define fi first
#define se second

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ll inf = ll(1e18);
const int MOD = (1e9 + 7);

int dp[3001][3001],sum1[3001][3001];

void add(int & a,int b){
	a+=b;
	while(a>=MOD) a-=MOD;
}

int mul(int a, int b){
	return (1LL*a*b)%MOD;
}

int su(int i,int l,int r){
	l=max(l,0);
	if(l>r) return 0;
	if(l==0)
		return sum1[i][r]%MOD;
	else{
		return (sum1[i][r]+MOD-sum1[i][l-1])%MOD;
	}
}

int main() {

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	#ifdef DEBUG_
		freopen("input.txt","r",stdin);
	#endif
	cout.setf(ios::fixed), cout.precision(20);
	ll n;
	cin >> n;
	string st;
	cin >> st;
	for(int i=0;i<3001;i++){
		for(int j=0;j<3001;j++){
			dp[i][j]=0;
			sum1[i][j]=0;
		}
	}
	dp[0][0]=1;
	sum1[0][0]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=i;j++){
			if(st[i-1]=='<'){
				dp[i][j]=su(i-1,0,j-1);
			}
			else{
				dp[i][j]=su(i-1,j,i-1);
			}
		}
		sum1[i][0]=dp[i][0];
		for(int j=1;j<=i;j++){
			sum1[i][j]=dp[i][j];
			add(sum1[i][j],sum1[i][j-1]);
		}
	}

	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<n;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	int ans=0;
	for(int i=0;i<n;i++){
		add(ans,dp[n-1][i]);
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin >>N>>K;
  string S;cin>>S;
  int ans=0;
  for(int i=1;i<S.size();++i){
    if(S[i]==S[i-1]) ans+=1;
  }
  for(int i=0;i<K;++i) {
    if(ans==S.size()-1) {
      cout << ans;
      return 0;
    }
    if(ans<=S.size()-3) {ans+=2;continue;}
    if(ans==S.size()-2) ans+=1;
  }
  cout <<ans;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <assert.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

ll mod;
const int N = 4000;
ll fact[N], invf[N], two[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

ll dp[N][N];

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

    fact[0] = invf[0] = two[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
        invf[i] = divll(invf[i-1], i);
        two[i] = (two[i-1] * 2) % (mod - 1);
    }

    dp[0][0] = 1;
    FOR(i,1,n){
        dp[i][0] = 1;
        FOR(j,1,i){
            dp[i][j] = (dp[i-1][j] + dp[i-1][j-1] + j * dp[i-1][j]) % mod;
        }
    }

    // FOR(i,0,10){
    //     REP(j,i+1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    ll ans = 0;
    REP(k,n+1){
        ll tmp = 0;
        REP(i,k+1){
            tmp = (tmp + dp[k][i] * powll(2, (ll)(n - k) * i)) % mod;
        }
        tmp = (tmp * powll(2, two[n - k])) % mod;
        tmp = (tmp * nCr(n, k)) % mod;
        if (k % 2 == 0) ans = (ans + tmp) % mod;
        else ans = (ans - tmp + mod) % mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 92928
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}
typedef double Real;
const Real PI=acos(-1);
struct Complex {
	Real re, im;
	Complex &operator+=(const Complex &o) {re+=o.re; im+=o.im; return *this;}
	Complex &operator/=(Real k) {re/=k; im/=k; return *this;}
};
Complex operator~(const Complex &a) {return {a.re, -a.im};}
Complex operator-(const Complex &a) {return {-a.re, -a.im};}
Complex operator+(const Complex &a, const Complex &b) {return {a.re+b.re, a.im+b.im};}
Complex operator-(const Complex &a, const Complex &b) {return {a.re-b.re, a.im-b.im};}
Complex operator*(const Complex &a, const Complex &b) {return {a.re*b.re-a.im*b.im, a.im*b.re+b.im*a.re};}
Complex operator/(const Complex &a, Real k) {return {a.re/k, a.im/k};}
int len;
Complex w[1<<19];
void init(int len) {
	for(int i=0; i<len/2; ++i) w[len/2+i]={cos(2*PI/len*i), sin(2*PI/len*i)};
	for(int i=len/2; --i; w[i]=w[i*2]);
}
void dft(Complex *x) {
	for(int i=1, j=0, k; i<len; ++i) {
		for(k=__builtin_ctz(len); j>>--k&1; ) j^=1<<k;
		j^=1<<k;
		if(i<j) std::swap(x[i], x[j]);
	}
	for(int i=1; i<len; i*=2)
		for(int j=0; j<len; j+=i+i)
			for(int k=0; k<i; ++k) {
				Complex z=w[i+k]*x[i+j+k];
				x[i+j+k]=x[j+k]-z;
				x[j+k]+=z;
			}
}

const int N=1<<19, P=2e5+3;
int a[P], up[P], lg[P];
long long f[N], g[P];
Complex c[N];
long long t, ans=0;
int main() {
	int n=rd();
	for(int i=0; i<n; ++i) a[i]=rd();
	for(int i=0; i<n; ++i) ans-=1llu*a[i]*a[i]%P;
	std::sort(a, a+n);
	up[0]=1;
	for(int i=1; i<P-1; ++i) up[i]=up[i-1]*2%P;
	for(int i=0; i<P-1; ++i) lg[up[i]]=i;
	len=1;
	while(len<2*P) len*=2;
	init(len);
	for(int i=0; i<n; ++i) if(a[i]) ++f[lg[a[i]]];
	for(int i=0; i<len; ++i) c[i]={(double)f[i], 0.0};
	dft(c);
	for(int i=0; i<len; ++i) c[i]=c[i]*c[i];
	std::reverse(c+1, c+len);
	dft(c);
	for(int i=0; i<len; ++i) f[i]=round(c[i].re/len);
	for(int i=0; i<len; ++i) ans+=up[i%(P-1)]*f[i];
	printf("%lld\n", ans/2);
	return 0;
}


Measured memory_bytes: 26896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	unordered_map<int,int> mp;
    int n, k;
	cin >> n >> k;
	rep(i, n){
		int a;
		cin >> a;
		mp[a]++;
	}
	vector<int> v;
	for(auto it = mp.begin(); it != mp.end(); it++) v.push_back(it->second);
	sort(v.begin(), v.end());
	int sum = 0;
	rep(i, max((int)v.size() - k, 0)) sum += v[i];
	cout << sum << endl;
}

Measured memory_bytes: 10312
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	char c;
	cin>>c;
	if(c>='a' && c<='z')
	cout<<'a'<<endl;
	else

	cout<<'A'<<endl;
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n;
    if(n==1)
    {
        cout<<"Hello World"<<"\n";
    }
    if(n==2)
    {
        cin>>a>>b;
        cout<<a+b;
    }
}


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

int func(int num, int rest, int before){
	//if(before + 1 < 0) return 0;
	if(num == 0){
		if(rest == 0){
			//cout << before << endl;
			return 1;
		}
		return 0;
	}
	int res = 0;
	for(int i = 0; i <= rest && i <= before; ++i){
		res += func(num - 1, rest - i, i - 1);
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, s;
	while(cin >> n >> s && (n != 0 || s != 0) ){
		cout << func(n, s, 9) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main()
{
    int a[100], n, i, j, k, x;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);

    for (k = 0; k < n; k++) {
        if (k == n - 1) {
            printf("%d\n", a[k]);
        } else {
            printf("%d ", a[k]);
        }
    }

    for (i = 1; i < n; i++) {
        x = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > x) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = x;
        for (k = 0; k < n; k++) {
            if (k == n - 1) {
                printf("%d\n", a[k]);
            } else {
                printf("%d ", a[k]);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

#define min(x, y) x<y ? x : y

int main(void)
{
    long a, b, n;
    scanf("%ld %ld %ld", &n, &a, &b);

    long ans = 0;
    if((b-a)%2 == 0){
        ans = (b-a)/2;
    }
    else{
        if(a-1 > n-b){
            ans = (n-b) + 1 + (n-(a+(n-b)+1))/2;
        }
        else{
            ans = (a-1) + 1 + ((b-((a-1)+1))-1)/2;
        }
    }

    printf("%ld\n", ans);

    return 0;
}

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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnta=0,cntb=0;
    for(int i=0; i<n; i++){
        if(s[i]=='a'&&(cnta<a||cnta+cntb<a+b)){
            cout << "Yes" << endl;
            cnta++;
        }
        else if(s[i]=='b'&&cntb<b&&cnta+cntb<a+b){
            cout << "Yes" << endl;
            cntb++;
        }
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int B[] = new int[N];
        long sum_of_A = 0, sum_of_B = 0;
        for(int i=0; i<N; i++) {
            A[i] = sc.nextInt();
            sum_of_A+=A[i];
        }
        for(int i=0; i<N; i++) {
            B[i] = sc.nextInt();
            sum_of_B+=B[i];
        }
        if(sum_of_A < sum_of_B) {
            System.out.println("-1");
            return;
        }
        long sum_of_lack=0;
        int lack_count=0;
        List<Integer> li = new ArrayList<>();
        for(int i=0; i<N; i++) {
//            System.out.println(String.format("%d, %d", A[i], B[i]));
            if(A[i] == B[i]) continue;
            if(A[i] < B[i]) {
                sum_of_lack += B[i] - A[i];
                lack_count++;
            } else {
                li.add(A[i] - B[i]);
            }
        }
        li.sort((a,b)->b-a);
        long add_sum = 0;
//      System.out.println(String.format("size() is %d", li.size()));
        for(int k=0; k<li.size(); k++) {
//            System.out.println(String.format("add_sum:%d", add_sum));
            if(add_sum >= sum_of_lack) {
                System.out.println(lack_count + k);
                return;
            }
            add_sum += li.get(k);
        }
        System.out.println(lack_count + li.size());
    }
}


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

int main() {
  int n, l;
  cin >> n >> l;
  int a = l;
  int b = l + n - 1;
  if (a > 0) cout << (2 * l + n) * (n - 1) / 2 << endl;
  else if (b < 0) cout << (2 * l + n - 2) * (n - 1) / 2 << endl;
  else cout << (2 * l + n - 1) * n / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0;i<n;i++) cin >> d[i];

    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}


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

int main(void)
{
    int a,b,c;
    a = b = c = 0;
    string s;
    cin >> s;
    for(int i = 0;i<3;i++)
    {
        switch(s[i])
        {
            case 'a':
            a++;
            break;
            case 'b':
            b++;
            break;
            case 'c':
            c++;
            break;
        }
    }
    if(a == 1 && b == 1 && c == 1){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 256
N = int(input())
*P, = map(int, input().split())

LL = [0] + [i for i in range(N+1)]
RR = [i+1 for i in range(N+1)] + [N+1]

E = [(v, i+1) for i, v in enumerate(P)]
E.sort()

ans = 0
for v, i in E:
    l0 = LL[i]; l1 = LL[l0]

    r0 = RR[i]; r1 = RR[r0]

    LL[RR[i]], RR[LL[i]] = LL[i], RR[i]

    ans += ((r1 - r0) * (i - l0) + (r0 - i) * (l0 - l1)) * v
print(ans)

Measured memory_bytes: 25700
sd=input()
t=input()
n=len(sd)
m=len(t)
if n<m:
    print("UNRESTORABLE")
    exit(0)
for i in range(n-m,-1,-1):
    t_kana=sd[i:i+m]
    for j in range(m+1):
        if j==m :
            print((sd[:i]+t+sd[i+len(t):]).replace("?","a"))
            exit(0)
        if t_kana[j]=="?":
            continue
        elif t_kana[j]!=t[j]:
            break
print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin >> s;
    int i=0,cnt1=0,cnt2=0;
    while(s[i]) {
    	if(s[i]=='A') cnt1++;
    	else cnt2++;
    	i++;
    }
    if(cnt1&&cnt2) cout << "Yes";
    else cout << "No";
    cout << "\n";
    return 0;
}



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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

N = INT()
grid = build_grid(N, N, '', str, space=0)

def check(i, j):
    for k in range(N):
        for l in range(k+1, N):
            if grid[(k+i)%N][(l+j)%N] != grid[(l+i)%N][(k+j)%N]:
                return False
    return True

# 片側しかやらなくていい
cnt = 0
for i in range(N):
    if check(0, i):
        cnt += 1
print(cnt * N)


Measured memory_bytes: 44784
pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);
 
impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn solve(n: usize, k: usize, snacks: &[Vec<usize>]) -> usize {
    let mut snackless = vec![1; n];
    for snack in snacks {
        for snuke in snack {
            snackless[snuke-1] = 0;
        }
    }
    snackless.iter().filter(|s| **s == 1).count()
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n = sc.read();
    let k = sc.read();
    let mut snacks = Vec::new();
    for i in 1..=k {
        let d = sc.read();
        snacks.push(sc.vec(d));
    }
    let ans = solve(n, k, &snacks);
    println!("{}", ans);
}
 


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,k,ans=0,len,tmp;
  cin >> n >> k;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  vector<long long> bit[n],limit;
  tmp=k;
  while(tmp>0){
    limit.push_back(tmp%2);
    tmp/=2;
  }
  for(int i=0;i<n;i++){
    tmp=a[i];
    while(tmp>0){
      bit[i].push_back(tmp%2);
      tmp/=2;
    }
    len=max(limit.size(), bit[0].size());
    while((long long)bit[i].size()<len){
      bit[i].push_back(0ll);
    }
  }
  long long by2=1,XOR=0;
  for(int i=1;i<len;i++){
    by2*=2;
  }
  for(int i=len-1;i>=0;i--){
    long long one=0, zero=0;
    for(int j=0;j<n;j++){
      if(bit[j][i]==1){
        one++;
      }else{
        zero++;
      }
    }
    if(zero>one and XOR+by2<=k){
      XOR+=by2;
    }
    by2/=2;
  }
  for(int i=0;i<n;i++){
    ans+=XOR xor a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 54912
#include<bits/stdc++.h>
using namespace std;
int main(){
    int cases=1;
    for(int iii=1;iii<=cases;++iii){
        int n,m;
        scanf("%d%d",&n,&m);
        printf("%d\n",n*(n-1)/2+m*(m-1)/2);
    }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();        
        int b = stdIn.nextInt();        
        stdIn.close();

        if (a >= b){
            for (int i = 0; i < a; i++) {
                System.out.print(b);
            }
        } else {
            for (int i = 0; i < b; i++) {
                System.out.print(a);
            }
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

//-------------------------------------------------
//--Segment tree
//-------------------------------------------------
template<typename T>
class SegmentTree
{
private:
    using F = function<T(T,T)>;
    ::std::vector<T> btree;
    F f, _update;
    T e;
    int n;
public:
    SegmentTree(){}
    SegmentTree(int _n, F f, T e, F g=[](T a,T b){return b;})
         : f(f),e(e),_update(g)
    {
        init(_n);
    }
    SegmentTree(const ::std::vector<T> &v, F f, T e, F g=[](T a,T b){return b;})
         : f(f),e(e),_update(g)
    {
        int _n = v.size();
        init(_n);
        for(int i=0; i<_n; i++) btree[i+n-1] = v[i];
        build();
    }
    void init(int _n){
        n = 1;
        while(_n>n) n<<=1;
        btree.resize(2*n-1, e);
    }
    void build(){
        for(int i=n-2; i>=0; i--) btree[i] = f(btree[2*i+1], btree[2*i+2]);
    }
    void update(int k, T a){
        k += n-1;
        btree[k] = _update(btree[k], a);
        while(k>0){
            --k>>=1;
            btree[k] = f(btree[2*k+1], btree[2*k+2]);
        }
    }
    T query(int a, int b){
        T L=e, R=e;
        a+=n-1; b+=n-1;
        while(a<b){
            if (!(a & 1)) L=f(L, btree[a++]);
            if (!(b & 1)) R=f(btree[--b], R);
            a>>=1; b>>=1;
        }
        return f(L, R);
    }
    T operator[](int k){return btree[k+n-1];}
};

const int A_MAX = 3e5;

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin>>N>>K;
    SegmentTree<int> seg(A_MAX+1,
        [](int x, int y){return max(x,y);},
        0
    );
    rep(i,N){
        int a; cin>>a;
        int l = max(0,a-K);
        int r = min(a+K+1,A_MAX+1);
        seg.update(a,seg.query(l,r)+1);
    }
    cout<<seg.query(0,A_MAX+1)<<"\n";
    return 0;
}


Measured memory_bytes: 7412
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
lst=[-1]*n

for i in range(m):
    s,c=sc[i]
    if lst[s-1]==-1 or lst[s-1]==c:
        lst[s-1]=c
    else:
        print(-1)
        quit()
# print(lst)
for i in range(n):
    if i==0:
        if lst[i]==0 and n!=1:
            print(-1)
            quit()
        elif lst[i]==-1:
            if n==1:
                lst[i]=0
            else:
                lst[i]=1
    elif lst[i]==-1:
        lst[i]=0

print("".join(map(str,lst)))

Measured memory_bytes: 69136
#include<bits/stdc++.h>
using namespace std;
long long int a[105];
int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	if(n<3){
		cout<<"0"<<endl;
		return 0;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n-2;i++){
		for(int j=i+1;j<=n-1;j++){
			for(int z=j+1;z<=n;z++){
				if(a[i]!=a[j]&&a[j]!=a[z]&&a[i]+a[j]>a[z]){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}

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

//nのp乗
ll power(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*power(n,(p-1)/2)*power(n,(p-1)/2);}
    else{return power(n,p/2)*power(n,p/2);}
}

int main() {
    ll N,M;
    cin>>N>>M;
    priority_queue<ll> A;
    rep(i,N){
        ll a;
        cin>>a;
        A.push(a);
    }
    rep(i,M){
        ll x=A.top();
        A.pop();
        x/=2;
        A.push(x);
    }
    ll ans=0;
    rep(i,N){
        ll z=A.top();
        ans+=z;
        A.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll A,B,C,D;
	string result;
	cin>>A>>B>>C>>D;
	while(true){
		C-=B;
		if(C<=0) {
			result = "Yes";
			break;
		}
		A-=D;
		if(A<=0) {
			result = "No";
			break;
		}
	}

	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 22:51:25 2019

@author: yuta
"""
from collections import Counter
#入力
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for j in range(M)]

def main(s,t):
    count_blue = Counter(s)
    count_red = Counter(t)
    all_str = list(set(s+t))
    count_max = 0
    for i in all_str:
        count_i = count_blue[i] - count_red[i]
        if count_i >= count_max:
            count_max = count_i
    print(count_max)

main(S,T)

Measured memory_bytes: 3316
ABC = list(map(int,input().split()))
A=ABC[0]
B=ABC[1]
C=ABC[2]

cnt=1
summary=0
tmp=[]
flag=False
while True:
    summary=cnt*A
    cnt=cnt+1
    if summary%B in tmp:
        break
    else:
        tmp.append(summary%B)
    
    if summary%B==C:
        flag=True
        break

if flag:
    print('YES')
else:
    print('NO')


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll k;
/******* define variable end *******/
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1)
			res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
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;
}
int solve() {

	cin >> k;
	REP(i, 1000000){
		if((7 * (modpow(10, i+1, 9*k)-1)) % (9*k) == 0){
			cout << i+1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
using Point = tuple<i64, i64>;
const i64 INF = 5e18;
int main() {
    int N, K;
    cin >> N >> K;
    vector<Point> C;
    set<i64> X, Y;
    for(int i = 0; i < N; i++) {
        i64 x, y;
        cin >> x >> y;
        C.emplace_back(x, y);
        X.insert(x);
        Y.insert(y);
    }
    i64 ans = INF;
    for(auto x1 : X) {
        for(auto x2 : X) {
            for(auto y1 : Y) {
                for(auto y2 : Y) {
                    if(x1 >= x2 || y1 >= y2) continue;
                    int k = 0;
                    for(auto c : C) {
                        int64_t x, y;
                        tie(x, y) = c;
                        if(x1 <= x && x <= x2 && y1 <= y && y <= y2) {
                            k++;
                        }
                    }
                    if(k >= K) {
                        ans = min(ans, (x2 - x1) * (y2 - y1));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int h, w;
int l[2010][2010] = {};
int r[2010][2010] = {};
int u[2010][2010] = {};
int d[2010][2010] = {};


char s[2010][2010];

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

    for(int i = 0;i < h;i++){
        cin >> s[i];
    }

    int ans = 0;
    for(int i = 0;i < h;i++){
        l[i][0] = (s[i][0] == '.' ? 1 : 0);
        for(int j = 1;j < w;j++){
            l[i][j] = (s[i][j] == '.' ? l[i][j-1] + 1 : 0);
        }
    }

    for(int i = 0;i < h;i++){
        for(int j = w-1;j >= 0;j--){
            r[i][j] = (s[i][j] == '.' ? r[i][j+1] + 1 : 0);
        }
    }

    for(int j = 0;j < w;j++){
        u[0][j] = (s[0][j] == '.' ? 1 : 0);
        for(int i = 0;i < h;i++){
            u[i][j] = (s[i][j] == '.' ? u[i-1][j]+1 : 0);
        }
    }

    for(int j = 0;j < w;j++){
        for(int i = h-1;i >= 0;i--){
            d[i][j] = (s[i][j] == '.' ? d[i+1][j]+1 : 0);
        }
    }

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(s[i][j] == '.'){
                ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
            }
        }
    }

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



Measured memory_bytes: 67200