akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
using namespace std;
long long N, K;
vector<long long> a, acc;
vector<long long> b;
long long mask[50];
long long cand[1000000];
int main()
{
    cin >> N >> K;
    int hoge = 1;
    for (long long i = 1; hoge <= 45; i *= 2)
    {
        mask[hoge++] = i;
    }
    a.resize(N);
    b.resize(N*(N+1)/2);
    acc.resize(N + 1);
    acc[0] = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        acc[i + 1] = a[i] + acc[i];
    }

    long long cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j < i;j++)
        {
            b[cnt++] = acc[i] - acc[j];
        }
    }
    long long num = (N+1)*N / 2;
    for (int i = 45; i >= 1; i--)
    {
        cnt = 0;
        for (int j = 0; j < num; j++)
        {
            if((b[j] & mask[i]) != 0)
            {
                cand[cnt++] = b[j];
            }
        }
        if(cnt >= K)
        {
            for (int j = 0; j < cnt;j++)
            {
                b[j] = cand[j];
            }
            num = cnt;
        }
    }
    long long ans = b[0];
    for (int i = 1; i < num;i++)
    {
        ans = ans & b[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
using namespace std;
 
class Dice{
		int _num[6];
		
	public:
        void set(int num[6]){
            for(int i = 0; i < 6; i++) _num[i] = num[i];
        }
		int Get(int n){
			return _num[n];
		}
		void N(){
			swap(_num[0],_num[4]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[1]);
		}
		void S(){
			swap(_num[0],_num[1]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[4]);			
		}
		void W(){
			swap(_num[0],_num[3]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[2]);			
		}
		void E(){
			swap(_num[0],_num[2]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[3]);			
		}
		void SetTop(int n){
			if(_num[2] == n) W();
			else if(_num[3] == n) E();
			else{
				for(int i = 0; i < 4; i++){
					if(_num[0] == n) break;
				S();
				}
			}
		}
		void SetFront(int n){
			for(int i = 0; i < 4; i++){
				if(_num[1] == n) break;
				S(); W(); N();
			}
		}

		bool Same(Dice other){
			other.SetTop(this->Get(0));
			other.SetFront(this->Get(1));
			
			bool same = true;
			for(int i = 0; i < 6; i++){
				if(other.Get(i) != this->Get(i)){
					same = false;
					break;
				}
			}
			return same;
		}
};
 
int main(){
	int n;
	cin >> n;
	
	Dice dice[n];
	for(int i = 0; i < n; i++){
		int num[6];
		for(int j = 0; j < 6; j++){
				cin >> num[j];
		}
		dice[i].set(num);
	}
	
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			if(dice[i].Same(dice[j])){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 1160
def roman_to_arabic(roman)
  roman_arabic = {
    'I' => 1,
    'V' => 5,
    'X' => 10,
    'L' => 50,
    'C' => 100,
    'D' => 500,
    'M' => 1000
  }

  arabic = 0
  for i in 0...roman.size
    a, b = roman[i], roman[i + 1]
    left = roman_arabic[a] || 0
    right = roman_arabic[b] || 0
    if left < right
      arabic -= left
    else
      arabic += left
    end
  end
  arabic
end

while line = gets
  puts roman_to_arabic(line.chomp)
end

Measured memory_bytes: 8556
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	int n, a;
	map<ll, ll> mp;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		mp[a]++;
	}
	cout << (mp.size() % 2 ? mp.size() : mp.size() - 1);
	return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

int main() {
	ll n,t;
	cin>>n>>t;
	vector<ll> v;
	rep(i,0,t){
		ll a;
		cin>>a;
		v.pb(a);
	}
	sort(all(v));
	reverse(all(v));
	ll mx = v[0];
	if(mx<=n/2){
		cout << 0 << endl;
		return 0;
	}
	if(n%2==1){
		if(mx <= n/2+1){
			cout << 0 << endl;
			return 0;
		}
	}
	ll d[10005];
	clr(d,0);
	ll c = mx;
	rep(i,0,n){
		if(i%2==0){
			d[i]=1;
			c--;
		}
	}
	if(n%2==0&&c!=0){
		d[n-1]=1;
		c--;
	}
	rep(i,0,n){
		if(d[i]==0&&c!=0){
			d[i]=1;
			c--;
		}
	}
	ll ans = 0;
	rep(i,0,n-1){
		if(d[i]==1&&d[i+1]==1){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	long long ans = pow(3.0, a.size());
	
	int minus = (a[0] % 2 == 0 ? 2 : 1);
	for (int i = 1; i < a.size(); i++) {
		if (a[i] % 2 == 0)minus *= 2;
	}
	cout << ans - minus << endl;

	return 0;
}

Measured memory_bytes: 256
// 27
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) \
  for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) \
  for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef LOCAL
#define debug(e)                             \
  cerr << "\033[48;5;196m\033[38;5;15m" << e \
       << "\033[0m";
#else
#define debug(e)
#endif
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << " " << p.se << ")";
}
// 8
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, (int)v.size()) o << setw(7) << left << v[i];
  return o << endl;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 3
void _main(int tc) {
  string s;
  cin >> s;
  int groupcnt = 0;
  for (int i = 0; i + 1 < len(s); i++) {
    groupcnt++;
    while (s[i] == s[i + 1]) i++;
  }
  if (s[len(s) - 1] != s[len(s) - 2]) groupcnt++;

  cout << groupcnt - 1 << endl;

}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int M = 998244353;

int add(int a, int b) {
        a += b;
        if (a >= M)
                return a - M;
        if (a < 0)
                return a + M;
        return a;
}

int mul(int a, int b) {
        return a * (ll) b % M;
}

int pw(int a, int b) {
        int r = 1;
        while (b) {
                if (b & 1)
                        r = mul(r, a);
                a = mul(a, a);
                b /= 2;
        }
        return r;
}

int dv(int a, int b) {
        return mul(a, pw(b, M - 2));
}

const int N = (int) 2e5 + 7;
int n, pw2[N];
int x[N], y[N], ord[N], p11[N], p22[N], p33[N];
map<int, int> xs;
int fent[N];

void clr() {
        for (int i = 1; i <= n; i++)
                fent[i] = 0;
}

void add(int i) {
        while (i <= n) {
                fent[i]++;
                i += i & (-i);
        }
}

int sma(int i) {
        int sol = 0;
        while (i) {
                sol += fent[i];
                i -= i & (-i);
        }
        return sol;
}

bool cmp(int i, int j) {
        return y[i] < y[j];
}

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        pw2[0] = 1;
        for (int i = 1; i < N; i++)
                pw2[i] = mul(pw2[i - 1], 2);
        cin >> n;
        for (int i = 1; i <= n; i++) {
                cin >> x[i] >> y[i];
                xs[x[i]] = 0;
                ord[i] = i;
        }
        sort(ord + 1, ord + n + 1, cmp);
        int trans = 0;
        for (auto &it : xs)
                it.second = ++trans;
        for (int i = 1; i <= n; i++)
                x[i] = xs[x[i]];
        for (int it = 1; it <= n; it++) {
                int i = ord[it];
                p11[i] = sma(x[i]);
                p22[i] = it - 1 - p11[i];
                add(x[i]);
        }
        clr();
        for (int it = n; it >= 1; it--) {
                int i = ord[it];
                p33[i] = n - it - sma(x[i]);
                add(x[i]);
        }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
                int con;
                con = pw2[n - 1];
                int p1 = 0, p2 = 0, p3 = 0, p4 = 0;
                p1 = p11[i];
                p2 = p22[i];
                p3 = p33[i];
                p4 = n - 1 - p1 - p2 - p3;
                int a1, a2, a3, a4;
                a1 = add(pw2[p1], -1);
                a2 = add(pw2[p2], -1);
                a3 = add(pw2[p3], -1);
                a4 = add(pw2[p4], -1);
                con = add(con, mul(pw2[p2 + p4], mul(a1, a3)));
                con = add(con, mul(pw2[p1 + p3], mul(a2, a4)));
                con = add(con, -mul(mul(a1, a2), mul(a3, a4)));
                ans = add(ans, con);
        }
        cout << ans << "\n";
        return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int N,M;
