akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
  int n,ans=3*1e5,l=0,r=0;
  string s;
  cin>>n>>s;
  for(int i=1;i<n;i++)if(s[i]=='E')r++;
  for(int i=0;i<n;i++){
    ans=min(ans,l+r);
    if(s[i]=='W')l++;
    if(s[i+1]=='E')r--;
  }
  cout<<ans<<endl;
  return 0;
}

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

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

    int n;
    cin >> n;
    int tmp = sqrt(n);
    if(tmp * tmp == n);
    else tmp = sqrt(n - 1);
    cout << tmp * tmp << endl;

    return 0;
}

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

template<typename T, T max_v>
struct StarrySky{
    size_t n;
    vector<T> dat, lazy;

    StarrySky(vector<T> a){
        n = 1;
        while(n<a.size()) n <<= 1;
        dat.resize(2*n-1,max_v);
        lazy.resize(2*n-1,0);
        for(size_t i=0;i<a.size();i++) dat[i+n-1]=a[i];
        for(int i=n-2;i>=0;i--) dat[i]=min(dat[i*2+1],dat[i*2+2]);
    }

    inline void propagation(int k,int l,int r){
        dat[k]+=lazy[k];
        if((size_t)k<n-1){    // 最下段でない場合
            lazy[2*k+1]+=lazy[k];
            lazy[2*k+2]+=lazy[k];
        }
        lazy[k]=0;
    }

    // add to [a,b)
    void add(int a, int b, T x, int k, int l, int r){
        propagation(k,l,r);
        if(r<=a||b<=l) return; // no overlap area
        if(a<=l&&r<=b){ // [a,b) contains [l,r)
            lazy[k]+=x;
            propagation(k,l,r);
        }else{ // overlap
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }
    void add(int a,int b, T x){
        add(a,b,x,0,0,n);
    }

    // min of [a,b)
    T get(int a,int b,int k,int l,int r){
        propagation(k,l,r);
        if(r<=a||b<=l) return max_v;
        if(a<=l&&r<=b){ // [a,b) contains [l,r)
            return dat[k];
        }else{ // overlap
            T lv=get(a,b,2*k+1,l,(l+r)/2);
            T rv=get(a,b,2*k+2,(l+r)/2,r);
            return min(lv,rv);
        }
    }
    T get(int a,int b){
        return get(a,b,0,0,n);
    }
};

int main(){
    int n,q; cin >> n >> q;
    vector<long long> a(n,0);
    StarrySky<long long,(1LL<<60)> seg(a);
    for(int i=0;i<q;i++){
        int type; cin >> type;
        if(type == 0){
            int s,t,x; cin >> s >> t >> x;
            seg.add(s,t+1,x);
        }else{
            int s,t; cin >> s >> t;
            cout << seg.get(s,t+1) << endl;
        }
    }
}



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

int p_num[51];

//Level n のベーガーをlastまで食べる
long count_p(int n, long last){
    // DP
    long length = pow(2,n+2) - 3;
    if(last == length && p_num[n] != -1){
        return p_num[n];
    }
    
    //再起止め
    if(last<=1){
        return 0;
    }
    if(n==0){
        return 1;
    }
    
    
    //順当に数える
    long cnt = 0;
    
    if(last >= pow(2,n+1)-2){
        cnt += count_p(n-1, pow(2,n+1)-3);
    }else{
        cnt += count_p(n-1, last-1);
        return cnt;
    }
    //cout << cnt << "po";
    if(last >= pow(2,n+1)-1){
        cnt += 1;
    }
    
    if(last >= pow(2,n+2)-4){
        cnt += count_p(n-1, pow(2,n+1)-3);
        p_num[n] = cnt;
    }else{
        cnt += count_p(n-1, last - (pow(2,n+1) - 1));
        
    }
    
    return cnt;
}

int main(void){
    p_num[0]=1;
    for(int i=1;i<51;i++){
        p_num[i] = -1;
    }
    // Your code here!
    long N, X;
    cin >> N >> X;
    long ret = 0;
    ret = count_p(N, X);
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll 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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)

class Point {
public:
    double x,y;
    Point(double x,double y):x(x),y(y){}
    Point():x(0),y(0){}

    Point operator + (Point p) {return Point(x + p.x,y + p.y);}
    Point operator - (Point p ){return Point(x - p.x,y - p.y);}
    Point operator * (double a){return Point(x*a,y*a);}
    Point operator / (double a){return Point(x/a,y/a);}

