akhauriyash/Code-Regression huggingface dataset:
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int a, b, c, d, n;
  cin >> a >> b >> c >> d >> n;
  b = min(b, 2 * a);
  c = min(c, 2 * b);
  d = min(d, 2 * c);
  cout << d * (n / 2) + c * (n % 2) << "\n";
}



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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());
      int[] x=new int[n+1];
      for(int i=0; i<n+1; i++){
        x[i]=Integer.parseInt(sc.next());
      }

      Arrays.sort(x);
      int[] y=new int[n];
      for(int i=0; i<n; i++){
        y[i]=x[i+1]-x[i];
      }

      int ans=0;
      for(int i=0; i<n; i++){
        ans=gcd(y[i], ans);
      }

      System.out.println(ans);
    
      }catch (Exception e) {
      System.out.println("out");
    }
  }

  public static int gcd(int m, int n){
    if(m<n){
      return gcd(n,m);
    }   
    if(n==0){
      return m;
    }else{
      return gcd(n, m%n);
    }
    
  }
}


Measured memory_bytes: 48024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
  	cin >> N;
    bool ok = true;
   for(int i=0;i<N;i++){
        int a[i];
        cin>>a[i];
        if(a[i]%2==0 && (a[i]%3!=0 &&a[i]%5!=0)){
            ok = false;
            break;
        }
    }
    if(ok){
        cout <<"APPROVED" << endl;
    }
    else{
        cout <<"DENIED" << endl;
    }
}


Measured memory_bytes: 256
// lolinkの自作ライブラリ
/* option1:グラフが非連結の場合,option2:bridgeの検出,option3:関節点の検出*/
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define loINF (long)10000000000
#define shINF (short)10000
#define SORT(c) sort((c).begin(),(c).end())
//#define NOT_ALL_CONNECTED 	//option1
//#define BRIDGE   				//option2
#define ARTICULATION_POINT    //option3
using namespace std;
const long V_START = 0;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef pair<long,long> pr;
typedef vector<pr> VP;

VVL edge;
VL ord;
VL low;
VL pre;

void dfs(long now_ver,long parent,long order){
	long child_num = 1;
	char flag = 0;
	pre[now_ver] = parent;
	low[now_ver] = ord[now_ver] = order;

	REP(i,edge[now_ver].size()){
		long to = edge[now_ver][i];
		if (to == parent) continue;
		if (ord[to] == -1) { // 子ノードへの辺
			dfs(to,now_ver,order + child_num);
			child_num++;
			low[now_ver] = min(low[now_ver],low[to]);
		}
		low[now_ver]=min(low[now_ver],ord[to]);
	}
}

int main(void){
	long V,E;
	cin >> V >> E;
	edge = VVL(V+1,VL(0));
	ord = VL(V+1,-1);
	low = VL(V+1,loINF);
	pre = VL(V+1,-1);

	REP(i,E){
		long u,v;
		cin >> u >> v;
		edge[u].push_back(v);
		edge[v].push_back(u); 
	}

	#ifdef NOT_ALL_CONNECTED // グラフが非連結の場合
		FOR(i,V_START,V+V_START) 
			if(ord[i] == -1)
				dfs(i,-1,1);
	#endif

	#ifndef NOT_ALL_CONNECTED // グラフが連結の場合
		dfs(1,-1,1);
	#endif

	#ifdef BRIDGE
		VP bridge;
		long bridge_count = 0;

		FOR(i,V_START,V+V_START){
			if (ord[i] == low[i]) {
				bridge.push_back(make_pair(i,pre[i]));
				bridge_count++;
			}
		}

		REP(i,bridge.size()) cout << bridge[i].first << "-" << bridge[i].second << endl;
	#endif

	#ifdef ARTICULATION_POINT
		VL point;
		long point_count = 0;
		char root_count = 0;
		FOR(i,V_START,V+V_START){
			if (pre[i] == -1) continue;
			if (pre[i] == 1) root_count++;
			else {
				if (ord[pre[i]] <= low[i]) {
					point.push_back(pre[i]);
					point_count++;
				}
			}
		}
		if(root_count >= 2) {
			point.push_back(1);
			point_count++;
		}

		SORT(point);
		point.erase(unique(point.begin(),point.end()),point.end());
		REP(i,point.size()) cout << point[i] << endl;
		//cout << "関節点の個数:" << point_count << endl;

	#endif

	#ifdef DEBUG
		dump1d_arr(ord);
		dump1d_arr(low);
		dump1d_arr(pre);
	#endif

	return 0;
}




Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define M 1000000007
#define MM 998244353
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define r2 1.41421356237
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  string s,ss,t;
  cin>>s>>t;
  int k=M;
  int a=s.size();
  int b=t.size();
  for(int i=0;i<=a-b;i++) {
  	ss=s.substr(i,b);
  	int ans=0;
  	for(int j=0;j<b;j++) { if(ss[j]!=t[j]) { ans++; } }
  		k=min(ans,k);
  }
  cout<<k;
  //}  
  return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

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

		int c = Math.max(a+b,a-b);
		int d = Math.max(c, a*b);

		System.out.println(d);



	}

}