int A[10];

//                1,2,3,4,5,6,7,8,9
int match[] = {-1,2,5,5,4,5,6,3,7,6};

int dp[10010];

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

	cin >> N >> M;

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

	sort(A,A+M);
	fill(dp,dp+N+5, INT_MIN);

	dp[0] = 0;

	for (int i = 1;i <= N;i++){
		for (int j = 0;j < M;j++){
			if(i-match[A[j]] >= 0 && dp[i-match[A[j]]] != INT_MIN){
				dp[i] = max(dp[i-match[A[j]]]+1, dp[i]);
			}
		}
	}

	int now = N;
	int MAX = M-1;
	for (int i = 0;i < dp[N];i++){
		for (int j = MAX;j >= 0;j--){
			if(now-match[A[j]] >= 0 && dp[now-match[A[j]]] == dp[now]-1){
				cout << A[j];
				now -= match[A[j]];
				MAX = j;
				break;
			}
		}
	}
	cout << endl;

	return 0;

}


Measured memory_bytes: 256
/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9+7;
ll n,m;
ll s=0;
bool prime(int n)
{
    if(n==1) return false;
    if(n==2||n==3) return true;
    if(n%6!=1&&n%6!=5) return false;
    for (int i=5;i*i<=n;i+=6)
    if (n%i==0||n%(i+2)==0) return false;
    return true;
}
int check(int x,int y)
{
	if (x>n||x<1||y>=m||y<0) return 0;
	return 1;
}
long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
inline int read()
{
    int X=0,w=1;
	char c=getchar();
    while (c<'0'||c>'9')
    {
		if (c=='-') w=-1;
		c=getchar();
    }
    while (c>='0'&&c<='9')
	{
	 	X=(X<<3)+(X<<1)+c-'0';
		c=getchar();
	}
    return X*w;
}
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	s=(n-2)*180;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
//
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(abs(A-B)<=D&&abs(B-C)<=D){
    Yes(1);
  }else if(abs(A-C)<=D){
    Yes(1);
  }else{
    Yes(0);
  }
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> memo(n + 1, 0);
	memo[0]++;
	vector<bool> usable(n + 1, true);
	for(int i = 0; i < m; i++){
		int a;
		cin >> a;
		usable[a] = false;
	}
	for(int i = 1; i <= n; i++){
		if(usable[i] == false) continue;
		if(i == 1) memo[i] = memo[i - 1];
		else{
			if(usable[i - 1] && usable[i - 2]) memo[i] = memo[i - 1] + memo[i - 2];
			else if(usable[i - 1]) memo[i] = memo[i - 1];
			else if(usable[i - 2]) memo[i] = memo[i - 2];
			memo[i] %= 1000000007;
		}
	}
	cout << memo[n] << endl;
	return 0;
}


