akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

template<typename T>
class dynamic_segtree{
  private:
    using F = std::function<T(T,T)>;
    F f;
    F g;
    T ei;
    struct node_t{
        int L,R;
        T val;
        node_t *ch[2];
        node_t(int L,int R,T val):L(L),R(R),val(val){
            ch[0]=NULL;
            ch[1]=NULL;
        }
    };
    node_t *root;
    node_t *update(node_t* nd,int k,T x){
        if(nd->L==nd->R){
            nd->val = g(nd->val,x);
            return nd;
        }
        if(k<=(nd->R+nd->L)/2){
            if(!nd->ch[0]) nd->ch[0] = new node_t(nd->L,(nd->L+nd->R)/2,ei);
            nd->ch[0] = update(nd->ch[0],k,x);
        }
        else{
            if(!nd->ch[1]) nd->ch[1] = new node_t((nd->L+nd->R)/2+1,nd->R,ei);
            nd->ch[1] = update(nd->ch[1],k,x);
        }
        nd->val = f(nd->ch[0]?nd->ch[0]->val:ei,nd->ch[1]?nd->ch[1]->val:ei);
        return nd;
    }
    T query(node_t *nd,int l,int r){
        if(nd->R<l||r<nd->L) return ei;
        if(l<=nd->L&&nd->R<=r) return nd->val;
        return f(nd->ch[0]?query(nd->ch[0],l,r):ei,nd->ch[1]?query(nd->ch[1],l,r):ei);
    }
  public:
    dynamic_segtree(F f,T ei):f(f),ei(ei){}
    ~dynamic_segtree(){delete root;root = nullptr;}
    void init(int n){
        root = new node_t(0,n-1,ei);
    }
    void update(int k,T x,F fc){
        g=fc;
        update(root,k,x);
    }
    T query(int l,int r){
        return query(root,l,r);
    }
};


int main(){
    int N;cin>>N;
    vector<int> a(N);
    REP(i,N) cin>>a[i];
    vector<vector<int>> graph(N);
    REP(i,N-1){
        int u,v;
        cin>>u>>v;
        u--;v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    vector<int> ans(N);
    function<int(int,int)> f=[](int,int b){return b;};
    dynamic_segtree<int> seg([](int a,int b){return max(a,b);},0);
    seg.init(1e9+7);
    function<void(int,int)> dfs=[&](int u,int pre){
        int rb=seg.query(a[u],a[u]);
        seg.update(a[u],seg.query(0,a[u]-1)+1,f);
        ans[u]=seg.query(0,1e9);
        for(auto v:graph[u]) if(v!=pre){
            dfs(v,u);
        }
        seg.update(a[u],rb,f);
    };
    dfs(0,-1);
    REP(i,N) cout<<ans[i]<<'\n';
}


Measured memory_bytes: 184812
X=int(input())
if X<=1999 and X>=1800:
    print(1)
elif X>=1600:
    print(2)
elif X>=1400:
    print(3)
elif X>=1200:
    print(4)
elif X>=1000:
    print(5)
elif X>=800:
    print(6)
elif X>=600:
    print(7)
elif X>=400:
    print(8)

Measured memory_bytes: 9180
def calc(a,b,ans):
  if b==0:
    return ans
  else:
    return calc(b,a%b,ans+b*(a//b)*3)

n,x=map(int,input().split())
n=n-x
n,x=max(n,x),min(n,x)
print(calc(n,x,0))

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
answer=0
if N==1:
    print(0)
else:
    for n in range(N - 1):
        if A[n] > A[n + 1]:
            sa = A[n] - A[n + 1]
            answer += sa
            A[n + 1] = A[n]
    if A[-2] > A[-1]:
        answer += A[-2] - A[-1]
    print(answer)
    

Measured memory_bytes: 94088
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer cout<<endl<<"answer : ";
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0;string s;bool flag=false;
        char ch;
        cin>>ch;
        if(ch>='a')
            cout<<"a"<<endl;
        else
            cout<<"A"<<endl;
        
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|
 
*/

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

int main() {
	ll a,b,c,d,q,ans=0;
	cin>>a>>b>>c>>d>>q;
	a*=4;b*=2;
	ll mi=min({a*2,b*2,c*2,d});
	ans+=q/2*mi;
	q%=2;
	mi=min({a,b,c});
	ans+=q*mi;
	cout <<ans;
	return 0;
}

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

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1e3 + 7;
int n, m, a, b;

int main() {
	rd(n, m), rd(a, b);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			printc('0' + ((i <= b && j <= a) || (i > b && j > a)));
		printc('\n');
	}
	return 0;
}

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

// @author: pashka

vector<vector<pair<int, int>>> g;
vector<bool> mark;

bool dfs(int x, int y, int p) {
    if (x == y) return true;
    for (auto e : g[x]) {
        if (e.first == p) continue;
        if (dfs(e.first, y, x)) {
            mark[e.second] = true;
            return true;
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back({y, i});
        g[y].push_back({x, i});
    }

    int m;
    cin >> m;
    vector<int> cover(n - 1);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        mark.assign(n - 1, false);
        dfs(x, y, -1);
        for (int j = 0; j < n - 1; j++) {
            if (mark[j]) {
                cover[j] |= (1 << i);
            }
        }
    }

    vector<long> d(1 << m);
    d[0] = 1;
    for (int i = 0; i < n - 1; i++) {
        for (int x = (1 << m) - 1; x >= 0; x--) {
            long q = d[x];
            d[x | cover[i]] += q;
        }
    }
    cout << d[(1 << m) - 1];

    return 0;
}

Measured memory_bytes: 8448
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int kotae = 0;
	while (A >= B) {
		B *= 2;
		kotae++;
	}

	while (B >= C) {
		C *= 2;
		kotae++;
	}

	if (K >= kotae) co("Yes");
	else co("No");



	Would you please return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
  int N;
  cin>>N;
  out(2*3.14159265*N);
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

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

    int ans = 0;
    int maxp = 0;
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        maxp = max(p, maxp);
        ans += p;
    }
    ans -= maxp/2;
    cout << ans << endl;
    return 0;
}


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


