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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li h, w, m;

set<PI> st;

int main() {
    cin >> h >> w >> m;
    map<li, li> mx;
    map<li, li> my;
    rep(i, m) {
        li y, x;
        cin >> y >> x;
        st.insert({y, x});
        mx[x]++;
        my[y]++;
    }

    vector<li> rmx;
    vector<li> rmy;
    li rx = 0;
    li ry = 0;
    for (auto && kv : mx) {
        rx = max(rx, kv.S);
    }
    for (auto && kv : my) {
        ry = max(ry, kv.S);
    }
    li res = rx + ry - 1;
    for (auto && kv : mx) {
        if (kv.S == rx) {
            rmx.pb(kv.F);
        }
    }
    for (auto && kv : my) {
        if (kv.S == ry) {
            rmy.pb(kv.F);
        }
    }

    for (auto && vx : rmx) {
        bool ok = false;
        for (auto && vy : rmy) {
            if (st.count({vy, vx}) == 0) {
                ok = true;
                res++;
                break;
            }
        }
        if (ok)break;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 67856
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	map<ll,ll> mp;
	static ll n,a[200010],sum=0,ans=0;
	mp[0]=1;
	cin>>n;
	REP(i,n){
		cin>>a[i];
	}
	REP(i,n){
		sum+=a[i];
		ans+=mp[sum];
		mp[sum]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    string s, res;
	cin >> s;
    res = s[0]+to_string(s.size()-2)+s[s.size()-1];
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l_t = []
l_pos = []

l_pos.append([0, 0])
l_t.append(0)
# input
for i in range(n):
    a, b, c = (list)(map(int, input().split()))
    l_t.append(a)
    l_pos.append([b, c])


def manhattan(pos1, pos2):
    return abs(pos1[0]-pos2[0]) + abs(pos1[1]-pos2[1])


# check
ans = 'Yes'
for i in range(n):
    dis = manhattan(l_pos[i], l_pos[i+1])
    time = abs(l_t[i+1]-l_t[i])
    if dis > time:
        ans = 'No'
        break
    elif dis % 2 != time % 2:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 65624
#include<bits/stdc++.h>
using namespace std;
long long GCD(int a,int b){
	if(b==0)return a;
	return GCD(b,a%b);
} 
int main(){
    long long a,b;
    cin>>a>>b;
    cout<<a*b/GCD(a,b);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	string s,t;
	cin >> s >> t;
	
	int r[26],rr[26];
	REP(i,26){
		r[i] = -1;
		rr[i] = -1;
	}
	
	REP(i,s.size()){
		int ss = s[i] - 'a';
		int tt = t[i] - 'a';
		
		if(r[ss]==-1){
			r[ss] = tt;
		}else{
			if(r[ss]!=tt){
				cout << "No\n";
				return 0;
			}
		}
		
		if(rr[tt]==-1){
			rr[tt] = ss;
		}else{
			if(rr[tt]!=ss){
				cout << "No\n";
				return 0;
			}
		}
		
	}
	
	cout << "Yes\n";
	return 0;
	
	return 0;
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
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...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}
vii mul(vii a,vii b){
	vii c;
	c.resize(a.size()+b.size());
	c.resize(411);
	for(ll i=0;i<a.sz();++i){
		for(ll j=0;j<b.sz();++j){
			if(j+i>=c.sz())continue;
			c[i+j]+=((a[i]%md)*(b[j]%md))%md;c[i+j]%=md;
		}
	}
	return c;
}

ll dp[411][411];

int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n>>k;
    vii  v1,v2;
    lp(1,n)cin>>x,v1.pb(x);
    lp(1,n)cin>>x,v2.pb(x);
    
    vii ans(411);ans[0]=1;
    for(i=0;i<=400;++i){
    	for(j=0;j<=400;++j)dp[i][j]=exp(i,j)%md;
    }
    for(j=0;j<=400;++j){
    	for(i=1;i<=400;++i){
    		dp[i][j]+=dp[i-1][j]%md,dp[i][j]%=md;
    	}
    }
    for(j=0;j<n;++j){
    	vii p(411);
    	for(i=0;i<=400;++i){
    		ll s=0;
    		s=dp[v2[j]][i]-dp[v1[j]-1][i];s=(s+md)%md;
    		p[i]=s;
    	}
    	// for(i=0;i<=10;++i)cout<<p[i]<<" ";cout<<"\n";
    ans=mul(p,ans);
    }
    cout<<ans[k]<<"\n";


}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

int main(){
   ll X;
   cin >> X;
   cout << 360 / __gcd(X,(ll)360) << endl;
}


Measured memory_bytes: 3632
N, K = map(int, input().split())
S = input()
S = list(S)

if S[K-1] == "A":
    S[K-1] = "a"
if S[K-1] == "B":
    S[K-1] = "b"
if S[K-1] == "C":
    S[K-1] = "c"
S = ''.join(S)
print(S)

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
	ll a,p;
	cin>>a>>p;
	cout<<(3*a+p)/2<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

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

using namespace std;
typedef long long ll;

const int N=100005;

int n,a[N],m;
vector<int>e[N];

ll dfs(int x,int fa){
	ll r=a[x];
	if(e[x].size()>1)r+=a[x];
	for(int v:e[x])if(v!=fa){
		ll c=dfs(v,x);
		if(c>a[x])puts("NO"),exit(0);
		r-=c;
	}
	if(r<0||r>a[x])puts("NO"),exit(0);
	return r;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	if(n==2){
		if(a[1]==a[2])puts("YES");else puts("NO");
		exit(0);
	}
	for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),e[u].pb(v),e[v].pb(u);
	for(int i=1;i<=n;i++)if(e[i].size()>1)m=i;
	if(dfs(m,0))puts("NO");else puts("YES");
	return 0;
}

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

using P = complex<long long>;

int cross(P p1, P p2) {
    return (p1.real() * p2.imag() - p1.imag() * p2.real());
}

string adj(string num) {
    int cnt = 0;
    while (cnt < num.size() && num[cnt] != '.') cnt++;
    if (cnt == num.size()) {
	num += ".00000";
    }
    else {
	int len = num.size() - 1 - cnt;
	for (int i = 0; i < 5 - len; i++) num += '0';
    }
    return num;
}


long long pr(string num) {
    num = adj(num);
    long long ans = 0;
    for (int i = 0; i < num.size(); i++) {
	if ('0' <= num[i] && num[i] <= '9') {
	    ans = ans * 10 + num[i] - '0';
	}
    }
    if (num[0] == '-') ans = -ans;
    return ans;
}

int main() {
    int n;
    cin >> n;
    while (n--) {
	P pp[4];
	for (int i = 0; i < 4; i++) {
	    string x, y;
	    cin >> x >> y;
	    pp[i] = P(pr(x), pr(y));
	}
	if (cross(pp[1] - pp[0], pp[3] - pp[2]) == 0) {
	    cout << "YES" << endl;
	}
	else {
	    cout << "NO" << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;	cin>>n;
	int i,j,a[n],b[n],c[n];
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	int ans[n][3];
	ans[n-1][0]=a[n-1];
	ans[n-1][1]=b[n-1];
	ans[n-1][2]=c[n-1];
	for(i=n-2;i>=0;i--){
		ans[i][0]=a[i]+max(ans[i+1][1],ans[i+1][2]);
		ans[i][1]=b[i]+max(ans[i+1][0],ans[i+1][2]);
		ans[i][2]=c[i]+max(ans[i+1][1],ans[i+1][0]);
	}
	cout<<max(ans[0][0],max(ans[0][1],ans[0][2]));
	return 0;
}

Measured memory_bytes: 2688
def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while visitct!=n:
    ct+=1
    for i in range(len(next)):
      distance[next[i]]=ct
      visited[next[i]]=1
      visitct+=1
      for j in range(len(connection[next[i]])):
        if visited[connection[next[i]][j]]==-1:
          next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
    
  return distance

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)
 
if max(bfs(bfs(0).index(max(bfs(0)))))%3==1:
  print('Second')
else:
  print('First')

Measured memory_bytes: 137128
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int grundy1(ll A, ll K) {
	if(A < K) return 0;
	if(A % K == 0) return A / K;
	else return grundy1(A - A / K - 1, K);
}

int grundy2(ll A, ll K) {
	// debug(A, K);
	if(A < K) return 0;
	if(A % K == 0) return A / K;
	else {
		ll m = A / K;
		ll to = m * K;
		return grundy2(A - ((A - to + m) / (m + 1)) * (m + 1), K);
	}
}

void solve() {
	ll N;
	cin >> N;
	ll res = 0;
	rep(i, 0, N) {
		ll A, K;
		cin >> A >> K;
		if(K <= 10000) res ^= grundy1(A, K);
		else res ^= grundy2(A, K);
		// debug(grundy1(A, K), grundy2(A, K));
	}
	if(res != 0) cout << "Takahashi\n";
	else cout << "Aoki\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main(void)
{
	int q1, b, c1, c2, q2;
	
	while(1){
		scanf("%d", &q1);
		if (q1 == 0) break;
		scanf("%d %d %d %d", &b, &c1, &c2, &q2);
		
		if (c1 <= c2){
			int x = min(b/c1, q2);
			int y = (b - (x * c1)) / c2;
			if ((x + y) < q1){
				printf("NA\n");
			}
			else {
				printf("%d %d\n", x, y);
			}
		}
		else {
			int x = min(min((b - (c2 * q1)) / (c1 - c2), q2), (b / c1));
			int y = (b - (x * c1)) / c2;
			if(x <= 0){
				printf("NA\n");
			}
			else {
				printf("%d %d\n", x, y);
			}
		}
	}
	return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100, MAXK = 25;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000;
const ld PI = asin(1) * 2;

int main()
{
    FAST_IO;

    int n, m; cin >> n >> m;
    priority_queue<int> q;
    REP(n) {int x; cin >> x; q.push(x);}
    REP(m) {int x = q.top(); q.pop(); q.push(x/2);}
    ll sum = 0;
    while (!q.empty()) {sum += q.top(); q.pop();}
    cout << sum << endl;

    return 0;
}


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

const int max_n = 200000;

struct student
{
  bool win;
  int next;
  int prev;
};

int main()
{
  int n, m, q;
  int a[max_n];
  int query[1000];

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

  student students[max_n];

  for (int i=0;i<n;i++)
  {
    students[i].win = true;
    students[i].next = (i+1) % n;
    students[i].prev = (i-1+n) % n;
  }

  int baton = 0;
  for (int i=0;i<m;i++)
  {
    if (a[i] % 2)
      for (int k=0;k<a[i];k++) baton = students[baton].prev;
    else
      for (int k=0;k<a[i];k++) baton = students[baton].next;

    int pre = students[baton].prev;
    int nxt = students[baton].next;
    students[baton].win = false;
    students[pre].next = nxt;
    students[nxt].prev = pre;
    baton = nxt;
  }

  for (int i=0;i<q;i++)
  {
    if (students[query[i]].win) cout << 1 << endl;
    else cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 4288
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

double Absv(double value){
  if(value >= 0) return value;
  else return -value;
}

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  int H[N];
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }

  double dT = Absv(A - (T - H[0]*0.006));
  double dTa;
  int Ans = 1;

  for(int i = 1 ; i < N; i++){
    dTa = Absv(A - (T - H[i]*0.006));
    if(dTa < dT){
      dT = dTa;
      Ans = i + 1;
    }
  }

  printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 384
import sys, re

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, K = MAP()
h = LIST()

dp = [INF]*N
dp[0] = 0
for i in range(N):
	for j in range(1, K+1):
		if i < N-j:
			dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])


Measured memory_bytes: 55264
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
r, g, b = gi()
k, = gi()
while k and g <= r:
	k -= 1
	g *= 2
while k and b <= g:
	k -= 1
	b *= 2
if g <= r or b <= g:
	print("No")
else:
	print("Yes")

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

int main(){
    long N;
    cin >> N;
    long long sum = 0LL;
    for(long i = 1; i <= N; i++){
        if(i % 3 !=0 && i % 5 != 0 && i % 15 != 0 ){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int k = 1;
        for(int i=0;i<S.length();i++){
            int c = S.charAt(i)-'a'+1;
            if( (k & (1<<c)) != 0){

                System.out.println("no");
                return;
            }
            k |= (1<<c);
        }
        
        System.out.println("yes");
    }

    public static void main(String[] args) {
        new Main();
    }
}


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

typedef pair<int, int> P;

int main(){
	int H, W, Ch, Dh, Cw, Dw;
	cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
	char S[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> S[i][j];
		}
	}
	int dh[4] = {1, 0, -1, 0}, dw[4] = {0, 1, 0, -1};
	int wh[20] = {2, 1, 0, -1, -2, 2, 1, -1, -2, 2,
					-2 , 2, 1, -1, -2, 2, 1, 0, -1, -2};
	int ww[20] = {2, 2, 2, 2, 2, 1, 1, 1, 1, 0,
					0, -1, -1, -1, -1, -2, -2, -2, -2, -2};
	queue<P> queA, queB;
	int D[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			D[i][j] = -1;
		}
	}
	queA.push(P(Ch - 1, Cw - 1));
	queB.push(P(Ch - 1, Cw - 1));
	D[Ch - 1][Cw - 1] = 0;
	while(queB.size() > 0){
		while(queA.size() > 0){
			P p = queA.front();
			queA.pop();
			if(p.first == Dh - 1 && p.second == Dw - 1) break;
			for(int i=0;i<4;i++){
				int nh = p.first + dh[i];
				int nw = p.second + dw[i];
				if(0 <= nh && nh < H &&
					0 <= nw && nw < W && 
					S[nh][nw] == '.' && D[nh][nw] == -1){
					queA.push(P(nh, nw));
					queB.push(P(nh, nw));
					D[nh][nw] = D[p.first][p.second];
					//cout << "A:" << nh << ":" << nw << ":" << D[nh][nw] << endl; 
				}
			}
		}
		P p = queB.front();
		queB.pop();
		if(p.first == Dh - 1 && p.second == Dw - 1) break;
		for(int i=0;i<20;i++){
			int nh = p.first + wh[i];
			int nw = p.second + ww[i];
			if(0 <= nh && nh < H &&
				0 <= nw && nw < W && 
				S[nh][nw] == '.' && D[nh][nw] == -1){
				queA.push(P(nh, nw));
				queB.push(P(nh, nw));
				D[nh][nw] = D[p.first][p.second] + 1;
				//cout << "B:" << nh << ":" << nw << ":" << D[nh][nw] << endl;
			}
		}	
	}
	cout << D[Dh - 1][Dw - 1] << endl;
}


Measured memory_bytes: 8444
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    while(true){
        int N; cin >> N;
        if(N==0) break;
        int A[N]; rep(i,N) cin >> A[i];
        sort(A,A+N);
        int ans=INF;
        rep(i,N-1){
            chmin(ans,A[i+1]-A[i]);
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3104
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NK = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, K) = (NK[0], NK[1]);
            var D = Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
            var able = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }.Except(D).ToArray();

            bool CheckDigit(int n)
            {
                var ret = true;
                var x = n.ToString().ToCharArray();
                foreach (var i in x)
                {
                    ret &= able.Contains(i);
                }
                return ret;
            }

            var answer = N;
            while (!CheckDigit(answer))
            {
                answer++;
            }

            Console.WriteLine(answer);

        }
    }
}

