akhauriyash/Code-Regression huggingface dataset:
fun main(args : Array<String>){
    val (n,m) = readLine()!!.split(' ').map{ it.toInt() }
    var hoge = Array(m,{Pair(0,0)})
    var nyan = Array(m,{Pair(0,0)})

    for(i in 0 until m){
        var (a,b) = readLine()!!.split(' ').map{ it.toInt() }
        hoge[i] = Pair(a,i)
        nyan[i] = Pair(b,i)
    }

    var ok = Array<Boolean>(m,{false})
    var now = 0
    var ans = 0
    hoge = hoge.sortedBy { it.first }.toTypedArray()
    nyan = nyan.sortedBy { it.first }.toTypedArray()

    for(i in 0 until m){
        if(ok[nyan[i].second])continue
        while(now < m && hoge[now].first < nyan[i].first){
            ok[hoge[now].second] = true
            now++
        }
        ans++
    }

    println(ans)

}


Measured memory_bytes: 117920
#include <stdio.h>
#include <math.h>

int main()
{

	int n;
	scanf("%d", &n);

	int i;
	int h[n];
	for (i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}

	int sum[n];
	sum[0] = 0;
	sum[1] = abs(h[0] - h[1]);
	for (i = 2; i < n; i++) {
		sum[i] = fmin( sum[i-2] + abs(h[i-2] - h[i]), sum[i-1] + abs(h[i-1] - h[i]));
	}

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

Measured memory_bytes: 896
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    string s;
    cin >> s;
    ll sum = 0;
    for(ll i=0;i<s.size();i++)   sum += s[i]-'0';
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else   cout<<"No";
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 3740
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(void){
  double x1,y1,x2,y2;//double型　変数名x1,y1,x2,y2;　
  cin>>x1>>y1>>x2>>y2;//入力 x1 y1 x2 y2
  double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));//double型 dに平方根(x1-x2)の二乗-(y1-y2)の二乗を代入
  printf("%lf\n",d);

  return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

struct shop {
    long long int price;
    long long int num;
};