using namespace std;

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


int main() {
	ll a, b, x;
	cin >> a >> b >> x;

	ll ua = (a + x - 1) / x;
	ll lb = b / x;



	cout << lb - ua + 1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

int func(int i,char s[],char t[]){
  return (i==0?s[0]==t[0]:func(i-1,s,t)+(s[i]==t[i]) );
}

int main(){
  char s[3],t[3]; scanf("%s",s); scanf("%s",t);
  cout << func(2,s,t);
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val set = mutableSetOf<Int>()
    for (i in 1..n) {
        val a = readLine()!!.toInt()
        if(set.contains(a)){
            set.remove(a)
        }else{
            set.add(a)
        }
    }
    println(set.size)
}

Measured memory_bytes: 43984
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,x,y;
lol i[100001];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    lol c,d=0,e=0,f=0,g=1,h=0;
    cin >>a;
    for(int n=0;n<=a;n++){
	cin >>i[n];
    }
    for(int n=0;n<a;n++){
	cin >>b;
	c=min(b,i[n]);
	b-=c,i[n]-=c,d+=c;
	c=min(b,i[n+1]);
	i[n+1]-=c,d+=c;
    }
    cout <<d<<'\n';
    return (0);
}


Measured memory_bytes: 1024
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >> getLine >>= print . maximum . scanl ( \acc c -> if c == 'I' then acc + 1 else acc - 1 ) 0


Measured memory_bytes: 508
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())

sorted_A = sorted(A, reverse=True)
A1 = sorted_A[0]
A2 = sorted_A[1]
for A_i in A:
    if A_i == A1:
        print(A2)
    else:
        print(A1)


Measured memory_bytes: 58328
import collections, sys

n, m = map(int, input().split())
pres = collections.defaultdict(list)
nxts = collections.defaultdict(list)
for line in sys.stdin:
    x, y = map(int, line.split())
    pres[y].append(x)
    nxts[x].append(y)

stack, count, nodes = [], [0], []
for node in range(1, n + 1):
    count.append(len(pres[node]))
    if count[node] == 0:
        stack.append(node)

while stack:
    node = stack.pop()
    nodes.append(node)
    for nxt in nxts[node]:
        count[nxt] -= 1
        if count[nxt] == 0:
            stack.append(nxt)

dp = [0] * (n + 1)
for node in nodes:
    for pre in pres[node]:
        dp[node] = max(dp[node], dp[pre] + 1)