Measured memory_bytes: 640
#10 C - Together
N = int(input())
a = list(map(int,input().split()))
a = sorted(a, reverse = True)
a_set = set(a)

#aの各要素の個数をカウント
a_cnt = [0]*(max(a)+2)#0からmax(a)+1まで
for i in a:
    a_cnt[i] += 1

mcnt = 0
for j in a:
    cnt = a_cnt[j]
    if j-1 in a_set:
        cnt += a_cnt[j-1]
    if j+1 in a_set:
        cnt += a_cnt[j+1]
    mcnt = max(mcnt,cnt)    
print(mcnt)

Measured memory_bytes: 20648
fun main(args: Array<String>) {
    val S = readLine()!!
    val T = readLine()!!


    val candidates = mutableListOf<String>()
    (0..((S.length - 1) - (T.length - 1))).forEach {startIndex ->
        val replaced = S.replaceRange(startIndex, startIndex + T.length, T).replace("?", "a")
        // Check if it keeps original form
        var keepsOriginalForm = true
        S.forEachIndexed { index, c ->
            if (c != '?') {
                if (S[index] != replaced[index]) {
                    keepsOriginalForm = keepsOriginalForm && false
                }
            }
        }
        if (keepsOriginalForm) {
            candidates.add(replaced)
        }
    }
    candidates.sort()

    if (candidates.size > 0) {
        println(candidates[0])
    } else {
        println("UNRESTORABLE")
    }
}


Measured memory_bytes: 37704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	vector <ll>a;
	for(ll i=0;i<=10000;i++){
		ll now=i;
		a.push_back(pow(now,5));
	}
//	cout << a[2];
	for(ll i=0;i<=10000;i++){
		ll now=a[i];
		ll nex=n-now;
		for(ll j=0;j<=10000;j++){
			if(a[j]==nex){
				cout << (i)<<" "<<-1*(j);
				return 0;
			}
			else if(a[j]==-1*nex){
				cout << i <<" "<<j;
				return 0;
			}
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<int>a ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	int n;
	cin>>n;
	cout<<a[n-1];

}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * (10 ** 5 + 10)
dp[0] = 0

for i in range(1,N):
  dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[N-1])