Measured memory_bytes: 33652
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

n, k, c = inpl()
s = list(input())[:-1]
q = collections.deque()
cool = 0
left = [0] * n
right = [0] * n
val=-1
for i in range(n):
    if cool<=0 and s[i]=="o" and val<k:
        val += 1
        cool = c
    else:
        cool-=1
    left[i] = val
cool = 0
val+=1
for i in range(n-1,-1,-1):
    if cool<=0 and s[i]=="o" and val>0:
        val -= 1
        cool = c
    else:
        cool-=1
    right[i]=val
# print(left)
# print(right)
for i in range(n):
    if left[i]==right[i] and (i == 0 or left[i] - left[i - 1] == 1) and (i == n - 1 or right[i + 1] - right[i] == 1):
        print(i + 1)


Measured memory_bytes: 65688
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int N = Integer.parseInt(sl[0]);
            int A = Integer.parseInt(sl[1]);
            int B = Integer.parseInt(sl[2]);

            int sm = 0;

            for (int i = 1; i <= N; i++) {
                if (check(String.valueOf(i), A, B)) sm += i;
            }


            System.out.println(sm);
        }
    }
    static boolean check(String s, int a, int b) {
        boolean flg = false;

        int sm = 0;

        for (int i = 0; i < s.length(); i++) {
            sm += Character.getNumericValue(s.charAt(i));
        }

        if (a <= sm && sm <= b) flg = true;
        return flg;
    }
}


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