Measured memory_bytes: 21716
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 1;
    switch (s) {
      case "RRR":
        ans = 3;
        break;
      case "RRS":
      case "SRR":
        ans = 2;
        break;
      case "SSS":
        ans = 0;
        break;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if (h == 0 && w == 0) {
				scanner.close();
				return;
			}
			
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 33380
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;

int main(){
        int A[3];
        cin >> A[0] >> A[1] >> A[2];
        sort(A,A+3);
        int cost = 0;
        cost+=A[2]-A[1];
        int tmp = A[1]-A[0];
        if(tmp%2==0) cost+=tmp/2;
        else cost+= tmp/2 + 2;
        cout << cost << endl;

        return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};  // UnionFind uf(N+1);  // 1-indexed

set<int> sx[200005];
set<int> sy[200005];

int main() {
  // x座標をrootとする、10**5+1のupper_bound
  int N;
  cin >> N;
  UnionFind uf(200005);   // 0-indexed
  vector<int> Xlist;
  vector<int> Ylist;
  rep(i, N) {
    int X, Y;
    cin >> X >> Y;
    Y += 1e5;
    Xlist.push_back(X);
    Ylist.push_back(Y);
    uf.unite(X, Y);
  }
  ll ans = 0;
  for (int x : Xlist) {
    int root = uf.root(x);
    sx[root].insert(x);
  }
  for (int y : Ylist) {
    int root = uf.root(y);
    sy[root].insert(y);
  }
  for (int i = 1; i < 100001; i++) {
    if (i != uf.root(i)) continue;
    ans += ll(sz(sx[i])) * sz(sy[i]);
  }
  ans -= N;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 28264
/// author: Mr.Hakimov

#include <bits/stdc++.h>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define pf push_front
#define Pb pop_back
#define Pf pop_front
#define all(x) (x).begin(), (x).end()
#define fin(s) freopen(s, "r", stdin);
#define fout(s) freopen(s, "w", stdout);

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll;
typedef long double ld;

int TN = 1;

void solve() {
	int a;
	int b;
	int c;
	
	cin >> a >> b >> c;
	
	int k;
	cin >> k;
	
	int x = min(k, a);
	k -= x;
	a -= x;
	
	ll answer = 0;
	answer += x;
	
	x = min(k, b);
	b -= x;	
	k -= x;
	
	x = min(k, c);
	c -= x;
	answer -= x;
	
	cout << answer;
}

int main() {
    auto start = chrono::steady_clock::now();
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    /// =========================================
    /// fin("input.txt"); fout("output.txt");
    /// fin("file.in"); fout("file.out");
    /// cin >> TN;
    /// =========================================

    while (TN--) {
        solve();
    }

    auto finish = chrono::steady_clock::now();
    auto elapsed_ms = chrono::duration_cast<chrono::milliseconds>(finish - start);
    cerr << endl << "Time: " << elapsed_ms.count() << " ms\n";

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int X,A,B,C;
    cin >> X >> A >> B;
    C = X - A;
    if(C + B <= X) cout << "delicious" << endl;
    else if(X < C + B && C + B <= 2*X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#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 ld long double
#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 mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; ll x; cin>>n>>x;
    vll a(n);
    rep(i,n) cin>>a[i];
    ll ans=0;
    rep(i,n-1){
        if (a[i]+a[i+1]<=x) continue;
        ll c = a[i]+a[i+1]-x;
        if (a[i+1]>=c){
            a[i+1]-=c;
        }else{
            a[i+1]=0;
            a[i]-=c-a[i+1];
        }
        ans+=c;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  vector<long long int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    v[i]=-v[i];
  }
  sort(v.begin(),v.end());
  double res_max=0;
  for(int i=0;i<a;i++) res_max+=v[i];
  res_max/=a;
  res_max=-res_max;
  long long int last=v[a-1];
  int num=upper_bound(v.begin(),v.end(),last)-lower_bound(v.begin(),v.end(),last);
  int ra=a-(lower_bound(v.begin(),v.end(),last)-v.begin());
  int rb=b-(lower_bound(v.begin(),v.end(),last)-v.begin());
  rb=min(rb,num);
  if(v[0]!=v[a-1]) rb=ra;

  //cnt=numCr+numCr+1+...+numCb;
  vector<vector<long long int>> c(num+1,vector<long long int>(num+1,1));
  for(int i=2;i<=num;i++){
    for(int j=1;j<i;j++){
      c[i][j]=c[i-1][j]+c[i-1][j-1];
    }
  }
  cout<<setprecision(10)<<fixed;
  cout<<res_max<<endl;
  long long int sum=0;
  for(int i=0;i<=rb-ra;i++){
    sum+=c[num][i+ra];

  }
  cout<<sum<<endl;
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){

    ll N, M;
    cin >> N >> M;

    
    vector<ll > in(N + 2, 0);
    for(ll i = 1; i <= N; i++){
        cin >> in[i];
    }

    ll ans = 0;
    ll k_ans = 0;
    ll g_ans = 0;
    //奇数番だけ食べ続ける
    for(ll i = 1; i <= N; i++){
        ll l = in[i-1] + in[i] - M;
        //ll r = in[i+1] + in[i] - M;
        ans += max(l, ll(0));
        in[i] -= max(l, ll(0));
        //cout << in[i] << " ";
    }


    //ll ans = min(k_ans, g_ans);

    cout << ans << endl;


}

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

int main() {
  int N, M,A;
  cin >> N >> M;

  A = 0;
  
  for (int i = 0; i < M; i++) {
    int t;
    cin >> t;
    
    A += t;
  }
  
  if (N - A >= 0) cout << N - A << endl;
  
  else cout << -1 << endl;

    

}


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

int main() {
    int ta, tb, ra, rb;
    cin >> ta >> tb >> ra >> rb;
    function<string()> solve = [&]() {
        if(ra == -1 || rb == -1) {
            if(ta < tb) return "Alice";
            else if(ta == tb) return "Draw";
            else return "Bob";
        } else {
            if(ra > rb) return "Alice";
            else if(ra == rb) return "Draw";
            else return "Bob";
        }
    };
    cout << solve() << endl;
    return 0;
}



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

import bisect

s = sorted(s)

res = 0
for i in range(n)[::-1]:
    for j in range(i)[::-1]:
        if s[j] <= s[i] / 2:
            break
        k = bisect.bisect_left(s, s[i]-s[j]+1)
        res += max(0, j-k)
print(res)

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

int main(){
	int a,  b, c, d;
	cin >> a >> b >> c >> d;
	if(b < c || d < a){
		cout << 0 << endl;
	}
	else if(c >= a && c <= b && d > b){
		//cout << 1 << endl;
		cout << b-c << endl;
	}
	else if(a >= c && a <= d && b > d){
		//cout << 2 << endl;
		cout << d-a << endl;
	}
	else if(c >= a && d <= b){
		//cout << 3<< endl;
		cout << d-c << endl;
	}
	else if(a >= c && b <= d){
		//cout << 4 << endl;
		cout << b-a << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
const double eps=1e-9;

struct Point{
	double x,y;
};
typedef struct Point Point;
struct Line{
	double a,b,c;//ax+by+c=0
};
typedef struct Line Line;

void input(Point *ret){
	scanf("%lf %lf",&ret->x,&ret->y);
}
Line make(Point a,Point b){
	//(ax-bx)(y-ay)=(ay-by)(x-ax)
	//(ay-by)x+(bx-ax)y+ay(ax-bx)+ax(by-ay)=0
	Line ret;
	ret.a=a.y-b.y;
	ret.b=b.x-a.x;
	ret.c=a.y*(a.x-b.x)+a.x*(b.y-a.y);
	return ret;
}

int main(){
	int n;	scanf("%d",&n);
	while(n--){
		Point a,b,c,d;
		input(&a);	input(&b);	input(&c);	input(&d);
		Line l1=make(a,b);
		Line l2=make(c,d);
		if(-eps<l1.b&&l1.b<eps){
			if(-eps<l2.b&&l2.b<eps)	printf("YES\n");
			else 	printf("NO\n");
		}
		else if(-eps<l2.b&&l2.b<eps)	printf("NO\n");
		else{
			double l1a=l1.a/l1.b;
			double l2a=l2.a/l2.b;
			if(-eps<l1a-l2a&&l1a-l2a<eps)	printf("YES\n");
			else 	printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 620
import sys

input=sys.stdin.readline

N,A,B=map(int,input().split())
X=list(map(int,input().split()))

data=[]
for i in range(0,N-1):
    data.append(A*(X[i+1]-X[i]))

data.sort(reverse=True)

ans=sum(data)
s=sum(data)
for i in range(0,N-1):
    s=s-data[i]+B
    ans=min(ans,s)

print(ans)


Measured memory_bytes: 60396
#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

int main() {
    init_io();
    ll N;
    cin >> N;
    V<PLL> A;
    for(ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.emplace_back(a, i);
    }
    A.emplace_back(0, -1);
    sort(ALL(A), [](const auto &a, const auto &b) { return a.first != b.first ? a > b : a < b; });
    DEBUG(A);
    ll idx = 0;
    V<ll> cnt(N, 0);
    ll preh;
    while(idx < N) {
        ll nidx = idx + 1;
        while(A[nidx].second > A[idx].second) nidx++;
        ll sum = idx * (preh - A[nidx].first);
        preh = A[nidx].first;
        for(ll i = idx; i < nidx; i++) sum += A[i].first - A[nidx].first;
        cnt[A[idx].second] = sum;
        idx = nidx;
    }
    for(ll e : cnt) cout << e << endl;
    return 0;
}


Measured memory_bytes: 3440
n=input()
n_len=len(n)
if n[n_len-1]==str(3):
  print("bon")
elif n[n_len-1]==str(0) or n[n_len-1]==str(1) or n[n_len-1]==str(6) or n[n_len-1]==str(8):
  print("pon")
else:
  print("hon")


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

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


int main()
{
    long long h,w,a,b;
	long long nm;
	cin >> h;
	cin >> w;
	cin >> a;
	cin >> b;
	/*vector<vector<double>> a(2, vector<double>(n));
	vector<int> b(n);
	*/
	nm = 2*1000000 / 3;

	/*long long kai;
	kai = 1;
	for (long long i = 1; i <= nm; i++) {
		kai = (kai * i) % mod;
	}*/

   
	//cout << fel(kai,mod-2);

	vector<long long> sei(nm), gyaku(nm);

	long long t = 1;
	for (long long i = 1; i < nm; i++) {
		t = (t * i) % mod;
		sei[i] = t;
	}
	sei[0] = 1;
	t = 288540294;
	for (long long i = nm; i>0; i--) {
		t = (t * i) % mod;
		gyaku[i-1] = t;
	}


	long long sum = 0;
	
	for (long long i = 0; i <= (h - a - 1); i++) {
		long long kai = 1;
		kai = (kai * sei[i + b - 1]) % mod;
		kai = (kai * gyaku[i]) % mod;
		kai = (kai * gyaku[b-1]) % mod;
		kai = (kai * sei[h+w-i-b -2]) % mod;
		kai = (kai * gyaku[h-i-1]) % mod;
		kai = (kai * gyaku[w-b-1]) % mod;
		sum = (sum + kai)%mod;
	}

	cout << sum;

}


Measured memory_bytes: 10624
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); //品数
        int M = sc.nextInt(); // 商品券の枚数

        long[] prices = new long[N]; // ねだん
        for (int i = 0; i < N; i++) {
            prices[i] = sc.nextLong();
        }
        Arrays.sort(prices);

        List<Long> are = LongStream.rangeClosed(0, 30)
                .map(l -> (long) Math.pow(2, l))
                .mapToObj(Long::valueOf)
                .collect(Collectors.toList());

        int count = 0;
        loop: for (int i = 30; i >= 0; i--) {
            if (prices[N - 1] < are.get(i)) {
                continue;
            }
            
            for (int j = N - 1; j >= 0; j--) {
                
                if(prices[j] >= are.get(i)) {
                    prices[j] /= 2;
                    count++;
                }
                
                if (count >= M) {
                    break loop;
                }

            }
            Arrays.sort(prices);
        }
        System.out.println(Arrays.stream(prices).sum());
    }

}


Measured memory_bytes: 62320
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=998244353;
const long long int INF=99999999999999999;

long long int n,m,res,di=1;
long double x[20],y[20],sum=0;
string str;
int main() {
	cout << fixed << setprecision(10);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    for(int i=2;i<=n;i++){
        di *= i;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=2.0*di/n*sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    cout<<sum/(long double)di;
} 


Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(n: usize, a: [usize; n], b: [usize; n]);

    if let Some(ans) = solve(n, &a, &b) {
        println!("Yes");
        println!("{}", ans.iter().map(|&v| v.to_string()).join(" "))
    } else {
        println!("No")
    }
}

fn solve(n: usize, a: &[usize], b: &[usize]) -> Option<Vec<usize>> {
    let mut cnt = vec![0; n];
    for x in [a, b].concat() {
        cnt[x - 1] += 1;
    }
    if cnt.iter().any(|&c| c > n) {
        return None;
    }
    let b = [b; 2].concat();
    let mut d = 0;
    for i in 0..n {
        while i + d < n && a[i] >= b[i + d] {
            d += 1;
        }
    }
    Some((&b[d..d + n]).into())
}


Measured memory_bytes: 14048
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;

class Node {
  public int id;
  public Node[] friends;

  public int count;

  this(int id) {
    this.id = id;
  }
  
  alias opCmp = Object.opCmp;
  int opCmp(Node b) {
    return this.id == b.id ? 0 : this.id < b.id ? -1 : 1;
  }
}

class Nodes {
  public int origin;
  public Node[int] nodes;

  this(int size, int origin = 1) {
    this.origin = origin;
    size.iota.each!((i) {
      auto id = origin + i;
      this.nodes[id] = new Node(id);
    });
  }

  void setPath(int from, int to) {
    this.nodes[from].friends ~= this.nodes[to];
    this.nodes[to].friends ~= this.nodes[from];
  }

  Node root() {
    return this.nodes[origin];
  }

  void apply(int id, void delegate(Node) d) {
    d(this.nodes[id]);
  }

  void applyAllFromRoot(void delegate(Node) d) {
    auto cursors = [this.root()];
    bool[int] checked;
    while(!cursors.empty) {
      foreach(node; cursors) {
        d(node);
        checked[node.id] = true;
      }
      cursors = cursors.map!(node => node.friends)
        .joiner.filter!(node => node !is null && node.id !in checked).array;
    }
  }
}

void main() {
  int N, Q; readf("%d %d\n", &N, &Q);

  auto nodes = new Nodes(N);
  foreach(i; 1..N) {
    int from, to; readf("%d %d\n", &from, &to);
    nodes.setPath(from, to);
  }
  
  foreach(i; 0..Q) {
    int nodeId, increments; readf("%d %d\n", &nodeId, &increments);
    nodes.apply(nodeId, (node){ node.count += increments; });
  }

  int[] totals = new int[N+1];
  nodes.applyAllFromRoot((node) {
    totals[node.id] += node.count;
    node.friends.each!(n => totals[node.id] += totals[n.id]);
  });

  totals.popFront();
  totals.to!(string[]).join(" ").writeln;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a, b, s, f, result = 0;
   cin >> a >> b >> n;
   rep(i, n) {
     cin >> s >> f;
     if (s < b && a < f) result = 1;
   }
   cout << result << endl;
	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

void solve(){
	int cnt = 1 ;
	int n , x , t ;
	re(n,x,t);
	while(cnt*x<n) cnt++;
	cout << cnt * t << endl; 
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3576
def gcd (a, b):
	x1, x2 = 0, 1
	y1, y2 = 1, 0
	q = 0
	while b != 0:
		x1, x2 = x2, x1 - q * x2
		y1, y2 = y2, y1 - q * y2
		q = a // b
		a, b = b, a % b
	return a, x2, y2



N = int(input())
*A, = map(int, input().split())

d_left = [0] * N
d_right = [0] * N
d_left[0] = A[0]
d_right[N-1] = A[N-1]
for i in range(1, N):
	d_left[i], _, _ = gcd(d_left[i-1], A[i])
	d_right[N-i-1], _, _ = gcd(d_right[N-i], A[N-i-1])

max_d = max(d_right[1], d_left[N-2])
for i in range(1, N-1):
	max_d = max(max_d, gcd(d_left[i-1], d_right[i+1])[0])
print(max_d)


Measured memory_bytes: 14400
import sys
import numpy as np
from numba import njit
from heapq import heappop, heappush

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(b1[:],i8,i8,i8,i8,i8)', cache=True)
def main(C, H, W, S, T, K):
    INF = 10**18
    N = H * W
    q = [5 * S]
    dist = np.full((5 * N), INF, np.int64)
    dist[5 * S] = 0
    move = [0, 1, -1, W, -W]
    B = 5 * N + 10
    while q:
        x = heappop(q)
        dist_x, x = divmod(x, B)
        if dist_x > dist[x]:
            continue
        v, d = divmod(x, 5)
        if d == 0:
            # どちらかに進む
            for i in range(1, 5):
                w = v + move[i]
                y = 5 * w + i
                dist_y = dist_x + 1
                if C[w] and dist_y < dist[y]:
                    dist[y] = dist_y
                    heappush(q, B * dist_y + y)
        else:
            # 直進する
            if dist_x % K != 0:
                w = v + move[d]
                y = 5 * w + d
                dist_y = dist_x + 1
                if C[w] and dist_y < dist[y]:
                    dist[y] = dist_y
                    heappush(q, B * dist_y + y)
            # 止まって向きを変える権利を得る
            y = 5 * v
            dist_y = dist_x + (-dist_x) % K
            if dist_y < dist[y]:
                dist[y] = dist_y
                heappush(q, B * dist_y + y)
    x = dist[5 * T]
    if x == INF:
        return -1
    return dist[5 * T] // K

H, W, K = map(int, readline().split())
x1, y1, x2, y2 = map(int, readline().split())

C = np.zeros((H + 2, W + 2), np.bool_)
C[1:-1, 1:-1] = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'.'
C = C.ravel()
H += 2
W += 2

S = W * x1 + y1
T = W * x2 + y2

print(main(C, H, W, S, T, K))

Measured memory_bytes: 224916
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
vector<pair<int,int> > scvec;
vector<vector<int> > adj;
vector<int> color;
void paint(int v, int s, int c)
{
  if(s<0) return;
  int olds=scvec[v].first, oldc=scvec[v].second;
  if(s<=olds) return;
  scvec[v]=make_pair(s,c);
  for(int av:adj[v]) paint(av, s-1, c);
  if(!color[v]) color[v]=c;
  
}
int main(void)
{
  int n, m;
  cin >> n >> m;
  scvec.assign(n+1,pair<int,int>(-1,0));
  adj.assign(n+1,vector<int>());
  color.assign(n+1,0);
  REP(i,m) {
    int a,b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int q;
  cin >> q;
  vector<int> v(q),d(q),c(q);
  REP(i,q) cin >> v[i] >>d[i] >>c[i];
  for(int i=q-1;i>=0;--i) paint(v[i],d[i],c[i]);
  REP(i,n) cout << color[i+1] << endl;
  return 0;
}

Measured memory_bytes: 8824
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s;cin>>n;
  vector<int>a(n),b(n-1);
  for(int i=0;i<n-1;i++)cin>>b.at(i);
  a.at(0)=b.at(0);
  s=a.at(0);
  for(int i=1;i<n;i++){
    if(i==n-1)a.at(i)=b.at(n-2);
    else a.at(i)=min(b.at(i-1),b.at(i));
    s+=a.at(i);
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
a[2][101],n,m,i,j,c,p;main(s){for(;scanf(m="%d",&n),n;printf(m>210?"NA\n":"%d\n",m)){for(i=2;i--;)for(j=0;j-n;scanf(m,a[i]+j++));for(i=2;i--;m>c?m=c:0)for(j=i,c=p=0;s=a[j][p],c<220&&s==2|n+~p;)p<n&s<2?s-1|a[j][p+1]-1?p+=2,j=1&~j,++c:++p:--p;}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  int x=n*800;
  int y=n/15*200;
  cout << x-y << endl;

  		 

  return 0;
    

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

	long long int A,B,C,D;

	cin >> A >> B >> C >> D;

	while(A>0){
		C = C - B;
		if(C <= 0){
			cout << "Yes";
		return 0;
		}
		A = A - D;
	}
	
	cout << "No";
	return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cmath>


using namespace std;

int main(){
    int  n;
    cin>>n;
    
    long long input,sub,min;

    for(int i=0;i!=n;++i){
        cin>>input;
        if(i==0){
            min=input;
            continue;
        }
        if(i==1){
            sub=input-min;
            min=((min<input)?min:input);
           
            //cout<<"min:"<<min<<endl;
            //cout<<"sub:"<<sub<<endl;
            continue;
        }
      
        sub=((input-min)>=sub)?(input-min):sub;
        min=((min<input)?min:input);
        //cout<<"min:"<<min<<endl;
        //cout<<"sub:"<<sub<<endl;
       
    }
    
    cout<<sub<<endl;
             
}



Measured memory_bytes: 3120
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc150_a();
	}
  
  	public static void solve_abc150_a(){
		
		Scanner sc = new Scanner(System.in);
		
		int K = sc.nextInt();
		int X = sc.nextInt();
		
		if(500 * K >= X) System.out.println("Yes");
		else System.out.println("No");
		
		sc.close();
		
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    int N; cin >> N;
    vector<int> a(N),b(N),c(N-1);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    for (int i = 0; i < N-1; i++) cin >> c[i];
    int ans = b[a[0]-1];
    for (int i = 1; i < N; i++){
        ans += b[a[i]-1];
        if (a[i-1] + 1 == a[i]){
            ans += c[a[i-1]-1];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void){
  vector<vector<int>> g{{1,3,5,7,8,10,12},{4,6,9,11},{2}};
  
  int x,y;
  int g_x, g_y;
  
  cin >> x >> y;
  
  for(int i = 0 ; i < 3 ; i++){
    auto itr_x = find(g[i].begin(), g[i].end(), x);
    auto itr_y = find(g[i].begin(), g[i].end(), y);
    
    if(itr_x != g[i].end()) g_x = i;
    if(itr_y != g[i].end()) g_y = i;
  }
  
  cout << (g_x == g_y ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    string n;
    cin >> n;

    int m = n.size();
    if(n[m-1] == '3'){
        cout << "bon";
    } else if(n[m-1] == '0' || n[m-1] == '1' || n[m-1] == '6' || n[m-1] == '8'){
        cout << "pon";
    } else cout << "hon";

}

void solve_B(){
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();

    if(n <= k) cout << s;
    else{
        for(int i = 0; i < k; i++){
            cout << s[i];
        }
        cout << "...";
    }
}

int main(void){
    solve_B();
    
    return 0;
}

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

int main() {
    string today;
    cin >> today;
    if(today == "Sunny"){
        cout << "Cloudy" << endl;
        return 0;
    }

    if(today == "Cloudy"){
        cout << "Rainy" << endl;
        return 0;
    }

    cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int n, k, p;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> k >> p;
		if(k % p)
			cout << k % p << endl;
		else
			cout << p << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {bool F=K=0;char C=getchar();while(C<'0'||C>'9')
{if(C=='-')F=1;C=getchar();}while(C<='9'&&C>='0')K=(K<<1)+(K<<3)+C-'0',C=getchar();if(F)K=-K;}
template < class R > inline bool Checkmax( R &A , R B ) { return A > B ? A = B , 1 : 0 ; }
template < class R > inline bool Checkmin( R &A , R B ) { return A < B ? A = B , 1 : 0 ; }
const int MaxN = 100000 + 10 ;
int N , Ans ;
pair<int,int> Num[MaxN] ;
int main() {
	Readin( N ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		Readin( Num[i].first ) ;
		Num[i].second = i ;
	}
	sort( Num + 1 , Num + 1 + N ) ;
	for(register int i = 0 ; ++i <= N ; )
		Ans += ( Num[i].second & 1 ) xor ( i & 1 ) ;
	cout << ( Ans >> 1 ) << endl ;
	return 0 ;
}

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

int n,q,u,v,w,ans=0;
int father[200005],visited[200005];

int find(int x)
{
	if (x!=father[x])  father[x]=find(father[x]);
	return father[x];
}

signed main()
{
	cin>>n>>q;
	for (int i=1;i<=n;i++)  father[i]=i;
	for (int i=1;i<=q;i++)
	{
		cin>>u>>v>>w;
		father[find(v)]=find(u);
	}
	for (int i=1;i<=n;i++)  father[i]=find(i);
	for (int i=1;i<=n;i++)  visited[father[i]]++;
	for (int i=1;i<=n;i++)
	{
		if (visited[i])  ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main(){
  ll N,D,count=0;
  cin>>N>>D;
  vector<ll> X(N);
  vector<ll> Y(N);
  for(ll i=0; i<N; i++){
    cin>>X.at(i);
    cin>>Y.at(i);
    ll xx=X.at(i)*X.at(i);
    ll yy=Y.at(i)*Y.at(i);
    if(sqrt(xx+yy)<=D){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 6452
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5+10;

int main(){
  int n,k,p[MAX],le[MAX],i,flag,
      sum,minh[MAX],maxh[MAX],minl,maxl,mins,maxs;
  
  scanf("%d%d",&n,&k);
  
  for(i=0;i<n;i++)
    scanf("%d",&p[i]);
  
  le[0]=1;
  for(i=1;i<n;i++)
    if(p[i] > p[i-1]){
      le[i] = le[i-1]+1;
    }else{
      le[i] = 1;
    }
  
  minl = 0;mins = 0;
  maxl = 0;maxs = 0;
  minh[0] = 0;maxh[0] = 0;
  for(i=1;i<k;i++){
    while(mins <= minl && p[minh[minl]] > p[i])
      minl--;
    minl++;
    minh[minl] = i;
    
    while(maxs <= maxl && p[maxh[maxl]] < p[i])
      maxl--;
    maxl++;
    maxh[maxl] = i;
  }
  
  sum=0;
  flag=0;
  if(le[k-1] >= k)
    flag=1;
  else
    sum++;
  
  for(i=0;i<n-k;i++){
    while(mins <= minl && p[minh[minl]] > p[i+k])
      minl--;
    minl++;
    minh[minl] = i+k;
    
    while(maxs <= maxl && p[maxh[maxl]] < p[i+k])
      maxl--;
    maxl++;
    maxh[maxl] = i+k;
    
    if(le[i+k] >= k)
      flag=1;
    else if(minh[mins] != i || maxh[maxs] != i+k)
      sum++;
    
    if (minh[mins] == i)
      mins++;
    if (maxh[maxs] == i)
      maxs++;
  }
  if(flag)sum++;
  printf("%d\n",sum);
  return 0;
}

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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] dice = new int[2][n];
        for(int i = 0; i<n; i++){
            dice[0][i] = sc.nextInt();
            dice[1][i] = sc.nextInt();
        }

        int[] count = new int[n-2];
        for(int i = 0; i<n-2; i++){
            for(int j = i; j<i+3; j++){
                if(dice[0][j] == dice[1][j]){
                    count[i]++;
                }
            }
        }

        Arrays.sort(count);
        if(count[n-3] == 3){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 36112
#include<bits/stdc++.h>
using namespace std;
using LL=int64_t;
const int INF=0x3f3f3f3f;
const int maxn=1e7+5;

set<int>ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>x;
        ans.insert(x);
    }
    cout<<ans.size();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n, m; cin >> n >> m;
    ll ans = 0;
    ans = 1900*m + 100*(n-m);
    rep(i, m){
        ans *= 2;
    }
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 504
S = input().split(" ")
N = int(S[0])
M = int(S[1])

def calculate(n,m):

    if n == 1 and m == 1:
        return 1

    if n == 1:
        return m - 2

    if m == 1:
        return n - 2

    return (n - 2) * (m - 2)
result = calculate(N,M)
print(result)

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

struct State{
    int count,price;
    State(int count, int price): count(count),price(price){}
};

bool operator < (const State &e, const State &f){
    return e.count!=f.count ? e.count < f.count : e.price>f.price;
}

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

    int n;
    while(cin>>n,n){
        vector<int> p(n+1);
        for(int i=1;i<=n;i++) cin>>p[i];
        vector<vector<State>> dp(n+1,vector<State>(66666,State(-1,0)));
        dp[0][0]=State(0,0);
        for(int i=0;i<n;i++){
            for(int j=0;j<=50000;j++){
                int cnt=dp[i][j].count,pri=dp[i][j].price;
                if(cnt<0) continue;
                dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
                int r=(1000-p[i+1]%1000)%1000;
                dp[i+1][j+r]=max(dp[i+1][j+r],State(cnt,pri+p[i+1]));
                if(j+r>=500) dp[i+1][(j+r)-500]=max(dp[i+1][(j+r)-500],State(cnt+1,pri+p[i+1]));
            }
        }
        State res=dp[n][0];
        for(int i=1;i<=50000;i++) res=max(res,dp[n][i]);
        cout<<res.count<<" "<<res.price<<endl;
    }
}


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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> a(n),b(n);
  set<long> s;
  for(long i=0;i<n;i++) {
    cin >> a[i];
    b[a[i]-1]=i;
  }
  s.insert(-1);
  s.insert(n);
  for(long i=0;i<n;i++) {
    auto itr2=s.upper_bound(b[i]);
    itr2--;
    auto itr=itr2;
    itr2++;
    ans+=(i+1)*(b[i]-*(itr))*(*(itr2)-b[i]);
    s.insert(b[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 15592
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <complex>
using namespace std;

typedef complex<double> P;

struct ComplexLess {
  bool operator()(const P& lhs, const P& rhs) const {
    return (lhs.real() == rhs.real()) ? (lhs.imag() < rhs.imag()) : (lhs.real() < rhs.real());
  }
};

int main() {
  int m;
  while (cin >> m, m) {
    vector<P> asterism(m);
    for (int i = 0; i < m; ++i) {
      int x, y; cin >> x >> y;
      asterism[i] = P(x, y);
    }

    set<P, ComplexLess> stars;
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
      int x, y; cin >> x >> y;
      stars.insert(P(x, y));
    }

    for (P p : stars) {
      P diff = p - asterism[0];
      auto pred = [&](P q){ return stars.count(q + diff); };
      if (all_of(asterism.begin(), asterism.end(), pred)) {
        cout << diff.real() << " " << diff.imag() << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1328
from collections import deque
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

n=int(input())

tree=[[] for i in range(n)]
for i in range(n-1):
  a,b,c=nii()
  a-=1
  b-=1
  tree[a].append([b,c])
  tree[b].append([a,c])

q,k=nii()
k-=1

dist=[-1 for i in range(n)]
dist[k]=0

que=deque()
que.append(k)

while que:
  x=que.popleft()
  for tb,tc in tree[x]:
    if dist[tb]==-1:
      que.append(tb)
      dist[tb]=dist[x]+tc

for i in range(q):
  x,y=nii()
  x-=1
  y-=1
  print(dist[x]+dist[y])

Measured memory_bytes: 50032
n = int(input())
a = list(map(int,input().split()))
color = [False]*8
almighty = 0
for i in a:
    if i<3200:
        color[i//400] = True
    else:
        almighty += 1
c = color.count(True)
if almighty==0:
    print(c,c)
else:
    print(max(1,c),c+almighty)


Measured memory_bytes: 3060