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

#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 FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

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 vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  int a,b;
  cin>>a>>b;
  int ans=0;
  if(b%a==0)ans=a+b;
  else ans=b-a;
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 125568
#include<stdio.h>
int main(){
  int a,b[200000],i,max,min;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  min=b[0];
  max=b[1]-b[0];
  for(i=1;i<a;i++){
    if(max<b[i]-min){
      max=b[i]-min;
    }
    if(min>b[i]){
      min=b[i];
    }
  }
  
  printf("%d\n",max);
  return 0;
}



Measured memory_bytes: 2572
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let x: i64 = read();
    let y: i64 = read();
    let mut ans = 1_000_000_000;

    let ab = 2 * c;

    for i in 0..max(x, y)+1 {
        let mut maybe_ans = i * ab;
        
        if (i < x) {
            maybe_ans += a * (x-i);
        } 
        if (i < y) {
            maybe_ans += b * (y-i);
        }
        ans = min(ans, maybe_ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll n,k,i,j;
	string s;
	cin>>n>>k>>s;
	for(i=0; i<k-1; i++)
	cout<<s[i];
	s[k-1]+=('a'- 'A');
	//i++;
	cout<<s[k-1];
	for(j=k; j<n; j++)
	cout<<s[j];
    return 0;
}























Measured memory_bytes: 256
#!/usr/bin/perl

my $s = scalar(<STDIN>);
$s =~ s/[\x00-\x20]+$//ios;
my $t = scalar(<STDIN>);
$t =~ s/[\x00-\x20]+$//ios;

if( $s eq substr($t,0,length($s)) and length($t) == length($s) + 1 and substr($t,length($s),1) =~ /[a-z]/os ){
  print "Yes\n";
} else {
  print "No\n";
}



Measured memory_bytes: 4812
#include<stdio.h>

int main(){

	int n,l[201],tmp,sum=0;
	
	scanf("%d",&n);
	for(int i=0;i<2*n;i++){
		scanf("%d",&l[i]);
//		printf("%d\n",l[i]);
	}

	for(int i=0;i<2*n-1;i++){
		for(int j=i+1;j<2*n;j++){
			if(l[i]>l[j]){
				tmp=l[i];
//				printf("%d\n",l[i]);
				l[i]=l[j];
				l[j]=tmp;
//				printf("%d\n",l[i]);
			}
		}
	}


/*	for(int i=0;i<2*n;i++){
		printf("%d",l[i]);
	}
*/

	for(int i=0;i<n;i++){
		sum+=l[2*i];
		}

	printf("%d",sum);

	return 0;
}

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

using namespace std;

const int M = 110;
vector <int> odd;
int A[M];
int n, m;

int main() {
     //freopen("a.txt", "r", stdin);
     cin >> n >> m;
     for(int i = 1; i <= m; ++i)
         cin >> A[i];
     if(m == 1) {
         cout << A[1] << endl;
         if(A[1] == 1) {
             cout << 1 << endl << 1 << endl;
             return 0;
         }
         cout << 2 << endl;
         cout << A[1] - 1 << " " << 1 << endl;
         return 0;
     }
     for(int i = 1; i <= m; ++i) {
         if(A[i] % 2 == 1)
             odd.push_back(i);
     }
     if(odd.size() > 2) {
         puts("Impossible");
         return 0;
     }
     if(odd.size() > 0) swap(A[odd[0]], A[1]);
     if(odd.size() > 1) swap(A[odd[1]], A[m]);

     for(int i = 1; i <= m; ++i)
         cout << A[i] << " ";
     cout << endl;
     A[1]++; A[m]--;
     if(A[m] == 0) m--;
     cout << m << endl;
     for(int i = 1; i <= m; ++i) {
         cout << A[i] << " ";
     }

}

Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

const ll maxp = 100000 * 10000 + 1;

int n, k, w[100005];

bool check(int p) {
  int i = 0;
  rep(j, k) {
    int t = p;
    while (t >= w[i]) {
      t -= w[i];
      i++;
      if (i == n) return true;
    }
  }
  return false;
}

ll binarySearch(ll left, ll right) {
  if (left >= right) return left;
  ll mid = (left + right) / 2;
  if (check(mid)) binarySearch(left, mid);
  else binarySearch(mid + 1, right);
}

int main() {
  cin >> n >> k;
  rep(i, n) cin >> w[i];

  cout << binarySearch(0, maxp) << endl;;

  
  return 0;
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

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

int mp[333][333];
pair<int,int> p[333*333];
vector<vector<int> > v;

int main()
{
	int h,w,d;cin >> h >> w >> d;
	
	REP(i,h)REP(j,w)
	{
		cin >> mp[i][j];
		p[mp[i][j]] = MP(i,j);
	}
		
	REP(i,d)
	{
		vector<int> a;
		a.PB(0);
		int tmp = i + 1;
		for(int j = tmp+d;j <= h*w; j += d)
		{
			a.PB(a[a.size()-1] + abs(p[j].FI - p[j-d].FI) + abs(p[j].SE - p[j-d].SE));
		}
		v.PB(a);
	}
	
/*
	REP(i,d)
	{
		SHOW1d(v[i],v[i].size());
	}
	*/
	
	int q;cin >> q;
	
	REP(i,q)
	{
		int a,b;cin >> a >> b;
		int tmp = a % d;
		int T;
		if(tmp == 0)
		{
			T = d - 1;
			tmp = d;
		}
		else T = tmp - 1;
		//cout << T << endl;
		//cout << (b-tmp)/d << ' ' << (a-tmp)/d << endl;
		//cout << v[T][(b-tmp)/d] << ' ' << v[T][(a-tmp)/d] << endl;
		cout << v[T][(b-tmp)/d] - v[T][(a-tmp)/d] << endl;
	}
			
	
	
	
	return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;cin>>a>>b>>c;
  if(a+b>=c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
  }


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

using namespace std;

typedef long long LL;

const int N = 100010;

int n;

int main()
{
    cin >> n;

    int res = 0;
    while(n--)
    {
        int l, r;
        cin >> l >> r;
        res += (r - l + 1);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int H,W; cin>>H>>W;
    vector<string> a(H);
    REP(i,H) cin>>a[i];

    vector<bool> row(H,false);
    vector<bool> col(H,false);
    REP(i,H) REP(j,W){
        if(a[i][j]=='#'){
            row[i]=col[j]=true;
        }
    }
    
    REP(i,H){
        if(!row[i]) continue;
        REP(j,W){
            if(!col[j]) continue;
            cout<<a[i][j];
        }
        cout<<endl;
    }

}


Measured memory_bytes: 256
M=10**9+7
N,A,B,C=map(int,input().split())
f=[1]
for i in range(1,2*N):
	f.append(f[-1]*i%M)
t=pow(A+B,M-2,M)
A*=t
B*=t
a=pow(A,N,M)
b=pow(B,N,M)
z=0
for i in range(N):
	z+=(N+i)*100*pow(100-C,M-2,M)*f[N+i-1]*pow(f[N-1]*f[i],M-2,M)*(a+b)
	z%=M
	a=a*B%M
	b=b*A%M
print(z)


Measured memory_bytes: 11052
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "YES";
const string NO  = "NO";

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

    int a, b, x;

    cin >> a >> b >> x;

    if (x >= a && a + b >= x) {
        cout << YES;
    } else {
        cout << NO;
    }
    cout << endl;

    return 0;
}



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

long long n;
vector<vector<int>> edge;
vector<bool> ch;
vector<long long> p, memo;

long long solve();
void dfs(int now);
void calc(int now, int bf);

int main() {
  cin >> n;
  edge.resize(n);
  for(int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  p.resize(n);
  for(int i = 0; i < n; ++i) cin >> p[i];
  for(int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    p[i] -= b;
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  ch.assign(n, 0);
  ch[0] = 1;
  dfs(0);
  ch.assign(n, 0);
  ch[0] = 1;
  memo.assign(n, 0);
  calc(0, -1);
  long long res = 0, one = 0;
  for(auto p : memo) {
    res += p;
    one = min(one, p);
  }
  return res - one * n;
}

void dfs(int now) {
  for(auto to : edge[now])
    if(!ch[to]) {
      ch[to] = 1;
      dfs(to);
      p[now] += p[to];
    }
}

void calc(int now, int bf) {
  if(bf >= 0) memo[now] = memo[bf] + p[now];
  for(auto to : edge[now])
    if(!ch[to]) {
      ch[to] = 1;
      calc(to, now);
    }
}



Measured memory_bytes: 14236
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,d=IL()
X=[IL() for i in range(n)]
c=0
for i in range(n-1):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis+=(X[i][k]-X[j][k])**2
        if int(dis**0.5)==dis**0.5:
            c+=1
print(c)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int A, B;
    cin >> A >> B;
    int a = A / 2;
    int d = 25 * a % 10;
    int t = B - 25 * a / 10;
    if (t < 0) {
        cout << "-1\n";
        return 0;
    }
    if (A % 2 == 0) {
        if (t == 0) {
            cout << 25 * a << "\n";
        } else {
            if (t > 1) cout << "-1\n";
            else {
                if (d == 0) {
                    cout << 25 * a + 10 << "\n";
                } else {
                    cout << 25 * a + 5 << "\n";
                }
            }
        }
    } else {
        if (t == 0 || t > 2) {
            cout << "-1\n";
            return 0;
        }
        if (t == 1) {
            cout << 25 * a + 13 << "\n";
        } else {
            if (d == 0) {
                cout << 25 * a + 20 << "\n";
            } else {
                cout << 25 * a + 15 << "\n";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
r, s, p = map(int, readline().split())
t = input()
ans = [0, 0, 0]
check = t[:k]
for i in range(k, n):
    if t[i] == check[i - k]:
        check += '?'
    else:
        check += t[i]
for i in range(n):
    if check[i] != check[i - k] or i < k:
        if check[i] == 'r':
            ans[0] += 1
        elif check[i] == 's':
            ans[1] += 1
        elif check[i] == 'p':
            ans[2] += 1
print(ans[0] * p + ans[1] * r + ans[2] * s)


Measured memory_bytes: 3444
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

const int BIT_MAX = 100010;
const LL mod = 1e9 + 7;

template <class T> class BIT {
    T x[BIT_MAX + 1];

public:

    BIT() {
        fill(x, x + BIT_MAX + 1, 0);
    }

    void add(int a , T b) {
        ++a;
        for(; a <= BIT_MAX ; a += a & -a) (x[a] += b) %= mod;
    }

    T get(int a) {
        ++a;
        T b = 0;
        for(; a > 0 ; a -= a & -a) (b += x[a]) %= mod;
        return b;
    }
};

int N;
LL A, B;
LL S[100010];
int ta[100010];
int tb[100010];
BIT<LL> va , vb;
int qa , qb;

int main() {
    scanf("%d%lld%lld" , &N , &A , &B);
   // if(A < B) swap(A, B);
    S[0] = -A - 3;
    qa = qb = 0;
    repp(i, 1, N + 1) {
        scanf("%lld" , S + i);
        while(S[i] - S[qa + 1] >= A) ++qa;
        while(S[i] - S[qb + 1] >= B) ++qb;
        ta[i] = qa;
        tb[i] = qb;
    }
    qa = qb = 0;
    va.add(1, 1);
    vb.add(1, 1);
    repp(i, 2, N + 1) {
        int x = (vb.get(ta[i] + 1) - vb.get(qb) + mod) % mod;
        int y = (va.get(tb[i] + 1) - va.get(qa) + mod) % mod;
        if(ta[i] + 1 > qb) va.add(i , x);
        if(tb[i] + 1 > qa) vb.add(i , y);
        if(S[i] - S[i - 1] < A) qa = i - 1;
        if(S[i] - S[i - 1] < B) qb = i - 1;
    }
    printf("%lld\n" , (va.get(N) - va.get(qa) + vb.get(N) - vb.get(qb) + mod + mod) % mod);
    return 0;
}


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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define lu unsigned long long int
#define pi pair<ll, ll>
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define vll ve<ll>
#define vpl ve<pll>
#define lr(n) for(ll i = 0; i < n; i++)
#define ltr(i, l, r) for (ll i = l; i <= r; i++)
#define rtl(i, l, r) for (ll i = r; i >= l; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define be begin
#define sz(a) (ll)(a.size())
#define con continue
#define ret return
#define endl "\n"
const ll INF = 1e18;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

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

// ll mod = 1e9+7;

// ll mult(ll x, ll y){
//     ll rem=1;
//     while(y){
//         if(y&1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y>>=1;
//     }
//     return rem;
// }

struct segtree{
	ll size;
	ve<ll> seg;

	ll neutral = 0;

	ll single(ll v){
		return v;
	}

	ll merge(auto &a, auto &b){
		return max(a, b);
	}

	void init(ll n){
		size = 1;
		while(size < n) size *= 2;
		seg.assign(2*size, neutral);
	}

	void set(ll i, ll v, ll x, ll lx, ll rx){
		if(rx - lx == 1){
			seg[x] = single(v);
			return;
		}
		ll m = (lx + rx) / 2;
		if(i < m){
			set(i, v, 2*x+1, lx, m);
		}
		else{
			set(i, v, 2*x+2, m, rx);
		}
		seg[x] = merge(seg[2*x+1], seg[2*x+2]);
	}

	void set(ll i, ll v){
		set(i, v, 0, 0, size);
	}

	ll query(ll l, ll r, ll x, ll lx, ll rx){
		if(lx>=r || rx<=l){
			return neutral;
		}
		if(lx>=l && rx<=r){
			return seg[x];
		}
		ll m = (lx + rx) / 2;
		auto q1 = query(l, r, 2*x+1, lx, m);
		auto q2 = query(l, r, 2*x+2, m, rx);
		return merge(q1, q2);
	}

	ll query(ll l, ll r){
		return query(l, r, 0, 0, size);
	}
};


void solve(ll T){
	ll n,k;
	cin>>n>>k;
	ve<ll>ar(n);
	lr(n){
		cin>>ar[i];
	}
	segtree seg;
	seg.init(300001);
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll x = seg.query(max(ar[i]-k, 0LL), min(ar[i]+k, 300000LL)+1);
		ans=max(ans, x+1);
		seg.set(ar[i], x+1);
	}
	cout << ans << "\n";
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// std::cout << std::unitbuf;
	ll T=1;
	// cin>>T;
	for(ll t=1;t<=T;t++){
		solve(t);
	}
	return 0;
}


Measured memory_bytes: 13768
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	ll x,y;
	cin>>x>>y;
	if(y%2==0&&y>=2*x&&y<=4*x)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(int k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
  
  Mint inv(){return pow(MOD-2);}
  
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
  
  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-(){return v?MOD-v:v;}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}

};
//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  int n=s.size();

  {
    string t=s;
    t.erase(unique(t.begin(),t.end()),t.end());
    if(s==t){
      cout<<1<<endl;
      return 0;
    }
  }
  
  vector<int> a(n+1);
  for(int i=0;i<n;i++)
    a[i+1]=a[i]+(s[i]=='a'?1:2);

  vector<vector<int> > x(3);
  for(int i=1;i<=n;i++)
    x[a[i]%3].emplace_back(i);

  x[0].emplace_back(n+1);
  x[1].emplace_back(n+1);
  x[2].emplace_back(n+1);
  
  using M = Mint<int>;
  vector<M> dp(n+1,0);
  dp[0]=1;
  
  for(int i=0,j=0;i<n;i++){
    dp[i+1]+=dp[i];

    chmax(j,i+1);
    while(j<n&&s[j-1]!=s[j]) j++;

    //cout<<(a[i]+1+(s[i]=='a'))%3<<endl;
    auto v=x[(a[i]+1+(s[i]=='a'))%3];
    int k=*lower_bound(v.begin(),v.end(),j);
    if(k<=n) dp[k]+=dp[i];
    
    //cout<<i<<":"<<dp[i].v<<":"<<j<<" "<<k<<endl;
  }

  M ans(0);
  for(int i=1;i<=n;i++)
    if((a[n]-a[i])%3==0) ans+=dp[i];
  
  cout<<ans.v<<endl;
  return 0;
}


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

using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void chmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  ll n;
  cin >> n;
  vi a(n);
  rep(i, 0, n){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll mx = a.back();
  vi dp(mx+5, 0);
  
  rep(i, 0, n){
    if(dp[a[i]] > 1)
      continue;
    
    for(int j = a[i]; j <= mx; j += a[i]){
      dp[j]++;
    }
  }
  
  int ans = 0;
  
  rep(i, 0, n){
    if(dp[a[i]] == 1)
      ans++;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 12764
// https://atcoder.jp/contests/abc090/tasks/abc090_b
"use strict";
function Main(input) {
  // const [A, B] = input.split(" ").map(Number);
  const A = input.split(" ")[0] - 0;
  const B = input.split(" ")[1] - 0;
  let count = 0;

  for (let i = A; i <= B; i++) {
    const s = i.toString();
    const reverseS = s.split("").reverse().join("");

    if (s === reverseS) {
      count++;
    }
  }

  console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 13472
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int vy[4] = {1, 0, -1, 0};
int vx[4] = {0, 1, 0, -1};

int main() {
    int h, w; cin >> h >> w;
    vector<string> vc;

    for (int i = 0; i < h; ++i) {
        string str; cin >> str;
        vc.push_back(str);
    }

    bool drawable = true;
    for (int i = 0; i < h && drawable; ++i) {
        for (int j = 0; j < w && drawable; ++j) {
            if (vc[i][j] == '.') continue;
            bool check = false;
            for (int k = 0; k < 4; ++k) {
                if ((i - vy[k]) < 0 || (i - vy[k]) >= h) continue;
                if ((j + vx[k]) < 0 || (j + vx[k]) >= w) continue;
                if (vc[i - vy[k]][j + vx[k]] == '#') check = true;
                if (check) break;
            }
            drawable = check;
        }
    }

    cout << (drawable ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
(defun solve (lst)
  (let ((prices (mapcar
                 (lambda (price-and-unit)
                   (let ((price (car price-and-unit))
                         (unit (cadr price-and-unit)))
                     (if (string-equal unit "JPY")
                         price
                         (* price 380000))))
                 lst)))
    (apply '+ prices)))

(defun main ()
  (let* ((n (read))
         (lst (loop for x from 1 to n
                    collect `(,(read) ,(read)))))
    (format t "~A~%" (solve lst))))


(main)


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> alpha(n, vector<int>(26, 0)); // i番目の文字列に含まれる各アルファベットの個数
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, (int)s.size()) {
            alpha[i][s[j]-'a']++;
        }
    }
    string ans;
    rep(j, 26) {
        int _min = 50;
        rep(i, n) {
            _min = min(_min, alpha[i][j]);
        }
        rep(i, _min) {
            ans.push_back('a'+j);
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

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

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> p(N);
    rep(i, N) { 
        cin >> p[i];
    }
    vector<ll> a(N);
    vector<ll> b(N);
    rep(i, N) {
        a[i] = (i+1) * 30000;
        b[i] = (N-i) * 30000; 
    }
    rep(i, N) {
        a[p[i]-1] += i;
    }
    print(a);
    print(b);
    return 0;
} 

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;

struct Data{
	int y,x;
	Data(){}
	Data(int _y,int _x){
		y=_y; x=_x;
	}
};

int pW,pH,N;
bool fld[6000][6000];
const int dy[4]={-1,0,1,0},dx[4]={0,1,0,-1};

int press(int x[][1000],int W){
    vector<int> x_c;
    for(int i=0;i<N;i++){
        x_c.push_back(x[0][i]); x_c.push_back(x[1][i]);
        if(x[0][i]!=0) x_c.push_back(x[0][i]-1);
        if(x[1][i]!=0) x_c.push_back(x[1][i]-1);
        if(x[0][i]!=W-1) x_c.push_back(x[0][i]+1);
        if(x[1][i]!=W-1) x_c.push_back(x[1][i]+1);
    }
    sort(x_c.begin(),x_c.end());
    x_c.erase(unique(x_c.begin(),x_c.end()),x_c.end());
    //for(int i=0;i<x_c.size();i++) printf(" %d",x_c[i]); puts("");
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            x[i][j] = find(x_c.begin(),x_c.end(),x[i][j])-x_c.begin();
        }
    }
    return x_c.size();
}

int main(){
    int W,H;
	while(cin>>W>>H,W||H){
		int x[2][1000],y[2][1000];
		cin>>N;
		for(int i=0;i<N;i++){
			cin>>x[0][i]>>y[0][i]>>x[1][i]>>y[1][i];
			x[1][i]--; y[1][i]--;
		}
		pW = press(x,W); pH = press(y,H);
		for(int i=0;i<pH;i++)for(int j=0;j<pW;j++) fld[i][j]=false;
		for(int k=0;k<N;k++){
			for(int i=y[0][k];i<=y[1][k];i++){
				for(int j=x[0][k];j<=x[1][k];j++){
					fld[i][j]=true;
				}
			}
		}
		int ans=0;
		for(int i=0;i<pH;i++){
			for(int j=0;j<pW;j++){
				//printf("%d ",fld[i][j]);
				if(fld[i][j]) continue;
				fld[i][j]=true;
				ans++;

				stack<Data> s; s.push(Data(i,j));
				Data s_c;
				while(!s.empty()){
					s_c = s.top(); s.pop();
					for(int k=0;k<4;k++){
						int ny = s_c.y+dy[k],
							nx = s_c.x+dx[k];
						if(ny<0 || pH<=ny || nx<0 || pW<=nx || fld[ny][nx]) continue;
						fld[ny][nx]=true;
						s.push(Data(ny,nx));
					}
				}
			}//puts("");
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 11916
#include<iostream>
using namespace std;
int main(){
  int n,i,j,ans=0;
  cin >> n;
  for(i=1;i<=n;i=i+2){
    int count=0;
    for(j=1;j<=i;j++){
      if(i%j==0){
        count++;
      }
    }
    if(count==8){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3516
#include<stdio.h>
int n;
int num;
int i,j,k,l;
int main()
{
    while(scanf("%d",&n) != -1)
    {
        num = 0;
        for(i = 0;i < 10;i++)
        {
            for(j = 0;j < 10;j++)
            {
                for(k = 0;k < 10;k++)
                {
                    for(l = 0;l < 10;l++)
                    {
                      if(n == i + j + k + l)
                      {
                          num++;
                      }
                    }
                }
            }
        }
        printf("%d\n",num);



    }
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N, H;  cin >> N >> H;
	V b(N);
	int max_a = -1;
	REP(i, N){
			int a, ib;  cin >> a >> ib;
			max_a = max(a, max_a);
			b[i] = ib;
	}

	PQ que;
	REP(i, N)
			if(b[i] >= max_a)
					que.push(b[i]);


	int ans = 0;
	while(!que.empty() && H > 0){
			H -= que.top();
			que.pop();
			ans += 1;
	}
	if(H > 0)
			ans += (H + (max_a - 1)) / max_a;

	cout << ans << endl;

	return 0;
}


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

using namespace std;

int gcd(int a, int b) {
  if(a < b) swap(a, b);
  if(b == 0) return a;
  return gcd(b, a%b);
}

int main() {
  int N;
  int A[100001];
  cin >> N;
  for(int i=0; i<N; ++i) {
    cin >> A[i];
  }
  int ans = gcd(A[0], A[1]);
  for(int i=2; i<N; ++i) {
      ans = gcd(ans, A[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())
l = []
if 0 <= n <= 10000:
    for i in range(1,(n + 1)):
        if i % 3 == 0:
            l.append(str(i))
        elif i % 10 == 3:
            l.append(str(i))
        elif '3' in str(i):
            l.append(str(i))    

print(' ' + ' '.join(l))

Measured memory_bytes: 7840
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
    }
    int ans = 0;
    vector<int> suf(n);
    suf[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; -- i) {
        suf[i] = max(a[i], suf[i + 1]);
    }
    int profit = 0;
    for (int i = 0; i < n - 1; ++ i) {
        if (suf[i + 1] - a[i] > profit) profit = suf[i + 1] - a[i];
    }
    for (int i = 0; i < n - 1; ++ i) {
        if (suf[i + 1] - a[i] == profit) ans ++;
    }
    cout << ans;
}

Measured memory_bytes: 1024
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

string s;
string form = "ABC";


int cntC[N];
int cntA[N];
int cntQ[N];
int Lways[N];
int Rways[N];

void add_self(int & a , int b){
    a += b;
    a %= mod;
}

int fastP(int b, int e){
    if(!e)
        return 1;
    if(e & 1)
        return b * 1ll * fastP(b * 1ll * b % mod, e >> 1) % mod;
    return fastP(b * 1ll * b % mod, e >> 1) % mod;
}

int main(){
    cin >> s;
    int n = s.size();
    int ways = 0;
    cntA[0] = (s[0] == 'A');
    cntQ[0] = (s[0] == '?');
    cntC[0] = (s[0] == 'C');
    for(int i = 1; i < n; i++){
        cntA[i] = (s[i] == 'A') + cntA[i - 1];
        cntQ[i] = (s[i] == '?') + cntQ[i - 1];
        cntC[i] = (s[i] == 'C') + cntC[i - 1];
    }
    for(int i = 1; i < n; i++){
        if(s[i] == 'B' || s[i] == '?'){
            Lways[i] = 1ll * cntA[i - 1] * fastP(3 , cntQ[i - 1]) % mod;
            if(cntQ[i - 1]){
                add_self(Lways[i] , 1ll * cntQ[i - 1] * fastP(3 , cntQ[i - 1] - 1) % mod);
            }
        }
    }
    for(int i = n - 1; i > 0; i--){
        if(s[i] == 'B' || s[i] == '?'){
            Rways[i] = 1ll * (cntC[n - 1] - cntC[i]) * fastP(3 , cntQ[n - 1] - cntQ[i]) % mod;
            if(cntQ[n - 1] - cntQ[i]){
                add_self(Rways[i] , 1ll * (cntQ[n - 1] - cntQ[i]) * fastP(3 , (cntQ[n - 1] - cntQ[i]) - 1) % mod);
            }
        }
    }
    for(int i = 0; i < n; i++){
        add_self(ways , 1ll * Lways[i] * Rways[i] % mod);
    }
    cout << ways << endl;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
#define vi vector<int>
long long mod=1000000007;
//int count=INT_MAX;
 
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
ll repUnitValue(ll n) 
{ 
  
    // To check n is coprime or not 
    if (n % 2LL == 0 || n % 5LL == 0) 
        return 0; 
  
    // to store R(k) mod n and 10^k 
    // mod n value 
    ll rem = 1; 
    ll power = 1; 
    ll k = 1; 
    while (rem % n != 0LL) 
    { 
        k++; 
        power = power * 10LL % n; 
        rem = (rem + power) % n; 
    } 
      
    return k; 
} 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    while(testcases--){  
        ll k;
        cin>>k;
        if(k%2LL==0LL){
            cout<<"-1\n";
            continue;
        }
        if(k==7){
            cout<<"1\n";
            continue;
        }
        if(k%7==0){
            k=k/7;
        }
        ll ans=repUnitValue(k);
        if(ans==0LL) cout<<"-1\n";
        else cout<<ans<<endl;
    }                                                                                          
    
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

const long long INF = 1LL<<60;
int H, N;
vector<int> A, B;

long long solve() {
    vector<vector<long long>> dp(N+1, vector<long long>(H+1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+A[i], H)], dp[i+1][j] + B[i]);
        }
    }
    return dp[N][H];
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    
    while (cin >> H >> N) {
        A.resize(N); B.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
        cout << solve() << endl;
    }
}


















Measured memory_bytes: 78592
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  uint64_t N;
  cin >> N;
  vector<pair<uint64_t, uint64_t>> vp;

  for (uint64_t i = 1; i <= sqrt(N); ++i)
  {
    if (N % i == 0)
      vp.push_back({N/i, i});
  }

  uint64_t min = vp[0].first + vp[0].second;
  for(auto& p: vp) {
    if(p.first + p.second < min)
      min = p.first + p.second;
  }

  cout << min - 2 << endl;

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main( void ){
  int a, b;
  char op;

  scanf( "%d %c %d", &a, &op, &b );

  if( op == '-' ){
    printf( "%d\n", a-b );
  }else if( op == '+' ){
    printf( "%d\n", a+b );
  }

  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int a,b,q;
  cin >> a >> b >> q;
  vi s(a),t(b);
  REP(i,a) cin >> s.at(i);
  REP(i,b) cin >> t.at(i);
  REP(i,q){
    int x;
    cin >> x;
    auto sit = lower_bound(ALL(s),x);
    auto tit = lower_bound(ALL(t),x);
    int sr = *sit;
    int tr = *tit;
    int sl,tl;
    if(sr==x||sit==s.begin()) sl = -LLONG_MAX/10;
    else if(sit==s.end()) sr = LLONG_MAX/10,sl = *(sit-1);
    else sl = *(sit-1);
    if(tr==x||tit==t.begin()) tl = -LLONG_MAX/10;
    else if(tit==t.end()) tr = LLONG_MAX/10,tl = *(tit-1);
    else tl = *(tit-1);
    ll ans = max(sr-x,tr-x);
    ans = min(ans,max(x-sl,x-tl));
    ans = min(ans,2*(sr-x)+x-tl);
    ans = min(ans,2*(-sl+x)+tr-x);
    ans = min(ans,2*(tr-x)+x-sl);
    ans = min(ans,2*(-tl+x)+sr-x);
    cout << ans << endl;
  }
}



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

int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	long long ans;
	if (x==y||x%y==0) puts("-1");
	else{
		int i=2;
		while(true){
			ans=x*(i++);
			if (ans%y!=0)
				break;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())
import sys
sys.setrecursionlimit(10**6)

c,n=sep()
ar=lis()
ar.sort()
m=-10
for i in range(n):
    t=min(abs(ar[i]-ar[((i-1) + n)%n]),c-abs(ar[i]-ar[((i-1) + n)%n]))
    #print(t)
    if t>m:
        m=t
print(c-m)


Measured memory_bytes: 91500
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int M;

int main() {
  cin >> M;
  cout << 24 - M + 24 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var R = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray()[0];
            Console.WriteLine(Math.PI * 2 * R);
        }
    }
}

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

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
/*
木 dfs 最短経路
https://qiita.com/drken/items/a803d4fc4a727e02f7ba
*/
// using Graph = vector<vector<ll>>;
const ll MAX_N = 1e5;
vector<ll> G[MAX_N];
ll distance_U[MAX_N];
ll distance_V[MAX_N];

// 深さ優先探索
ll seen[MAX_N];
void dfs(ll i, ll d, ll distance[], int N){// i: 今いる場所, d: ここまでの移動距離, distance[]: 各頂点の距離, N: distanceの要素数
	ll G_size = G[i].size();
	// printf("i %lld, size: %lld\n", i, G_size);
    seen[i] = true; // i を訪問済にする
	distance[i] = d; // 距離を記録
    // i から行ける各頂点 next_i について
	REP(j,G_size){
		ll next_i = G[i][j];
		// printf("dfs %lld-> %lld\n", i, next_i);

        if (seen[next_i]) continue; // next_v が探索済だったらスルー
		dfs(next_i, d+1, distance, N); // 再帰的に探索
	}
}

int main() {
	// 入力
	ll N,u,v;cin>>N>>u>>v;u--;v--;
    REP(i,N-1){
        ll a,b;cin>>a>>b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
	}
    // REP(i,N){
	// 	printf("i: %lld -> ", i);
	// 	REP(j,G[i].size()){
	// 		printf("%lld ", G[i][j]);
	// 	}
	// 	printf("\n");
	// }
	// 解法
	REP(i,N)seen[i] = false; // 全頂点を「未訪問」に初期化
	dfs(u, 0, distance_U, N); // 高橋君の各頂点までの距離
	REP(i,N)seen[i] = false; // 全頂点を「未訪問」に初期化
	dfs(v, 0, distance_V, N); // 高橋君の各頂点までの距離
	// REP(i,N)printf("i: %lld, dist U: %lld\n",i, distance_U[i]);
	// REP(i,N)printf("i: %lld, dist V: %lld\n",i, distance_V[i]);
	ll ans = 0;
	REP(i,N){
		if (distance_U[i]<=distance_V[i] & distance_V[i]>ans) ans = distance_V[i];
	}
	ans--;
	//出力
	printf("%lld\n", ans);
}


Measured memory_bytes: 13312
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int num[3];
	cin >> num[0] >> num[1] >> num[2];
	sort(num, num+3);

	int res = 0;
	int tmp = 0;

	tmp = num[2] - num[1];
	num[0] += tmp;
	num[1] += tmp;
	res += tmp;

	tmp = (num[2] - num[0]) / 2;
	num[0] += tmp * 2;
	res += tmp;

	if(num[0] != num[2]){
		res += 2;
	}

	cout << res << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 200010
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;

bool vis[MAXN];
vector<pair<ll int,int>>col[MAXN];
vector<int>adj[MAXN],vv;
ll int fc[MAXN],bfc[MAXN],c[MAXN],w[MAXN],min1,min2,col1,col2,cnt,ans;

void dfs(int node){
	vis[node]=true;vv.pb(c[node]);
	for(int i=0;i<adj[node].size();i++){
		int child=adj[node][i];
		if(!vis[child])
			dfs(child);
	}
}

ll pw(ll a, ll b) {
	ll an = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = (a * a) % mod;
		an = (an * a) % mod, --b;
	}
	return an;
}
 
void init() {
	fc[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fc[i] = (fc[i - 1] * i) % mod;
	for (int i = 0; i < MAXN; ++i)
		bfc[i] = pw(fc[i], mod - 2);
}

int main(){
	ios_base::sync_with_stdio(false);
	ll int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		cin>>c[i]>>w[i];
		col[c[i]].pb(mp(w[i],i));
	}
	min1=min2=mod;
	init();
	for(int i=1;i<=n;i++){
		sort(col[i].begin(),col[i].end());
		if(!col[i].size())continue;
		if(col[i][0].first<min1){
			min2=min1;
			col2=col1;
			min1=col[i][0].first;
			col1=i;
		}
		else if(col[i][0].first<min2){
			min2=col[i][0].first;
			col2=i;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<col[i].size();j++){
			ll int wt1=col[i][j].first; ll int wt2=col[i][0].first;
			ll int u=col[i][j].second; ll int v=col[i][0].second;
			if(wt1+wt2<=x){
				adj[u].pb(v);
				adj[v].pb(u);
			}
			if(i!=col1 && wt1+min1<=y && col1!=0){
				adj[col[col1][0].second].pb(u);
				adj[u].pb(col[col1][0].second);
			}
			if(i!=col2 && wt1+min2<=y && col2!=0){
				adj[col[col2][0].second].pb(u);
				adj[u].pb(col[col2][0].second);
			}
		}
	}
	ans=1;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			vv.clear();
			dfs(i);
			sort(vv.begin(),vv.end());
			ans=(ans*fc[vv.size()])%mod;
			cnt=0;
			for (int i = 0; i < vv.size(); ++i) {
				++cnt;
				if (i == vv.size() - 1 || vv[i + 1] != vv[i]) {
					ans = (ans * bfc[cnt]) % mod;
					cnt = 0;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 30696
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int N,M;
int swi[10][10];
int tuku[10];
int now[10];
int ans;
void func(int s){
    if(s==N){
        int flg=1;
        for(int i=0;i<M;i++){
            int cou=0;
            for(int j=0;j<N;j++){
                if(swi[i][j]==1&&now[j]==1)cou++;
            }
            if(cou%2!=tuku[i]){
                flg=0;
            }
        }
        ans+=flg;
        return;
        /*
        int flg=1;
        for(int i=0;i<M;i++)
        if(nowsum[i]%2!=tuku[i])flg=0;
        ans+=flg;
        return;
        */
    }




    func(s+1);


    now[s]++;
    func(s+1);
    now[s]--;

}
int main(){
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int a;
            cin>>a;
            swi[i][a-1]=1;
        }
    }
    for(int i=0;i<M;i++)cin>>tuku[i];
    func(0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644