print(max(dp))


Measured memory_bytes: 90460
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}

ll bit[10000009], a[200009],h[200009],ans[200009],n,gg=0;
ll query(ll x){
    ll req=0;
    while(x>0){
        req = maxx(req , bit[x]);
        x-=(x&-x);
    }
    return req;
}
void update(ll x, ll up){
    while(x<10000009){
        bit[x] = maxx(bit[x], up);
        x+= (x&-x);
    }
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++){
        ans[i] = a[i] + query(h[i] - 1);
        update(h[i],ans[i]);
        gg = maxx(gg,ans[i]);
    }
    cout<<gg;
}

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

int a,b,c,d,mx;

int num(int v) {
	return (a/(b+1))*v+min(v,mx)+v;
}

bool valid(int v, int i) {
	return num(v)>=i;	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int q; cin >> q;
	f(_,0,q) {
		cin>>a>>b>>c>>d;	
		string s;
		ll k = int(ceil(1.00*max(a,b)/(min(a,b)+1)));
		int lo = 0, hi = a;
		while (lo<=hi) {
			ll Na = (lo+hi)/2;
			ll Nb = max(0LL,(Na-1)/k);	
			if (b-Nb <= k*(a-Na+1)) 
				lo = Na+1;
			else
				hi = Na-1;
		}
		ll Na = hi, Nb = max(0LL,(hi-1)/k);
		f(i,c,d+1) {
			if (i <= Na+Nb)
				s += 'A'+!(i%(k+1));
			else 
				s += 'B'-((a+b-i+1)%(k+1)==0);
		}
		cout << s << endl;
	}


#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}
	


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef int64_t i64;

static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

i32 kth_element (const i32 k, const i32 *a, const i32 n) {
  i32 *b = (i32 *) calloc (n, sizeof (i32));
  memcpy (b, a, sizeof (i32) * n);
  i32 l = 0;
  i32 r = n;
  while (r - l > 1) {
    i32 p = rand() % (r - l) + l;
    const i32 pivot = b[p];
    b[p] = b[l];
    i32 lp = l + 1;
    i32 rp = r;
    i32 ll = l;
    while (lp < rp) {
      if (b[lp] == pivot) {
        lp++;
      } else if (b[lp] < pivot) {
        b[ll++] = b[lp++];
      } else {
        i32 swap = b[--rp];
        b[rp] = b[lp];
        b[lp] = swap;
      }
    }
    if (ll <= k && k < rp) {
      b[k] = pivot;
      l = k;
      r = k + 1;
    } else if (k < ll) {
      r = ll;
    } else {
      l = rp;
    }
  }
  i32 ress = b[k];
  free (b);
  return ress;
}

void run (void) {
  i32 n = read_int();
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    a[i] = read_int() - i - 1;
  }
  i32 val = kth_element (n/2, a, n);
  i64 ans = 0;
  for (i32 i = 0; i < n; ++i) {
    i32 d = a[i] - val;
    ans += d > 0 ? d : -d;
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};

ll MOD = 998244353;


int main() {
    int n; cin >> n;
    vector<ll> d(n);
    rep(i,n) cin >> d[i];
    if(d[0] != 0) {cout << 0 << endl; return 0;}
    sort(d.begin(),d.end());

    ll MAX = d[n-1];
    ll ko[MAX+1];
    rep(i,MAX+1) ko[i] = 0;
    rep(i,n) ko[d[i]]++;
    if(ko[0] != 1){cout << 0 << endl; return 0;}

    ll ans = 1; //rep(i,MAX+1) cout << ko[i] << endl;
    rep(i,MAX+1){if(ko[i] == 0){cout << 0 << endl; return 0;}}

    rep(i,MAX){
        rep(j,ko[i+1]){
            ans *= (ko[i] % MOD);
            ans %= MOD;
        }
    }
    cout << ans % MOD << endl;

}


Measured memory_bytes: 4844
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();
		for(int i = 0; i < 10; i++) {
			x *= r;
			x -= D;
			System.out.println(x);
		}
	}

}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll n, x;
	cin>>n>>x;
	ll l[n];
	scan(l, 0, n);
	ll c = 0, ans = 1;
	forn(i, 0, n){
		
		c+=l[i];
		if(c<=x)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return b;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return b;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
            if (i > 1)
                dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
        }
        System.out.println(dp[n - 1]);
    }
}


