akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF INT_MAX
#define endl '\n'
#define ll long long int
#define N 200006
using namespace std;

inline int redi() {
	int ret = 0,f = 0;char ch = getchar_unlocked();
	while (!isdigit (ch)) {
		if (ch == '-') f = 1;
		ch = getchar_unlocked();
	}
	while (isdigit (ch)) {
		ret = ret*10  + ch - 48;
		ch = getchar_unlocked();
	}
	return f?-ret:ret;
}
inline void print(int x) {
	if(x<0) {putchar_unlocked('-');x=-x;}
	int y=10,len=1;
	while(y<=x)    {y*=10;len++;}
	while(len--){y/=10;putchar_unlocked(x/y+48);x%=y;}
}

inline void init()
{
	int n,num[N];
	cin >> n;
	for(int i=0;i<n;++i)
		cin >> num[i];
	
	int q[N],p=1;
	q[0]=num[n-1];

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

inline void solve()
{
}

int main()
{
	//freopen("input.in","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	init();
	solve();
	cout << flush;

	return 0;
}


Measured memory_bytes: 1024
l, r = map(int, input().split())

if r - l >= 2018:
  print(0)
else:
  res = float('inf')
  for i in range(l, r):
    for j in range(i+1, r+1):
      res = min(res, (i%2019)*(j%2019)%2019)
      
  print(res)

Measured memory_bytes: 40812
#include <cstdio>
#include <algorithm>

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

using namespace std;

int n;
int s[1000];

int main(){
	while(scanf("%d", &n), n){
		rep(i, n){
			scanf("%d", &s[i]);
		}
		int t = 0;
		rep(i, n){
			t += s[i];
		}
		int a = *min_element(s, s + n);
		int b = *max_element(s, s + n);
		printf("%d\n", (t - a - b) / (n - 2));
	}
	return 0;
}

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

m = M
f = {}
while m%2==0:
    f[2] = f.get(2,0)+1
    m = m//2

l = int(m**0.5)+1
k = 3
while m != 1:
    if k>l:
        f[m] = f.get(m,0)+1
        break
    while m%k==0:
        f[k] = f.get(k,0)+1
        m = m//k
    k+=2
ans = 1
for k in f:
    for i in range(N-1+f[k],N-1,-1):
        ans = (ans * i) 
    for i in range(f[k]):
        ans = ans // (i+1)
    ans = ans % ((10**9)+7)
print(ans)


Measured memory_bytes: 3188
#include <cstdio>
int main()
{
    int a, b, c;
    while (~scanf("%d%d%d", &a, &b, &c))
    {
        if ((a == b && b != c) || (a == c && a != b) || (b == c && c != a))
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

LL gcd(LL val1, LL val2);


int main(){
    int N;
    cin >> N;
    vector<LL> A(N);
    REP(i,N)cin>>A[i];

    LL g = A[0];
    FOR(i, 1, N){
        g = gcd(A[i], g);
    }

    cout << g << endl;
    return 0;

}

LL gcd(LL val1, LL val2){
    LL _val1 = max({val1, val2});
    LL _val2 = min({val1, val2});

    LL _val3 = _val1 % _val2;
    if(_val3==0){return _val2;}
    return gcd(_val2, _val3);
}

Measured memory_bytes: 3992
import Control.Monad
import Data.List

firstBinary :: (Int -> Bool) -> Int -> Int -> Int
firstBinary _ l r | l == r = l
firstBinary f l r = let m = div (l + r) 2 in if f m then firstBinary f l m else firstBinary f (m + 1) r

main = do
    [a, b]  <- map read . words <$> getLine
    print $ (a-1) * (b-1)


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

long long int cnt = 0, pc = 0;

void calc(long long int k)
{
	pc += pow(2,cnt);
	cnt++;
	
	if (k == 1)
	{
		return;
	}
	
	calc(floor(k/2));
}

int main()
{
	long long int h;
	cin >> h;
	
	calc(h);
	
	cout << pc << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 9999999999999999
#define MOD 1000000007

void func()
{
    ll n,m;
    cin>>n>>m;
    ll h[n+1];
    loop(i,1,n+1)
    {
        cin>>h[i];
    }
    vector<ll> v[n+1];
    loop(i,0,m)
    {
        ll a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    ll flag=1,ans=0;
    loop(i,1,n+1)
    {
        flag=1;
        for(auto x:v[i])
        {
            if(h[x]>=h[i]){
                flag=0;
                break;
            }
        }
        if(flag||v[i].size()==0)
            ++ans;
    }
    cout<<ans<<"\n";
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r" , stdin);
    // freopen("output.txt", "w" , stdout);
    // #endif

    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 10284
#include <cstdio>
#include <vector>
#include <queue>

int testcase_ends() {
  size_t N;
  int A, B, C, X;
  scanf("%zu %d %d %d %d", &N, &A, &B, &C, &X);
  if (N == 0 && A == 0 && B == 0 && C == 0 && X == 0) return 1;

  std::queue<int> q;
  for (size_t i = 0; i < N; ++i) {
    int y;
    scanf("%d", &y);
    q.push(y);
  }
  for (int i = 0; i <= 10000; ++i) {
    if (q.front() == X) {
      q.pop();
      if (q.empty()) return !printf("%d\n", i);
    }
    X = (A * X + B) % C;
  }
  puts("-1");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n,m;
    cin>>n>>m;
    
    cout<<(1900*m+(n-m)*100)*pow(2,m)<<endl;
}

//期待値がわからん

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i,n) for(int i = 0;i<(n);i++)
#define FOR(i,j,n) for(int i = (j);i<(n);i++)
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

using namespace std;

int ans = 0;
const int Col = 6;
  int h,w;
int TargetCol;

inline bool isRange(int y,int x){
  return y>=0&&y<h&&x>=0&&x<w;
}
void solve(int depth,vector<vector<int> > mp,int zeroc){
  int pre_c = mp[0][0];
  mp[0][0] = zeroc;
  queue<pair<int,int> > que;
  que.push(make_pair(0,0));

  vector<vector<bool> > stepped(h,vector<bool>(w,false));
  stepped[0][0] = true;
  while(!que.empty()){
    pair<int,int> now = que.front();
    que.pop();
    REP(i,4){
      int y = now.first+dy[i];
      int x = now.second+dx[i];
      if(isRange(now.first+dy[i],now.second+dx[i]) 
      && mp[now.first+dy[i]][now.second+dx[i]] == pre_c && !stepped[y][x]){
        mp[y][x] = zeroc;
        stepped[y][x] = true;
        que.push(make_pair(now.first+dy[i],now.second+dx[i]));
      }
    }
  }
  if(depth>=5){
    int res = 1;
    queue<pair<int,int> > q;
    q.push(make_pair(0,0));
    vector<vector<bool> > st(h,vector<bool>(w,false));
    st[0][0] = true;
    
    while(!q.empty()){
        pair<int,int> now = q.front();
      q.pop();
     REP(i,4){
        int y = now.first+dy[i];
        int x = now.second+dx[i];
        if(isRange(y,x) && !st[y][x] && mp[y][x] == TargetCol){
          res++;
          st[y][x] = true;
          q.push(make_pair(y,x));
        }
     }
    }
    ans = max(res,ans);
  }else{
    FOR(i,1,Col+1)solve(depth+1,mp,i);
  }
}

int main(){
  while(cin>>h>>w>>TargetCol,h){
    ans = 0;
    vector<vector<int> > mp(h,vector<int>(w));
    REP(i,h)REP(j,w)cin>>mp[i][j];
    FOR(i,1,Col+1)
    solve(1,mp,i);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3132
N=int(input())
data=[0]*(N+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            if i**2+j**2+k**2+i*j+j*k+k*i<=N:
                data[i**2+j**2+k**2+i*j+j*k+k*i]+=1

for i in range(1,N+1):
    print(data[i])


Measured memory_bytes: 69088
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,v,t;
	// PROCESS IN HERE
	ld sans=0;
	sc2(n,k);
	f1(i,n)sc(A[i]);
	ld ssum=0;
	f1(i,k-1)ssum+=(ld)(A[i]+1)/2;
	fu(i,k,n){
		if(i-k>=1)ssum-=(ld)(A[i-k]+1)/2;
	 ssum+=(ld)(A[i]+1)/2;
		if(ssum>sans)sans=ssum;
	//	debug(ssum);
	}
	cout<<prec(10)<<sans<<endl;
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

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

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int h, w;
    cin >> h >> w;
    pair<int, int> src, dest;
    cin >> src.f >> src.s;
    cin >> dest.f >> dest.s;
    src.f--;
    src.s--;
    dest.f--;
    dest.s--;
    vector<string> matrix(h);
    for (auto &x : matrix)
        cin >> x;
    using elem = pair<int, pair<int, int>>;
    vector<vector<int>> dist(h, vector<int>(w, MOD));
    vector<vector<int>> vis(h, vector<int>(w, 0));
    using type = pair<int, pair<int, int>>;
    priority_queue<type, vector<type>, greater<type>> Q;
    // queue<pair<int, int>> Q;
    Q.push({0, {src.f, src.s}});
    dist[src.f][src.s] = 0;
    // vis[src.f][src.s] = 1;
    int a[] = {0, 0, 1, -1};
    int b[] = {1, -1, 0, 0};
    while (Q.size())
    {
        auto top = Q.top();
        Q.pop();
        // db(top, dist[top.f][top.s]);
        if (vis[top.s.f][top.s.s])
            continue;
        vis[top.s.f][top.s.s] = true;
        for (size_t i = 0; i < 4; i++)
        {
            int x = top.s.f + a[i];
            int y = top.s.s + b[i];
            // db(x, y);
            if (0 <= x && x < h && 0 <= y && y < w)
            {
                if (!vis[x][y] && matrix[x][y] == '.')
                {
                    if (top.f < dist[x][y])
                    {
                        dist[x][y] = top.f;
                        Q.push({dist[x][y], {x, y}});
                    }
                }
            }
        }

        for (int i = -2; i <= 2; i++)
            for (int j = -2; j <= 2; j++)
            {
                int x = top.s.f + i;
                int y = top.s.s + j;
                // db(x, y);
                if (0 <= x && x < h && 0 <= y && y < w)
                {
                    if (!vis[x][y] && matrix[x][y] == '.')
                    {
                        if (top.f + 1 < dist[x][y])
                        {
                            dist[x][y] = 1 + top.f;
                            Q.push({dist[x][y], {x, y}});
                        }
                    }
                }
            }
    }
    if (dist[dest.f][dest.s] == MOD)
        cout << -1 << '\n';
    else
    {
        cout << dist[dest.f][dest.s] << '\n';
    }

    return 0;
}

Measured memory_bytes: 12492
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define MOD 1000000007

int main(void){
	lli n; cin >> n;
	vector<lli> dp(n+1, 0); lli s;
	dp[0] = 1; dp[1] = n; s = n;
	for(lli i = 2; i <= n; i++){
		dp[i] = (((n-1)*(n-1))%MOD + s - dp[i-2] + n + 2 - i + MOD) % MOD;
		s = (s + dp[i])%MOD;
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;
    string S;
    cin >> K;
    cin >> S;
    if (S.size() <= K) cout << S << endl;
    else{
        cout << S.substr(0,K) << "..." << endl;
    }
    return 0;
}

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

int main()
{
    string s = "abcdefghijklmnopqrstuvwxyz";

    ll n;
    cin >> n;
    ll mod = 26;
    stack<ll> stack;
    while (n > 26)
    {
        stack.push(n % mod);
        bool flag = false;
        if (n % mod == 0)
        {
            flag = true;
        }
        n = n / mod;
        if (flag)
        {
            n = n - 1;
        }
    }
    stack.push(n % mod);

    while (!stack.empty())
    {
        ll a = stack.top();
        stack.pop();
        if (a == 0)
        {
            a = 25;
        }
        else
        {
            a = a - 1;
        }
        cout << s[a];
    }
    cout << endl;
    return 0;
}

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

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
public class Main{
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long result = 0;
            for (int p = 1; p<=n;p++){
                long d = n / p;
                result += p * (d * (d + 1) / 2);
            }
            out.println(result);
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

Measured memory_bytes: 32892
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	ll n;
	cin >> n;
	if(n&1) cout << 0;
	else
	{
		ll ans = 0;
		for(ll i=10; i<=n; i*=5) ans += n/i;
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int hp = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        int atk = 0;
        for (int i = 0; i < n; i++) {
            atk += Integer.parseInt(sc.next());
        }
        if (hp <= atk) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}


Measured memory_bytes: 58228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pow(a,b) (ll)(pow(a,b)+0.5);

//#define min(a,b)  ((a)<=(b)?(a):(b));
// #define aass(x)   x>=0?x:-x;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
 ll i;
string s;
cin>>s;
string str[8]={"SUNa","SAT","FRI","THU","WED","TUE","MON","SUN"};
for(i=0;i<8;i++)
    if(str[i]==s)
    {
        cout<<i<<"\n";
        break;
    }

return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

int main(){
    ll N,M;
    cin>>N>>M;
    vector<ll> v;
    for(ll i=1;i*i<=M;i++){
        if(M%i==0){
            v.push_back(i);
            if(i*i!=M) v.push_back(M/i);
        }
    }
    sort(v.begin(),v.end());
    for(ll i=0;i<v.size();i++){
        if(v[i]>=N){
            cout<<M/v[i]<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int cnt=0;  
    for(int i=0;i<a.size();i++)
	{
        if(a[i]=='C')
		{
            cnt=1;
        }
        if(a[i]=='F'&&cnt==1)
		{
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end(),greater<int>());
  int b=0,bb=0;
  for(int i=0;i<n;i++){
    if(i%2){
      b+=a[i];
    }else{
      bb+=a[i];
    }
  }
  cout<<abs(b-bb)<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x: a) cin >> x;

  vector<int> ai = a;
  sort(ai.begin(), ai.end());
  unordered_map<int, int> idx;
  for (int i = 0; i < n; i++) idx[ai[i]] = i;
  for (int i = 0; i < n; i++) a[i] = idx[a[i]];

  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    if (a[i] % 2 != 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5156
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

int n, m;
vi G[MAXN];
int p[MAXN], cmp[MAXN];

void dfs(int v, int root){
    if(cmp[v] != -1) return;
    cmp[v] = root;
    for(auto u : G[v]) dfs(u, root);
}

int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    ms(cmp, -1);
    rii(n, m);
    FOR(i,0,n) ri(p[i]), p[i]--;
    FOR(i,0,m){
        int u, v;
        rii(u, v); u--, v--;
        G[u].pb(v);
        G[v].pb(u);
    }

    FOR(i,0,n) dfs(i,i);
    int ans = 0;
    FOR(i,0,n) ans += cmp[i] == cmp[p[i]];
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 11264
// V solo
#include <bits/stdc++.h>

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)1e5 + 1;
const int INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

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

int n, a[N];
map < int, int > cnt;
int main (){
  scanf ("%d", &n);
  forn (i, 1, n) scanf ("%d", a + i), cnt[a[i]]++;
  int ans = 0;
  forn (i, 1, n){
    if (cnt[a[i]] != a[i]){
      ans++;
      cnt[a[i]]--;
    }
  }
  printf ("%d\n", ans);
  return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define sor(a) sort(a.begin(),a.end())
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vel vector<long long>
using namespace std;
signed main(){
	int h, w; cin >> h >> w;
	vel a(h);
	vel b(w);
	int sum = 0;
	rep(i, h) { cin >> a[i]; sum += a[i]; }
	rep(j, w) { cin >> b[j]; sum -= b[j]; }
	if (sum != 0) { cout << 0 << endl; return 0; }
	sor(a);
	rep(j, w) {
		int x = b[j];
		rep(i, x) { a[h-1-i]--; }
		sor(a);
	}
	rep(i, h) {
		if (a[i] != 0) { cout << 0 << endl; return 0; }
	}
	cout << 1 << endl;
	return 0;
}


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

int n;
long long ans;
int main(){
	scanf("%d",&n);
	for (int i=1; i<=n;i++){
		if (i%3!=0 && i%5!=0) ans+=i;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3760
#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 Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#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;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}
int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    vec inv_n(N + 1, 1);
    ll temp = 0, ans = 0, factN = 1;
    reps(i, 1, N + 1) (factN *= i)%=MOD;
    reps(i,1,N+1) {
        inv_n[i] = (factN * fastpow(i, MOD - 2))%MOD;
        (temp += inv_n[i])%=MOD;
    }
    rep(i,N){
        (ans += (temp * a[i])%MOD)%=MOD;
        if(i != N - 1) (temp += MOD - inv_n[N - i] + inv_n[i + 2])%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,n;
	cin>>a>>b>>n;
	long long x;
	x=(n/b)*b-1;
	long long ans=((a*x)/b)-a*(x/b);
	long long ans1=((a*n)/b)-a*(n/b);
	ans=max(ans,ans1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    if( a >= 13 ) cout << b << endl;
    else if( a >= 6 ) cout << b / 2 << endl;
    else cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 892
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;


int main()
{
	int n;
	cin >> n;
	bool ok = true;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	if (n != 1)  {
		for (int i = 0;i < n - 1;i++) {
			int sa = h[i + 1] - h[i];
			if (sa > 0) h[i + 1]--;
		}

		rep(i, n-1) {
			if (h[i] > h[i + 1]) ok = false;
		}
	}
	if (ok) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3748
A,B,M = list(map(int, input().split()))
AL = list(map(int, input().split()))
BL = list(map(int, input().split()))
#L = []
ans = min(AL) + min(BL)
for _ in range(M):
  x,y,c = list(map(int, input().split()))
  x,y = x-1, y-1
  ans = min(ans, AL[x] + BL[y] - c)
  
print(ans)

Measured memory_bytes: 18736
#include "bits/stdc++.h"
using namespace std;
int main(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int cnt=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				int val = 500*i + 100*j + 50*k;
				if(val == x) cnt++;
			}
		}
	}

	cout<< cnt <<endl;

	return 0;
}

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

int H,W,K,a[7],b[8];
ll DP[101][8];

int main(){
	cin>>H>>W>>K;
	if(W==1){
		cout<<1<<endl;
		return 0;
	}
	for(int i=0;i<(1<<W-1);++i){
		bool f=true;
		for(int j=0;j<W-2;++j){
			if((i&(1<<j))&&(i&(1<<j+1))){
				f=false;
				break;
			}
		}
		if(f){
			for(int j=0;j<W-1;++j){
				if(i&(1<<j)){
					++a[j];
				}
			}
			if(!(i&1)){
				++b[0];
			}
			if(!(i&(1<<W-2))){
				++b[W-1];
			}
			for(int j=1;j<W-1;++j){
				if((!(i&(1<<j-1)))&&(!(i&(1<<j)))){
					++b[j];
				}
			}
		}
	}
	DP[0][0]=1;
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			DP[i+1][j]=DP[i][j]*b[j];
			if(j){
				DP[i+1][j]+=DP[i][j-1]*a[j-1];
			}
			if(j!=W-1){
				DP[i+1][j]+=DP[i][j+1]*a[j];
			}
			DP[i+1][j]%=1000000007;
		}
	}
	cout<<DP[H][K-1]<<endl;
}

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

void Init();
void update(int index, int value, int searchLeft, int searchRight, int left, int right);
int find(int index, int searchLeft, int searchRight, int left, int right);
void lazy_propagate(int index);

const int INF = INT_MAX;

vector<int> tree;
vector<int> lazy;

int n, q;


int main() {

	cin >> n >> q;

	Init();

	for (int i = 0; i < q; i++) {

		int com, a, b, x;
		cin >> com;

		switch (com) {
		case 0:
			cin >> a >> b >> x;
			update(0, x, 0, n, a, b + 1);
			break;

		case 1:
			cin >> x;
			cout << find(0, 0, n, x, x + 1) << endl;
			break;
		}

	}

	return 0;
}

void Init() {

	int _n = 1;
	while (_n < n)
		_n *= 2;
	n = _n;
	tree = vector<int>(2 * n - 1, INF);
	lazy = vector<int>(2 * n - 1, -1);

}

void lazy_propagate(int index) {


	if (lazy[index] == -1)
		return;

	tree[index] = lazy[index];

	if (index < n - 1) {
		lazy[index * 2 + 1] = lazy[index];
		lazy[index * 2 + 2] = lazy[index];
	}
	lazy[index] = -1;

}

void update(int index, int value, int searchLeft, int searchRight, int left, int right) {

	if (right <= searchLeft || searchRight <= left) {
		lazy_propagate(index);
	}
	else if (left <= searchLeft && searchRight <= right) {
		lazy[index] = value;
		lazy_propagate(index);
	}
	else {
		lazy_propagate(index);

		int mid = (searchLeft + searchRight) / 2;
		update(index * 2 + 1, value, searchLeft, mid, left, right);
		update(index * 2 + 2, value, mid, searchRight, left, right);

		tree[index] = min(tree[index * 2 + 1], tree[index * 2 + 2]);
	}
		

}

int find(int index, int searchLeft, int searchRight, int left, int right) {

	if (right <= searchLeft || searchRight <= left) {
		return INF;
	}
	else if (left <= searchLeft && searchRight <= right) {
		lazy_propagate(index);
		return tree[index];
	}
	else {
		lazy_propagate(index);
		int mid = (searchLeft + searchRight) / 2;
		int lValue = find(index * 2 + 1, searchLeft, mid, left, right);
		int rValue = find(index * 2 + 2, mid, searchRight, left, right);
		return min(lValue, rValue);
	}

}





Measured memory_bytes: 5888
package main

import "fmt"

func main() {
  var N, M int
  fmt.Scan(&N, &M)
  A := make([]int, N+M)
  lenCount := 0

  nCount := 0
  mCount := 0

  for i := 1; ; i++ {
    if i%2 == 0 && nCount < N {
      A[lenCount] = i
      nCount += 1
      lenCount += 1
    }
    if i%2 != 0 && mCount < M {
      A[lenCount] = i
      mCount += 1
      lenCount += 1
    }
    if lenCount > len(A)-1 {
      break
    }
  }

  anser := 0
  for i := 0; i < len(A); i++ {
    for j := i + 1; j < len(A); j++ {
      if (A[i]+A[j])%2 == 0 {
        anser += 1
      }
    }
  }
  fmt.Println(anser)
}

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

ll cnt(ll i, ll j, ll k) {
  return k - k/i - k/j + k/lcm(i,j);
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << cnt(c,d,b) - cnt(c,d,a-1) << endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String answer="";
    final String S=sc.next();
    char[] s=S.toCharArray();
    char[] sA={s[0],s[1]};
    char[] sB={s[2],s[3]};
    int a=Integer.parseInt(String.valueOf(sA));
    int b=Integer.parseInt(String.valueOf(sB));
    if(a==0&&b==0){
      answer="NA";
    }else if(a==0){
      if(b<=12){
        answer="YYMM";
      }else{
        answer="NA";
      }
    }else if(b==0){
      if(a<=12){
        answer="MMYY";
      }else{
        answer="NA";
      }
    }else if(a<=12){
      if(b<=12){
        answer="AMBIGUOUS";
      }else{
        answer="MMYY";
      }
    }else{
      if(b<=12){
        answer="YYMM";
      }else{
        answer="NA";
      }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 22868
//Author : Ayush Jain

#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
const int N=1e5 + 5;
const int M=1e5 + 5;

ull pw[67];
void pre()
{
	pw[0]=1;
	for(int i=1;i<64;i++) pw[i]=2*pw[i-1];
}

int main()
{
	ios_base::sync_with_stdio(false);
	pre();
	bool isp[N];

	int arr[N];
	int i;
	for(i=0;i<N;i++){
		isp[i]=true;
	}
	isp[0]=isp[1]=false;
	for(i=2;i*i<N;i++){
		for(int j=2*i;j<N;j+=i){
			isp[j]=false;
		}
	}
	for(i=0;i<N;i++){
		arr[i]=0;
	}	
	for(i=1;i<N;i++){
		if(isp[i] && isp[(i+1)/2]){
			arr[i]=arr[i-1]+1;
		}
		else arr[i]=arr[i-1];
	}
	int q;
	cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<arr[r]-arr[l-1]<<endl;
	}

	
		
	return 0;
}

Measured memory_bytes: 1152
import java.io.*;
import java.util.*;
public class Main {
static PrintWriter pw =new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] args)throws IOException {
	// write your code here
        MyScanner sc = new MyScanner();
        int A = sc.nextInt();
        int B  =sc.nextInt();
        if (A>8||B>8) pw.println(":(");
        else pw.println("Yay!");
        pw.flush();
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}



Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <cstdio>

#define fol(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    string s,ans="";
    cin >>s;
    fol(i,s.size()){
        if (i%2==0)ans+=s[i];
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

const int N = 100010;
ll n, m, a[N], tp[N];

ll lcm (ll a, ll b) { return a / __gcd(a, b) * b; }

ll solve() {
	memset(tp, 0, sizeof tp);
	for (int i = 0; i < n; i++) { a[i] /= 2; }
	for (int i = 0; i < n; i++) {
		ll t = a[i];
		while (t % 2 == 0) { tp[i]++; t /= 2; }
	}
	for (int i = 1; i < n; i++) if (tp[i] != tp[0]) return 0;
	ll l = a[0];
	for (int i = 1; i < n; i++) {
		l = lcm(l, a[i]);
		if (l > m) return 0;
	}
	return m / l - m / (2 * l);
}

int main() {
	scanf("%lld%lld", &n, &m);	
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	printf("%lld\n", solve());
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

typedef long long ll;
using namespace std;


int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int INF = 1<<10;

int bfs(int y, int x, int W, int H, vector<vector<int> > &Map, vector<vector<int> > &d){
	complex<int> P(x,y);
	queue<complex<int> > Q;
	Q.push(P);
	
	while(!Q.empty()){
		complex<int> crr = Q.front();
//		cout<< crr.real()<< " "<< crr.imag()<< endl;
		Q.pop();
		for(int i=0;i<4;i++){
			int nx = crr.real() + dx[i];
			int ny = crr.imag() + dy[i];
			if(0 <= nx && nx < W && 0 <= ny && ny < H && Map[ny][nx] != 1 && d[ny][nx] == INF){
				d[ny][nx] = d[crr.imag()][crr.real()] + 1;
				complex<int> nex(nx, ny);
				Q.push(nex);
				if(Map[ny][nx] == 3) return d[ny][nx];
			}
		}
	}
	return -1;
}

bool solve(){
	int w, h;
	cin>> w>> h;
//	cout<< w<< " "<<h<< endl;
	if(w==0&&h==0) return false;
	
	int W = 2 * w + 1;
	int H = 2 * h + 1;
	vector<vector<int> > Map(H, vector<int>(W, 1));
	vector<vector<int> > d(H, vector<int>(W, INF));
	d[0][1] = 0;
	
	for(int i=0;i<H;i++){
		if(i==0){
			Map[i][1] = 2;
			continue;
		}
		if(i==H-1){
			Map[i][W-2] = 3;
			continue;
		}
		for(int j=0;j<W;j++){
			if(j==0 || j==W-1) continue;
			if(i%2==1){
				if(j%2==1) Map[i][j] = 0;
				else cin>> Map[i][j];
			}
			if(i%2==0){
				if(j%2==1) cin>> Map[i][j];
				else Map[i][j] = 1;
			}
		}
	}
/*	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout<< " "<< Map[i][j];
		}
		cout<< endl;
	}
*/
	int ans = bfs(0, 1, W ,H, Map, d) / 2;
	cout<< ans<< endl;	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

 

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;

    if(N==3){
    	cout << 2 << " "<< 5 << " " << 63 << endl;
    	return 0;
    }

    ll q = N/8;
    vector<ll> res;
    vector<ll> cand = {2, 3, 4, 6, 8, 9, 10, 12};
    REP(i, q){
    	ll base = 12*i;
    	REP(j, 8){
    		res.push_back(base+cand[j]);
    	}
    }

    ll base = 12*q;
    ll r = N%8;
    vector<ll> cand2;
    if(r==1){
    	res.push_back(base+6);
    }
    if(r==2){
    	res.push_back(base+6);
    	res.push_back(base+12);
    }
    if(r==3){
    	res.push_back(base+3);
		res.push_back(base+9);
		res.push_back(base+6);	
    }
    if(r==4){
    	res.push_back(base+3);
		res.push_back(base+9);
		res.push_back(base+2);	
		res.push_back(base+4);		
    }
    if(r==5){
    	res.push_back(base+2);
		res.push_back(base+4);
		res.push_back(base+3);	
		res.push_back(base+9);	
		res.push_back(base+6);
    }
    if(r==6){
    	res.push_back(base+2);
		res.push_back(base+4);
		res.push_back(base+8);	
		res.push_back(base+10);	
		res.push_back(base+3);
    	res.push_back(base+9);	
    }
    if(r==7){
    	res.push_back(base+2);
		res.push_back(base+4);
		res.push_back(base+8);	
		res.push_back(base+10);
		res.push_back(base+3);
		res.push_back(base+9);
		res.push_back(base+6);	
    }
    REP(i, res.size()) cout << res[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 50;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N, X, D;

void solve() {
    if (D < 0) {
        X *= -1;
        D *= -1;
    }
    if (D == 0) {
        if (X == 0) {
            cout << 1 << endl;
        } else {
            cout << N + 1 << endl;
        }
        return;
    }
    map<int, vector<pair<int, int>>> mp;
    FOR(i, 0, N + 1) {
        int l = X * i + D * i * (i - 1) / 2;
        int r = l + D * (N - i) * i;
        //cerr << i << " " << l << " " << r << endl;
        int d = ((l % D) + D) % D;
        l -= d;
        r -= d;
        l /= D;
        r /= D;
        r++;
        mp[d].eb(l, r);
    }
    //cerr << endl;
    int ans = 0;
    for (auto& m : mp) {
        auto& vec = m.second;
        sort(all(vec));
        int l = -INF, r = -INF;
        for (auto& p : vec) {
            if (p.first > r) {
                ans += r - l;
                l = p.first;
                r = p.second;
            } else {
                chmax(r, p.second);
            }
        }
        //cout << m.first << " " << l << " " << r << endl;
        ans += r - l;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> X >> D;


    solve();
    return 0;
}


Measured memory_bytes: 22144
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;


signed main() {
	int D,T,S;
	cin >> D >> T >> S;
	if (T*S >= D) {
		answer("Yes");
	}
	else {
		answer("No");
	}
	

	system("pause");
	return 0;
}

Measured memory_bytes: 3696
class BinarySearchTree:
    def __init__(self):
        self.lcs = {}
        self.rcs = {}
        self.root = None

    def insert(self, key):
        if self.root is None:
            self.root = key
            self.lcs[key] = None
            self.rcs[key] = None
            return
        parent = self.root
        while True:
            if key < parent:
                if self.lcs[parent] is None:
                    self.lcs[parent] = key
                    self.lcs[key] = None
                    self.rcs[key] = None
                    break
                else:
                    parent = self.lcs[parent]
            else:
                if self.rcs[parent] is None:
                    self.rcs[parent] = key
                    self.lcs[key] = None
                    self.rcs[key] = None
                    break
                else:
                    parent = self.rcs[parent]

    def _find(self, key, cur):
        if key == cur:
            return True
        elif key < cur:
            if self.lcs[cur] is None:
                return False
            else:
                return self._find(key, self.lcs[cur])
        else:
            if self.rcs[cur] is None:
                return False
            else:
                return self._find(key, self.rcs[cur])

    def find(self, key):
        return self._find(key, self.root)

    def _print(self, cur):
        self.preorder.append(cur)
        if self.lcs[cur]:
            self._print(self.lcs[cur])
        self.inorder.append(cur)
        if self.rcs[cur]:
            self._print(self.rcs[cur])

    def print(self):
        self.preorder = []
        self.inorder = []
        self._print(self.root)
        print(' ' + ' '.join(map(str, self.inorder)))
        print(' ' + ' '.join(map(str, self.preorder)))


T = BinarySearchTree()
N = int(input())
for _ in range(N):
    s = input().split()
    if s[0] == 'insert':
        T.insert(int(s[1]))
    elif s[0] == 'find':
        print('yes' if T.find(int(s[1])) else 'no')
    else:
        T.print()



Measured memory_bytes: 101792
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::cmp::{max, min};
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        x: i64,
        y: i64,
    }
    let mut x = x;
    let mut y = y;
    let min = if c * 2 < a + b {c*2} else {a+b};
    let mut sum = 0;
    while x - 1 >= 0 && y - 1 >= 0 {
        sum+= min;
        x-=1;
        y-=1;
    }
    if a < c * 2 {
        sum += x * a;
    } else {
        sum += x * c * 2;
    }
    if b < c * 2 {
        sum += y * b;
    } else {
        sum += y * c * 2;
    }
    println!("{}", sum);
}

Measured memory_bytes: 4352