int main() {

    long long int N, M;
    cin >> N >> M;

    vector<shop> shops;

    long long int a, b;
    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        shop s;
        s.price = a;
        s.num = b;
        shops.push_back(s);
    }

    sort(shops.begin(), shops.end(),
         [](const shop& x, const shop& y) {return x.price < y.price;});

    long long int sum = 0;
    long long int num = 0;
    for (int i = 0; i < N; i++) {
        if (num + shops[i].num >= M) {
            sum += (M - num) * shops[i].price;
            break;
        }
        else {
            num += shops[i].num;
            sum += shops[i].price * shops[i].num;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<int> a(n);
    int ans = 0;
    rep(i,n) {
        cin>>a[i];
        if (i%2==0 && a[i]%2==1) ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int ans = 100100100;
	for (int ii = 0; ii < N; ++ii){
		int c, t;
		cin >> c >> t;
		if (t <= T){
			ans = min(ans, c);
		}
	}

	if (ans == 100100100){
		cout << "TLE" << endl;
	} else {
		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 256
n=int(input())
p=print
if n in [2**i for i in range(32)]:
 p("No")
 exit()
p("Yes")
p(n+1,n+2)
for i in range(3,n+1,2):
 p(1,i)
 p(1,i-1)
 p(i,n+i-1)
 p(i-1,n+i)
if n%2==0:
 u=1<<(n.bit_length()-1)
 l=n^1^u
 p(u,n)
 p(l,n+n)

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

struct Rec
{
	int l[2];
	/*
	bool operator == (const Rec r) const
	{
		return l[0] ==  r.l[0] ? l[1] < r.l[1] :  l[0] < l[1];
	}
	*/
};

int main()
{
	int n,w,d;
	while(cin >> n >> w >> d)
	{
		if(n == 0 && w == 0 && d == 0)
		{
			break;
		}

		vector<Rec> v;
		Rec r;
		r.l[0] = w;
		r.l[1] = d;
		v.pb(r);

		rep(i,n)
		{
			int p,s;
			cin >> p >> s;

			p--;
			Rec r1 = v[p];
			v.erase(v.begin() + p);

			int count = 0,x = 0;
			while(true)
			{
				if(s - r1.l[count%2] <= 0)
				{
					x = s;
					break;
				}
				else
				{
					s -= r1.l[count%2];
					count++;
				}
			}
			count %= 2;
			Rec r2,r3;
			if(count == 0)
			{
				r2.l[0] = x;
				r2.l[1] = r1.l[1];

				r3.l[0] = r1.l[0] - x;
				r3.l[1] = r1.l[1];

				if(r2.l[0] * r2.l[1] < r3.l[0]*r3.l[1])
				{
					v.pb(r2);
					v.pb(r3);
				}
				else
				{
					v.pb(r3);
					v.pb(r2);
				}
			}
			if(count == 1)
			{

				r2.l[0] = r1.l[0];
				r2.l[1] = x;

				
				r3.l[0] = r1.l[0];
				r3.l[1] = r1.l[1] - x;

				if(r2.l[0] * r2.l[1] < r3.l[0]*r3.l[1])
				{
					v.pb(r2);
					v.pb(r3);
				}
				else
				{
					v.pb(r3);
					v.pb(r2);
				}
			}
		}
		vector<int> ans;
		rep(j,v.size())
		{
			ans.pb(v[j].l[0]*v[j].l[1]);
		}

		sort(ans.begin(),ans.end());

		bool flag = true;
		rep(j,ans.size())
		{
			if(flag)
			{
				cout << ans[j];
				flag = false;
			}
			else
			{
				cout << " " << ans[j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define repeat(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    cin >> str;
    int x = 0;
    int y = 0;
    for(int i = 0; i < (int)str.size(); ++i){
        char ch = str[i];
        if(ch == 'A' ||ch == 'T'||ch == 'G' ||ch == 'C') x ++;
        else{
            if (y < x) y = x;

            x = 0;

        }
    }
    if (x > y) cout << x << endl;
    else if(x == (int)str.size()) cout << x << endl;
    else cout << y << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+9
#define MOD 1000000007
#define debug(x) cerr << #x << ": " << x << "\n"
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    int N;
    string str[2];
    cin >> N >> str[0] >> str[1];

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

    if(N == 1){
        cout << "3\n";
        return 0;
    }

    ll res;
    if(s[0] == 0) res = 6;
    else if(s[0] == 2) res = 3;

    for(int i = 0; i < N-1; i++){
        if(s[i] == 1){
            if(s[i+1] == 0) res = res * 3 % MOD;
        }else if(s[i] == 2){
            res = res * 2 % MOD;
        }
    }

    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void exception(int s, int g){
  int a[17]={7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8};
  int j;

  j=0;
  while(a[j]!=s)
    j++;
  while(a[j]!=g){
    printf("%d ",a[j]);
    j++;
  }
  printf("%d\n",a[j]);
}

int main(){
  int a[16]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0};
  int n,i,j,k;
  int s,g;
  int p1,p2;
  int i_p1,i_p2;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&s,&g);
    
    if(s>=7&&s>g&&g>=6){
      exception(s,g);
    }
    else{
      //Normal
      
    j=0;
    while(a[j]!=s)
      j++;
    i_p1=j;
    p1=0;
    while(a[j]!=g){
      j++;
      p1++;
    }
    
    j=14;
    while(a[j]!=s)
      j--;
    i_p2=j;
    p2=0;
    while(a[j]!=g){
      j++;
      p2++;
      if(j==16){
	p2=20; //OF
	break;
      }
    }

    if(p1<p2){
      for(k=i_p1;k<i_p1+p1;k++)
	printf("%d ",a[k]);
      //puts("");
      printf("%d\n",a[i_p1+p1]);
    }
    else{
      for(k=i_p2;k<i_p2+p2;k++)
	printf("%d ",a[k]);
      //      puts("");
      printf("%d\n",a[i_p2+p2]);
    }
    
    }//Normal End

  }
  return 0;
}

Measured memory_bytes: 0
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 9999999999
#define N 4000
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
double b = 0.1 , a = 0.08;
int A , B , q , p ;
int main(){
	cin>>A>>B;
	for(int i = 1 ; i <= 10000 ; i++){
		q = b*i;
		p = a*i;
		if(q == B && p == A) {
			cout<<i<<"\n";
			return 0;
		}
	}
	cout<<-1;

}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    /////////
    //write//
    /////////
    
    while (1){
        int n; cin >> n;
        if(n==0)break;
        int s[1000] = {0};
        for(int i=0; i<n; i++){
            cin >> s[i];
        }
        
        sort(s, s+n);
        
        int sum = 0;
        for(int i=1; i<n-1; i++){
            sum+=s[i];
        }
        sum/=(n-2);
        
        cout << sum << endl;
    }
    return 0;
}



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

int res;

void sum(int n)
{
    if(n < 10)
    {
        res+=n;
    }
    else
    {
        res+=n%10;
        sum(n/10);
    }
}

int main () 
{
    int n , a , b , ans=0;
    cin>>n>>a>>b;
    for(int i=1;i<=n;++i)
    {
        sum(i);
        if(res >= a && res <= b)
            ans+=i;
        res=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;
typedef pair<P,ll> PP;

const ll MOD=1000000007;
const ll MAX_N=400010, INF=1e17;
struct LazySegmentTree{
    ll node[2*MAX_N-1], lazy[2*MAX_N-1], SIZE; //SIZE:nを２べきにしたもの
    bool lazyflag[2*MAX_N-1];
    
    //初期化
    void init(int n_){
        //要素数を2べきに
        SIZE=1;
        while(SIZE<n_) SIZE*=2;
        
        //全ての値をI_MAXに
        rep(i,0,2*SIZE-1) node[i]=INF;
    }
    
    //k番目のノードについて遅延評価を行う
    void eval(int k, int l, int r){
        // 遅延配列が空でない場合、自ノード及び子ノードへの値の伝播が起こる
        if(lazyflag[k]){
            node[k]=lazy[k];
            // 最下段かどうかのチェックをしよう
            if(r-l>1){
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyflag[k*2+1] = lazyflag[k*2+2] = true;
            }
            lazyflag[k] = false;
        }
    }
    
    void update(int a, int b, ll x, int k=0, int l=0, int r=-1){
        if(r<0) r=SIZE;
        eval(k,l,r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyflag[k]=true;
            eval(k, l, r);
        }
        else{
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k]=min(node[2*k+1], node[2*k+2]);
        }
    }
    
    ll getmin(int a, int b, int k=0, int l=0, int r=-1){
        if(r<0) r=SIZE;
        eval(k,l,r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        ll vl=getmin(a, b, 2*k+1, l, (l+r)/2);
        ll vr=getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};
LazySegmentTree S;
vector<PP> v;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    v.resize(m);
    rep(i,0,m){
        cin>>v[i].fr.fr>>v[i].fr.sc>>v[i].sc;
        v[i].fr.fr--;
    }
    sor(v);
    S.init(n);
    S.update(0, 1, 0);
    rep(i,0,m){
        int l=v[i].fr.fr, r=v[i].fr.sc, c=v[i].sc;
        ll M=S.getmin(l, l+1);
        if(M==INF) break;
        ll ng=r,ok=l;
        while(ng-ok>1){
            ll mid=(ng+ok)/2;
            if(S.getmin(mid, mid+1)<=M+c) ok=mid;
            else ng=mid;
        }
        if(ok+1<r) S.update(ok+1, r, M+c);
    }
    cout <<(S.getmin(n-1, n)==INF?-1:S.getmin(n-1, n))<<"\n";
}

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

using pdouble = pair<double,double>;

double distance(pdouble p1, pdouble p2){
  double dx,dy;
  dx=p1.first-p2.first;
  dy=p1.second-p2.second;
  return sqrt(dx*dx+dy*dy);
}

signed main(void){
  int n;cin>>n;
  double ans=0;
  vector<pdouble> t(n);
  rep(i,n){
    cin >> t[i].first >> t[i].second;
  }
  vector<double> dis;
  rep(i,n-1){
    repi(j,i+1,n){
      dis.push_back(distance(t[i],t[j]));
    }
  }
  rfor(dis,d)ans+=d;
  ans/=dis.size();




  printf("%lf\n",ans*(n-1));
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  int n;
  cin >> n;
  set<string> a;
  while (n--) {
    string cmd;
    string s;
    cin >> cmd >> s;
    if (cmd == "insert") a.insert(s);
    if (cmd == "find") cout << (a.count(s) ? "yes" : "no") << endl;
  }
}

Measured memory_bytes: 32140
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll dist(ll x,ll y)
{
    if(x<=0 && y<=0)
        return abs(abs(x)-abs(y));
    else if(x<=0 && y>=0)
        return abs(x)+y;
    else
        return y-x;
}
ll sum(int n,ll ARR[])
{
    ll res=0;
    for(int i=0; i<n; i++)
    {
        res+=(((ARR[i]*(i+1))%MOD)*(n-i))%MOD;
        res%=MOD;
    }
    return res;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,m;
    cin>>n>>m;
    ll x[n+5],y[m+5];
    for(int i=0; i<n; i++)
    {
        cin>>x[i];
        if(i)
            x[i-1]=dist(x[i-1],x[i]);
    }
    for(int i=0; i<m; i++)
    {
        cin>>y[i];
        if(i)
            y[i-1]=dist(y[i-1],y[i]);
    }
    cout<<(sum(n-1,x)*sum(m-1,y))%MOD<<endl;





    return 0;
}


Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin, k;
    vector<ll> ans;
    REP(i, 1, 10) {
        ans.push_back(i);
    }
    vector<ll> prev = ans;
    while (ans.size() < k) {
        vector<ll> vv;
        for (ll n : prev) {
            ll lst = n % 10;
            if (lst != 0) {
                vv.push_back(n * 10 + lst - 1);
            }
            vv.push_back(n * 10 + lst);
            if (lst != 9) {
                vv.push_back(n * 10 + lst + 1);
            }
        }
        for (auto t : vv) {
            ans.push_back(t);
        }
        prev = vv;
    }
    sort(ans.begin(), ans.end());
    cout << ans[k - 1] << endl;

    return 0;
}


Measured memory_bytes: 4724
#include <stdio.h>

int main(void)
{
	int d[100];
	int n,i=0;
	
	while(scanf("%d", &n) != EOF){
		if(n == 0){
			i--;
			printf("%d\n", d[i]);
		}
		else {
			d[i] = n;
			i++;
		}
	}
	
	return (0);
	
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='+'){
		cout<<a+b<<endl;
	}
	
	else if(op=='-'){
		cout<<a-b<<endl;
		
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    ll C;
    cin>>A>>B>>C>>K;
    ll ans = min(A ,K);
    K -= A + B;
    if(K > 0) ans -= K;
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    //*
    if(a - b >= 0){
        cout << b * c + ( a - b ) * d << endl;
    } else {
        cout << a * c << endl;
    }
    //*/
    
    //cout << b * c + ( a - b ) * d << endl;

    return 0; 
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define mod 1000000007
    using namespace std;
    ll power(ll x,ll y)
    {
        ll res=1;
        while(y>0)
        {
            if(y%2==1)
                res=(res*x);
            x=(x*x);
            y=y/2;
        }
        return res;
    }
    int main()
    {
        ll n,W;
        cin>>n>>W;
        ll val[n+1],wt[n+1],knap[n+1][W+1];
        for(ll i=0;i<n;i++)
            cin>>wt[i]>>val[i];
    //         W=8
    //         val{2,3,1,4}//see video abdul bari
    //         wt{3,4,6,5}
    //         0 1 2 3 4 5 6 7 8 i--->
    // vi wi 0 0 0 0 0 0 0 0 0 0 j---v (downwards)
    //  2  3 1 0 
    //  3  4 2 0
    //  1  6 3 0
    //  4  5 4 0
        for(ll i=0;i<=n;i++)
        {
            for(ll j=0;j<=W;j++)
            {
                if(i==0||j==0)
                    knap[i][j]=0;
                else if(j>=wt[i-1])
                    knap[i][j]=max(knap[i-1][j],knap[i-1][j-wt[i-1]]+val[i-1]);
                else
                    knap[i][j]=knap[i-1][j];
            }
        }
        cout<<knap[n][W];
    }

Measured memory_bytes: 79104
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////

ll gcd(ll a,ll b){
    if(a>b)swap(a,b);
    if(a==0)return b;
    else return gcd(b%a,a);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,x;cin>>n>>x;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll b[n];rep(i,0,n-1)b[i]=abs(a[i]-x);
    ll ans=b[0];
    rep(i,1,n-1){
        ans=gcd(ans,b[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var AB = Sarray();
            var A = AB[0];
            var B = AB[1];
            var g = gcd(A, B);
            var div = divisors(g);
            var cnt = 1;//1の分
            foreach (var l in div)
                if (isPrime(l)) ++cnt;
            WriteLine(cnt);

        }
        static long gcd(long x, long y) => y == 0 ? x : gcd(y, x % y);
        static HashSet<long> divisors(long n)
        {
            var div = new HashSet<long>();
            for (long i = 1; i * i < n; ++i)
            {
                if (n % i == 0)
                {
                    div.Add(i);
                    if (i != n / i)
                        div.Add(n / i);
                }
            }
            return div;
        }
        static bool isPrime(long x)
        {
            if (x <= 1) return false;
            if (x == 2) return true;
            if (x % 2 == 0) return false;
            for (long i = 3; i * i <= x; i += 2)
                if (x % i == 0)
                    return false;
            return true;
        }
    }
}

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

int main(){
  	int N, P_flag, W_flag, G_flag, Y_flag, flag = -1;
  	char S[110];
  
  	P_flag = -1; W_flag = -1; G_flag = -1; Y_flag = -1;
  
  	cin >> N;
  	for(int i = 0;i < N; i++)	cin >> S[i];
  
  	for(int i = 0;i < N; i++){
      	if(S[i] == 'P')	P_flag = 1;
      	else if(S[i] == 'W')	W_flag = 1;
      	else if(S[i] == 'G')	G_flag = 1;
      	else if(S[i] == 'Y')	Y_flag = 1;
      
      	if(P_flag == 1 && W_flag == 1 && G_flag == 1 && Y_flag == 1){
          	cout << "Four" << endl;
          	flag = 1;
          	break;
        }
    }
  
  	if(flag == -1) cout << "Three" << endl;
  
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	typedef pair<int,int> P;
	const int N=1e5+9;
	int ans[N],n,A[N],C[N],D[N],B[N],m,sum[N],pre[N],used[N];
	inline int id(int x){return lower_bound(D+1,D+m+1,x)-D;}
	vector<int> pos[N];
	priority_queue<P> pq;
	int main(){
		n=read<int>();
		for(int i=1;i<=n;i++) A[i]=read<int>(),B[i]=read<int>();
		for(int i=1;i<=n+1;i++) D[i]=C[i]=read<int>();
		sort(D+1,D+n+2),m=unique(D+1,D+n+2)-D-1;
		for(int i=1;i<=n+1;i++) C[i]=id(C[i]);
		for(int i=1;i<=n;i++) A[i]=id(A[i]),B[i]=id(B[i]);

		for(int i=1;i<=n+1;i++){sum[C[i]]--;if(i<=n) sum[A[i]]++;}
		for(int i=1;i<=n+1;i++) sum[i]+=sum[i-1];

		int Q=read<int>();
		for(int i=1;i<=n;i++)
			if(B[i]<A[i]) pos[A[i]-1].push_back(i);
			else used[i]=1;
		int tmp=0;
		for(int i=n+1,s=0;i>=1;i--){
			for(int j=0;j<pos[i].size();j++) pq.push(P(-B[pos[i][j]],pos[i][j]));
			s+=pre[i],assert(s>=0);
			while(s+sum[i]<=-2){
				if(pq.empty()){while(Q--) puts("-1");return 0;}
				P o=pq.top();pq.pop();int l=-o.first,id=o.second,r=A[id]-1;
				pre[r]++,s++,pre[l-1]--,used[id]=1,tmp++;
			}
		}
		for(int i=n+1;i>=1;i--) sum[i]+=pre[i]+=pre[i+1];
		for(int i=1;i<=n+1;i++) pre[i]=0,pos[i].clear();

		for(int i=1;i<=n;i++)
			if(!used[i]) pos[B[i]].push_back(i);
		pre[0]=sum[0]=0,pos[0].clear();
		while(!pq.empty()) pq.pop();
		for(int i=0,s=0;i<=n+1;i++){
			for(int j=0;j<pos[i].size();j++) pq.push(P(A[pos[i][j]],pos[i][j]));
			s+=pre[i];
			while(sum[i]+s<0){
				if(pq.empty()){
					for(int j=i+1;j<=n+2;j++) ans[j]=-1;
					goto where;
				}
				P o=pq.top();pq.pop();int id=o.second,l=B[id],r=A[id];
				pre[l]++,s++,pre[r]--,tmp++;
			}
			ans[i+1]=tmp;
		}

		where:
	//	for(int i=1;i<=n+2;i++) cout<<ans[i]<<" ";cout<<endl;
		for(int i=1;i<=Q;i++){
			int x=read<int>(),y=read<int>(),ret=-1,tmp;
			if((tmp=ans[id(x)])!=-1) ret=max(ret,n-tmp+1);
			if((tmp=ans[id(y)])!=-1) ret=max(ret,n-tmp);
			printf("%d\n",ret);
		}
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 12480
"use strict";
function main(input) {
  let n = input[0].trim().split(" ");
  for(let i=0;i<n;i++){
    n[i] = parseInt(n[i]);
  }

  if (n[0]==n[1] && n[0]==n[2]){
    console.log("No");
  }else if(n[0]==n[1] || n[0]==n[2] || n[1]==n[2]){
    console.log("Yes");
  }else{
    console.log("No");
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 21064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    int n;
    cin >> n;
    int res = 0;
    while(n > 0){
        n -= ++res;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
a=input()
A=int(a[0])
B=int(a[1])
C=int(a[2])
D=int(a[3])
f=False

if A+B+C+D==7:
  print("{}+{}+{}+{}=7".format(A,B,C,D))
elif A+B+C-D==7:
  print("{}+{}+{}-{}=7".format(A,B,C,D))
elif A+B-C+D==7:
  print("{}+{}-{}+{}=7".format(A,B,C,D))
elif A+B-C-D==7:
  print("{}+{}-{}-{}=7".format(A,B,C,D))
elif A-B+C+D==7:
  print("{}-{}+{}+{}=7".format(A,B,C,D))
elif A-B+C-D==7:
  print("{}-{}+{}-{}=7".format(A,B,C,D))
elif A-B-C+D==7:
  print("{}-{}-{}+{}=7".format(A,B,C,D))
elif A-B-C-D==7:
  print("{}-{}-{}-{}=7".format(A,B,C,D))

  


Measured memory_bytes: 3064
#include<iostream>

bool f[30];

int main()
{
	for( int i = 0; i < 28; i++ ){
		int x;
		std::cin >> x;
		f[x-1] = true;
	}
	
	for( int i = 0; i < 30; i++ ){
	 	if( !f[i] ){
		 	std::cout << i + 1 << std::endl;
		}
	}

 	return 0;
}

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

using namespace std;

int a[1005],b[1005],c[1005][15];

int main()
{
    int N,m;
    cin>>N>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a[i]>>b[i];
        for(int j=1;j<=b[i];j++)
        {
            cin>>c[i][j];
        }
    }
    const int INF=1e9;
    vector<int>dp(5000,INF);
    dp[0]=0;
    for(int keys=1;keys<=m;keys++)
    {
        int val=0;
        for(int i=1;i<=b[keys];i++)
        {
            val|=(1<<(c[keys][i]-1));
        }
        for(int k=0;k<(1<<N);k++)
        {
            dp[k|val]=min(dp[k|val],dp[k]+a[keys]);
        }
    }
    if(dp[(1<<N)-1]==INF) dp[(1<<N)-1]=-1;
    cout<<dp[(1<<N)-1]<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

int check(int m, int d) {
	string t = to_string(d);
	if (t.size() < 2) {
		return 0;
	}
	if (t[0] < '2' || t[1] < '2') {
		return 0;
	}
	int ml = (t[0] - '0') * (t[1] - '0');
	return ml == m;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int ans = 0;
	int m, d;
	cin >> m >> d;
	for (int f = 1; f <= m; f++) {
		for (int s = 1; s <= d; s++) {
			ans += check(f, s);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i
mask = Array.new(26).map { [] }

(0..4).each{|i|
	(0..4).each{|j|
		(0..4-i).each{|h|
			(0..4-j).each{|w|
				m  = 0	
				(i..i+h).each{|y|
					(j..j+w).each{|x|
						m |= 1 << 5*y+x
					}
				}
				mask[(w+1)*(h+1)] << m
			}
		}
	}
}

n.times {
	bits = (1..5).map{gets.split.map &:to_i}.flatten.inject(0){|s, i| (s << 1) | i}
	max = 0
	25.downto(1){|area|
		mask[area].each{|m|
			if bits & m == m
				max = area
				break
			end
		}
		break if max > 0
	}
	p max
	gets
}

Measured memory_bytes: 6144
n, m = map(int, input().split())

student = list()

for x in range(n):
    student.append(list(map(int, input().split())))

checkpoint = list()

for y in range(m):
    checkpoint.append(list(map(int, input().split())))

INF = 4*(10**8) + 1
tmp = INF
ans = 51

for x in range(n):
    for y in range(m-1, -1, -1):
        distance = abs(student[x][0] - checkpoint[y][0]) + \
            abs(student[x][1] - checkpoint[y][1])

        if tmp >= distance:
            tmp = distance
            ans = y
    print(ans+1)
    tmp = INF


Measured memory_bytes: 3064
dec = [[False for i in range(1,14)] for j in range(4)]
pattern = ['S', 'H', 'C', 'D']

n = int(input())
for _ in range(n):
    c, rank = input().split()
    rank = int(rank)
    dec[pattern.index(c)][rank-1] = True

for i in range(4):
    for j in range(13):
        if dec[i][j] == False:
            print(pattern[i], j+1)


Measured memory_bytes: 5604
S = input()
acgt = ['A', 'C', 'G', 'T']


flag = False
best = 0
a = 0

for s in S:
    if s in acgt:
        if flag:
            a += 1
        else:
            a = 1
            flag = True
        if a > best:
            best = a
    else:
        if flag:
            flag = False
print(best)


Measured memory_bytes: 3188
using System;

namespace Wandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int A = int.Parse(imp[0]);
            int B = int.Parse(imp[1]);
            if(A%2==0||B%2==0)
            {
            Console.Write("No");
            }
            else
            {
            Console.Write("Yes");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
// #include <chrono>
// #include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'
#define pi 3.14159265358979323846
 
ll power(ll a,ll p,ll m=mod)
{ll res=1;while(p>0){if(p&1)res=(res*a)%m;a=(a*a)%m;p>>=1;}
return res;}
 
int pow(int a,int b){
	if(b == 0)return 1;
	int res = pow(a,b/2);
	res = res*res;
	if(b&1)res *= a;
	return res;
}

int ceil(int a,int b){
	if(a%b == 0)return a/b;
	return a/b+1;
}


int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
    // int t;
    //  cin >> t;
 
 //     while(t--){

 // }

int x;
cin >> x;
x = x^1;
cout << x << endl;





return 0;
	
	}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long inf = 4523372036854775807;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
		cout << "Yes\n";
	}
	else
		cout << "No\n";
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
    int n, m, a[10000], b[100], sum = 0, i, j;
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", a + i * m + j);
        }
    }

    for (i = 0; i < m; i++)
    {
        scanf("%d", b + i);
    }
     
    for (i = 0; i < n; i++)
    {
        sum = 0;
        for (j = 0; j < m; j++)
        {
            sum += a[m * i + j] * b[j];
        }
        printf("%d\n", sum);
    }
    
    return 0;
}


Measured memory_bytes: 2108
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        _n: usize,
        a: Usize1,
        b: Usize1,
        c: Usize1,
        d: Usize1,
        s: Chars,
    }
    if d < c && ! s[b - 1..=d + 1].windows(3).any(|w| w.iter().copied().all(|s| s == '.')) {
        println!("No");
        return;
    }
    if s[a..c].windows(2).any(|w| w.iter().copied().all(|s| s == '#')) || s[b..d].windows(2).any(|w| w.iter().copied().all(|s| s == '#')) { println!("No"); }
    else { println!("Yes"); }
}


Measured memory_bytes: 3008
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

class C{
  public:
  int N,K;
  std::vector<int> P;
  std::map<int,int> mp;
  void input();
  void solve();
};

void C::input(){
  std::cin>>N>>K;
  P.resize(N);
  for(int i=0;i<N;i++){
    std::cin>>P[i];
  }
}

void C::solve(){
  C::input();
  int cnt=0,l=0,r=1;
  int ok[N]={};
  while(l<N){
    if(l>=r) r=l+1;
    while(P[r-1]<P[r]&&r<N){
      if(r-l+1>=K) ok[r]=1;
      r++;
    }
    if(r>N) break;
    if(r==N&&l==0){
      std::cout<<"1\n";
      return;
    }
    cnt+=std::max(0,r-l-K+1);
    l=r;
  }
  
  int ans=0,pre=0;
  for(int i=0;i<N;i++){
    mp[P[i]]=1;
    if(i>=K-1){
      auto it_min=mp.begin();
      auto it_max=mp.end();
      it_max--;
      int j=i-(K-1);
      if(ok[i]==0){
        if(j){
          if(P[j-1]>it_min->first||P[i]!=it_max->first){
            ans++;
          }
        }else ans++;
      }
      mp.erase(P[j]);
    }
  }
  std::cout<<ans+(cnt!=0)<<"\n";
  return;
}

int main(){
  C c;
  c.solve();
  return 0;
}

Measured memory_bytes: 11136
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		String S = next();
		int n = S.length();
		for(int i = 0; i < n; i++) {
			System.out.print("x");
		}
		System.out.println();
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  int n,k;cin>>n>>k;
  string s;cin>>s;
  //caricurate
  for(int i=0;i<n;i++){
   if(i==(k-1)){
     if(s.at(i) =='A'){cout<<"a";}
     else if(s.at(i) =='B'){cout<<"b";}
   else{cout<<"c";}
   }
    else{cout<<s.at(i);}
  }
  //output
    cout<<endl;
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int INF = 1e9+100;
const ll LINF = 1e18+100;
const int MAXN = 2e5+100;
const double EPS = 1e-6;


int n, k;
ll dp[MAXN][3];
ll a[MAXN], b[MAXN], c[MAXN];

void solve() {
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i] >> b[i] >> c[i];
	
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	
	for(int i = 2; i <= n; ++i) {
		dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
	}
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]);
}

int main() {

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int t = 1;
//	cin >> t;
	while(t--) {
		solve();
	}
}

Measured memory_bytes: 7680
#include <iostream>

using namespace std;

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

  int pay = 0;
  pay = (n / 1000) * 1000;
  if(n % 1000 == 0) {
    std::cout << 0 << '\n';
  }else {
    std::cout << (n / 1000 + 1) * 1000 - n << '\n';
  }
  return 0;
}


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

using namespace std;

typedef long long int lli;

vector<vector<lli>> dp(401, vector<lli>(401, 0));
lli a[400], sum[401] = { 0 };

lli rec (int l, int r) {
    if (dp[l][r]) return dp[l][r];
    if (l == r) return 0;

    lli res = 1e+18;
    for (int i=l; i<r; i++) {
        res = min(res, rec(l, i)+rec(i+1, r)+sum[i+1]-sum[l]+sum[r+1]-sum[i+1]);
    }

    return dp[l][r] = res;
}

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

    int n;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }

    cout << rec(0, n-1) << endl;

    return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
const int N=1e5+20;
int n,k,len,ans;
char a[N];
vector <int> v={0};
int main()
{
	scanf("%d%d %s",&n,&k,a);

	for(int i=0;i<n;i++)
	{
		if(i==0 or a[i]==a[i-1]) v.back()++;
		else v.push_back(1);
	}

	len=n;
	n=v.size();
	k=k*2+1;
	if(k>=n) return 0 * printf("%d",len-1);

	printf("%d",len-n+k-1);
}

Measured memory_bytes: 1020
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
 
int main(){
    long long int n;
    cin>>n;
    long long int sum=0;
    for(long long int i=1;i<=n;i++){
    	
    	if(i%3==0 && i%5==0){
    		continue;
		}
		else if(i%3==0){
			continue;
		}
    	else if(i%5==0){
    		continue;
		}
		else{
			sum=sum+i;
		}
    	
	}
    cout << sum;
    
    
	
	   return 0;
}


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

int main(){
    int K,X;
    cin>>K>>X;
    if(500*K>=X)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

long long  mod = 1000000007;

int dp[16010];
int dp2[16010];
int dp3[16010];
int dp4[16010];
int main(){
	string s;
	cin >> s;
	int x,y;
	cin >> x >> y;
	vector<int> p,q;
	int a=0,b=0;
	bool m = 0;
	bool w = 1;
	for(int i=0;i<s.size();i++){
		if(s[i]=='F'){
			if(m==0){
				a++;
				if(i==s.size()-1){
					p.PB(a);
				}
			}else{
				b++;
				if(i==s.size()-1){
					q.PB(b);
				}
			}
		}else{
			if(m==0){
				if(w==1){
					x-=a;
					w = 0;
				}else if(a!=0){
					p.PB(a);
				}
				a=0;
				b=0;
				m=1;
			}else{
				if(b!=0)q.PB(b);
				a=0;
				b=0;
				m=0;
			}
		}
	}
	if(w==1){
		if(x==s.size()){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
		return 0;
	}
	int pp = p.size();
	int qq = q.size();
	// rep(i,p.size()){
	// 	cout << p[i] << " ";
	// }
	// cout << endl;
	// rep(i,q.size()){
	// 	cout << q[i] << " ";
	// }
	// cout << endl;
	dp[8000]=1;
	dp3[8000]=1;
	rep(i,pp){
		rep(j,16000){
			if(dp[j]!=0){
				dp2[j+p[i]]++;
				dp2[j-p[i]]++; 
			}
		}
		rep(j,16000){
			dp[j]=dp2[j];
			dp2[j]=0;
		}
	}
	rep(i,qq){
		rep(j,16000){
			if(dp3[j]!=0){
				dp4[j+q[i]]++;
				dp4[j-q[i]]++; 
			}
		}
		rep(j,16000){
			dp3[j]=dp4[j];
			dp4[j]=0;
		}
	}
	if(dp[8000+x]!=0&&dp3[8000+y]!=0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
H = sorted(h)
# print(H)
minH = 10 ** 9
for x in range(N - K + 1):
    sumh = H[x + K - 1] - H[x]
    # print("sumh", sumh)
    if minH > sumh:
        minH = sumh
print(minH)


Measured memory_bytes: 51032