Measured memory_bytes: 61956
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x,i=0,stack[100];
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      stack[i-2] = stack[i-2] + stack[i-1];
      i--;
    } else if ( s[0] == '-' ){
      stack[i-2] = stack[i-2] - stack[i-1];
      i--;
    } else if ( s[0] == '*' ){
      stack[i-2] = stack[i-2] * stack[i-1];
      i--;
    } else {
      x = atoi(s);
      stack[i] = x;
      i++;
    }
  }
  printf("%d\n",stack[i-1]);  
  return 0;
}

Measured memory_bytes: 548
program main
implicit None
integer::n,m,x,y,z,i,j,k
integer,allocatable::a(:),b(:)

read *,n,m,x,y
allocate(a(n))
allocate(b(m))

read *,a
read *,b

z = x

do i = 1,n
	if(z < a(i))then
		z = a(i)
	endif
enddo

k = y

do i = 1,m
	if(k >= b(i))then
		k = b(i)
	endif
enddo

j = 0
if (z >= y)then
	j = 1
endif

if (z >= k)then
	j = 1
endif

if (j == 0)then
	print 101,"No War"
	else
		print 101,"War"
endif

101 format(a)
end program main

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N;
	int T , A;
	scanf("%d %d %d",&N ,&T ,&A);
	int H[N];
	for(int i=0;i<N;i++){
		scanf("%d",&H[i]);
	}
	int x[N];
	for(int j=0;j<N;j++){
		x[j] = 1000*A - (1000*T - 6*H[j]);
		if(x[j]<0){
			x[j] *= -1;
		}
	}
	int min = 0;
	for(int k=0;k<N;k++){
		if(x[k] < x[min]){
			min = k;
		}
	}
	printf("%d",min+1);
	return 0;
}	

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  int a[3][109];
  cin>>n;
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      if(j>=i){
	sum+=a[1][j];
      }
      if(j<=i){
	sum+=a[0][j];
      }
    }
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
  return(0);
}


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