Measured memory_bytes: 13928
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

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

    ll a, b;
    cin >> a >> b;

    if (a > b) {
        cout << "No" << "\n";
        return 0;
    }
    cout << "Yes" << "\n";

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int H,W;
    while(H!=0||W!=0){
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<H;i++){
            if(i==0||i==H-1)for(int v=0;v<W;v++){
                if(v!=W-1)cout<<"#";
                if(v==W-1)cout<<"#"<<endl;
            }
            if(i!=0&&i!=H-1)for(int v=0;v<W;v++){
                if(v==0)cout<<"#";
                if(v!=0&&v!=W-1)cout<<".";
                if(v==W-1)cout<<"#"<<endl;
            }
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, K, num, x;
    cin >> N >> K;
    num = 0;
    
    for (int i=0; i<N; i++) {
        cin >> x;
        if (x <= K-x) num+=x;
        else num+=(K-x);
        
    }
    cout << num*2 << endl;
}

Measured memory_bytes: 3616
import fractions
def main():
    n,m=map(int,input().split())
    s=input()
    t=input()
    ans=-1
    gcd0=fractions.gcd(n,m)
    lcm=n*m//gcd0
    flg=1
    for i in range(gcd0):
        if s[n*i//gcd0]!=t[m*i//gcd0]:
            flg=0
            break
    if flg==1:
        ans=lcm
    print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 5344
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
using namespace::std;

int main(){
    double n;
    cin >> n;
    if((int )n % 2 == 0){
        cout << 0.5 << endl;
    } else{
        cout << ((n-1)/2 +1) / n;
    }
}

Measured memory_bytes: 256
using System;

class Atcoder74
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int product = a * b;

        if (product % 2 == 0)
            Console.WriteLine("Even");
        else
            Console.WriteLine("Odd");
    }
}

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

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

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

int main() {
  char A;
  cin >>A;
  if (A=='a'){
    cout <<'b';
  }
  if (A=='b'){
    cout <<'c';
  }
  if (A=='c'){
    cout <<'d';
  }if (A=='d'){
    cout <<'e';
  }if (A=='e'){
    cout <<'f';
  }if (A=='f'){
    cout <<'g';
  }if (A=='g'){
    cout <<'h';
  }if (A=='h'){
    cout <<'i';
  }if (A=='i'){
    cout <<'j';
  }if (A=='j'){
    cout <<'k';
  }if (A=='k'){
    cout <<'l';
  }if (A=='l'){
    cout <<'m';
  }if (A=='m'){
    cout <<'n';
  }if (A=='n'){
    cout <<'o';
  }if (A=='o'){
    cout <<'p';
  }if (A=='p'){
    cout <<'q';
  }if (A=='q'){
    cout <<'r';
  }if (A=='r'){
    cout <<'s';
  }if (A=='s'){
    cout <<'t';
  }if (A=='t'){
    cout <<'u';
  }if (A=='u'){
    cout <<'v';
  }if (A=='v'){
    cout <<'w';
  }if (A=='w'){
    cout <<'x';
  }if (A=='x'){
    cout <<'y';
  }if (A=='y'){
    cout <<'z';
  }
}


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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a+b,min(b+c,a+c))<<endl;

    return 0;
}

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

int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  int k=0;
  if(x==w/2&&y==h/2) k=1;
  cout << w*h/2 << ' ' << k << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int n; cin >> n;
  LL h[n], dp[n];

  rep(i, n) cin >> h[i];
  rep(i, n) dp[i] = 1LL << 60;
  dp[0] = 0;

  for (int i = 1; i < n; i++) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if (i > 1) {
      chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
  }

  cout << dp[n-1] << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int sz = 1e5+1;
