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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	vi a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(all(a));
	int ans=0;
	ans+=a[2]-a[1];
	a[1]+=ans;
	a[0]+=ans;
	while(a[0]<a[2]){
		a[0]+=2;
		ans++;
	}
	if(a[0]>a[2])ans++;
	cout<<ans<<endl;
}

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

int main() {
    string s; cin >> s;
    int n = s.size();
    vector<int> masks(n + 1), dp(n + 1, n);
    for (int i = 0; i < n; ++i) masks[i + 1] = masks[i] ^ (1 << (s[i] - 'a'));
    map<int, int> dps;
    dps[0] = 0;
    for (int i = 1; i <= n; ++i) {
        dp[i] = dp[i - 1] + 1;
        if (dps.find(masks[i]) != dps.end()) dp[i] = min(dp[i], dps[masks[i]] + 1);
        for (int j = 0; j < 26; ++j) {
            int target = masks[i] ^ (1 << j);
            if (dps.find(target) != dps.end()) dp[i] = min(dp[i], dps[target] + 1);
        }
        if (dps.find(masks[i]) == dps.end()) dps[masks[i]] = dp[i];
        else dps[masks[i]] = min(dps[masks[i]], dp[i]);
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 11396
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void init(int *b){
  int n=b[0];
  int i;
  for(i=1;i<=n;i++) b[i]=0;
}

void add(int *b,int index,int v){
  int i;
  for(i=index;i<=b[0];i+=i&-i) b[i]+=v;
}

int sum(int *b,int index){
  int res=0;
  int i;
  for(i=index;i>0;i-=i&-i) res+=b[i];
  return res;
}

int *c=NULL;
int *d=NULL;
int *bit=NULL;

int64 count(const int *a,const int n,const int v){
  c[0]=0;
  int i;
  for(i=1;i<=n;i++) c[i]=c[i-1]+(a[i-1]<=v?1:0);
  for(i=0;i<=n;i++) d[i]=2*c[i]-i+n+1;
  init(bit);
  int64 cnt=0;
  for(i=0;i<=n;i++){
    cnt+=sum(bit,d[i]-1);
    add(bit,d[i],1);
  }
  return cnt;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int *b=(int *)malloc(sizeof(int)*n);
  c=(int *)malloc(sizeof(int)*(n+1));
  d=(int *)malloc(sizeof(int)*(n+1));
  bit=(int *)malloc(sizeof(int)*(3*n+2));
  bit[0]=3*n+1;
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  for(i=0;i<n;i++) b[i]=a[i];
  qsort(b,n,sizeof(int),cmp);
  int64 t=(int64)(n+0)*(n+1)/2;
  if(count(a,n,b[0])>=t/2+1){
    printf("%d\n",b[0]);
    return;
  }
  int l=0;//
  int r=n;//
  while(r-l>1){
    int m=(l+r)/2;
    int64 cnt=count(a,n,b[m]);
    //printf("%d %lld\n",b[m],cnt);
    if(cnt<t/2+1){
      l=m;
    } else {
      r=m;
    }
  }
  printf("%d\n",b[r]);
}

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


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

using namespace std;


int isp(int x) {
    for (int i = 2; i * i < x; i++) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    int d, x;
    cin >> n >> d >> x;
    for(int i = 0 ; i < n ; i++){
        int a;
        cin >> a;
        x += (d+a-1) / a;
    }
    cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi v;
vb used;
vvi g;
bool dfs(int i,int p){
    used[i]=true;
    for(ll x:g[i]){
        if(x==v[0]&&p==0)return true;
        if(!used[x])if(dfs(x,0))return true;
    }
    return false;
}
int main(){
    ll n,m;cin>>n>>m;
    g=vvi(n);
    used=vb(n,false);
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    rep(i,n)if(g[i].size()&1)dame("No");
    rep(i,n)if(g[i].size()>=6)dame("Yes");
    ll cnt=0;
    rep(i,n)if(g[i].size()>=4)cnt++;
    if(cnt>=3)dame("Yes");
    if(cnt<=1)dame("No");
    rep(i,n)if(g[i].size()==4)v.pb(i);
    used[v[1]]=true;
    used[v[0]]=true;
    for(ll x:g[v[0]])if(dfs(x,1))dame("Yes");
    out("No");
}

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

int main(){
	int n;cin>>n;
	vector<ll>a(3*n);
	for(int i=0;i<3*n;++i){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	ll ans=0;
	for(int i=0;i<2*n;++i){
		if(i%2==0)ans+=a[n+i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
int main() {
	string S, front, back; cin >> S;
	int Q; cin >> Q;
	int temp2;
	string c;
	string result;
	bool S_reverse = false;
	for (int i = 0; i < Q; i++) {
		int temp;
		cin >> temp;
		if (temp == 1) {
			S_reverse = !S_reverse;
		}
		else {
			cin >> temp2 >> c;
			
			if (!S_reverse&& temp2 == 1) {
				front.insert(0, c);
			}

			if (!S_reverse && temp2 == 2) {
				back.insert(back.length(),c);
			}

			if (S_reverse && temp2 == 1) {
				back.insert(back.length(), c);
			}

			if (S_reverse && temp2 == 2) {
				front.insert(0, c);
			}
		}
	}
	if (!S_reverse) {
		result = front + S + back;
	}
	else {
		reverse(front.begin(), front.end());
		reverse(S.begin(), S.end());
		reverse(back.begin(), back.end());
		result = back + S + front;
	}
	cout << result << endl;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100005
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)            //counts no of ones in binary representation
#define w(t)     int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	fast;
	ll n;
	cin>>n;
	set<ll> se1,se2,se3;
	map<ll,ll> ma1,ma2,ma3;
	ll x=0;
	ll i=1;
	while(x<=50000){
		x=3*i*i;
		se1.insert(x);
		ma1[x]++;
		i++;
	}
	for(i=1;i<=200;i++){
		ll temp=4*i*i;
		ll temp2=temp;
		if(temp>=30000)		break;
		for(int j=1;j<=200;j++){
			if(j==i)	continue;
			temp+=(2*(j+i)*(j+i));
			se2.insert(temp);
			ma2[temp]++;
			if(temp>=30000)		break;
			temp=temp2;
		}
		
 	}
 	for(i=1;i<=200;i++){
 		if(i*i>=30000)	break;
 		for(int j=i+1;j<=200;j++){
 			ll temp=(j+i)*(j+i);
 			ll temp2=temp;
 			if(temp>=30000)		break;
 			for(int k=j+1;k<=200;k++){
 				temp+=((k+j)*(k+j));
 				temp+=((k+i)*(k+i));
 				se3.insert(temp);
 				ma3[temp]++;
 				if(temp>=30000)		break;
 				temp=temp2;
			 }
		 }
	 }
	 for(int i=1;i<=n;i++){
	 	ll ans=0;
	 	if(se1.find(2*i)!=se1.end())	ans+=ma1[2*i];
	 	if(se2.find(2*i)!=se2.end())	ans+=(3*ma2[2*i]);
	 	if(se3.find(2*i)!=se3.end())	ans+=(6*ma3[2*i]);
	 	cout<<ans<<endl;
	 }
	 
}

Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int e;
    cin >>e;

    while(e)
    {
        int x=0;
        int y=0;
        int z=0;
        int m=0;
     for(z=0;z*z*z<=e;z++)
        for(y=0;z*z*z+y*y<=e;y++)
        {
            x = e-z*z*z-y*y;
            if(x<0)
                continue;

                int t = x+y+z;
                if(m ==0||m>t)
                    m=t;
            }

        cout <<m<<endl;




        cin >>e;
    }
    return 0;
}



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

int main(){
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int> vec(N,0);
  
  for(int i=0;i<Q;i++){
    int q;
    cin>>q;
    vec.at(q-1)++;
  }
  for(int i=0;i<N;i++){
    if(vec.at(i)>Q-K){
      cout<<"Yes"<<endl;
    }
    if(vec.at(i)<=Q-K){
      cout<<"No"<<endl;
    }
  }

}

Measured memory_bytes: 1152
#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>;
using E = tuple<int,int,int>;

struct UnionFind{
    vector<int> parent;
    vector<int> rank;
    UnionFind(int n): rank(n,0), parent(n){
        rep(i,n) parent[i] = i;
    }

    int find(int x){
        if(parent[x] == x) return x;
        else return parent[x] = find(parent[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x==y) return;
        else if(rank[x]<rank[y]) parent[x]=y;
        else{
            parent[y] = x;
            if(rank[x]==rank[y]){
                rank[x]+=1;
            }
        }
    }
};

int main(){
    int n;
    cin >> n;
    vector<P> cord;
    vector<P> x;
    vector<P> y; 
    rep(i,n){
        int x_,y_;
        cin >> x_ >> y_;
        P p(x_,y_);
        cord.push_back(p);
        p.first = x_;
        p.second = i;
        x.push_back(p);
        p.first = y_;
        y.push_back(p);
    }

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());


    /*
    cout << "x" << endl;
    rep(i,x.size()){
        cout << x[i].first << " "<<x[i].second << endl;
    }
    cout << "y" << endl;
    rep(i,y.size()){
        cout << y[i].first << " "<<y[i].second << endl;
    }
    */

    vector<E> edge;

    rep(i,n-1){
        int e;
        e = x[i+1].first-x[i].first;
        E ed(e,x[i+1].second,x[i].second);
        edge.push_back(ed);
        
        e = y[i+1].first-y[i].first;
        E edy(e,y[i+1].second,y[i].second);
        edge.push_back(edy);
    }

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

    UnionFind uf(n);

    ll res=0;
    rep(i,edge.size()){
        int s,t,w;
        w = get<0>(edge[i]);
        s = get<1>(edge[i]); t = get<2>(edge[i]);
        //cout << "w,i,j" << w << ":" << s << ":" << t << endl;
        if(uf.find(s)==uf.find(t)) continue;
        //cout << "unite" << endl;
        uf.unite(s,t);
        
        /*
        cout <<"par" << endl;
        rep(i,n) cout << uf.parent[i] << " ";
        cout << endl;
        */
        res+=ll(w);
    }

    
    cout << res << endl;
}

Measured memory_bytes: 7900
#include<iostream>
using namespace std;
int main(){
int a, b, c;
cin >> a >> b >> c;
int tmp;
if(a > b ){
tmp = a;
a = b;
b= tmp;
}
if(b > c){
tmp =b;
b = c;
c = tmp;
}
// c is max
if(a > b){
tmp = a;
a = b;
b= tmp;
}

cout << a << " " << b << " " << c << endl;

return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

string s;

int main()
{
    cin >> s;
    string t = s;

    int res = 0, cnt = 0;
    for(int i = 0; i < s.size(); i++)
        if(s[i] - '0' != i % 2) cnt++;
    res = cnt;

    cnt = 0;
    for(int i = 0; i < s.size(); i++)
        if(s[i] - '0' != (i % 2) ^ 1) cnt++;
    res = min(res, cnt);

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


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

int main()
{
	int k, a, b, i;
	cin>>k>>a>>b;
	for(i=a; i<=b; i++)
	{
		if(i%k == 0)
		{
			cout<<"OK"<<endl;
			break;
		}
	}
	if(i == b+1) cout<<"NG"<<endl;
	
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define emb emplace_back
#define em emplace
#define ii pair<int,int>
#define iii pair<int ,ii>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define allc(x) x.begin(),x.end(),cmp
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
const int INF = 0x3f3f3f3f;

const int MXN = 1e5 + 5;

long long dp[MXN];
long long w[105][2];

int main(){
    int n , m;
    scanf("%d %d",&n,&m);
    for(int i = 1 ; i <= n ; i++){
        scanf("%lld %lld",&w[i][0] , &w[i][1]);
    }
    fill(dp , dp + MXN , (long long)1e18);
    dp[0] = 0;
    for(int i = 1 ; i <= n ; i++){
        for(int j = MXN - 1 ; j >= w[i][1] ; j--){
            dp[j] = min(dp[j] , dp[j - w[i][1]] + w[i][0]);
        }
    }
    int l = 0;
    for(int i = 1 ; i < MXN ; i++){
        // printf("%lld\n",dp[i]);
        if(dp[i] <= m && dp[i] != (long long)1e18){
            l = max(l , i);
        }
    }
    printf("%d",l);
}

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

long long a[200005];
long long plusv[200005],subv[200005];

int main() {
  int n;
  cin>>n;
  for(int i=1;i<=n;i++) {
    cin>>a[i];
    plusv[i]=i+a[i];
    subv[i]=i-a[i];
  }
  
  //sort(plusv+1,plusv+n+1);
  sort(subv+1,subv+n+1);
  /*for(int i=1;i<=n;i++) {
  	cout<<plusv[i]<<' ';
  }
  cout<<endl;
  for(int i=1;i<=n;i++) {
  	cout<<subv[i]<<' ';
  }
  cout<<endl;*/
  //i+a[i]=j-a[j]
  long long ans=0;
  for(int i=1;i<=n;i++) {
    ans+=upper_bound(subv+i+1,subv+n+1,plusv[i])-lower_bound(subv+1,subv+n+1,plusv[i]);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 8236
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };


#define fs first
#define sc second






int main() {
	int a, b, c, e, d;
	int n, m, o, p, q, r;
	string s, t, u;

	ll ret = 1;
	ll x = 1;
	cin >> n;
	rep(i, n) {
		cin >> a;
		x *= 3;
		if (a % 2 == 0)ret *= 2;
	}

	cout << x - ret << endl;



	

	return 0;
}




Measured memory_bytes: 256
count :: [Char] -> Int
count s = let y = length $ fst x in if snd x then y else y-1
    where x = foldl step ([], True) s

step :: ([String], Bool) -> Char -> ([String], Bool)
step ([], _) c = ([[c]], True)
step ((x:ys), False) c = (((c:x):ys), True)
step ((x:ys), True) c | x == [c] = (([c]:x:ys), False)
                      | otherwise = (([c]:x:ys), True)

main = do
  s <- getLine :: IO String
  putStrLn . show $ count s


Measured memory_bytes: 16636
def abc098_b():
    import numpy as np
    n = int(input())
    s = input()
    counts = []
    if len(s) == 2:
        return [0,1][s[0] == s[1]]
    for i in range(1, n - 1):
        x = s[:i]
        y = s[i:]
        count = 0
        for let in set(x):
            if let in set(y):
                count += 1
        counts.append(count)
    return np.max(counts)


print(abc098_b())

Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000

ll a[3005][3005];
ll dp[3005][3005][4];
ll r,c;

ll fun(ll i,ll j,ll cnt){
  if(r==i and j==c){
    if(cnt<3)return a[i][j];
    else return 0;
  }
 
  ll &res = dp[i][j][cnt];
  if(res!=-1)return res;

  ll ans=0;

  if(cnt<3){
    if(j<c)ans=max({ans,fun(i,j+1,cnt),a[i][j]+fun(i,j+1,cnt+1)});

    if(i<r)ans=max(ans,a[i][j]+fun(i+1,j,0));
    
  }
  else { if(j<c)ans = max(ans,fun(i,j+1,cnt));
         if(i<r)ans = max(ans,fun(i+1,j,0));}

  return res=ans;
}

int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif


    
    ll t;
    t=1;
    // cin>>t;
    while(t--){
      ll k;
      cin>>r>>c>>k;

      while(k--){
        ll x,y,val;
        cin>>x>>y>>val;
        a[x][y]=val;
      }

      fori(1,r+1)
      for(int j=1;j<=c;j++)
        for(int r=0;r<=3;r++)dp[i][j][r]=-1;

      cout<<fun(1,1,0);
     


    


     
      
    }





return 0;
}     



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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;cin>>s;
  sort(All(s));
  flag2func(s=="abc");
}


Measured memory_bytes: 256
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[A,B] = inpl()
print((A+B)//2 if (A+B)%2 ==0 else 'IMPOSSIBLE')

Measured memory_bytes: 12464
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



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

    int res = a - 2*b;

    if(res < 0){
        cout << 0 << endl;
    }else{
        cout << res << endl;
    }
}


Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
x_list = list(map(int,input().split()))
x_max = max(x_list)
y_list = list(map(int,input().split()))
y_min = min(y_list)
ans = "War"
for i in range(x+1,y+1):
    if x_max < i <= y_min:
        ans = "No War"
        break
print(ans)

Measured memory_bytes: 61944
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i,s,l) for(int i=s;i<l;i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long,long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main(){
    fast();
    ll a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define pi acos(-1);
ll strtoint(string str);
int main(){
	fast;
	ll a,b; cin>>a>>b;
	(a-2*b>=0)?cout<<a-2*b:cout<<0;
	cout<<'\n'; 
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

struct mint {
    // Preparation: MOD is already defined.
    ll value;

    mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(mint m) const {
        return pow(m.value);
    }

    mint inv() const {
        ll a = value, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }

    mint &operator+=(const mint a) {
        if ((value += a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((value += MOD - a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (value *= a.value) %= MOD;
        return *this;
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    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 operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    int ans = 0;
    rep(i, n) {
        if (a[i] == i) {
            if (i == 0) {
                swap(a[i], a[i + 1]);
                ans++;
            } else if (i == n - 1) {
                swap(a[i], a[i - 1]);
                ans++;
            } else {
                swap(a[i + 1], a[i]);
                ans++;
            }
        }
    }
    out(ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int rd(){
    int x=0,fl=1;char ch=gc();
    for (;ch<48||ch>57;ch=gc())if(ch=='-')fl=-1;
    for (;48<=ch&&ch<=57;ch=gc())x=(x<<3)+(x<<1)+(ch^48);
    return x*fl;
}
inline void wri(int a){if(a<0)a=-a,putchar('-');if(a>=10)wri(a/10);putchar(a%10|48);}
inline void wln(int a){wri(a);puts("");}
struct node{
	int x,y;
}u;
int dis[1002][1002],n,m,i,j,dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},xx,yy,ans;
char s[1002][1002];
queue<node>q;
int main(){
	scanf("%d%d",&n,&m);
	memset(dis,63,sizeof(dis));
	for (i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for (j=1;j<=m;j++)
			if (s[i][j]=='#') q.push((node){i,j}),dis[i][j]=0;
	}
	while (!q.empty()){
		u=q.front(),q.pop();
		for (i=0;i<4;i++){
			xx=u.x+dx[i],yy=u.y+dy[i];
			if (1<=xx && xx<=n && 1<=yy && yy<=m && dis[u.x][u.y]+1<dis[xx][yy]){
				dis[xx][yy]=dis[u.x][u.y]+1;
				q.push((node){xx,yy});
			}
		}
	}
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) ans=max(ans,dis[i][j]);
	printf("%d",ans);
}

Measured memory_bytes: 13328
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

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

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(int TEST_CASE){
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC";
    else cout << "ABC";
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a + b > c + d){
    cout << "Left" << endl;
  }
  else if(a + b == c + d){
    cout << "Balanced" << endl;
  }
  else if(a + b < c + d){
    cout << "Right" << endl;
  }
}


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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=n-1;i>=m;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-9

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

typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	bool g[8][8];
	REP(i, n)REP(j, n)g[i][j] = false;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a][b] = true;
		g[b][a] = true;
	}
	vector<int> v(n);
	REP(i, n) {
		v[i] = i;
	}
	int cnt = 0;
	int f = 1;
	REP(i, n - 1) {
		if (!g[v[i]][v[i + 1]])f = 0;
	}
	if (f)cnt++;
	while(next_permutation(ALL(v))) {
		if (v[0] != 0)break;
		int flag = 1;
		REP(i, n-1) {
			if (!g[v[i]][v[i + 1]])flag = 0;
		}
		if (flag)cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

#define fr first
#define sc second
#define mk make_pair

using namespace std;

int n;
double t, v, l;
deque<pair<double, double> > dq;

int main()
{
    cin >> n >> l;
    for(int i = 1; i <= n; i++)
    {
        double a, b;
        cin >> a >> b;
        if(b == l)
        {
            t = v = 0;
            dq.clear();
        }
        while(v + b > l && dq.size() != 0)
        {
            double t1 = dq.front().fr;
            double v1 = min(dq.front().sc, v + b - l);

            t = (t * v - t1 * v1) / (v - v1);
            v = v - v1;

            if(v1 == dq.front().sc)
                dq.pop_front();
            else
            {
                dq.front().sc -= v1;
                break;
            }
        }

        t = (t * v + a * b) / (v + b);
        v = v + b;

        cout << fixed << setprecision(6) << t << endl;

        while( dq.size() != 0)
        {
            //cout << "&";
            double t1 = dq.back().fr;
            double v1 = dq.back().sc;

            if(t1 < a)
                break;

            a = (a * b + t1 * v1) / (v1 + b);
            b = v1 + b;
            dq.pop_back();
        }
        dq.push_back(mk(a, b));
    }
    return 0;
}


Measured memory_bytes: 16784
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int main()
{
  stack<int> S;
  int n;
  while(cin>>n){
    if(n==0){
      cout<<S.top()<<endl;
      S.pop();
    }else S.push(n);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#define maxn 3005 
using namespace std;
const long long mo=998244353;
long long a,b,c,d;
long long f[maxn][maxn][2][2];
long long g[maxn][maxn];
int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	f[a][b][0][0]=f[a][b][1][0]=f[a][b][0][1]=1;
	g[a][b]=1;
	for(long long i=a;i<=c;i++)
	{
		for(long long j=b;j<=d;j++)
		{
			if(i==a&&j==b) continue;
			f[i][j][0][0]=(g[i-1][j-1]*(i-1)*(j-1))%mo;
			f[i][j][0][1]=((f[i-1][j][0][1])*(j-1)+g[i-1][j])%mo; 
			f[i][j][1][0]=((f[i][j-1][1][0])*(i-1)+g[i][j-1])%mo;
			g[i][j]=(f[i][j][0][0]+f[i][j][1][0]+f[i][j][0][1])%mo;
			//printf("%lld %lld %lld\n",i,j,g[i][j]);
		}
	}
	printf("%lld",g[c][d]);
	return 0;
}

Measured memory_bytes: 355764
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    ll n;
    cin >> n;

    vector<ll> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];

    ll m;
    cin >> m;

    vector<ll> p(m), x(m);
    for(int i = 0; i < m; i++){
        cin >> p[i];
        cin >> x[i];
    }

    for(int i = 0; i < m; i++){
        cout << accumulate(all(t), 0ll) - t[p[i]-1] + x[i] << endl;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int w, n;
		w = sc.nextInt();
		n = sc.nextInt();
		int amida[] = new int[31];
		for (int i = 0; i <= 30; i++)
		{
			amida[i] = i;
		}
		String[] s;
		int a, b;
		int tmp;
		for (int i = 0; i < n; i++)
		{
			s = sc.next().split(",");
			a = Integer.valueOf(s[0]).intValue();
			b = Integer.valueOf(s[1]).intValue();
			tmp = amida[a];
			amida[a] = amida[b];
			amida[b] = tmp;
		}
		for (int i = 1; i <= w; i++)
		{
			System.out.println(amida[i]);
		}
		sc.close();
	}
}


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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static long C(long n, long k)
        {
            long bunbo = 1;
            long bunsi = 1;
            for (long i = n - k+1; i <= n; i++)
                bunsi *= i;
            for (long i = 1; i <= k; i++)
                bunbo *= i;
            return bunsi / bunbo;
        }
        bool f = false;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var n = Read();
            char[][] s = new char[n][];
            string[] str = new string[n];

            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine().ToCharArray();
                Array.Sort(s[i]);
                str[i] = new string(s[i]);
            }

            Array.Sort(str);

            long ans = 0;
            long count = 0;
            for (int i = 0; i < n - 1; i++)
            {
       
                if (str[i] == str[i + 1]) count++;
                else
                {
                    ans += C(count+1,2);
                    count = 0;
                }
            }

      
            if (count != 0) ans += C(count + 1, 2);
            Console.WriteLine(ans);
   
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 29524
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datA, datB) = readLine.split(" ").map(_.toInt)

    val distance = datB - datA - 1
    val winnerAlice = (distance % 2 == 1)

    println(if(winnerAlice) "Alice" else "Borys")
  }
}


Measured memory_bytes: 27348
N, M = map(int, input().split())
a = [0] * (N+1)
for _ in range(M):
    i = int(input())
    a[i] = 1

dp = [0] * (N+2)
dp[N] = 1
mod = 1000000007

for i in range(N-1, -1, -1):
    if a[i]:
        dp[i] = 0
        continue
    dp[i] = (dp[i+1] + dp[i+2]) % mod 

print(dp[0])

Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<vi> vii;
typedef map<int, int> mp;
typedef multiset<int> mset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int64> vi64;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define form(i,j,k,l) for(int i=j;i<int(k);i+=l)
#define rform(i,j,k,l) for(int i=int(j);i>int(l);i-=l)
#define rep(i, j) for(int i=0;i<int(j);i++)
#define rrep(i, j) for(int i=int(j);i>=0;i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define forc(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define INF (int)1e9
#define INF64 (int64)1e18
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define F first
#define S  second
const double pie = acos(-1.0);
template <typename T>
T Max(T x, T y)
{
  return (x > y) ? x : y;
}
template <typename T>
T Min(T x, T y)
{
  return (x > y) ? y : x;
}
int gcd(int n1, int n2)
{
  if (n2 != 0) return gcd(n2, n1 % n2);
  else return n1;
}
#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
clock_t time_p = clock();
void rtime() { time_p = clock() - time_p; cerr << "Time Taken : " << (float)1000 * (time_p) / CLOCKS_PER_SEC << "\n";}
int main()
{ fast;
  int64 n;
  cin >> n;
  int64 r = (int64)sqrt((double)n);
  for (int64 i = r; i >= 1; i--)
  { if (n % i == 0)
    { int k = n / i;
      int l = 0;
      while (k > 0)
      { k = k / 10;
        l++;
      }
      cout << l;
      return 0;
    }

  }
}

Measured memory_bytes: 3664
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  ll N, Y, a, b, c;
  bool ng = true;
  cin >> N >> Y;

  a = Y / 10000;
  while (a >= 0 && ng) {
    b = (Y - a*10000) / 5000;
    while (b >= 0 && ng) {
      c = (Y -a*10000 - b*5000) / 1000;
      if (a + b + c == N) {
        cout << a << " "<< b << " "<< c << endl;
        ng = false;
      }else{
        b--;
      }
    }
    a--;
  }

  if (ng) {
    cout << "-1 -1 -1" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
using namespace std;

int main(){

    int n;
    cin >> n;
    string s; 
    int p;
    vector<pair<string,int>> v;
    vector<pair<string,int>> v1;
    for (int i = 0; i < n; i++)
    {
        cin>> s >> p;
        v.push_back(make_pair(s,p));
    }
    v1 = v;
    pair<string,int> tmp;
    sort(v.begin(),v.end());
    bool flag = false;
    while(flag == false){
        flag = true;
        for (int i = 0; i < n; i++)
        {
            if(i == n-1){
                break;
            }
            if(v[i].first == v[i+1].first && v[i].second < v[i+1].second){
                swap(v[i],v[i+1]);
                flag = false;
            }
        } 
    }
    


    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if(v[i].first == v1[j].first && v[i].second == v1[j].second){
                cout << j+1 << endl;
            }
        }
        
        
    }
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z -> key = k;
    z -> left = NIL;
    z -> right = NIL;
    
    while( x != NIL ) {
        y = x;
        if ( z->key < x->key ) {
            x = x -> left;
        }
        else {
            x = x -> right;
        } 
    }
    z -> parent = y;
    if( y == NIL ) {
        root = z;
    }
    else {
        if ( z->key < y->key ) {
            y -> left = z;
        }
        else {
            y -> right = z;
        }
    }
}

void inorder(Node *u) {
    if ( u == NIL )  return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if ( u == NIL ) return;
    printf(" %d", u -> key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert" ) {
            scanf("%d", &x);
            insert(x);
        }
        else if( com == "print" ) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


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

using namespace std;

int main(){
  	int n, x;
  	vector<int> nums, sortNums;
  
  	cin >> n;	
  
  	for(int i=0; i<n; i++){
    	cin >> x;
      	nums.push_back(x);
    }
  	
  	sortNums = nums;
  	sort(sortNums.begin(), sortNums.begin()+n);
  
    if(nums == sortNums){
      cout << "YES\n";
      return 0;
    } 
  
  	for(int i=0; i<n-1; i++){
    	for(int j=i+1; j<n; j++){
    		swap(nums[i],nums[j]);
        	if(nums == sortNums){
              	cout << "YES\n";
              	return 0;
            } 
          	swap(nums[i],nums[j]);
        }
    }
  
  	cout << "NO\n";
  
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

typedef	long long	ll;

int main(){
	for(ll n;scanf("%lld",&n),n;){
		string ans;
		while(n){
			int dgt=n%10;
			if(dgt<0)	dgt+=10;
			ans+=(dgt+'0');
			n=(n-dgt)/-10;
		}
		reverse(ans.begin(),ans.end());
		puts(ans.c_str());
	}
	return 0;
}

Measured memory_bytes: 0