int main() {
  char c;
  cin >> c;
  vector<char> vec = {'a', 'e', 'i', 'o', 'u'};

  for (int i = 0; i < 5; i ++) {
    if (c == vec.at(i)) {
      cout << "vowel" << endl;
      return 0;
    }
  }

  cout << "consonant" << endl;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
MOD=10**9+7

def calculate_combination(n,k):
    x,y=1,1
    for i in range(k):
        x=x*(n-i)%MOD
        y=y*(k-i)%MOD
    return x*pow(y,MOD-2,MOD)%MOD

for i in range(1,K+1):
    a=calculate_combination(N-K+1,i)
    b=calculate_combination(K-1,i-1)
    print(a*b%MOD)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define upper(n,m) (n+m-1)/m
#define rounding(n) (int)((double)n+0.5)

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define ALL(a) a.begin(),a.end()

#define coutALL(i,a) {int i=0;for(auto e:a) cout<<(i++?" ":"")<<e.se; cout<<endl;}
#define coutYN(a) cout<<(a?"Yes":"No")<<endl;
#define coutyn(a) cout<<(a?"yes":"no")<<endl;

#define deb cout<<"debug"<<endl
#define debn(n) cout<<"debug: "<<n<<endl

const int INF=INT_MAX;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
//const int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using namespace std;

//typedef pair<int,int> P;
typedef long long LL;

typedef pair<int,int> P;

int partition(vector <P> &a,int p,int r){

  int x=a[r].fi;
  int i=p-1;

  REAP(j,p,r){

    if(a[j].fi<=x){

      i++;
      swap(a[i],a[j]);

    }

  }

  swap(a[i+1],a[r]);

  return i+1;

}

void quicksort(vector <P> &a,int p,int r){

  if(p<r){

    int q=partition(a,p,r);
    quicksort(a,p,q-1);
    quicksort(a,q+1,r);

  }

}

signed main(){

  ios::sync_with_stdio(false);

  int n;
  cin>>n;

  vector <P> a(n),b;
  vector <char> c(n);
  vector <int> num(n);

  REP(i,n){

    cin>>c[i]>>num[i];

    a[i]=mp(num[i],i);

  }

  b=a;
  quicksort(a,0,n-1);
  stable_sort(ALL(b));

  cout<<(a!=b?"Not stable":"Stable")<<endl;

  for(P e:a) cout<<c[e.se]<<" "<<e.fi<<endl;

  return 0;

}


Measured memory_bytes: 5668
k,x = map(int,input().split())

minx,maxx = -1000000, 1000000

if minx + (k-1) > x:
    l = [i for i in range(minx,minx+x+1)]
elif maxx - (k-1) < x:
    l = [i for i in range(maxx-x,maxx+1,-1)]
else:
    l = [i for i in range(x-(k-1),x+(k-1)+1)]

print(" ".join([str(s) for s in l]))


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60; 

int main()
{
  string S; cin >> S;
  int N = S.size();
  bool res = true;
  rep(i,N)
  {
    if(i%2 == 0)
    {
      if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D')
        res = false;
    }
    else
    {
      if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D')
        res = false;
    }
  }
  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (1..n).map { sc.nextLong() }
    val count = mutableMapOf<Long,Int>()
    count[0] = 1
    var sum = 0L
    var ans = 0L
    for (i in a.indices) {
        sum += a[i]
        val countTmp = count.getOrElse(sum, {0})
        ans += count.getOrElse(sum, {0})
        count[sum] = countTmp + 1
    }
    println(ans)
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

typedef long long LL;

int n, m;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    if(n%2 == 0) n--;

    int l = 1, r = n/2;
    for(int i = 0; i < m/2; ++i) {
        cout << l << ' ' << r << '\n';
        l++; --r;
    }

    l = n/2+1, r = n;
    for(int i = m/2; i < m; ++i) {
        cout << l << ' ' << r << '\n';
        l++; --r;
    }
    
    return 0;
}


Measured memory_bytes: 3664
c=(3..8).zip [0.4]+[*1..5]
while(n=gets.to_i)>s=0
n.times{x,y,h,w=gets.split.map &:to_i;s+=(c.find{|i,j|x+y+h<=i*20&&w<=j*5}||[0])[0]*200}
p s
end

Measured memory_bytes: 6140
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
A=n1()

ans=[0]*n

ans[0]=sum([A[i]*((-1)**i) for i in range(n)])
for i in range(1,n):
    ans[i]=2*A[i-1]-ans[i-1]
print(*ans)

Measured memory_bytes: 14152
#include <iostream>
#include <string>

int main() {
  int a;
  std::cin >> a;
  std::string s;
  std::cin >> s;

  if (a >= 3200) {
    std::cout << s << std::endl;
  } else {
    std::cout << "red" << std::endl;
  }
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    int P;
    cin>>P;
    int cnt=0;
    for(int i=0;i<N;++i){
        int tmp;
        cin>>tmp;
        if(tmp%2==0){
            cnt++;
        }
    }
    if(cnt==N){
        if(P==1){cout<<0<<endl;
        }else{
            long long ans=pow(2,N);
            cout<<ans<<endl;
        }
    }else{
        long long ans=pow(2,N-1);
        cout<<ans<<endl;
    }


    
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  
  ll pre = -999;
  
  rep(i,n){
    if(pre<=h[i]-1){
      pre = h[i]-1;
    }else if(pre==h[i]){
      pre = h[i];
    }else{
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}
  
  

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

int main(void){
   
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]){
        cout << "Yes" <<endl;    
    }
    else if(s[1] == s[2] && s[2] == s[3]){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 200100;
ll rA[MAX_N], lA[MAX_N];
ll A[MAX_N];
int N;

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        scanf("%lld", &A[i]);
        lA[i] = rA[i] = A[i];
    }

    for(int i = 1; i < N; ++i) lA[i] += lA[i-1];
    for(int i = N-2; i >= 0; --i) rA[i] += rA[i+1];

    ll res = 4000000000000000LL;
    for(int i = 0; i < N-1; ++i) res = min(res, abs(lA[i] - rA[i+1]));
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w,n;cin>>h>>w>>n;
  ll r,c;cin>>r>>c;
  string s,t;cin>>s>>t;
  bool fl = true;
  // right
  ll now = c;
  for(int i=0;i<n;i++){
    if(s[i] == 'R')now++;
    if(now > w)fl = false;
    if(now > 1 && t[i] == 'L')now--;
  }

  now = c;
  for(int i=0;i<n;i++){
    if(s[i] == 'L')now--;
    if(now < 1)fl = false;
    if(now < w && t[i] == 'R')now++;
  }

  now = r;
  for(int i=0;i<n;i++){
    if(s[i] == 'D')now++;
    if(now > h)fl = false;
    if(now > 1 && t[i] == 'U')now--;
  }

  now = r;
  for(int i=0;i<n;i++){
    if(s[i] == 'U')now--;
    if(now < 1)fl = false;
    if(now < h && t[i] == 'D')now++;
  }

  if(fl)cout<<"YES"<<endl;
  else cout<<"NO"<<endl; 
  return 0;
}

Measured memory_bytes: 920
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int n, s, t, ans;
vector<int> edge[110000];
int dist[110000][3];
bool done[110000][3];

void bfs(int s, int type) {
  queue<P> q;
  
  q.push(P(s, 0));
  done[s][type] = true;
  
  while (q.size()) {
    P p = q.front();
    q.pop();
    int u = p.first;
    dist[u][type] = p.second;
    for (int v: edge[u]) {
      if (done[v][type]) continue;
      q.push(P(v, dist[u][type]+1));
      done[v][type] = true;
    }
  }
}

int main() {
  cin >> n >> s >> t;
  s--;
  t--;
  
  for (int i = 0; i < n-1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  
  bfs(s, 0);
  bfs(t, 1);
  
  if (dist[t][0] % 2) {
    ans = dist[t][0]/2;
    for (int i = 0; i < n; i++) {
      if (dist[i][0] == ans and dist[i][1] == ans + 1) {
        s = i;
      }
      if (dist[i][0] == ans+1 and dist[i][1] == ans) {
        t = i;
      }
    }
  } else {
    ans = dist[t][0]/2-1;
    for (int i = 0; i < n; i++) {
      if (dist[i][0] == ans and dist[i][1] == ans + 2) {
        s = i;
      }
      if (dist[i][0] == ans+1 and dist[i][1] == ans + 1) {
        t = i;
      }
    }
    ans++;
  }
  
  done[t][2] = true;
  bfs(s, 2);
  int d = 0;
  for (int i = 0; i < n; i++) {
    d = max(d, dist[i][2]);
  }
  
  cout << ans+d << endl;
  return 0;
}

Measured memory_bytes: 7680
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int q = scanner.nextInt();
			IntStream.range(0, q).mapToLong(i -> getResult(scanner.nextInt(), scanner.nextInt()))
					.forEach(System.out::println);
		}
	}

	/**
	 * 順位が高橋より低い最大の人数を計算する （解説通りに実装）
	 * 
	 * @param a 高橋の1回目の順位
	 * @param b 高橋の2回目の順位
	 * @return 順位が高橋より低い最大の人数
	 */
	private static long getResult(long a, long b) {
		if (1 >= Math.abs(a - b)) {
			return 2 * Math.min(a, b) - 2;
		}
		long c = (long) Math.sqrt(a * b);
		if (c * c == a * b) {
			c--;
		}
		if (c * (c + 1) >= a * b) {
			return 2 * c - 2;
		} else {
			return 2 * c - 1;
		}
	}
}


