akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

long long n, m, a, b, p, q, minx, d, s, B;
long long x[10000], y[10000], c[10000];
long long rem;

int main() {
	cin >> n >> m >> a >> b >> p >> q;
	x[0] = 1; y[0] = 1;
	s = min((long long)10000, n);

	if (a >= 1000000000 && b >= 1000000000) {
		if (p >= 1000000000 && q >= 1000000000) {
			cout << min(m, abs(m - p - q)) << endl;
		}
		else {
			cout << min(m, min(abs(m - p - q), min(abs(m - a * p - b * q), abs(m - a * p - b * q - p - q)))) << endl;
		}
		return 0;
	}

	for (int i = 1; i < s; i++) {
		x[i] = x[i - 1] * a;
		if (x[i] > m) { break; }
	}
	for (int i = 1; i < s; i++) {
		y[i] = y[i - 1] * b;
		if (x[i] > m) { break; }
	}

	if (a == 1 && b == 1) {
		if (n >= 1000001 && (p + q) >= 1000001) { goto F; }
		if (m <= n * (p + q)) {
		F:;
			B = m % (p + q);
			if (B > (p + q) / 2) {
				B = (p + q) - B;
			}
			cout << B << endl;
		}
		else {
			cout << m - (long long)(n * (p + q)) << endl;
		}
		return 0;
	}

	for (int i = 0; i < s; i++) {
		c[i] = p*x[i] + q*y[i];
		if (c[i] > m) {
			d = i;
			minx = c[i] - m;
			goto E;
		}
	}
	minx = m;
	d = s;
E:;
	rem = m - c[d - 1];
	minx = min(minx, abs(rem));
	for (int i = d - 2; i >= 0; i--) {
		minx = min(minx, (long long)abs(rem - c[i]));
		if (rem >= c[i]) {
			rem -= c[i];
		}
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 1316
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
const int mod=1e9+7;
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chadd(T1 &x,T2 b) {x+=b;if(x>=mod) x-=mod;}
template <typename T1,typename T2> inline void chmul(T1 &x,T2 b) {x=1LL*x*b%mod;}
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}
string s;
int n;
int sum[1000005];
int maxch[1000005];
int main(){
	cin>>s;
	n=s.size();
	string ts=s;
	int mx=0;
	for(int i=0;i<n;i++){
		sum[i]=(i?sum[i-1]:0)+(s[i]=='1'?1:-1);
		chmax(mx,sum[i]);
	}
	int res=inf;
	for(int k=0;k<2;k++){
		s=ts;
		int mx=0;
		for(int i=0;i<n;i++){
			sum[i]=(i?sum[i-1]:0)+(s[i]=='1'?1:-1);
			chmax(mx,sum[i]);
		}
		mx+=k;
		for(int i=n-1;i>=0;i--){
			maxch[i]=min((i==n-1?inf:maxch[i+1]),(mx-sum[i])/2);
		}
		int ss=0;
		for(int i=0;i<n;i++){
			if(s[i]!='?'){
				continue;
			}
			if(ss<maxch[i]){
				ss++;
				s[i]='1';
			}
		}
		for(int i=0;i<n;i++){
			if(s[i]=='?') s[i]='0';
		}
		int mn=0;
		for(int i=0;i<n;i++){
			sum[i]=(i?sum[i-1]:0)+(s[i]=='1'?1:-1);
			chmin(mn,sum[i]);
		}
		chmin(res,mx-mn);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 13192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

string S,T,U;
int a,b,c;
vi A,B,C;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int N;cin>>N;
	int l = N %10;
	if(l==0||l==1||l==6||l==8){
		out("pon");
	}else if(l == 2||l==4||l==5||l==7||l==9){
		out("hon");
	}else{
		out("bon");
	}
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#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 each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    vl abc(3);
    rep(i, 3) cin >> abc[i];
    sort(all(abc));
    if (abc[0] == abc[2]) {
        cout << "No" << '\n';
    } else if (abc[1] == abc[2] || abc[0] == abc[1]) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    A = list("zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
    beki = [0, 26, 702, 18278, 475254, 12356630, 321272406, 8353082582, 217180147158, 5646683826134, 146813779479510, 3817158266467286]

    ika = 0
    for i in range(12):
        if n <= beki[i]:
            ika = i
            ran = n - beki[i-1]
            break

    t = ['']*ika
    for i in range(ika)[::-1]:
        d,m = divmod(ran,26)
        t[i] = A[m]
        ran = d
        if m != 0:
            ran += 1
#        if d == 0 or (d == 1 and m == 0):
#            break
    print(''.join(t))

if __name__ == '__main__':
    main()

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

 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,max=0;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    
    for(ll i=0;i<n;i++)
    {
        ll temp=0;
        for(ll j=i+1;j<n;j++)
        {
            while(j<n)
            {
                if(arr[j]<=arr[i])
                {
                    j++;
                    i++;
                    temp++;
                }
                else
                break;
            }
            break;
        }
        if(temp>max)
        max=temp;
        
    }
    cout<<max;
	
	return 0;
}


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

int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> v(m);
  for(int i = 0; i < m; i++){
    cin >> v[i];
  }
  int k = lower_bound(v.begin(), v.end(), x) - v.begin();
  cout << min(k, m - k) << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  vector<ll>veco(a);
  veco=vec;
  sort(vec.begin(),vec.end());
  ll b=0;
  for(ll i=0;i<a;i++){
    if(vec.at(i)!=veco.at(i)){
      b+=1;
    }
  }
  if(b>2){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
  return 0;
}


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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int MAXN = 100005;

ll a[MAXN][4];
ll d[MAXN][4];


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

    int n;
    cin >> n;
    FOR (i, 1, n) {
    	FOR (j, 0, 2) {
    		cin >> a[i][j];
    	} 
    }

    FOR (i, 1, n) {
    	FOR (j, 0, 2) {
    		FOR (k, 0, 2) {
    			if (j == k) continue;
    			d[i][j] = max(d[i][j], d[i - 1][k] + a[i][k]); 
    		}
    	}
    }

    ll res = 0;

    FOR (i, 0, 2) res = max(res, d[n][i]);

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

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    cin >> n;
    vi data(n+1,0);
    for(int i=2;i<=n;i++){
        int a;
        cin >> a;
        data[a]++;
    }
    for(int i=1;i<=n;i++){
        cout << data[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4052
N = int(input())

ans = "Yes"
a = 0
b = 0
T = 0
for _ in range(N):
    t,x,y = map(int, input().split())
    if abs(a-x)+abs(b-y) <= t-T and (abs(a-x)+abs(b-y))%2 == (t-T)%2:
        a = x
        b = y
        T = t
    else:
        ans = "No"

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;

string ar;

bool isPalindrome(int a, int b) {
	int i = a - 1;
	int j = b - 1;
	while (i <= j) {
		if (ar[i] == ar[j]) {
			i++;
			j--;
		}
		else return false;
	}
	return true;
}
int main()
{
	fast;
	cin >> ar;
	int n = ar.size();
	if (isPalindrome(1, n) && isPalindrome(1, (n - 1) / 2) && isPalindrome((n + 3) / 2, n)) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h  ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
char str[N][N];
int bucket[N][27];
int vis[27];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        int len=strlen(str[i]+1);
        for(int j=1;j<=len;j++){
            int temp=str[i][j]-'a'+1;
            bucket[i][temp]++;
        }
    }
 
    for(int i=1;i<=26;i++)
        vis[i]=bucket[1][i];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=26;j++){
            vis[j]=min(vis[j],bucket[i][j]);
        }
    }
    
    for(int i=1;i<=26;i++){
        while(vis[i]--){
            char temp=(char)(i+'a'-1);
            printf("%c",temp);
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 100000000;
using namespace std;

int main(){
    long long n, x;
    long long a[100005] = {0}, b[100005] = {0};

    cin >> n >> x;
    rep(i,n) cin >> a[i];
    rep(i,n - 1) {
        b[i] = a[i] + a[i + 1];
    }
    //rep(i,n - 1) show(a[i])

    long long ans = 0;
    rep(i,n - 1){
        if(b[i] > x){
            long long eat;
            eat = min(b[i] - x, max(a[i], a[i + 1]));
            b[i]-=eat;
            b[i + 1]-=eat;
            eat+=max(static_cast<long long>(0), b[i] - x);
            ans+=eat;
        }
    }
    //rep(i,n - 1) show(a[i])
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e3+10;
int n,T,a,b;
ll dp[2*N],ans;
struct node
{
	int a,b;
}e[N];
bool operator<(node a,node b)
{
	return a.a<b.a||(a.a==b.a&&a.b>b.b);
}
int main()
{
	scanf("%d%d",&n,&T);
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",&e[i].a,&e[i].b);
	}
	sort(e+1,e+n+1);
	for(int i=1;i<=n;++i)
	{
		int a=e[i].a,b=e[i].b;
		for(int j=T-1;j>=0;--j)
		dp[j+a]=max(dp[j+a],dp[j]+b);
	}
	for(int j=2*N-1;j>=0;--j)
	ans=max(ans,dp[j]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a,b; cin>>a>>b;
    if(a<=b){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
    
    
}


Measured memory_bytes: 3632
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)1e9+7 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-5 ;
const int    maxn = (int) 1e5+20 ;
const int    maxm = (int) 1e6+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

int n;
int a[maxn];

void work()
{
    int a, b;
    cin >>a >>b;
    a = max(a, b);
    if(a > 8)
    {
        cout <<":(" <<endl;
    }
    else
    {
        cout <<"Yay!" <<endl;
    }
}

//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

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

#define INF (int)1e9+1
#define NMAX (int)1e5+1

signed main() {
  IOS;
  int N,A[NMAX],L[NMAX],R[NMAX],i,ans;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0) L[i] = A[i];
    else L[i] = gcd(A[i], L[i-1]);
  }
  for (i = N-1; i >= 0; i--) {
    if (i == N-1) R[i] = A[i];
    else R[i] = gcd(A[i], R[i+1]);
  }

  ans = max(L[N-2], R[1]);
  for (i = 1; i < N-1; i++) {
    ans = max(ans, gcd(L[i - 1], R[i + 1]));
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
n,k = map(int,input().split())
s = input()+"a"


cnt = 1
li = []
for i in range(0,n):
    if s[i+1] != s[i]:
        li.append(cnt)
        cnt = 1
    else:
        cnt += 1

cursum = [0]*(len(li)+1)
for i in range(1,len(li)+1):
    cursum[i] = cursum[i-1]+ li[i-1]
    

ans = 0
if s[0]=="1":
  flag = True
else:
  flag = False

for i in range(1,len(cursum)):
        if flag:
            ans = max(ans,cursum[i] - cursum[max(i-2*k-1,0)])
            flag = False
        else:
            ans = max(ans,cursum[i] - cursum[max(i-2*k,0)])
            flag = True

if ans == 0:
    print(n)
else:
    print(ans)
        
      

Measured memory_bytes: 46192
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define hell 1000000007
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

void solve()
{
ll int i,j=0,a,p,q,r,b[3],c=0,d=0,m,n,k=0,x=-5e18,y=-5e18,z=-5e18,sum=0,flag=1,h;
cin>>n>>d;
c=3*n+d;
cout<<c/2;

}

int main()
{ ios;
 int t=1;
 //cin>>t;
 while(t--)
  solve();
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N, K; cin >> N >> K;

  double ans = 0;
  for (int n = 1; n <= N; n++) {
    double P = 1.0;
    int cur = n;
    while (cur < K) {
      cur *= 2;
      P *= 0.5;
    }
    ans += P;
  }
  ans /= N;
  printf("%.10f\n", ans);
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll res = 0;
  map<int,int> mp1, mp2;
  for (int i = 0; i < n; i++) {
    res += mp1[i - a[i]];
    res += mp2[i + a[i]];
    mp2[i - a[i]]++;
    mp1[a[i] + i]++;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 37936
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    edge = [[] for _ in range(N)]
    for i in range(M):
        a,b = MI_()
        edge[a].append(b)
        edge[b].append(a)
    queue = deque([0])
    dist = [inf]*N
    dist[0] = 0
    ans = [-1]*N
    while(queue):
        v = queue.popleft()
        for to in edge[v]:
            if(dist[to]==inf):
                ans[to] = v+1
                queue.append(to)
                dist[to] = dist[v] + 1

    print("Yes")
    print(*ans[1:],sep="\n")

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 104192
#include<iostream>
#include<vector>
#include<algorithm>
#define P pair<int,int>
using namespace std;
int main()
{
int x;
int n;
cin>>x>>n;
int d[101];
for(int i=0;i<n;i++)
{
	int pp;
	cin>>pp;
	d[pp]=1;
}
int ans,diff=INT_MAX;
for(int i=0;i<=101;i++)
{
	if(d[i]==1) continue;
	else {
		if(abs(x-i)<diff)
		{
			diff=abs(x-i);
			ans=i;
		}
	}
}
cout<<ans<<endl;
return 0;
}

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

int cnt[30303];
int id[10][10];

signed main() {
  int N;
  string S;
  cin >> N >> S;

  set<int> st;

  for (int i = N - 1; i >= 0; i--) {
    cnt[i] = st.size();
    st.insert(int(S[i] - '0'));
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      id[i][j] = -1;
    }
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {

      bool flag = false;
      for (int k = 0; k < N; k++) {
        if (flag == false) {
          if (int(S[k] - '0') == i) {
            flag = true;
          }
        } else {
          if (int(S[k] - '0') == j) {
            id[i][j] = k;
            break;
          }
        }
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (id[i][j] == -1) {
        continue;
      }

      ans += cnt[id[i][j]];
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(void)
{
	map < string, vector<int> > index;

	string sbuf;
	int ibuf;

	while (cin>>sbuf>>ibuf)
	{
		index[sbuf].push_back(ibuf);
	}

	for (auto &elem : index)
	{
		sort(elem.second.begin(), elem.second.end());
		cout << elem.first << endl;
		for (auto vecElem : elem.second)
		{
			cout << vecElem;
			if (vecElem != *(elem.second.end() - 1))
			{
				cout<<" ";
			}
		}
		cout << endl;
	}
	return 0;
}

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

const int maxn = 444;

using ll = long long;

ll dp[maxn][maxn] = {};
bool vis[maxn][maxn] = {};
int n;
ll a[maxn] = {};

ll rec(int l, int r) {
	if(l == r) return 0;
	if(vis[l][r]) return dp[l][r];
	vis[l][r] = true;
	ll ret = numeric_limits<ll>::max();
	for(int i=l;i<r;i++) {
		ret = min(ret, rec(l, i) + rec(i+1, r));
	}
	dp[l][r] = ret + a[r]-a[l-1];
	return dp[l][r];
}

int main() {
	cin >> n;
	for(int i=1;i<=n;i++) {
		cin >> a[i];
		a[i] += a[i-1];
	}
	cout << rec(1, n);
}

Measured memory_bytes: 1792
/*
Problem :
Algorithm :
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;

int m,k;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&m,&k);
	if(k > (1 << m) - 1){
		puts("-1");
		return 0;
	}
	if(m == 1){
		if(k == 0)
		    printf("0 0 1 1\n");
		else
		    puts("-1");
		return 0;
	}
	printf("%d ",k);
	for(int i = 0;i <= (1 << m) - 1;i++){
		if(i != k)
		    printf("%d ",i);
	}
	printf("%d ",k);
	for(int i = (1 << m) - 1;i >= 0;i--){
		if(i != k)
		    printf("%d ",i);
	}
	return 0;
}


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

int main() {
    int n; cin >> n;
    //vector<int> d(n);
    map<int, int> d;
    rep(i, n) {
        int tmp; cin >> tmp;
        d[tmp]++;
    }
    int m; cin >> m;
    vector<int> t(m);
    rep(i, m) {
        int tmp; cin >> tmp;
        if (d[tmp] == 0) {
            puts("NO");
            return 0;
        }
        d[tmp]--;
    }
    puts("YES");
}

Measured memory_bytes: 13560
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#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--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
//#define INF 1000000007
#define ARRAY_MAX 100005
const int INF = 1e9+7;

int main(){

    string s;
    cin >> s;
    int a = 0,b = 0,c = 0;

    for(int i = 0;i < s.length();i++){
        if(s[i] == 'a'){
            a++;
        }else if(s[i] == 'b'){
            b++;
        }else{
            c++;
        }
    }

    int mini = INF,maxi = -1;
    mini = min(min(a,b),c);
    maxi = max(max(a,b),c);
    if(maxi-mini <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }



    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y;
    char c;
    cin>>c;
    if(c>=65&&c<=90){
        cout<<"A"<<endl;
    }
    else{
        cout<<'a'<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e5+10, M = N * 2;
int n, m;
ll a[N];
bool cmp(ll a, ll b) {
	return a > b;
}
int main() {
	cin>>n>>m;
	int cnt0 = 0, cnt1 = 0;
	rep(i, 1, n + 1) {
		scanf("%lld", &a[i]);
		if(a[i] >= 0) cnt0++;
		if(a[i] < 0) cnt1++;
	}
	sort(a + 1, a + 1 + n, cmp);
	if(!cnt0&&m % 2 != 0) {
		ll res = 1;
		rep(i, 1, m + 1) res = (a[i] * res + mod) % mod;
		cout<<(res + mod) % mod;
	} else {
		int i = 1, j = n;
		ll res = 1;
		int k = m;
		while(k) {
			if(k%2) {
				res = (res * a[i] + mod) % mod;
				i++;
				k--;
				continue;
			}
			if(k >= 2) {
				if(a[i] * a[i + 1] > a[j - 1] * a[j]) {
					res = ((res * a[i] + mod) % mod * a[i + 1] + mod) % mod;
					i += 2;
				} else {
					res = ((a[j - 1] * a[j] + mod) % mod * res + mod) % mod;
					j -= 2;
				}
				k -= 2;
			} else {
				res = (res * a[i] + mod) % mod;
				i++;
				k--;
			}
		}
		cout<<(res + mod) % mod;
	}
	return 0;
}


Measured memory_bytes: 5188
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int H, W;
	int dx[3]={-1,0,1};
	int dy[3]={-1,0,1};
	cin >> H >> W;
	char s[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> s[i][j];
		}
	}
	for(int p=0;p<H;p++){
		for(int q=0;q<W;q++){
			if(s[p][q]=='#'){
				cout << "#";
			}else{
				int num = 0;
				for(int h=0;h<3;h++){
					for(int g=0;g<3;g++){
						if(s[p+dx[h]][q+dx[g]]=='#'&&q+dx[g]<W&&q+dx[g]>=0){
							num++;
						}
					}
				}
				cout << num;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
 
 
def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                # dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
                new_dist = dp[i][k] + dp[k][j]
                if dp[i][j] > new_dist:
                    dp[i][j] = new_dist
 
 
def main():
    N, M, R = [int(x) for x in input().split()]
    destinations = [int(x) for x in input().split()]
    dp = [[float('inf')]*(N+1) for _ in range(N+1)]
    for i in range(N+1):
        dp[i][i] = 0
    for _ in range(M):
        f, t, d = [int(x) for x in input().split()]
        dp[f][t] = dp[t][f] = d
 
    warshallFloyd(N+1, dp)
 
    minimum_cost = float('inf')
    for route in permutations(destinations, len(destinations)):
        cost = 0
        while len(route) > 1:
            f, t = route[0], route[1]
            cost += dp[f][t]
            if cost > minimum_cost:
                break
            route = route[1:]
        if cost < minimum_cost:
            minimum_cost = cost
    print(minimum_cost)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 4640
n,y = gets.chomp.split.map(&:to_i)

for i in 0..n do
    for j in 0..(n-i) do
        k = n-i-j
        if 10000 * i + 5000 * j + 1000 * k == y
            puts "#{i} #{j} #{k}"
            exit
        end
    end
end

puts "-1 -1 -1"

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

void f(string s,vector<string>&v){
  if(s.size()==3){
    v.push_back(s);
    return;
  }
  rep(i,10){
    s.push_back('0'+i);
    f(s,v);
    s.pop_back();
  }
  return;
}

bool solve(){
  ll n;cin>>n;
  string s;cin>>s;
  vector<string>v;
  f("",v);
  ll ans=0;
  for(auto t : v){
    ll cnt=0;
    rep(i,s.size()){
      if(cnt==3)break;
      if(s[i]==t[cnt])cnt++;
    }
    if(cnt==3)ans++;
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	char b;
	cin >> b;
	if (b == 'A') cout << 'T' << endl;
	if (b == 'T') cout << 'A' << endl;
	if (b == 'G') cout << 'C' << endl;
	if (b == 'C') cout << 'G' << endl;
	return 0;
}

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

int main()
{
    int a, n;  cin >> n;
    double sum = 0.0;

    rep(i,n) {
        cin >> a;
        sum += 1.0 / a;
    }
    
    double ans = 1.0 / sum;

    cout << setprecision(16) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
// using ll = long long;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
// #define irp(i,s,e) for(int i=(int)(s);i>(int)(e);--i)


int main(){
	int n, m; cin>>n>>m;
	vi P(n);
	rp(i,0,n){ cin>>P[i]; P[i]--; }
	vvi G(n, vi());
	rp(i,0,m){
		int x, y; cin>>x>>y; x--, y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	// rp(x,0,G.size()){
	// 	cout<<x<<") ";
	// 	for(auto y:G[x]){
	// 		cout<<y<<" ";
	// 	}
	// 	puts("");
	// }
	// puts("---------");

	int ans = 0;
	vi vis(n, false);
	queue<int> q;
	rp(i,0,n){
		vi xx, px;
		q.push(i);
		while(q.size()){
			int x = q.front(); q.pop();
			if(vis[x]) continue;
			vis[x] = true;
			xx.push_back(x);
			px.push_back(P[x]);
			// cout<<" x "<<x;
			// cout<<" P[x] "<<P[x];
			// cout<<"\n";
			for(int y:G[x]){
				if(vis[y]) continue;
				q.push(y);
			}
		}

		sort(all(xx));
		sort(all(px));

		// cout<<" i "<<i;
		// cout<<"\n";
		// puts("xx");
		// for(auto x:xx){
		// 	cout<<x<<" ";
		// }
		// puts("");
		// puts("px");
		// for(auto x:px){
		// 	cout<<x<<" ";
		// }
		// puts("");

		for(int x:xx){
			int i = lower_bound(all(px), x) - px.begin();
			if(px[i] == x) ans++;
			// cout<<" x "<<x;
			// cout<<" i "<<i;
			// cout<<" px[i] "<<px[i];
			// cout<<"\n";
		}
	// puts("---");

	}
	cout<< ans <<endl;

}


Measured memory_bytes: 7376
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> t(n+1, 0), x(n+1, 0), y(n+1, 0);
    for (int i = 1; i <= n; ++i) cin >> t[i] >> x[i] >> y[i];
    string ans = "Yes";

    for (int i = 0; i < n; ++i) {
        int tm = t[i+1] - t[i];
        int d = abs(x[i] - x[i+1]) + abs(y[i] - y[i+1]);
        if (d > tm || tm % 2 != d % 2) {
            ans = "No";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
N = int(input())
X = []
for i in range(N):
    x, l = map(int, input().split())
    s, e = x-l, x+l
    X.append((s, e))
X.sort(key=lambda x: x[1])
#print(X)
c1 = 1
n1 = X[0][1]
for i in range(1,N):
    if X[i][0] >= n1:
        c1 += 1
        n1 = X[i][1]
c2 = 0
n2 = X[0][0]
for i in range(1,N):
    if X[i][0] >= n2:
        c2 += 1
        n2 = X[i][1]
print(max(c1, c2))




Measured memory_bytes: 18264
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>A>>B>>N;
    cout<<((A <= N) && (A+B >= N) ? "YES" : "NO")<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a, b, n;

	cin >> n >> a >> b;

	int l = 0, r = 0;

	l = n * a;

	if (l == b)
		cout << b << endl;
	else if(l<b)
		cout << l << endl;
	else
		cout << b << endl;
}


Measured memory_bytes: 3644
X = int(input())
y =120
a ={i**5 for i in range(-y,y)}
ans_a =0
ans_b =0
for b in range(-y,y):
    if X +b**5 in a:
        #ans_a =int( (X +b**5 +1)**0.2 )
        if X +b**5 >0:
            ans_a =int( (X +b**5 )**0.2 )
        else:
            ans_a = -int( abs(X +b**5 )**0.2 )
        ans_b =b
        break
print(ans_a,ans_b)


Measured memory_bytes: 9448
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll x; cin >> x;
    cout << ((x<1200) ? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std; 

long long n,k,b,ans;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin); 
#endif
	cin>>n>>k;
	for(b=k+1;b<=n;++b){
		ans+=(b-k)*(n/b)+((n%b)?max(0ll,n%b-k+(k!=0)):0);
	}
	printf("%lld\n",ans);
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i<=r; ++i) {
        if ((i % d) == 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;

struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

mint dp[3001][3001];

void solve(istream& cin, ostream& cout) {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  // i 番目までの整数を使って和が j になるような組み合わせ
  dp[0][0] = 1;
  REP(i, n) {
    REP(j, s + 1) {
      // i 番目を使う or 使わない
      dp[i + 1][j] += dp[i][j] * 2;
      // i 番目を使う
      if (j + a[i] <= s) dp[i + 1][j + a[i]] += dp[i][j];
    }
  }
  cout << dp[n][s] << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 74024
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = [a,b,c,d,e]
g = 0
sm = f[0]%10
for i in f:
    if i %10 == 0:
        g = g+ i
    else:
        g = g + 10*(i//10)+10
        if i%10 < sm:
            sm = i%10
if sm == 0:
    print(g)
else:
    print(sm+g-10)


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int cross(double x0,double y0,double x1,double y1,double x2,double y2,double x3,double y3){
  double a0=0,a1=0;
  int b0=y1-y0;
  int b1=x1-x0;
  int b2=y3-y2;
  int b3=x3-x2;
  a0=(y1-y0)/(x1-x0);
  a1=(y3-y2)/(x3-x2);
  /*if(fabs(y2-y0)==fabs(y3-y1)) return 2; 
  else if((b0==0 && b3==0) || (b1==0 && b2==0)|| a0*a1==-1.0)    return 1;
  else return 0;
  */
  if((y1-y0)*(x3-x2)-(y3-y2)*(x1-x0)==0) return 2;
  else if((y1-y0)*(y3-y2)+(x1-x0)*(x3-x2)==0) return 1;
  else return 0;
  
}


int main(){
  int number,i,m;
  double x0,y0,x1,y1,x2,y2,x3,y3;
  scanf("%d",&number);
  for(i=0;i<number;i++){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3);
    m=cross(x0,y0,x1,y1,x2,y2,x3,y3);
    printf("%d\n",m);

  }
  return 0;
}

Measured memory_bytes: 1852
public_office = [[[0] * 10 for i in range(3)] for j in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    public_office[b - 1][f - 1][r - 1] += v

x = 0
for b in range(4):
    if x != 0:
        print('#' * 20)
    x += 1
    for f in range(3):
        for r in range(10):
            print(' {}'.format(public_office[b][f][r]), end='')
        print()



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

int main(){
  int n;
  int count=1;
  int flag=0;
  int index=0;
  string f;
  cin >> n;
  vector<string> memo(n,"");

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


  sort(memo.begin(), memo.end());

  for(int i=1;i<n;i++){
    if(memo[i]!=memo[i-1]){
      count+=1;
    }
  }

  cout << count;
}


Measured memory_bytes: 7540
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct RMQ{
  int n;
  vector<int> dat;
  const int def=-(1LL<<55LL);
  RMQ(){}
  RMQ(int n_){init(n_);}
  RMQ(int n_,int* a){init(n_);construct(n_,a);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
  }
  void construct(int n_, int* a){
    for(int i=0;i<n_;i++) dat[i+n-1]=a[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=max(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};
int x[214514];
int y[214514];
signed main(){
  int n,p;
  cin>>n>>p;
  for(int i=0;i<n;i++) cin>>x[i];
  y[0]=x[0];
  for(int i=1;i<n;i++) y[i]=y[i-1]+x[i];
  RMQ rmq(n,y);
  int ans=n+1;
  for(int i=0;i<n;i++){
    int base=y[i]-x[i];
    if(rmq.query(i,n)<base+p) continue;
    int l=i,r=n;
    while(l+1<r){
      int m=(l+r)/2;
      //cout<<i<<" "<<m<<" "<<r<<":"<<rmq.query(m,r)<<" "<<base<<" "<<p<<endl;
      if(rmq.query(l,m)>=base+p) r=m;
      else l=m;
    }
    ans=min(ans,r-i);
  }
  if(ans>n) ans=0;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6556