using namespace std;

#define MAX_V 150
#define INF 1e9

bool used[MAX_V];
int cost[MAX_V][MAX_V], mincost[MAX_V], V;

int prim(){
  for(int i = 0 ; i < V ; i++){
    mincost[i] = INF;
    used[i] = false;
  }
  mincost[0] = 0;
  int res = 0;

  while(true){
    int v = -1;
    for(int u = 0 ; u < V ; u++){
      if(!used[u] && (v == -1 || mincost[u] < mincost[v])){
        v = u;
      }
    }

    if(v == -1) break;
    used[v] = true;
    res += mincost[v];
    
    for(int u = 0 ; u < V ; u++){
      mincost[u] = min(mincost[u], cost[v][u]);
    }
  }
  return res;
}

int main(){
  int E, a, b, c;

  while(cin >> V >> E, (V|E)){
    fill(cost[0],cost[MAX_V],INF);
    for(int i = 0 ; i < E ; i++){
      cin >> a >> b >> c;
      cost[a][b] = cost[b][a] = c;
    }
    cout << prim() << endl;
  }

  return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <typename A, typename B>
string to_string(pair<A, B> p){
        return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
        string s = "{";
            bool first = true;
                for(const auto & x : v){
                            if(!first) s += ", ";
                                    first = false;
                                            s += to_string(x);
                                                }
                    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
        cerr << " " << to_string(F);
            debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

int main(){
        fcin;

        int n, m;
        cin >> n >> m;

        vector<pair<int, char>> v(m);
        for(int i = 0; i < m; i++){
            cin >> v[i].fi >> v[i].se;
            v[i].fi--;
        }

        int ans = -1;
        for(int i = 0; i <= 999; i++){
            string s = to_string(i);
            if(s.size() != n) continue;

            bool ok = true;
            for(int i = 0; i < m; i++){
                if(v[i].fi > n){
                    ok = false;
                    continue;
                }
                if(s[v[i].fi] != v[i].se) ok = false;
            }
            if(ok){
                ans = i;
                break;
            }
        }
        cout << ans << endl;
        return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <tuple>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

template<class T = ll>
struct Edge {
  int to;
  T cost;
  Edge() {}
  Edge(int to, T cost) : to(to), cost(cost) {}
  bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T = ll>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

  int V = (int)edges.size();
  const int INF = numeric_limits<T>::max();
  vector<T> dist(V, INF);
  dist[st] = 0;

  priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
  p_que.emplace(st, dist[st]);

  while (!p_que.empty()) {

    Edge<T> now(p_que.top().to, p_que.top().cost);
    p_que.pop();

    if (dist[now.to] < now.cost) continue;
    for (const Edge<T> &e : edges[now.to]) {
      T tmp_cost = now.cost + e.cost;
      if (dist[e.to] > tmp_cost) {
        dist[e.to] = tmp_cost;
        p_que.emplace(e.to, dist[e.to]);
      }
    }
  }

  return dist;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W;
  cin>>H>>W;
  vector<vector<Edge<int> > > edges(10);

  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      int c;
      cin>>c;
      edges[j].emplace_back(i,c);
    }
  }
  auto dij = Dijkstra<int>(edges,1);

  vector<int> cost;
  for (auto& i : dij) {
    cost.push_back(i);
  }

  int ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int tmp;
      cin>>tmp;
      if(tmp!=-1){
        ans+=cost[tmp];
      }
    }
  }
  cout<<ans<<endl;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    int ans = 0;
    vector<int> a(n), c(n - 1);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++){
        int b;
        cin >> b;
        ans += b;
    }

    for (int i = 0; i < n - 1; i++)
        cin >> c[i];

    for (int i = 1; i < n; i++){
        if (a[i - 1] + 1 == a[i])
            ans += c[a[i - 1] - 1];
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
date_set = gets.chomp.to_f
date_count = 0

loop  do
  break if date_count == date_set
  (a,b,c) = gets.chomp.split.map(&:to_f).sort
  if c.to_f ** 2 == a.to_f ** 2 + b.to_f ** 2
    puts "YES"
  else
    puts  "NO"
  end
  date_count += 1
end


Measured memory_bytes: 6892
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>k; int ara[n+9];

    for(i=1; i<=n; i++) cin>>ara[i];

    sort(ara+1, ara+n+1);
    reverse(ara+1, ara+n+1);

    v = 0;

    for(i=k+1; i<=n; i++)
    {
        v+=ara[i];
    }
    
    cout<<v<<endl;

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

bool binarysearch(int A[], int n, int key){
    int left = 0;
    int right = n;
    while(left < right){
        int mid = (left + right)/2;
        if (A[mid] == key)
            return true;
        else if(key > A[mid])
            left = mid+1;
        else
            right = mid;
    }
    return false;
}

int main(){
    int n, q, key, sum;
    scanf("%d", &n);
    int A[n-1];
    for(int i=0; i<n; i++){scanf("%d", &A[i]);}

    scanf("%d", &q);
    for(int i=0; i<q; i++){
        scanf("%d", &key);
        if (binarysearch(A, n, key)) sum++;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 3516
"""
素直に実装するとN**9
"""

import bisect
 
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
ans = 0
for ai in range(N):
    for bi in range(ai+1, N):
        ci = bisect.bisect_left(L, L[ai]+L[bi])
        if ci > bi:
            ans += ci - bi - 1
        else:
            pass
 
print(ans)

Measured memory_bytes: 3188
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2:
            a -= 1
        b += a // 2
        a -= a // 2
    else:
        if b % 2:
            b -= 1
        a += b // 2
        b -= b // 2
print(a, b)

Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
using namespace std; 

int main(){
    int n,r; cin >> n >> r;
    if (n<10) cout << r+100*(10-n) << "\n";
    else cout << r << "\n";
}


Measured memory_bytes: 256
def main():
    a = [0]*10
    b = list(map(int, input().split()))
    for v in b:
        a[v] += 1
    if a[1] == 1 and a[9] == 1 and a[7] == 1 and a[4] == 1:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(long long x, long long y) {
    long long diff = abs(x-y);
    if (diff < 2) {
        std::cout << "Brown" << std::endl;
    } else {
        std::cout << "Alice" << std::endl;
    }

}

int main() {
    struct timeval start,end;
    long long span;
    long long x, y;

    gettimeofday(&start,NULL);

    std::cin >> x >> y;
    solve(x, y);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
S=list(input())
S.append("X")
i=0
ans=0
for j in range(len(S)):
  if S[j]!="A" and S[j]!="T" and S[j]!="C" and S[j]!="G":
    ans=max(ans,len(S[i:j]))
    i=j+1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 2e2 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
int n, ans;
set <int> sst;
struct PP {
	int x, y;
	bool color;
	friend bool operator < (PP u, PP v) {
		return u.x < v.x;
	}
} p[maxx];

void Init() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> p[i].x >> p[i].y;
		p[i].color = 0;
	}
	for(int i = 1; i <= n; i++) {
		cin >> p[i + n].x >> p[i + n].y;
		p[i + n].color = 1;
	}
	sort(p + 1, p + 2 * n + 1);
}

void Scan() {
	set <int>::iterator id;
	for(int i = 2 * n; i >= 1; i--) {
		if(p[i].color) sst.insert(p[i].y);
		else {
			id = sst.upper_bound(p[i].y);
			if(id != sst.end()) {
				ans++;
				sst.erase(id);
			}
		}
	}
	cout << ans << endl;
}

int main() {
	Init();
	Scan();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	
	int N;
	int a[100] = {0};
	
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++){
		scanf("%d", &a[i]);
	}
	
	sort(a, a + N);
	reverse(a, a + N);
	
	int Alice = 0;
	int Bob = 0;
	
	for(int i = 0; i <= N; i += 2){
		Alice += a[i];
		Bob += a[i + 1];
	}
	
	printf("%d\n", Alice - Bob);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

int main()
{
	
string s;
cin>>s;
ll a=0,b=0;
for(ll i=0;i<s.length();i++)
{
	if(s[i]=='A')a++;
	else b++;
}
if(a>0 && b>0){cout<<"Yes";return 0;}
else 
cout<<"No";
}

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

int main() {
  int a,b,c;
  
  cin>>a>>b;
  
  c = b/a;
  
  
  if(c*a==b)
    cout<<a+b<<endl;
    
   else
     cout<<b-a<<endl;
    
    
}


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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a) < abs(x-b)){
     cout << "A" << endl;
  }
  else {
     cout << "B" << endl;
  }
}
   

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> cnt(n, 1), red(n, false);
    red[0] = true;
    while (m--) {
        int s, t; cin >> s >> t; s--, t--;
        red[t] |= red[s], cnt[t]++;
        if (--cnt[s] == 0) red[s] = 0;
    }
    cout << accumulate(begin(red), end(red), 0) << endl;
    return 0;
}


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