ll mod=1e9+7;

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    t=1;
    // cin>>t;
    //sieve();
    for(int cs=1;cs<=t;cs++)
    {
        
        ll n;
        cin>>n;
        ll ar[n];
        for(int i=0;i<n;i++)
        {
            cin>>ar[i];
        }
        sort(ar,ar+n);
        ll ans = 0;
        ans = ar[n-1];
        ll cnt=2;
        for(int i=n-2;i>=0;i--)
        {
            // cout<<ans<<endl;
            if(n-cnt==0)
            {
                break;
            }
            if(n-cnt==1)
            {
                ans+=ar[i];
                break;
            }
            ans+=(2*ar[i]);
            cnt+=2;
        }

        cout<<ans<<endl;

        
 
    }
    return 0;
} 

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define MAX 1111
#define mod 1000000007
const long long  inf = 20000000000000000;
using namespace std;
bool g[MAX][MAX];
int main(){ 
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
    string s;
    cin>>s;
    int n;cin>>n;
    for(int i =0 ; i < s.size(); i++){
        if(i%n == 0)cout<<s[i];
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    set<int> moti;
    for(int i=0;i<n;i++){
        int hoge;
        cin>>hoge;
        moti.insert(hoge);
    }
    
    cout<<moti.size()<<endl;
    
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    vector<int> T(N);
    int sumT = 0;
    rep(i, 0, N) cin >> T[i], sumT += T[i];
  
    int M; cin >> M;
    rep(i, 0, M) {
      int P, X; cin >> P >> X;
      cout << sumT + (X - T[P-1]) << endl;
    }
}


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

const int kNmax = 1e5 + 10;

int n, p[kNmax], pos[kNmax], root[kNmax], sz[kNmax], m;

int getRoot(int node) {
	if (node == root[node]) {
		return node;
	}
	return root[node] = getRoot(root[node]);
}

void merge(int x, int y) {
	int rx = getRoot(x);
	int ry = getRoot(y);
	if (rx == ry) {
		return ;
	}
	if (sz[rx] >= sz[ry]) {
		sz[rx] += sz[ry];
		root[ry] = rx;
	} else {
		sz[ry] += sz[rx];
		root[rx] = ry;
	}
}

int main() {
	//ifstream cin("in");
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
		pos[p[i]] = i;
		root[i] = i;
		sz[i] = 1;
	}
	
	for (int i = 1, x, y; i <= m; i++) {
		cin >> x >> y;
		merge(x, y);
	}
	
	int res = 0;
	for (int i = 1; i <= n; i++) {
		if (getRoot(i) == getRoot(pos[i])) {
			res++;
		}
	}
	
	cout << res;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	cin >> N >> K;
	vector<vector<ll>> to(N);
	vector<ll> d(N);
	rep(i,N-1){
		int a,b;
		cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	d[0] = K;
	queue<ll> q;
	q.push(0);
	while(!q.empty()){
		int now = q.front();q.pop();
		ll cnt = 1;
		for(int i=0;i<to[now].size();i++){
			int next = to[now][i];
			if(d[next])cnt++;
		}
		for(int i=0;i<to[now].size();i++){
			int next = to[now][i];
			if(d[next])continue;
			d[next] = K - cnt;
			if(K-cnt<=0){
				cout << 0 << endl;
				return 0;
			}
			cnt++;
			q.push(next);
		}
	}
	ll ans = 1;
	rep(i,N){
		(ans *= d[i])%=mod;
		if(d[i]<=0){
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8180
package main
 
import (
  "fmt"
  "os"
  "bufio"
  "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  a := make([]int, n)
  for i := range a {
    a[i] = nextInt()
  }

  ans := "APPROVED"
  for i := 0; i < n; i++ {
    if a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0 {
      ans = "DENIED"
      break
    }
  }
  fmt.Println(ans)
}

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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i = 0; i < N; i++) cin >> x[i] >> u[i];

  double ans = 0;
  for (int i = 0; i < N; i++) {
    if (u[i] == "JPY") ans += x[i];
    else ans += 380000.0 * x[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int n, a, b, c, d[100];

	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	sort(d, d + n, greater<int>());

	double doll = a, cal = c;
	for (int i = 0; i < n; i++) {
		if (cal / doll > (cal + d[i]) / (doll + b)) {
			cout << (int)(cal / doll) << endl;
			return 0;
		}
		cal += d[i];
		doll += b;
	}
	cout << (int)(cal / doll) << endl;

	return 0;
}

Measured memory_bytes: 3156
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(LL a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	LL s;
	LL a,b,c,d;
	//ab-cd=s
	cin>>s;
	if(s<=1000000000){
		cout<<"0 0 0 1 "<<s<<" 0"<<endl;
		return 0;
	} 
	else{
		cout<<"0 0 1000000000 1 "<<1000000000*(s/1000000000+bool(s%1000000000))-s<<" "<<s/1000000000+bool(s%1000000000)<<endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll n,a,b;
	cin>>n>>a>>b;
	ll tmp = b-a;
	if(tmp%2ll==0ll){
		cout<<tmp/2ll<<"\n";
		return 0;
	}
	ll fi=b-1ll;
	ll se=n-a;

	ll A=a+(b-a-1ll)/2ll;
	ll B=n-b+1+(n-a-(n-b)-1ll)/2ll;
	cout<<min(fi,min(A,min(se,B)))<<'\n';
	//cin>>n;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer a[][] = new Integer[2][N];
        for (int i=0; i<N; i++) {
            a[0][i] = Integer.parseInt(sc.next());
            a[1][i] = i + 1;
        }
        Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
        for (int i=0; i<N; i++)
            map.put(a[0][i], a[1][i]);
        int k = 0;
        for (int key : map.keySet()) {
            a[0][k] = key;
            a[1][k++] = map.get(key);
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<N; i++) {
            sb.append(a[1][i]);
            sb.append(" ");
        }
        System.out.println(sb);
    }
}

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

#define ll long long
int main() {
  ll N, T;
  cin >> N >> T;
  
  vector<ll> time(N);
  
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> time[i];
  }
  
  for (int i = 0; i < N-1; i++) {
    if (time[i+1] - time[i] < T) {
      ans += time[i+1]- time[i];
    } else {
      ans += T;
    }
  }
  
  ans += T;
  
  cout << ans << endl;
  
  
  
  
  
  
}

Measured memory_bytes: 4756
/*
  no pain, no gain
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define pii pair<int, int>
#define all(s) s.begin(), s.end()
#define prev myrza4321
#define y1 myrza1234
#define OK puts("OK")
using namespace std;

const int N = (int)1e5 + 5;
const int INF = 0x3f3f3f3f;

main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 5 && b == 7 && c == 5)puts("YES");
	else if (a == 5 && b == 5 && c == 7)puts("YES");
	else if (a == 7 && b == 5 && c == 5)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

ll beki(ll x, ll n){
  ll res = 1LL;
  while(n > 0){
    if(n & 1) res *= x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll X;
  cin >> X;
  vector<ll> box(0);
  set<ll> se;
  ll before = 1LL;
  ll num = 1LL;
  box.push_back(0);
  while(true){
    ll x = beki(num, 5LL);
    box.push_back(x);
    se.insert(x);
    if(x - before > 1000000000) break;
    num++;
    before = x;
  }

  ll bsize = box.size();
  
  ll A = 0, B = 0;
  for(int i = 0; i < bsize; i++){
    ll p = X - box.at(i);
    ll q = X + box.at(i);
    if(p > 0){
      if(se.count(p)){
        B = -1 * i;
        A = distance(box.begin(), lower_bound(ALL(box), p));
        break;
      }
    }
    if(se.count(q)){
      B = i;
      A = distance(box.begin(), lower_bound(ALL(box), q));
      break;
    }
  }
  cout << A << ' ' << B << endl;


}

Measured memory_bytes: 3600
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 2003
#include <bits/stdc++.h>
using namespace std;

vector<int> edge[maxn];
int res[maxn], visited[maxn], d[maxn];
int n, px, py;

void bfs(int root){
    visited[root] = 1;
    queue<int> Q;
    Q.push(root);
    while(!Q.empty()){
        //cout << node << endl;
        int node = Q.front();
        Q.pop();
        for(auto x: edge[node]){
            if(visited[x]) continue;
            visited[x] = 1;
            d[x] = d[node] + 1;
            Q.push(x);
        }
    }
    for(int i=1;i<=n;i++){
        res[d[i]] ++;
    }
}

int main() {


    cin >> n >> px >> py;
    for(int i=1;i<n;i++){
        edge[i].pb(i+1);
        edge[i+1].pb(i);
    }
    edge[px].pb(py);
    edge[py].pb(px);
    for(int i=1;i<=n;i++){
        memset(visited, 0, sizeof visited);
        memset(d, 0, sizeof d);
        bfs(i);
    }
    for(int i=1;i<n;i++){
        cout << res[i]/2 <<endl;
    }
    return 0;
}


Measured memory_bytes: 384
from operator import itemgetter
n, m = map(int, input().split())
bridge = 0
ab = []
for _ in range(m):
  a, b = map(int, input().split())
  ab.append((a,b))
ab = sorted(ab, key=itemgetter(1))
count = 0
for a, b in ab:
  if not a <= bridge <= b:
    count += 1
    bridge = b-1
print(count)


Measured memory_bytes: 18980
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n ; i++) {
            a[i] = in.nextInt();
        }

        int[] dp = new int[n];
        int max = -1;
        for (int i = n - 2; i >= 0 ; i--) {

            if (a[i] >= a[i+1]) {
                dp[i] = dp[i+1]+1;
                max = Math.max(max, dp[i]);
            } else {
                dp[i] = 0;
            }

        }
        if (max == -1) {
            System.out.println(0);
        } else {
            System.out.println(max);

        }




    }



}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    vector<int> cnt(201010);
    int cu = 0;
    int dg = 1;

    for(int i = n - 1; i >= 0; i--) {
        cu = (cu + dg * (s[i] - '0')) % 2019;
        dg = (dg * 10) % 2019;

        ans += cnt[cu];
        if(cu == 0) ans++;

        cnt[cu]++;
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

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

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

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


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


struct Node {
    int id;
    int parentId;
    int leftChildId;
    int rightSiblingId;
};


class RootedTree {
public:
    static const int NIL_ID = -1;

    Node *nodes;
    int size;

    RootedTree(int n) {
        nodes = (Node *)malloc(sizeof(Node) * n);
        size = n;
        for (int i = 0; i < size; i++)
        {
            nodes[i] = Node{i, NIL_ID, NIL_ID, NIL_ID};
        }
    }

    ~RootedTree() {
        free(nodes);
    }

    void push_values(int id, int childCnt, int childIds[]) {
        int prevChildId = NIL_ID;
        for (int i = 0; i < childCnt; i++)
        {
            int childId = childIds[i];
            if (i == 0)
            {
                nodes[id].leftChildId = childId;
            } else {
                nodes[prevChildId].rightSiblingId = childId;
            }
            prevChildId = childId;
            nodes[childId].parentId = id;
        }
    }

    int getDepth(int id) {
        int d = 0;
        int curId = id;
        while (nodes[curId].parentId != NIL_ID)
        {
            curId = nodes[curId].parentId;
            d++;
        }
        return d;
    }

    void printNode(int id) {
        cout << "node " << id << ": parent = " << nodes[id].parentId << ", depth = ";
        int depth = getDepth(id);
        cout << depth << ", " << getNodeType(id, depth) << ", [";
        for (int i = 0, childId = nodes[id].leftChildId; childId != NIL_ID; childId = nodes[childId].rightSiblingId, i++)
        {
            if (i > 0)
                cout << ", ";
            cout << childId;
        }
        cout << "]";
    }

private:
    string getNodeType(int id, int depth) {
        if (depth == 0) {
            return "root";
        } else if (depth > 0 && nodes[id].leftChildId == NIL_ID) {
            return "leaf";
        } else if (depth > 0 && nodes[id].leftChildId != NIL_ID) {
            return "internal node";
        } else {
            throw "there is something wrong on input";
        }
    }
};


int main() {
    int N;
    int i, j, id, deg;

    cin >> N;

    unique_ptr<RootedTree> tree(new RootedTree(N));

    for (i = 0; i < N; i++) {
        cin >> id >> deg;
        int childIds[deg];
        for (j = 0; j < deg; j++)
            cin >> childIds[j];
        tree->push_values(id, deg, childIds);
    }

    for (i = 0; i < N; i++) {
        tree->printNode(i);
        cout << endl;
    }
}



Measured memory_bytes: 4604
import java.util.*;

public class Main{
  public static void main(String[] main){
    Scanner sc = new Scanner(System.in);
    double A = sc.nextInt();
    double V = sc.nextInt();
    double B = sc.nextInt();
    double W = sc.nextInt();
    double T = sc.nextInt();
    
    if(V<=W){
       System.out.print("NO");
    }else{
      if(Math.abs(A - B) / Math.abs(V - W) <= T){
        System.out.print("YES");
      }else{
        System.out.print("NO");
      }
    } 
  }
}
    

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

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

    string s;
    cin >> s;
    vector<int> A(26, 0);
    for(int i = 0; i < s.size(); i++){
        A[s[i] - 'a']++;
    }

    for(int i = 0; i < 26; i++){
        if(A[i] == 0){
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################

#####ide_ele#####
ide_ele = 0
#################


class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

n, k = map(int, input().split())
st = SegTree([0] * 300001, segfunc, ide_ele)
for _ in range(n):
    a = int(input())
    v = st.query(max(0, a - k), min(300001, a + k + 1)) + 1
    st.update(a, v)
print(st.query(0, 300001))


Measured memory_bytes: 110232
import sys
import numpy as np


def inputs(func=lambda x: x, sep=None, maxsplit=-1):
	return map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit))

def input_row(n : int, type=np.int, **kwargs):
	return np.fromiter(inputs(type, **kwargs), dtype=type)

def input_2d(nrows : int, ncols : int, type=np.int, **kwargs):
	data = np.zeros((nrows, ncols), dtype=type)
	for i in range(nrows):
		data[i, :] = input_row(ncols, type, **kwargs)
	return data

from math import cos, sin, pi, sqrt

A, B, H, M = inputs(int)
t = H * 60 + M
hour_stick = A * cos(2 * pi * t / 720), A * sin(2 * pi * t / 720)
minute_stick = B * cos(2 * pi * t / 60), B * sin(2 * pi * t / 60)
difference = hour_stick[0] - minute_stick[0], hour_stick[1] - minute_stick[1]
distance = sqrt(sum(x * x for x in difference))

print(distance)


Measured memory_bytes: 27220
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    unordered_map<string, bool> exist;
    size_t Q; cin >> Q;

    while (Q--) {
        string com, s; cin >> com >> s;
        if (com[0] == 'i') {
            exist[s] = true;
        } else {
            cout << (exist[s] ? "yes" : "no") << "\n";
        }
    }

    return 0;
}



Measured memory_bytes: 44916
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int a[n];
	bool flag[n] = {};
	REP(i, n) cin >> a[i];
	REP(i, n-1){
		if (a[i] < a[i+1]) flag[i] = 1;
	}
	
	int cnt = 0;
	int ans = 0;
	REP(i, n-1){
		if (flag[i]){
			if (ans < cnt) ans = cnt;
			cnt = 0;
		}
		else cnt++;
	}

	cout << max(ans, cnt) << endl;


}


Measured memory_bytes: 768
#pragma warning(disable:4996)
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int N,T,A,h[10000000],ans,i;
double a=11111111;

int main()
{
	scanf("%d %d %d", &N, &T, &A);
	for (i = 1; i <= N; i++)
	{
		scanf("%d", &h[i]);
		if (a > fabs(T - 0.006*h[i] - A))
		{
			a = fabs(T - 0.006*h[i] - A);
			ans = i;
		}
	}
	printf("%d", ans);

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    int n;
    cin >> n;

    vector<int> a(n);

    for0(i, n){
        cin >> a[i];
    }

    if (find(a.begin(), a.end(), 1) == a.end()) {
        cout << -1;
        return 0;
    }

    if (n == 1) {
        cout << (a[0] == 1 ? 0 : -1);
        return 0;
    }

    bool flag = true;
    for1n(i, n){
        flag &= (i == a[i - 1]);
    }
    if (flag) {
        cout << 0;
        return 0;
    }

    auto x = a.begin(), t = a.begin();
    int result = 0;
    int i;

    for (i = 1; i < n; ++i) {
        t = find(x, a.end(), i);
        if (t == a.end()) { break; }
        result += t - x;
        x = t + 1;
    }

    {
        result += a.end() - x;

        cout << result;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  map<string,int> x;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    x[s]++;
  }
  for(string s:{"AC","WA","TLE","RE"}){
    cout<<s<<" x "<<x[s]<<endl;
  }
}

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.k << ", " << p.v << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    string s;
    cin >> s;
    string r;
    for (auto &c : s) {
        if (c == 'B' && r.size()) {
            r.pop_back();
        } else if (c != 'B') {
            r.push_back(c);
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){

int n,a,b,c,d,x,y,z;
cin>>n>>a>>b>>c>>d;

x=n/a;
if(n%a==0){
  x=x;
}
else{
  x=x+1;
}
y=n/c;
if(n%c==0){
  y=y;
}
else{
  y=y+1;
}

x=x*b;
y=y*d;

z=min(x,y);
cout<<z<<endl;
  return 0;
}



Measured memory_bytes: 3096