akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main(){
    int a , b,c;
    cin >> a >> b >> c;
    if(a == b && b != c) {
        cout << "Yes";
    } else if(a == c && c != b) {
        cout << "Yes";
    }else if(a != b && b== c){
        cout << "Yes";
    }else {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;

int main() {

	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
	vector<double> sugar, water;

	std::cin >> a >> b >> c >> d >> e >> f;

	for (int i = 0; i <= f; i++) {
		for (int j = 0; j <= f; j++) {
			int y = i * c + j * d;
			if (y <= f) {
				sugar.push_back(y);
			}
		}
	}

	for (int i = 0; i <= f; i++) {
		for (int j = 0; j <= f; j++) {
			int x = (100 * i * a) + (100 * j * b);
			if (x <= f) {
				water.push_back(x);
			}
		}
	}

	double kako = -1e5, nodo = 0;
	int ans1 = 0, ans2 = 0;

	rep(i, water.size()) {
		rep(j, sugar.size()) {
	
			if (water[i] + sugar[j] <= f) {
				if (sugar[j] <= e * (water[i] / 100.0)) {

					nodo = (100 * sugar[j]) / (water[i] + sugar[j]);
						
					if (nodo > kako) {
						kako = nodo;
						ans1 = sugar[j];
						ans2 = water[i] + sugar[j];

					}
				}
			}
		}
	}

	cout << ans2 << " " << ans1 << endl;

	return 0;
}

Measured memory_bytes: 2420
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


x = I()
# xの最大値が 10^ 9
# xの最大値となるa, bを考える
# xがより大きくなるのは a^5とb^5 の差が小さい(0ではない)とき
# a と b の差が 1 のとき差が最も小さい
# この場合で xが10^9をギリギリ越さない a, bを考える
# a, bが0以上の場合
# a = 120, b = 119のときがギリギリ
# a, bが0以下の場合
# a = -118, b = -119のときギリギリ
# a は [-118, 121], b は [-119, 119]の範囲で探索
a = list(range(-118, 121))
b = list(range(-119, 120))
ans = [-118, -119]
for i in a:
    for j in b:
        if i ** 5 - j ** 5 == x:
            ans = [i, j]
            break
print(*ans)


Measured memory_bytes: 9160
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = readl()
t = [t[i] * -1 for i in range(n)]
t.sort()
s = 0
while(n >= 3):
    for j in range(1, n):
        p = t[0] - t[j] - 1
        i = bisect.bisect_right(t, p)
        i -= 1
        if i >= j + 1 and t[i] <= p:
            s += i - j
    n -= 1
    t.pop(0)
print(s)

Measured memory_bytes: 5716
K, N = map(int, input().split())
As = list(map(int, input().split()))
ds = []
for i in range(N):
  if i == 0:
    d = K+As[i]-As[i-1]
  else:
    d = As[i]-As[i-1]
  ds.append(d)
#print(ds)
r = K-max(ds)
print(r)


Measured memory_bytes: 26420
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int cnt = 0;
    for (int i = 0; i < n-2; i++)
    {
        if (p[i]<=p[i+1] && p[i+1]<=p[i+2]) cnt++;
        else if (p[i]>=p[i+1] && p[i+1]>=p[i+2]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
    int first;
    int second;
} Number;

int main() {
    Number a[3000] = {0};
    int i = 0;
    int temp;

    scanf("%d %d", &a[0].first, &a[0].second);
    if (a[0].first > a[0].second){
        temp = a[0].first;
        a[0].first = a[0].second;
        a[0].second = temp;
    }

    while (!((a[i].first == 0) && (a[i].second == 0))) {
        printf("%d %d\n", a[i].first, a[i].second);

        i++;
        scanf("%d %d", &a[i].first, &a[i].second);
        if (a[i].first > a[i].second){
            temp = a[i].first;
            a[i].first = a[i].second;
            a[i].second = temp;
        }        
    }
    
    return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define ll long long
#define MOD int(1e9+7)
using namespace std;
int main(int argc, char const *argv[]) {
    //Parparosa
    //Shawi Algorithm

    int n;
    cin >> n;
    vector<int>po, ne;
    vector<pair<int, int>>ans;
    int c = 0;
    for(int i = 0, x; i < n; i++ ) {
        cin >> x;
        if(x >= 0)po.push_back(x);
        else ne.push_back(x);
        if(x == 0)c++;
    }
    if(c == n) {
        cout << 0 << endl;
        for(int i = 0; i < n - 1; i++)cout << "0 0" << endl;
        exit(0);
    }
    if(ne.size() && po.size()) {
        while(po.size() != 1) {
            ans.push_back({ne[ne.size() - 1], po.back()});
            ne[ne.size() - 1] -= po.back();
            po.pop_back();
        }
        while(!ne.empty()) {
            ans.push_back({po.back(), ne.back()});
            po[po.size() - 1] -= ne.back();
            ne.pop_back();
        }
        cout << po.back() << endl;
        for(auto xxx : ans)cout << xxx.first << " " << xxx.second << endl;
    } else if(!ne.size() && po.size()) {
        if(n == 2) {
            if(po[0] - po[1] > po[1] - po[0])cout << po[0] - po[1] << endl << po[0] << " " << po[1] << endl;
            else cout << po[1] - po[0] << endl << po[1] << " " << po[0] << endl;
            exit(0);
        }
        sort(po.begin(), po.end());
        ans.push_back({po[0], po.back()});
        po[po.size() - 1] = po[0] - po.back();
        int xx = 1;
        while(xx < n - 2 && n != 3) {
            ans.push_back({po.back(), po[xx]});
            po[po.size() - 1] -= po[xx];
            xx++;
        }
        ans.push_back({po[xx], po.back()});
        po[po.size() - 1] = po[xx] - po.back();
        cout << po.back() << endl;
        for(auto xxx : ans)cout << xxx.first << " " << xxx.second << endl;
    } else {
        sort(ne.rbegin(), ne.rend());
        ans.push_back({ne[0], ne[1]});
        ne[1] = ne[0] - ne[1];
        int xx = 2;
        while(xx != n ) {
            ans.push_back({ne[1], ne[xx]});
            ne[1] = ne[1] - ne[xx];
            xx++;
        }
        cout << ne[1] << endl;
        for(auto xxx : ans)cout << xxx.first << " " << xxx.second << endl;
    }
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long D){
    while(A > 0 && C > 0){
        C -= B;
        if(C <= 0){
            cout<<"Yes"<<endl;
            return;
        } 
        A -= D;
        if(A <= 0){
            cout<<"No"<<endl;
            return;
        }
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 3684
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

int main() {
    array<int,10> ar;
    for(int i=0;i<10;i++){
        int height;
        cin >> height;
        ar[i]=height;
        }
    sort(ar.begin(),ar.end());
    for(int j=0;j<3;j++){
        cout << ar[9-j] << endl;
        
    }
}

Measured memory_bytes: 3048
def main():
    N=int(input())
    A=list(map(int,input().split()))
    if 0 in A:
      print('0')
      return
    p=1
    for i in A:
      p=p*i
      if p>1000000000000000000:
        print(-1)
        return
    print(p)    
main()  
  

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

const int mx=500020;

int main()
{
  string s;
  cin>>s;
 int ans=0;int anss=0;
for(int i=0;i<3;i++){
    if(s[i]=='R'){
        ans++;anss=max(ans,anss);
    }else{
        ans=0;
    }
}cout<<anss;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int n=stdIn.nextInt();
			int x=stdIn.nextInt();
			if(n==0)
				break;
			int ans=0;
			for(int i=1;i<n;i++){
				for(int j=i+1;j<n;j++){
					for(int k=j+1;k<=n;k++){
						if(i+j+k==x)
							ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
}

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

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

  rep(i, N) {
    int A;
    cin >> A;
    if (A % 2 != 0) continue;
    if (A % 3 != 0 && A % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
//package pack4;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String strR = insBR.readLine();
			double dbR = Double.parseDouble(strR);
			double dbArea = dbR * dbR * Math.PI;
			String strArea = String.format("%1$.5f", dbArea);
			double dbCircle = dbR * 2 * Math.PI;
			String strCircle = String.format("%1$.5f", dbCircle);
			System.out.println(strArea + " " + strCircle);
		}catch(IOException e){
			System.out.println("入力が無効です。");
		}catch(NumberFormatException e){
			System.out.println("数値を入力してください。");
		}
	}
}



Measured memory_bytes: 24828
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <unordered_map>

using namespace std;

int main() {
    int N;
    cin >> N;
    unordered_map<int, int> count;
    for (int i = 0; i < N; i++) {
        int input;
        scanf("%d", &input);
        count[input]++;
    }

    int ans = 0;
    for (auto&& e : count) {
        if (e.second % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4128
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on




array<int, (int)1e6+1> C;

auto Main() {
	int n;
	cin>>n;
	vector<int> A(n);
	Cin(A);
	for(int a:A) C[a]++;

	int ans = 0;
	for(int a:A) {
		if(a==1 and C[1]>1) continue;
		if(a!=1 and (C[1]>0 or C[a]>1)) continue;
		bool good=true;		
		for(int p=2; p*p <= a; ++p) {
			if(a%p==0) {
				int q = a/p;
				if(C[p]>0 or C[q]>0) {
					good=false;
					break;
				}
			}
		}
		if(good) ans++;
	}
	cout<<ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll maxn_bellmanford=2505;
vector<vll> G(maxn_bellmanford);
bool reachableFrom1[maxn_bellmanford];
void dfs(ll v){
  if(reachableFrom1[v]) return;
  reachableFrom1[v]=true;
  for(auto nv: G[v]){
    dfs(nv);
  }
}

vector<vll> rG(maxn_bellmanford);
bool reachableToN[maxn_bellmanford];
void rdfs(ll v){
  if(reachableToN[v]) return;
  reachableToN[v]=true;
  for(auto nv: rG[v]){
    rdfs(nv);
  }
}

ll n,m;
vector<tuple<ll,ll,ll>> es;
ll dist[maxn_bellmanford];
bool ok[maxn_bellmanford];

bool bellmanford(ll s){
  fill(dist,dist+n,INF);
  dist[s]=0;
  bool update=true;
  ll cnt=0;
  while(update){
    update=false;
    for(auto e: es){
      ll a,b,c;
      tie(a,b,c)=e;
      if(!ok[a]||!ok[b]) continue;
      if(chmin(dist[b],dist[a]+c)) update=true;
    }
    if(cnt>=n){
      return true; // has negative loop
    }
    cnt++;
  }
  return false;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>m;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--; c=-c;
    es.emplace_back(a,b,c);
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i]=reachableFrom1[i] && reachableToN[i];
  if(bellmanford(0)){
    cout<<"inf"<<endl;
  }else{
    cout<<-dist[n-1]<<endl;
  }
}

Measured memory_bytes: 892
def f1():
    if check[0] - check[-1] == 0:
        return result1()
        
def f2():
    g = None; c = None; p = None
    for n in check:
        if n == 1: g = 1
        if n == 2: c = 1
        if n == 3: p = 1
        if g and c and p:
            return result1()
        
def f3():
    if check[0] == 1 and check[-1] == 2:
        result2(1, 2)
    elif check[0] == 1 and check[-1] == 3:
        result2(3, 1)
    elif check[0] == 2 and check[-1] == 3:
        result2(2, 3)
    
def result1():
    for i in range(5):
        print 3
    return True

def result2(p, q):
    for v in data:
        if v == p:
            print 1
        elif v == q:
            print 2

while True:
    a = int(raw_input())
    if a == 0: break
    data = [a]
    for i in range(1, 5):
        data.append(int(raw_input()))
    check = sorted(data)
    if f1(): continue
    if f2(): continue
    f3()

Measured memory_bytes: 4272
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define pf push_front
#define Mid ((l+r)/2)
#define pi pair<int,int>
#define pii pair<pi,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n,m,h[200200];
vector <int> adj[200200];
bool com(int i,int j){
    return h[i]>h[j];
}
int main()
{
    go;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=0,x,y;i<m;i++)
    {
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!adj[i].size())
        {
            ans++;
            continue;
        }
        sort(adj[i].begin(),adj[i].end(),com);
        ans+=(h[i]>h[adj[i][0]]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11448
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

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

int t,d,l;

int main(void){
	while(1){
		scanf("%d%d%d",&t,&d,&l);
		if(t==0 && d==0 && l==0)break;
		int cnt=0;
		int last=-1;
		for(int i=0;i<t;i++){
			int a;
			scanf("%d",&a);
			if(last>=0 && last+d>=i){
				cnt++;
			}
			if(a>=l)last=i;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
const int pi=3.1415926535897932384626433832795;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
int d[200005],a[200005],sum[200005];
int n,k;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		scanf("%1d",&d[i+1]);
	for(int i=1;i<=n;i++)
		a[i]=(d[i]^d[i-1]);
	sum[0]=0;
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	int b=0;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		b^=a[i];
		int x=upper_bound(sum,sum+n+1,k*2-(!b)+sum[i])-sum;
		ans=max(ans,x-i);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int x3 = x2-(y2-y);
		int y3 = y2+(x2-x);
		int x4 = x3-(x2-x);
		int y4 = y3-(y2-y);
		System.out.print(x3 + " " + y3 + " " + x4 + " " + y4);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    vector<ll> dp;
    ll ans = 1;
    ll minnum = vec[0];
    for(ll i=1;i<n;i++){
        if (vec[i]<minnum){
            minnum = vec[i];
            ans += 1;
        }
    }
    cout << ans << endl;


        
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;
#define toInt(_char) _char - '0'

using namespace std;
//
// Created by karayuu on 2019-3-28.
//

int main() {
    int n, m, l;
    cin >> n >> m >> l;

    int a[100][100] = {0};
    int b[100][100] = {0};
    FOR(i, 0, n) {
        FOR(j, 0, m) {
            cin >> a[i][j];
        }
    }
    FOR(i, 0, m) {
        FOR(j, 0, l) {
            cin >> b[i][j];
        }
    }

    long long int c[100][100] = {0};
    FOR(i, 0, n) {
        FOR(j, 0, l) {
            FOR(k, 0, m) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    FOR(i, 0, n) {
        FOR(j, 0, l) {
            if (j != 0) {
                cout << " ";
            }
            cout << c[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3260
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	ans := exec(s)
	fmt.Println(ans)
}

func exec(s string) string {
	l := strings.Split(s, "")
	n, _ := strconv.Atoi(l[len(l)-1])

	if n == 3 {
		return "bon"
	} else if n == 0 || n == 1 || n == 6 || n == 8 {
		return "pon"
	} else {
		return "hon"
	}
}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int X;
  cin >> X;
  int ans = 1;
  for (int i = 2; i < sqrt(X) + 1; i++) {
    int M = 1;
    while (M * i <= X) {
      M *= i;
    }
    ans = max(ans, M);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3684
using System;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        var query = from x in Enumerable.Range(1, 9)
                    from y in Enumerable.Range(1, 9)
                    select x + "x" + y + "=" + (x * y).ToString();
        foreach (var z in query) Console.WriteLine(z);
    }
}


Measured memory_bytes: 9328
import scala.io.{StdIn => in}

object Main extends App {
  val menu = Iterator.continually(in.readInt)
    .take(5).toArray.sortBy(i => if((i % 10) == 0) 0 else 10 - (i%10))
  
  val ans = menu.take(4).map(i => (i + 9) / 10 * 10).sum + menu.last
  println(ans)
}

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

int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double Aangle = 360 / 12 * H + 360 * M / 12 / double(60), Bangle = 360 * M / 60;
    double theta = Bangle - Aangle;
    if(theta < 0) theta = -theta;
    if(theta > 180) theta = 360 - theta;
    double rad = theta  * M_PI / 180;
    double c = sqrt(A * A + B * B - 2 * A * B * cos(rad));
    cout << fixed;
    cout << setprecision(20) << c << endl;
}

Measured memory_bytes: 4212
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const c = r.s()

    return String.fromCharCode(c.charCodeAt(0) + 1)
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N];
typedef long long LL;
LL ans;

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		if (i%2) ans+=a[i]; else ans-=a[i];
	
	printf("%lld",ans);
	for (int i=1;i<n;i++) {
		ans=2*a[i]-ans;
		printf(" %lld",ans);
	}	
	return 0;
}

Measured memory_bytes: 1664
from collections import defaultdict

table = defaultdict(lambda: 0)

n = int(input())
if (n==1):
    print(1)
elif n == 2:
    print(1)
else:
    xylist = []
    for _ in range(n):
        x, y = map(int, input().split())
        xylist += [[x, y]]

    xylist.sort()

    for i in range(n):
        for j in range(0, i):
            x = xylist[i][0] - xylist[j][0]
            y = xylist[i][1] - xylist[j][1]
            table[x+y*10**10] += 1

    max_v = max(table.values())
    print(n-max_v)

Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int inf = 2e9;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    
    int h[n];
    forn(i, 0, n) {
        cin >> h[i];
    }
    
    int dp[n] = {};
    forn(i, 1, n) {
        dp[i] = inf;
        forn(j, 1, k+1) {
            if (i-j < 0) continue;
            int a = dp[i-j] + abs(h[i]-h[i-j]);
            dp[i] = min(dp[i], a);
        }
    }
    
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 4436
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

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

int main(){
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans =a*x+b*y;
    ll mi = min(x,y);
    ll ma = max(x,y);
    ans = min(ans,ans-mi*(a+b)+2*mi*c);
    ans = min(ans,2*c*ma);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = IR(n)
sorted_L = sorted(L)
k1, k2 = sorted_L[-1], sorted_L[-2]


for i in range(n):
    if L[i] == k1:
        print(k2)
    else:
        print(k1)

Measured memory_bytes: 60240
n = int(input())
x = list(map(int, input().split()))
h = list(map(int, input().split()))

t = x[0]
a = x[1]
cnt = 1000000000000000000000
ans = 0
for i in range(n):
  tmp = abs(t-(h[i]*0.006)-a)
  if cnt > tmp:
    cnt = tmp
    ans = i+1
print(ans)


Measured memory_bytes: 9200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    vector<string> table;
    table.push_back("dream");
    table.push_back("dreamer");
    table.push_back("erase");
    table.push_back("eraser");

    for(int i = 0; i < table.size(); ++i) {
        reverse(table[i].begin(), table[i].end());
    }

    int i = 0;
    for(; i < s.size();) {
        bool ok = false;
        for(int j = 0; j < 4; ++j) {
            if (table[j] == s.substr(i, table[j].size())) {
                ok = true;
                i += table[j].size();
                break;
            }
        }
        if (!ok) {
            cout << "NO" << endl;
            return 0;
        }
    }

    if (i == s.size()) {
        cout << "YES" << endl;
    } else {
        cerr << s.size() << endl;
        cerr << i << endl;
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define debug cout<<"Orz"<<endl;
const int MAXN=200005;
int n;
int a[MAXN];
int s1,s2,g1,g2;

int main()

{
	cin>>n>>s1>>s2>>g1>>g2;
	for (int i=1;i<=n;i++){
		char c;
		cin>>c;
		a[i]=c=='#';
	}

	bool flag1=true;
	for (int i=s1;i<g1;i++){
		if (a[i] && a[i+1]){
			flag1=false;
			break;
		}
	}

	for (int i=s2;i<g2;i++){
		if (a[i] && a[i+1]){
			flag1=false;
			break;
		}
	}

	if (!flag1){
		cout<<"No"<<endl;
		return 0;
	}

	if (g1<g2){
		cout<<"Yes"<<endl;
		return 0;
	}
	for (int i=s2;i<=g2;i++){
		if (!a[i] && !a[i+1] && !a[i-1]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

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

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<iomanip>
using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;

        if (h >= K)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
using namespace std;

const int N = 200005;
vector<int> adj[N];
bool vst[N];
int maxi = 0;
int n, m;
set<pii> st;
int sz;

void dfs(int v) {
	sz++;
	vst[v] = true;
	for (int i = 0; i < adj[v].size(); i++) {
		if (!vst[adj[v][i]]) {
			dfs(adj[v][i]);
		}
	}
}

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

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int k, l;
		cin >> k >> l;
		if (k > l) swap(k, l);
		if (st.find(mp(k, l)) == st.end()) {
			st.insert(mp(k, l));
			adj[k].pb(l);
			adj[l].pb(k);
		}
	}

	for (int i = 1; i <= n; i++) {
		if (vst[i] == false) {
			sz = 0;
			dfs(i);
			maxi = max(sz, maxi);
		}
	}

	cout << maxi << '\n';


	

}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    i64 ans0 = INF, ans1 = INF;
    for (i64 i = 0; i < n; i++) {
        i64 a, b;
        cin >> a >> b;
        if (b < ans1) ans0 = a, ans1 = b;
    }

    cout << ans0 + ans1 << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

using namespace std;

const int INF = 0x0fffffff;

int N;
int K;

typedef pair<int, int> ii;

vector< vector<int> > M;
vector<bool> V; // visited

vector<ii> R; // range

const ii inf = make_pair(-INF, INF);
const ii fail = make_pair(INF, -INF);

ii dfs(int i) {
    //if (V[i]) {
    //    return inf;
    //}

    V[i] = true;

    for (size_t j = 0; j < M[i].size(); ++j) {
        int ni = M[i][j]; // next i

        if (V[ni]) {
            continue;
        }

        ii rv = dfs(ni);

        //if (rv == make_pair(-INF-1, INF+1)) {
        //    rv = inf;
        //}

        if (rv == fail) {
            return fail;
        //} else if (R[i] == inf){
        //    R[i] = rv;
        //} else if (rv == inf) {
        //    continue;
        } else if (R[i] != inf && rv != inf && R[i].first % 2 != rv.first % 2) {
            return fail;
        //} else if (R[i].second < rv.first) {
        //    return fail;
        //} else if (rv.second < R[i].first) {
        //    return fail;
        } else {
            R[i].second = min(R[i].second, rv.second);
            R[i].first  = max(R[i].first, rv.first);
        }
    }

    if (R[i].second < R[i].first) {
        return fail;
    }

    if (R[i] == inf) {
        return inf;
    } else {
        return make_pair(R[i].first-1, R[i].second+1);
    }
}

void dfs2(int i) {
    //if (V[i]) {
    //    return;
    //} 

    V[i] = true;

    R[i] = make_pair(R[i].first, R[i].first);
    
    for (size_t j = 0; j < M[i].size(); ++j) {
        int ni = M[i][j]; // next i
        
        if (V[ni]) {
            continue;
        }

        R[ni] = make_pair(max(R[ni].first, R[i].first-1), min(R[ni].second, R[i].second+1));

        dfs2(ni);
    }
}

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

    cin >> N;

    M.resize(N);

    for (int i = 0; i < N; ++i) {
        M[i].clear();
    }

    for (int i = 0; i < N-1; ++i) {
        int a;
        int b;

        cin >> a >> b;
        a--;
        b--;

        M[a].push_back(b);
        M[b].push_back(a);
    }

    V.resize(N);
    fill(V.begin(), V.end(), false);

    R.resize(N);
    fill(R.begin(), R.end(), inf);

    cin >> K;

    for (int i = 0; i < K; ++i) {
        int v;
        int p;

        cin >> v >> p;
        v--;

        R[v] = make_pair(p, p);
    }

    ii rv = dfs(0);

    if (rv == fail) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    fill(V.begin(), V.end(), false);

    dfs2(0);

    for (int i = 0; i < N; ++i) {
        printf("%d\n", R[i].first);
    }

    return 0;
}


Measured memory_bytes: 11904
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

vector<ll> dir;
vector<vector<P>> ad;
bool dfs(ll pos) {
	bool ret=true;
	REP(i,(ll)ad[pos].size()) {
		if(dir[ad[pos][i].first]==INF*INF) {
			dir[ad[pos][i].first]=dir[pos]+ad[pos][i].second;
			ret=ret&dfs(ad[pos][i].first);
		} else ret=ret&(dir[ad[pos][i].first]==dir[pos]+ad[pos][i].second);
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	ad.resize(n);
	dir.resize(n);
	REP(i,n) dir[i]=INF*INF;
	REP(i,m) {
		ll l,r,d;
		cin>>l>>r>>d;
		l--;
		r--;
		ad[l].pb(P(r,d));
		ad[r].pb(P(l,-d));
	}
	REP(i,n) {
		if(dir[i]==INF*INF) {
			dir[i]=0;
			if(!dfs(i)) {
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 16512
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [-1 for i in range(N+1)]
B[1] = 0
n = 1
m = 0
while 1:
  n = A[n]
  m += 1
  if m == K:
    print(n)
    break
  if B[n] == -1:
    B[n] = m
  else:
    a = (K - m) % (m - B[n])
    for i in range(a):
      n = A[n]
    print(n)
    break

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


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
        
    int t=1;
    //cin>>t;
    while(t--){
        string s;
        cin>>s;
        if(s[2]==s[3] && s[4]==s[5])
            cout<<"Yes";
        else
            cout<<"No";
    }



return 0;
}

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

using namespace std;
#define int long long
signed main(){
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	
	float ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			float as=sqrt(1.0*(a[i]-a[j])*(a[i]-a[j])+1.0*(b[i]-b[j])*(b[i]-b[j]));
			// cout<<as<<" ";
			ans=ans+as;
		}
	}
	ans=ans/n;
	cout<<fixed<<setprecision(8)<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

string s[7] = {
	"fri","sat","sun","mon","tue","wed","thu"
};

int main() {
	int x; cin >> x;
	cout << s[(x - 1) % 7] << endl;
	return 0;
}

Measured memory_bytes: 3200
x = input()
if len(x) % 2 == 0 :
  adjust = 0
else:
  adjust = 1
xa = x[0:(len(x)-adjust)//2]
xb = x[(len(x)+3)//2-1:]
xar = ''.join(list(reversed(xa)))
xbr = ''.join(list(reversed(xb)))
#print(xa,xb,xar,xbr)
if xa == xb and xar == xbr:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <iostream>
#define int long long
using namespace std;
signed main() {
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i * i + i >= n)break;
		if ((n - i) % i == 0)ans += (n - i) / i;
	}
	cout << ans << endl;
	cin >> n;
}

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

using namespace std;

#define sz(s) ((int)s.size())

typedef long long ll;

const long double eps = 0.0000000001;
const int MOD = 998244353;
const int INF = 1000055555;
const long long LLINF = 1223372000000000555;
const int N = 2250555;
const int M = 2522;

int t[N];
int a[N];

int get(int v, int tl, int tr, int l, int r){
    if (tl >= l && tr <= r) return t[v];
    if (tl > r || tr < l) return 0;
    int tm = (tl + tr) >> 1;
    return max(get(v + v, tl, tm, l, r), get(v + v + 1, tm + 1, tr, l, r));
}

void update(int v, int tl, int tr, int pos, int val){
    if (tl == tr){
        t[v] = val;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos <= tm) update(v + v, tl, tm, pos, val); else
        update(v + v + 1, tm + 1, tr, pos, val);
    t[v] = max(t[v + v], t[v + v + 1]);
}

int dp[N];
void solve() {
    int n, k;
    cin >> n >> k;

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

    int A = 300000;
    for (int i = 1; i <= n; i++){
        int l = max(0, a[i] - k), r = min(A, a[i] + k);
        dp[i] = get(1, 1, A, l, r) + 1;
        update(1, 1, A, a[i], dp[i]);
    }

    for (int i = 1; i <= n; i++){
        dp[1] = max(dp[1], dp[i]);
    }

    cout << dp[1];

}


int main() {
    ios_base::sync_with_stdio(false);
#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

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

    return 0;
}

Measured memory_bytes: 10016
#include<iostream>
#include<vector>
//#include<math.h>
#include <unordered_map>
using namespace std;

int main()
{
    string s;
    int n;
    int Lchild=0;
    int Rchild=0;
    string searchtype="L";
    cin>>s;
    n=s.size();
    vector<int> child(n,0);
    int now=0;
    int lastR=0;
    int nextL;
    while(now<n)
    {
        if(s[now]=='R'&&s[now+1]=='L')
        {
            child[now]+=(now-lastR+2)/2;
            child[now+1]+=(now-lastR+1)/2;
            nextL=now+1;
            while(1)
            {
                if(nextL==n-1)
                {
                    break;
                }
                else
                {
                    if(s[nextL+1]=='L')
                    {
                        nextL++;
                    }
                    else
                    {
                        break;
                    }
                    
                }
            }
            child[now]+=(nextL-now)/2;
            child[now+1]+=(nextL-now+1)/2;
            lastR=nextL+1;
            now=lastR;
        }
        else
        {
            now++;
        }
    }
    for(int i=0;i<n;i++)
    {
        cout<<child[i]<<" ";
    }
    cout<<endl;
}

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

int main(void) {

	int R[200000], n;

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

	int maxv = -2e9;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n;
cin >> n;

map<int,int> mp;
rep(i,n){
    int a;
    cin >> a;
    mp[a]++;
}

int ans = 0;
for(auto p: mp){
    if(p.second % 2 == 1) ans++;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 4992
n = int(input())
l = list(map(int, input().split()))
 
ans = 0
for i in range(1, n - 1):
  if l[i - 1] < l[i] and l[i] < l[i + 1]:
    ans += 1
  elif l[i + 1] < l[i] and l[i] < l[i - 1]:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int64_t a[3], k;
   cin >> a[0] >> a[1] >> a[2] >> k;
 
   sort(a, a + 3);
   while (k--)
      a[2] *= 2;
 
   cout << (a[0] + a[1] + a[2]);
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3 + 10;
int n;
int num[N][N], pos[N][N];
void add(set<int>& s, set<int>& s2, int i, int j) {
    s2.insert(pos[i][num[i][j]]);
    if(s2.count(pos[num[i][j]][i])) {
        s2.erase(pos[i][num[i][j]]);
        s2.erase(pos[num[i][j]][i]);
        s.insert(pos[i][num[i][j]]);
    }
}
int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        for(int j = 1, x; j < n; j++) {
            cin >> x;
            num[i][j] = x;
            pos[i][x] = i*n+j;
        }
    }

    set<int> s, s2;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        add(s, s2, i, 1);
    }

    while(!s.empty()) {
        set<int> new_s;
        for(int t : s) {
            int x = t/n, y = t%n;
            int t2 = pos[num[x][y]][x];
            y++;
            if(y != n) {
                add(new_s, s2, x, y);
            }
            x = t2/n; y = t2%n;
            y++;
            if(y != n) {
                add(new_s, s2, x, y);
            }
        }
        ans++;
        s = new_s;
    }

    if(s2.size()) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<cmath>
using namespace std;
int main() {
    string a, b;
    cin >> a >> b;
    string c = a + b;
    int c2 = atoi(c.c_str());
    for (int i = 4; i <= (int)sqrt(c2) + 1; i++) { //from 11
        if (c2 == i * i) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
in_str = gets.split(" ")
w = in_str[0].to_i
h = in_str[1].to_i
x = in_str[2].to_i
y = in_str[3].to_i
r = in_str[4].to_i

if (w >= (x + r)) && (h >= (y + r)) then
    if x < 0 || y < 0 then
        puts "No"
    else
        puts "Yes"
    end
else
    puts "No"
end


Measured memory_bytes: 8892
#include<stdio.h>
int main()
{
	int a,b,c,d,time,temp;
	time=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a>c)
	{
		temp=a;
		a=c;
		c=temp;
		temp=b;
		b=d;
		d=temp;
	}
	if(a<=c)
	{
	if(b<=c)
	{
		time=0;
	}
	else
	{
	if(b<=d)
	time=b-c;
	else
	time=d-c;
	}
    }
    printf("%d",time);
    return 0;
 } 

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		long sunukeNum = 1;

		for(int i=0;i<n;i++){
			
			String sunukeString = "" + sunukeNum;
			double min = Double.MAX_VALUE;
			long sunukecand = 0;

			for(int j=0;j<sunukeString.length() + 1;j++){
				String nine = "";
				for(int k=0;k<j;k++){
					nine += "9";
				}

				String compose = sunukeString.substring(0,sunukeString.length() - j) + nine;
				double sunukecandidate = Long.parseLong(compose)*calc(Long.parseLong(compose));

				if(min > sunukecandidate){
					min = sunukecandidate;
					sunukecand = Long.parseLong(compose);
				}

			}

			System.out.println(sunukecand);
			sunukeNum = sunukecand + 1;

		}
	}
	public static double calc(long num){
		int gradesum = 0;
		while(num >= 1){
			gradesum += num%10;
			num = num/10;
		}
		return (double)1/gradesum;
	}
 
}

Measured memory_bytes: 30548