Measured memory_bytes: 36540
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 100005
using namespace std;
int n,a[N];
bool solve(){
	scanf("%d",&n);
	bool t=1,t1=1;
	int mn=1e9,mx=-1e9;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]!=n-1) t=0;
		if(a[i]!=a[1]) t1=0;
		mn=min(mn,a[i]);
		mx=max(mx,a[i]);
	}
	if(t) return 1;
	if(t1&&a[1]*2>n) return 0;
	if(mx-mn>1) return 0;
	int sum=0,tot=0;
	for(int i=1;i<=n;i++)
		if(a[i]==mx) sum++;
		else tot++;
	if(mx<=tot) return 0;
	if((mx-tot)*2>sum) return 0;
	return 1;
}
int main(){
	if(solve()) puts("Yes");
	else puts("No");
	return 0;
}

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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

/////////////////////////////////////////////////////////////////////

const int N = 17, M = 1 << 17;

int a[N][N];
int dp[M], w[M];

int32_t main(){

    sync;

    int n; cin >> n;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];

    for(int mask = 0; mask < (1 << n); mask++) {
    	for(int i = 0; i < n; i++) for(int j = 0; j < i; j++) 
    		if ((mask & (1 << i)) && (mask & (1 << j))) w[mask] += a[i][j];
    }

    for(int mask = 0; mask < (1 << n); mask++) {
    	for(int submask = mask; submask; submask = (submask - 1) & mask)
    		dp[mask] = max(dp[mask], dp[mask ^ submask] + w[submask]);
    }

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

    return 0;
}