    double abs(){return sqrt(norm());}
    double norm(){return x * x + y * y;}

    bool operator < (const Point & p) const {
      return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
      return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }

    void set(double x,double y) {
      this->x = x;
      this->y = y;
    }


};

struct Segment{
    Point p1,p2;
};

typedef Point Vector;

double dot(Vector a, Vector b){
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a,Vector b){
  return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a,Vector b){
  return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
  return equals(dot(s1.p2 - s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a, Vector b){
  return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
  return equals(cross(s1.p2 - s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
  Point vec1,vec2;
  vec1 = s.p2 - s.p1;
  vec2 = p - s.p1;
  return s.p1 + vec1 * dot(vec1,vec2) / vec1.norm();
}

Point reflect(Segment s,Point p){
  return p + (project(s,p) - p)* 2;
}

int main(){
  double x1,x2,y1,y2,x,y;
  cin >> x1 >> y1 >> x2 >> y2;
  vector<Vector> p(3);
  p[0] = Point(x1,y1);
  p[1] = Point(x2,y2);
  Segment s;
  s.p1 = p[0];
  s.p2 = p[1];
  ll q;
  cin >> q;
  rep(i,q){
    cin >> x >> y;
    p[2] = Point(x,y);
    Point vec;
    vec = reflect(s,p[2]);
    printf("%.15f %.15f\n",vec.x,vec.y);
  }
}


Measured memory_bytes: 3292
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    String ans = "No";
    if((500 * k) >= x) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
import collections

n, m = [ int(v) for v in input().split() ]
connect_list = [ [] for i in range(n) ]
for i in range(m):
    a, b = [ int(v)-1 for v in input().split() ]
    connect_list[a].append(b)
    connect_list[b].append(a)


def dfs(a):
    color = [ 0 for i in range(n) ]
    color[a] = 1
    stack = collections.deque([a])
    r = 0

    while stack:
        s = stack.pop()
        color[s] = 2
        r += 1
        for i in connect_list[s]:
            if color[i] == 0:
                color[i] = 1
                stack.append(i)
    return r

x, y = dfs(0), dfs(1)
x, y = max(x, y), min(x, y)

def part_edge(a):
    return a*(a-1)//2

x = n - y
total_edge = part_edge(x) + part_edge(y)
print(total_edge-m)

Measured memory_bytes: 72992
<?php

while($line = fgets(STDIN)){
    $d = intval($line);

    /**
     * TODO: ?????????????????????????????????
     */
    $s = 0;
    $loop = (600 - $d) / $d;
    for($i = 1; $i <= $loop; $i++){
        $s += pow(($i * $d), 2) * $d;
    }

    echo $s."\n";  // $s ????¨?????????????????´??????????
}

Measured memory_bytes: 15072
#include <stdio.h>

int main()
{
    int dice[6];
    char when[100]={};
    for(int i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
    scanf("%s",when);
    int i = 0,flg = -1,box;
    while(1)
    {
        //switchの中関数化出来る。
        switch(when[i]){
            case 'W':
                box = dice[5];
                dice[5] = dice[3];
                dice[3] = dice[0];
                dice[0] = dice[2];
                dice[2] = box;
                break;
            case 'E':
                box = dice[5];
                dice[5] = dice[2];
                dice[2] = dice[0];
                dice[0] = dice[3];
                dice[3] = box;
                break;
            case 'S':
                box = dice[5];
                dice[5] = dice[1];
                dice[1] = dice[0];
                dice[0] = dice[4];
                dice[4] = box;
                break;
            case 'N':
                box = dice[4];
                dice[4] = dice[0];
                dice[0] = dice[1];
                dice[1] = dice[5];
                dice[5] = box;
                break;
            default:
                flg = 1;
                break;
        }
        if(flg == 1) break;
        i++;
    }
    printf("%d\n",dice[0]);
    return 0;
}


Measured memory_bytes: 2096
#include<stdio.h>

long long powmod(long long x,long long y){
    long long res=1;
    for(int i=0;i<y;i++){
        res=res*x%1000000007;
    }
    return res;
}

int main(void){
  long long n;
  scanf("%lld",&n);
  
  long long a=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
  a%=1000000007;
  a=(a+1000000007)%1000000007;
  printf("%lld\n",a);
  return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

void func(long long N) {}

int main() {
    long long N;
    scanf("%lld", &N);
    if (N % 10 == 3) {
        cout << "bon" << endl;
    }

    else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
        cout << "pon" << endl;
    }

    else {
        cout << "hon" << endl;
    }

    return 0;
}


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

int main(){
	int N;
	cin>>N;
	vector<int> H(N);
	for(int i=0;i<N;i++){
		cin>>H.at(i);
	}
	int ans=0;
	int temp=0;
	for (int i=0;i<N-1;i++){
		if (H.at(i)>=H.at(i+1)){
			temp+=1;
		}
		else{
			if(ans<=temp){
				ans=temp;
			}
			temp = 0;
		}
	}
	if(ans<=temp){
		ans=temp;
	}
	cout<<ans<<endl;
}


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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ANS = 0;

	cin >> N;

	vector<SINT32> DATA(N);
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> DATA[i];
		while ((DATA[i]%2) == 0) {
			DATA[i] = DATA[i]/2;
			ANS++;
		}
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll r,d,x;
    cin >> r >> d >> x;
    FOR(i,1,11){
      x = r * x  - d;
      cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
using namespace std;
#define int long long
const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const int INF = 1e13;

int dp[MAXV];
int N,W,V,wi[MAXN],vi[MAXN];

int32_t main(){

    cin >> N >> W;
    for(int i = 1;i<=N;i++){
        cin >> wi[i] >> vi[i];
        V += vi[i];
    }

    for(int i = 1;i<=V;i++) dp[i] = INF;
    dp[0] = 0;

    for(int item = 1;item<=N;item++){
        int w = wi[item], v = vi[item];
        for(int i = V;i>=v;i--){
            dp[i] = min(dp[i],dp[i - v] + w);
        }
    }

    for(int i = V;i>=0;i--){
        if(dp[i] <= W){
            cout << i << endl;
            break;
        }
    }

    return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================
template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

// Template End ======================================================

int main(void){
  int H,W; cin>>H>>W;
  Matrix<int> g(10,vec<int>(10));
  rep(i,10) cin>>g[i];
  mat<int> A(H,vec<int>(W));
  rep(i,H) cin>>A[i];
  
  warshall_floyd(g,-1);
  int ans=0;
  rep(i,H){
    rep(j,W){
      if(A[i][j]==-1) continue;
      else ans+=g[A[i][j]][1];
    }
  }
  cout<<ans;
}














Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if (A == B) {
			if (A == C) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
			//A=Bではない
		} else {
			if (A == C) {
				System.out.println("Yes");
			} else {
				if (B == C) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
		}
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
const int N=405;
int f[N][N][N],g[N][N],a[N],b[N],as[N],bs[N];
int n,m;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n),m=n/3;
	fp(i,1,n)scanf("%d",&a[i]),as[a[i]]=i;
	fp(i,1,n)scanf("%d",&b[i]),bs[b[i]]=i;
	f[1][1][0]=1;
	fp(i,1,n)fp(j,1,n)fp(k,0,m)
	if(f[i][j][k]){
		R int ret=f[i][j][k];
		if(bs[a[i]]<=j||as[b[j]]<=i){
			if(a[i]==b[j]){
				if(k)upd(f[i+1][j+1][k-1],mul(ret,k));
				continue;
			}
			upd((bs[a[i]]<=j?f[i+1][j][k]:f[i][j+1][k]),ret);
			continue;
		}
		upd(f[i+1][j+1][k+1],ret);
		if(k){
			upd(f[i+1][j][k-1],mul(ret,k));
			upd(f[i][j+1][k-1],mul(ret,k));
			if(k>1)upd(f[i+1][j+1][k-2],P-mul(ret,k*(k-1)));
		}
	}
	R int res=0;
	fp(i,m+1,n+1)upd(res,add(f[i][n+1][0],f[n+1][i][0]));
	upd(res,P-f[n+1][n+1][0]);
	g[0][0]=1;
	fp(i,0,n-1)fp(j,0,i)if(g[i][j]){
		if(i-j<m)upd(g[i+1][j],g[i][j]);
		if(j<m*2&&(i-j)*2>j)upd(g[i+1][j+1],mul(g[i][j],(i-j)*2-j));
	}
	res=mul(res,g[n][m<<1]);
	printf("%d\n",res);
	return 0;
}

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

int main()
{
	int n;
	int cnt = 0;
	cin >> n;
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	rep(i,n-2){
		if((p[i+1]<p[i+2] && p[i]<p[i+1]) || (p[i+1]>p[i+2] && p[i]>p[i+1])){
			cnt++;
		}
	}
	cout<<cnt;
}

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

int main() {
  string s;
  int i,f=0;
  cin >> s;
  
  for(i=0;i<2;i++){
    if(s.at(i)!=s.at(i+1))
      f++;
  }
  if(s.at(0)!=s.at(2))
    f++;
  
  if(f!=0)
    cout << "Yes" << endl;
  
  if(f==0)
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    ios::sync_with_stdio(0);
    cin>>s;
    string k=s;
    reverse(s.begin(),s.end());
    if(s==k){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<P> E[110000];
long long int ans[110000];

void func(int pos, int pre, long long int cost){
    ans[pos] = cost % 2;
    for(P p : E[pos]){
        if(p.first != pre){
            func(p.first, pos, cost + p.second);
        }
    }
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        long long int u, v, w;
        cin >> u >> v >> w;
        E[u].push_back(P(v, w));
        E[v].push_back(P(u, w));
    }
    func(1, -1, 0);
    for(int i = 1; i <= N; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10368
/* 

*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();

    vector<vector<int>> dp(n+5, vector<int>(m+5));
    for(int i = 1; i <= n; ++i)
    {
        char charS = s[i-1];
        for(int j = 1; j <= m; ++j)
        {
            char charT = t[j-1];
            if(charS == charT) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    string ans = "";
    int curri = n, currj = m;
    while(curri > 0 && currj > 0)
    {
        if(s[curri-1] == t[currj-1])
        {
            ans += s[curri-1];
            --curri; --currj;
        }
        else if(dp[curri][currj] == dp[curri-1][currj])
        {
            --curri;
        }
        else
        {
            --currj;
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
    return 0; 
}


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

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		List<String> result = new ArrayList<String>();
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				int[] n = new int[3];
				for(int i = 0; i < 3; i++){
					n[i] = stdIn.nextInt();
				}
				int sum = n[0]+n[1];
				int remain = 20-sum;
				int num = remain;
				for(int i = 0; i < 3; i++){
					if( n[i] <= remain ){
						num--;
					}
				}
				if( num >= 4 ){
					result.add("YES");
				} else {
					result.add("NO");
				}
			}
			for(String str : result){
				System.out.println(str);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

	

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    vector <int> nex(n);
    nex[n - 1] = n;
    for(int i = n - 2 ; i >= 0 ; i--){
        if(a[i + 1] > 0) nex[i] = i + 1;
        else nex[i] = nex[i + 1];
    }
    ll ans = 0;
    for(int l = 0 ; l < n ; l++){
        int su = 0, xo = 0;
        int r = l;
        while(r < n){
            su += a[r];
            xo ^= a[r];
            if(su != xo) break;
            r = nex[r];
        }
        ans += r - l;
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll a, b;

	cin >> a >> b;

	cout << max(max(a + b, a - b), a * b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9 + 7;
i64 n;
vector<i64> x;
int main() {
  cin >> n;
  read_n(x, n);

  i64 b = 0, ans = 1;
  for (i64 i = 0; i < n; ++i, ++b) {
    if (x[i] <= 2 * b) {
      (ans *= (b + 1)) %= mod;
      --b;
    }
  }
  for (; b > 0; --b) (ans *= b) %= mod;
  cout << ans << endl;
  return 0;
}

// *.**..*..
// 123456


Measured memory_bytes: 1024
n = int(input())
sp = [[i for i in range(3)] for i in range(n)]



for _ in range(n):
    s,ps = map(str,input().split())
    p = ps
    sp[_][0] = _
    sp[_][1] = s
    sp[_][2] = p

sp.sort(key=lambda x:(x[1],-int(x[2])))

for _ in sp:
    print(_[0]+1)

Measured memory_bytes: 3064
N, M = map(int, input().split())

flag = [ 0 for i in range(N+1)]
dp = [0 for i in range(N+1)]

for _ in range(M):
    a = int(input())
    flag[a] = 1


dp[0] = 1
if flag[1] == 1:
    dp[1] = 0
else:
    dp[1] = 1;

for i in range(2, N+1):
    if flag[i] == 1:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])


Measured memory_bytes: 47280
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;

int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};

void solve() {
    int a, b, c, d, e, f;
    vector<int> water, suger;
    int weight = -1, su = -1;
    double res = -1;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100, b *= 100;

    for(int i = 0; i*a <= 3000; i++){
        for(int j = 0; j*b <= 3000; j++){
            int tmp = ((i*a)+(j*b));
            if(tmp <= f && tmp > 0){
                water.push_back(tmp);
            }
        }
    }

    for(int i = 0; i*c <= 3000; i++){
        for(int j = 0; j*d <= 3000; j++){
            int tmp = ((i*c)+(j*d));
            if(tmp <= f && tmp >= 0){
                suger.push_back(tmp);
            }
        }
    }

    for(auto i = water.begin(); i != water.end(); i++){
        for(auto j = suger.begin(); j != suger.end(); j++){
            if((*i)+(*j) <= f && (*j) <= e*((*i)/100)){
                double density = (double)(100*(*j))/((*i)+(*j));
                if(res < density){
                    res = density;
                    su = (*j);
                    weight = (*i)+(*j);
                }
            }
        }
    }

    cout << weight << " " << su << endl;
}

int main(){
    solve();
    return 0;
}

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

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

  string s;
  cin >> s;

  int n = stoi(s);
  int sum = 0;
  for (char c : s) {
    sum += atoi(&c);
  }

  if (n % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, B, C, res;
  rd(A);
  rd(B);
  rd(C);
  res =max_L(0, C - (A-B));
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190802-2

// --- original code ---
// {
//   int A, B, C, res;
//   rd(A, B, C);
//   res = max(0, C - (A-B));
//   wt(res);
// }


Measured memory_bytes: 256
r, c = map(int, input().split())
ans = 0

map = []
for i in range(r):
    map.append(input())

L = [[0]*c for i in range(r)]
R = [[0]*c for i in range(r)]
D = [[0]*c for i in range(r)]
U = [[0]*c for i in range(r)]

for i in range(r):
    for j in range(c):
        if map[i][j] == ".":
            L[i][j] = L[i][j - 1] + 1
        else:
            L[i][j] = 0
for i in range(r):
    for j in range(c - 1, -1, -1):
        if j == c - 1:
            if map[i][j] == ".":
                R[i][j] = 1
            continue
        if map[i][j] == ".":
            R[i][j] = R[i][j + 1] + 1
        else:
            R[i][j] = 0
for i in range(r):
    for j in range(c):
        if map[i][j] == ".":
            D[i][j] = D[i - 1][j] + 1
        else:
            D[i][j] = 0
for i in range(r - 1, -1, -1):
    for j in range(c):
        if i == r - 1:
            if map[i][j] == ".":
                U[i][j] = 1
            continue
        if map[i][j] == ".":
            U[i][j] = U[i + 1][j] + 1
        else:
            U[i][j] = 0

for i in range(r):
    for j in range(c):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

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

int main() {
	long long a, b, k;
	cin >> a >> b >> k;

	if (k > a) {
		k -= a;
		a = 0;
		b = b - min(b, k);
	} else {
		a -= k;
	}

	cout << a << " " << b;
	
	return 0;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}

ll extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;
    y=0;
  }
  return d;
}

vector<pair<ll,int>> factorize(ll x){
  vector<pair<ll,int>> res;
  for(ll i=2;i*i<=x;i++){
      int num=0;
      while(x%i==0){
          x/=i;
          num++;
      }
    if(num) res.push_back(mkp(i,num));
  }
  if(x!=1) res.push_back(mkp(x,1));
  return res;
}

const ll INF=1e18;

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

  ll N;
  cin>>N;

  if(N==1){
    cout<<1<<endl;
    return 0;
  }/*else if(N%2){
    cout<<N-1<<endl;
    return 0;
  }*/

  {
      ll two=1;
      while(two<N) two*=2;
      if(two==N){
          cout<<two*2-1<<endl;
          return 0;
      }
  }

  vector<pair<ll,int>> primes=factorize(N);
  int P=primes.size();
  vector<ll> val(P,1);
  rep(i,P){
      rep(j,primes[i].second) val[i]*=primes[i].first;
  }

  ll ans=2*INF;
  for(int bit=0;bit<(1<<P);bit++){
      ll d=1;
      for(int i=0;i<P;i++) if(bit&(1<<i)) d*=val[i];
      ll rest=N/d;
      //if(d==1||rest==1) continue;

      if(rest%2&&rest!=1){
        ll x,y;
        extgcd(2*d,rest,x,y);
        //cout<<d<<" "<<x<<" "<<rest<<" "<<y<<endl;

        if(x<0) chmin(ans,rest*y-1);
        else chmin(ans,2*d*x-1);
      }
      if(d%2&&d!=1){
        ll x,y;
        extgcd(d,2*rest,x,y);
        //cout<<d<<" "<<x<<" "<<rest<<" "<<y<<endl;

        if(x<0) chmin(ans,2*rest*y-1);
        else chmin(ans,d*x-1);
      }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3652
// writed 2020/03/25
// bit全探索
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        scanner.close();
        int length = S.length() - 1;
        long sum = 0L;

        for(int i=0;i<(1<<length);i++) {
            StringBuilder sb = new StringBuilder(S);
            for (int j=length-1; j>=0; j--) {
				if ((1&i>>j) == 1) {
					sb.insert(j+1,"+");
				}
			}

            String[] s = sb.toString().split("\\+",0);
            for(int k=0;k<s.length;k++) {
                sum += Long.parseLong(s[k]);
            }
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == 1 && b == 1 && c == 0 || a == 0 && b == 0 && c == 1) cout << "Open" << endl;
  else cout << "Close" << endl;
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int h,n,dp[10001][1<<4],x,y,ans,t,maxval,cnt;
bool a[10001][4];
void dul(int i,int inc){
	maxval=0;
    for(int j=0;j<(1<<4);j++)
		maxval=max(maxval,dp[i-1][j]);
	if(i){
		for(int j=0;j<(1<<4);j++)
			dp[i+inc][j]=max(dp[i+inc][j],max(dp[i][j],maxval));
	}
}
void case2(int i){
	cnt=0;
	for(int j=0;j<4;j++)
		if(!a[i][j]&&!a[i+1][j])cnt++;
	if(cnt==4){
		dp[i+1][(1<<4)-1]=dp[i][0]+2;
	}
}
int main(){
	cin>>h>>n;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		a[y][x]=1;
	}
	for(int i=0;i<h-1;i++){
		dul(i,0);
		case2(i);
		for(int j=0;j<(1<<4);j++){
			for(int k=0;k<3;k++){
				if(!((j>>k)&1)&&!((j>>(k+1))&1)&&!a[i][k]&&!a[i][k+1]){
					if(!a[i+1][k]&&!a[i+1][k+1]){
						int p=0;
						for(int l=0;l<4;l++){
							if(a[i+1][l]||l==k||l==k+1){
								p+=(1<<l);
							}
						}
						dp[i+1][p]=max(dp[i+1][p],dp[i][j]+1);
					}
				}
			}
		}
		dul(i,1);
	}
	for(int i=0;i<(1<<4);i++)
		ans=max(ans,dp[h-1][i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 3780
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let nk = readInts()
    var _ = readInts()
    let(n, k) = (nk[0],nk[1])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var ans = 1
    var right = k
    
    while right < n {
        right += k - 1
        ans += 1
    }
    print(ans)
}
main()


Measured memory_bytes: 18656
#include <algorithm>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
static ll imin = std::numeric_limits<ll>::min() / 10;
static ll imax = std::numeric_limits<ll>::max() / 10;
#define rep(i, n) for (ll i = 0; (i) < (n); ++(i))
#define rep1(i, n) for (ll i = 1; (i) < (n); ++(i))
#define rev_rep(i, n) for (ll i = (n)-1; (i) >= 0; --(i))
#define range(a, i, b) for (ll i = (a); (i) < (b); ++(i))

#ifdef LOCAL
#define dump(x) cout << #x << ":" << x << "\n";
#endif
#ifndef LOCAL
#define dump(x)
#endif

#define all(v) v.begin(), v.end()
#define readl(N) \
  ll N;          \
  cin >> N;
#define readlv(N, vec) \
  vector<ll> vec(N);   \
  rep(i, N) { cin >> vec[i]; }
#define greater_than [](ll l, ll r) { return l > r; }
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::map<T1, T2>& mp);
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& pair);
template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& vec);
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& pair) {
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& vec) {
  std::size_t n = vec.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (ll i = 0; i < n - 1; ++i) {
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::map<T1, T2>& mp) {
  std::size_t n = mp.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (auto&& x : mp) {
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template <class T>
std::ostream& operator<<(std::ostream& os, std::set<T>& mp) {
  std::size_t n = mp.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (auto&& x : mp) {
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n) {
  ll res = 1;
  while (n > 0) {
    res *= n;
    n--;
  }
  return res;
}

ll pow(ll i, ll n) {
  ll res = 1;
  while (n >= 0) {
    res *= i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r) {
  if (l < r) {
    return gcd(r, l);
  }
  if (r == 0) {
    return l;
  }
  return gcd(r, l % r);
}

template <class T>
vector<T> accum_sum(vector<T> const& a) {
  vector<T> b(a.size() + 1);
  b[0] = 0;
  rep(i, a.size()) { b[i + 1] = b[i] + a[i]; }
  return b;
}
constexpr ll mod = 1e9 + 7;
int main(int argc, char const* argv[]) {
  readl(N);
  readl(T);
  vector<ll> t(N);
  rep(i, N) { cin >> t[i]; }
  ll prev = t[0];
  ll res = 0;
  rep1(i, N) { res += min(T, t[i] - t[i - 1]); }
  cout << res + T << endl;
  return 0;
}


Measured memory_bytes: 1792
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
vi lala,vec;
int a[123456],leno[123456];
set<int> seti;
set<int>::iterator it;
int main(){
    std::ios::sync_with_stdio(false);
    int n,k,q;
    cin>>n>>k>>q;
    int i;
    rep(i,n){
    	cin>>a[i];
    	seti.insert(a[i]);
    }
    a[n]=-10;
    n++;
    
    int val,j,p,mini=inf;
    for(it=seti.begin();it!=seti.end();it++){
    	lala.clear();
    	i=0;
    	val=*it;
    	//cout<<val<<endl;
    	rep(j,n){
    		leno[j]=0;
    	}
    	rep(j,n){
    		if(a[j]<val){
    			f(p,i,j){
    				leno[p]=j-i;
    				//cout<<p<<" "<<leno[p]<<endl;
    			}
    			i=j+1;
    		}

    	}
    	//return 0;
    			
    	rep(j,n){
    		if(leno[j]==0)
    			continue;
    		i=j;
    		vec.clear();
    		//cout<<j<<" "<<leno[j]<<endl;
    		while(leno[j]==leno[i]){
    			vec.pb(a[i]);
    			//cout<<i<<endl;
    			i++;
    		}
    		j=i;
    		
    		int wow=vec.size();
	    	sort(all(vec));
	    	//cout<<vec.size()<<endl;
	    	f(i,k-1,wow){
	    		lala.pb(vec[i-k+1]);
	    	}
    	}
    	//return 0;
    	sort(all(lala));
    	//cout<<lala.size()<<endl;
    	if(lala.size()<q){
    		continue;
    	}
    	mini=min(mini,lala[q-1]-lala[0]);
    	//break;


    }
    cout<<mini<<endl;


    return 0;  
    
}



Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return -*(int*)p + *(int*)q;
}
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);

int end(void){
return 0;
}


int main (void){

long long int a,c,d;
  long double b;
scanf("%lld %llf", &a, &b);
  if(a==0){
  printf("0\n");
  return 0;
  }
d=100*(b+0.0001);
 // printf("%lld\n",d);
  c=(long long int) a*d;
  if(c<100){
    printf("0\n");
  return 0;
  }
  c=c/100;
printf("%lld\n",c);

return 0;
}


Measured memory_bytes: 1764
N,M = map(int, input().split())
A = [0] * M
B = [0] * M

for i in range(M):
    A[i],B[i] = map(int, input().split())
aa = []
bb = []
for i in range(M):
    if(A[i] == 1):
        aa.append(B[i])
    if(B[i] == N):
        bb.append(A[i])

aa = set(aa)
bb = set(bb)
ret = aa & bb
if (len(ret) == 0):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

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


using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-6
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
const ll maxn = 2e5 + 10;
signed main(){
	set<int> q;
	_rep(i, 1, 3){
		int t;
		cin >> t;
		q.insert(t);
	}
	q.size() == 2 ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 256