if abs(x) >= k*d:
    print(abs(x)-k*d)
elif abs(x)%d==0:
    if (int(abs(x)/d)+1000000000000000-k)%2==0:
        print(0)
    else:
        print(d)
else:
    if (k-int(abs(x)/d))%2==0:
        print(abs(x)%d)
    else:
        print(d-(abs(x)%d))

Measured memory_bytes: 9076
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
  cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                               \
  cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define debug_4(x1, x2, x3, x4)                                           \
  cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                       \
  cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                      \
  CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
  (__VA_ARGS__)
#else
#define debug(...)
#endif

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

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int r, int c) {
    if (min(r, c) < 0) return 0;
    return fact[r + c + 2] * ifact[r + 1] * ifact[c + 1];
  }
};

void Main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  combination g(r2 + c2 + 2);
  mint ans = 0;
  ans += g(r2, c2);
  ans -= g(r2, c1 - 1);
  ans -= g(r1 - 1, c2);
  ans += g(r1 - 1, c1 - 1);
  cout << ans.x << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

typedef long long ll;

int N;
vector<int> arr;

int main() {
    scanf("%d", &N);
    arr.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &arr[i]);
    }

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

    ll x = -1, y = -1;
    int p = arr[N - 1];
    for(int i = N - 2; i >= 0; i--) {
        if(arr[i] == p) {
            if(x == -1) x = arr[i];
            else if(y == -1) y = arr[i];
            p = -1;
        }
        else p = arr[i];
    }
    if(y == -1) cout << 0;
    else cout << x*y;
}


Measured memory_bytes: 640
n, m = gets.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
lcm = s.size.lcm(t.size)
hash = Hash.new
s.each_char.with_index do |c, i|
  hash[i * lcm / n + 1] = c
end
ans = lcm
t.each_char.with_index do |c, i|
  if hash[i * lcm / m + 1] && hash[i * lcm / m + 1] != c
    ans = -1
    break
  end
end
puts ans


Measured memory_bytes: 22404
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int d = sc.nextInt();
            int count = map.getOrDefault(d, 0);
            map.put(d, ++count);
        }
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int d = sc.nextInt();
            int count = map.getOrDefault(d, 0);
            if (count == 0) {
                System.out.println("NO");
                return;
            }
            map.put(d, --count);
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 130200