Measured memory_bytes: 1280
(defun f (a b c n)
  (if (or (= (mod a 2) 1)
	  (= (mod b 2) 1)
	  (= (mod c 2) 1))
      n
      (f (/ (+ b c) 2)
	 (/ (+ a c) 2)
	 (/ (+ a b) 2)
	 (+ n 1))))

(defun ff (a b c)
  (if (and (= a b) (= b c))
      (if (= (mod a 2) 0)
	  -1
	  0)
      (f a b c 0)))

(let ((a (read))
      (b (read))
      (c (read)))
  (format t "~a~%" (ff a b c)))

Measured memory_bytes: 15972
n,k = map(int, input().split())
a = list(map(int, input().split()))
t = sum(a)
r = set()
r.add(t)
for i in range(2,int(t**0.5)+2):
    if t%i == 0:
        r.add(i)
        r.add(t//i)
ans = 1
for i in r:
    f = [x%i for x in a]
    f.sort()
    if sum(f[:-sum(f)//i]) <= k:
        ans = max(ans,i)
print(ans)


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

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

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

    if (a>=b) puts("delicious");
    else if (b-a > x) puts("dangerous");
    else puts("safe");
}

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

int X, Y, x, y;
int main () {
 cin >> X >> Y >> x >> y;
 
 if (x==X-1 && y==Y-1)
  cout << 1;
  
 else if (X>x && Y>y)
  cout << (X-x)*(Y-y);
  
 else
  cout << 0;
 
 
return 0;
}

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

int main(){
	int N,X;
	cin>>N>>X;
	int x[N];
	for(int i=0;i<N;i++){
		cin>>x[i];
		x[i]-=X;
		x[i]=abs(x[i]);
	}
	sort(x,x+N);
	for(int i=x[0];;i--){
		for(int j=0;j<N;j++){
			if(x[j]%i!=0) break;
			if(j==N-1){
				cout<<i<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int sum=0;
  int i=0;
  int cou=0;
  while(i<n&&cou<	k){
    sum+=a[i];
    i++;
    cou++;
  }
  cout<<sum<<endl;
  
 
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

const ll mod = 1e9 + 7;

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

  string s;
  cin >> s;
  vector<int> ans(s.size(), 0);
  char target = 'L';
  int count = 0;
  int x = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == target && target == 'L') {
      ans[i-1] += (count + 1) / 2;
      ans[i] += count / 2 + 1;
      target = 'R';
      count = 0;
      x = i;
    } else if (s[i] == target && target == 'R') {
      ans[x-1] += (count + 1) / 2;
      ans[x] += count / 2;
      target = 'L';
      count = 1;
    } else {
      count++;
    }
  }
  if (count != 0) {
    ans[x-1] += (count + 1) / 2;
    ans[x] += count / 2;
  }

  for (auto v : ans) {
    printf("%d ", v);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 1104
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   int N;
   cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   set<int> s;
   map<int,int> mp1,mp2;
   for(int i=0;i<N;i++){
      if(i%2==0) mp1[a[i]]++;
      else mp2[a[i]]++;
      s.insert(a[i]);
   }
   if(s.size()==1){
      cout<<N/2<<endl;
      return 0;
   }
   vector<pair<int,int>> odd,even;
   for(auto x:mp1){
      odd.push_back({x.first,x.second});
   }
   for(auto y:mp2){
      even.push_back({y.first,y.second});
   }
   sort(odd.begin(),odd.end(),sort_sec);
   sort(even.begin(),even.end(),sort_sec);
   int X=odd.size();
   int Y=even.size();
   if(odd[X-1].first!=even[Y-1].first){
      cout<<N-odd[X-1].second-even[Y-1].second<<endl;
   }else{
      int result1=N-odd[X-1].second-even[Y-2].second;
      int result2=N-odd[X-2].second-even[Y-1].second;
      cout<<min(result1,result2)<<endl;
   }
   return 0;
}


Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}


int bin_exp(int b,int e, int m)
{
	if(e==0)	
		return 1;
	int a=bin_exp(b,e/2, m);
	if(e&1)	
		return (((a * a) % m) * (b % m)) % m;
	else 
		return (a * a) % m;
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

int32_t main()
{
	fastIO
	inp_out();
	int n;
	string x;  
	cin >> n >> x; 

	reverse(x.begin(), x.end()); 

	vi ans; 
	int val = 0; 

	int cnt = 0; 
	for(int i = 0; i < n;  ++ i)
	{
		cnt += (x[i] == '1'); 
	}

	int v1 = 0, v2 = 0; 

	for(int i = 0; i < n;  ++ i)
		if(x[i] == '1')
		{
			if(cnt  >  1)
			{
				v1 += bin_exp(2, i, cnt - 1); 
				v1 %= (cnt - 1); 
			}
			v2 += bin_exp(2, i, cnt + 1); 
			v2 %= (cnt + 1); 
		}

	 //  db(v1, v2); 

	for(int i = 0; i < n;  ++ i)
	{
		int temp = 0; 
		int fa = 1; 
		if(x[i] == '0')
		{
			temp += bin_exp(2, i, cnt + 1) + v2;
			temp %= (cnt + 1); 
		}

		else
		{
			if(cnt == 1)
			{
				fa -- ;
				temp = 0;  
			}
			else
			{	
				temp -= bin_exp(2, i, cnt - 1); 
				temp +=  v1;
				temp %= (cnt -  1);
				temp += (cnt - 1); 
				temp %= (cnt - 1);  
			}
		}

		 // db(i, temp); 

		

		while(temp != 0)
		{
			temp = temp % (__builtin_popcountll(temp)); 
			 ++ fa; 
		}
		ans.pb(fa); 
	}

	for(int i = n - 1; i >= 0;  -- i)
		cout << ans[i] << "\n"; 


	return 0;
}

Measured memory_bytes: 5516
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cctype>
using namespace std;
int a[100010];
int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
    {
        int i;
        for(i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
        }
        int sum = 1, flag = -1;
        for(i = 1; i < n; i++)
        {
            if(a[i] == a[i-1]) continue;
            if(a[i] > a[i-1])
            {
                if(flag == 0)
                { 
                    sum++;flag = -1;continue;
                }
                flag = 1;
            } 
            if(a[i] < a[i-1])
            {
                if(flag == 1)
                { 
                    sum++;flag = -1;continue;
                }
                flag = 0;
            }
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
 string s;
 cin>>s;
 int counter =0;
 if(s[0]=='1') ++counter;
 if(s[1]=='1') ++counter;
 if(s[2]=='1') ++counter;
 cout<<counter<<endl; 

   }

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

int main(){
    ll N,A,B,C,D,E;
    cin>>N>>A>>B>>C>>D>>E;
    ll L=min(A,B);
    L=min(L,C);
    L=min(L,D);
    L=min(L,E);
    ll ans=4;
    ans+=N/L;
    if(N%L!=0){
        ans++;
    }
    cout<<ans<<endl;


    
}

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

int solve(int a, int b, int c, int k) {
    return min(0, a + b - k) + min(a, k);
}

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


    int a, b, c, k;
    cin >> a >> b >> c >> k;

    cout << solve(a, b, c, k) << "\n";
}


Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
    int a,b,i,result;
    char op;
    for(i=1;;i++)
    {
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')
            break;
        else{
    switch(op)
    {
        case '+':
            result=a+b;
            printf("%d\n",result);
            break;

        case '-':
            result=a-b;
            printf("%d\n",result);
            break;

        case '*':
            result=a*b;
            printf("%d\n",result);
            break;

        case '/':
            result=a/b;
            printf("%d\n",result);
            break;
    }
    }
    }

    return 0;
}



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




int main() {
int k;
cin>>k;
vector<int>s{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5,
		1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2,
		5, 4, 1, 4, 1, 51};
cout<<s[k-1]<<endl;


  return 0;
}

Measured memory_bytes: 256