akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = [sorted(input()) for _ in range(n)]

s.sort()

bef = s[0]
cnt = 1
ans=0
for i in range(1,len(s)):
  if bef == s[i]:
    cnt += 1
  else :
    if cnt > 1:
      ans += (cnt * (cnt -1) )/2
    cnt = 1
  bef = s[i]

if cnt > 1:
  ans += (cnt * (cnt -1) )/2
print(int(ans))


Measured memory_bytes: 26308
#include <bits/stdc++.h>
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
#define PI 3.141592653589793
using namespace std;


int main()
{
    FAST
    int x,y;cin>>x>>y;
    if(y>=2*x && y<=4*x && y%2==0) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
int main(void){
  int len, cnt = 0;
  char str[101] = "";
  
  scanf("%s", str);
  
  len = strlen(str);
  
  for(int i = 0; i < len/2; i++){
    if(str[i] != str[len-i-1])
      cnt++;
  }
  
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl
#define REP(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define Yes cout << "Yes" NL
#define No cout << "No" NL

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int INTMAX = numeric_limits<int>::max();
constexpr int INTMIN = numeric_limits<int>::min();
constexpr ll LLMAX = numeric_limits<long long>::max();
constexpr ll LLMIN = numeric_limits<long long>::min();
constexpr int MOD = 1000000007;

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int max = 0;
	REP(i, n) {
		cin >> a[i];
		max = std::max(max, a[i]);
	}

	int mind = INTMAX;
	int b;
	int t = (max + 1) / 2;
	int u = max / 2;
	REP(i, n) {
		if (a[i] == max) continue;
		if (mind > abs(t - a[i])) {
			mind = abs(t - a[i]);
			b = a[i];
		}
		if (mind > abs(u - a[i])) {
			mind = abs(u - a[i]);
			b = a[i];
		}
	}

	cout << max << ' ' << b NL;

	

	return 0;

}



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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x;
	cin >> n >> x;
	int a[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	ll ans = 0;
	if (a[1] > x)
	{
		ans += a[1] - x;
		a[1] = x;
	}
	for (int i = 2; i <= n; i++)
	{
		if (a[i] + a[i - 1] <= x)
		{
			continue;
		}
		int dec = a[i] + a[i - 1] - x;
		a[i] -= dec;
		ans += dec;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
#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,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}


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

template <std::size_t N>
struct Era {
	bool prime_array[ N + 1 ];

	constexpr Era() : prime_array() {
		prime_array[ 0 ] = false;
		prime_array[ 1 ] = false;
		rep( i, 2, N + 1 ){
			prime_array[ i ] = true;
		}
		int lim = N;
		rep( i, 2, lim ){
			if (!prime_array[ i ])
				continue;
			lim = N / i;
			for(int j = i * 2; j < N + 1; j += i){
				prime_array[ j ] = false;
			}
		}
	}
};

const int MaxN = 1e5 + 5;
int main( void ){
	constexpr auto era = Era <MaxN>();
	int p[ MaxN ] = {};
	rep( i, 0, MaxN ){
		if (era.prime_array[ i ]){
			if (era.prime_array[ ( i + 1 ) / 2 ])
				p[ i ] = 1;
		}
	}
	p[ 2 ] = 0;
	rep( i, 1, MaxN ){
		p[ i ] += p[ i - 1 ];
	}
	int Q; cin >> Q;
	rep(i,0,Q){
		int l, r;
		cin >> l >> r;
		cout << p[r]-p[l-1] << endl;
	}
}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

int main()
{
	lint N,W;
	lint w[110]={},v[110]={};
	lint dp[110][100010]={};
	
	cin >> N >> W;
	for(int i=1;i<=N;i++)
		cin >> w[i] >> v[i];
	
	for(int i=0;i<110;i++)
		for(int j=0;j<100010;j++)
			dp[i][j]=1e9+7;
	dp[0][0]=0;
	
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<=100000;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-v[i]>=0)
				dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
		}
	}
	
	for(int i=100000;i>=0;i--)
	{
		if(dp[N][i]<=W)
		{
			cout << i << endl; 
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 86144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    ll cnt1 = 0, cnt2 = 0;

    rep(i,N){
        string s1, s2;
        cin >> s1 >> s2;
        if (s1 < s2)
            cnt2 += 3;
        else if(s1>s2)
            cnt1 += 3;
        else
            cnt1++, cnt2++;
    }

    cout << cnt1 << " " << cnt2 << endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll A, B , Q;
  cin >> A >> B >> Q;
  vector<ll> s(A);
  vector<ll> t(B);
  for (ll i = 0; i < A; ++i)
  {
    cin >> s.at(i);
  }
  for (ll i = 0; i < B; ++i)
  {
    cin >> t.at(i);
  }
  for (ll i = 0; i < Q; ++i)
  {
    ll x;
    cin >> x;
    ll t_index = lower_bound(t.begin(), t.end(), x) - t.begin();
    ll s_index =  lower_bound(s.begin(), s.end(), x) - s.begin();
    // cout << t_index << ' ' << s_index << endl;
    ll ans = INF;
    ll front_t, back_t, front_s, back_s;
    // if (t_index != 0 && t_index != B && s_index != 0 && s_index != Q)
    // {
    //   front_t = x - t.at(t_index - 1);
    //   back_t = t.at(t_index) - x;
    //   front_s = x - s.at(s_index - 1);
    //   back_s = s.at(s_index) - x;
    //   ans = min(ans, front_t * 2 + back_s);
    //   ans = min(ans, front_s * 2 + back_t);
    //   ans = min(ans, max(front_t, front_s));
    //   ans = min(ans, max(back_t, back_s));
    //   cout << ans << endl;
    // }
    if (t_index != 0 && s_index != A)
    {
      front_t = x - t.at(t_index - 1);
      back_s = s.at(s_index) - x;
      ans = min(ans, front_t * 2 + back_s);
      ans = min(ans, front_t + back_s * 2);
    }
    // cout << ans << endl;
    if (s_index != 0 && t_index != B)
    {
      back_t = t.at(t_index) - x;
      front_s = x - s.at(s_index - 1);
      ans = min(ans, front_s * 2 + back_t);
      ans = min(ans, front_s  + back_t * 2);
    }
    // cout << ans << endl;
    if (s_index != 0 && t_index != 0)
    {
      front_t = x - t.at(t_index - 1);
      front_s = x - s.at(s_index - 1);
      ans = min(ans, max(front_t, front_s));
    }
    // cout << ans << endl;
    if (s_index != A && t_index != B)
    {
      back_t = t.at(t_index) - x;
      back_s = s.at(s_index) - x;
      ans = min(ans, max(back_t, back_s));
    }
    cout << ans << endl;
  }
}

// 2 3 1
// 100
// 600
// 400
// 900
// 1000
// 899


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

#define LL long long

int main(){
    int n;
    cin>>n;
    int a[n];
    int c=0;
    set<int,greater<>>s;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(i!=0){
            if(a[i-1]>=a[i]){
                c++;
            }
            else{
                s.insert(c);
                c=0;
            }
        }
    }
    s.insert(c);
    for(int x : s){
        cout<<x<<endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,c;
cin >> a >> b >> c;
if(a==b) {
  cout << c << endl;
} else if(b==c) {
  cout << a << endl;
} else {
  cout << b << endl;
}
return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Queue;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int K=sc.nextInt();
		int C=sc.nextInt();
		char[] cs=sc.next().toCharArray();
		int[] dp1=new int[N];
		int[] dp2=new int[N];
		int p=1;
		for(int i=0;i<N;++i) {
			if(cs[i]=='x')continue;
			dp1[i]=p++;
			i=i+C;
		}
		p=K;
		for(int i=N-1;i>=0;--i) {
			if(cs[i]=='x')continue;
			dp2[i]=p--;
			i=i-C;
		}
		for(int i=0;i<N;++i) {
			if(dp1[i]>0&&K>=dp1[i]&&dp1[i]==dp2[i])System.out.println(i+1);
		}
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 53104
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;



int main()
{
    ll n,x,y,xx,yy,minn=1e15,k;
    cin>>x>>y>>xx>>yy;
    cin>>n;
    ll G[n+2];
    G[0]=0;
    ld D[n+2][n+2],X[n+2],Y[n+2],R[n+2],P[n+2]={0},S[n+2]={minn};
    for(int i=1;i<=n;i++)
    {
        cin>>X[i]>>Y[i]>>R[i];
        G[i]=1;
    }
    G[n+1]=1;
    X[0]=x,X[n+1]=xx;
    Y[0]=y,Y[n+1]=yy;
    R[0]=0,R[n+1]=0;
    for(int i=0;i<=n+1;i++)
    {
        for(int j=0;j<=n+1;j++)
        {
            D[i][j]=sqrt((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]))-(R[i]+R[j]);
            if(D[i][j]<0)
            {
                D[i][j]=0;
            }
            S[j]=D[0][j];
        }
    }
    G[0]=0;
    for(int i=0;i<=n+1;i++)
    {
        minn=1e18,k=0;
        for(int j=0;j<=n+1;j++)
        {
            if(S[j]<minn&&G[j]==1)
            {
                minn=S[j];
                k=j;
            }
        }
        G[k]=0;
        for(int j=0;j<=n+1;j++)
        {
            if(S[k]+D[k][j]<S[j]&&G[j])
            {
                S[j]=S[k]+D[k][j];
            }
        }
    }
    cout<<fixed<<setprecision(10)<<S[n+1]<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define bit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int calc(const vi& members) {
  int ret = INF;
  for (int i=0; i<int(members.size()); i++) {
    for (int j=i+1; j<int(members.size()); j++) {
      chmin(ret, ABS(members[i], members[j]));
    }
  }
  return ret;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vi D(N);
  for (int i=0; i<N; i++) {
    cin >> D[i];
  }

  D.emplace_back(0);
  Sort(D);
  for (int i=2; i<int(D.size()); i+=2) {
    D[i] = 24 - D[i];
  }

  cout << calc(D) << endl;

  return 0;
}


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

int N, Q;
vector<int> v, t;

int combine(int i, int j) {
    return i + j;
}

void build(int id = 1, int l = 0, int r = N) {
    if (r - l < 2) {
        t[id] = v[l];
        return;
    }

    int mid = (l + r) / 2;
    build(id<<1  , l, mid);
    build(id<<1|1, mid, r);
    t[id] = combine(t[id<<1], t[id<<1|1]);
}

void modify(int p, int val, int id = 1, int l = 0, int r = N) {     // set v[p] = val
    if (r - l < 2) {
        t[id] += val;
        return;
    }

    int mid = (l + r) / 2;
    if (p < mid)
        modify(p, val, id<<1  , l, mid);
    else
        modify(p, val, id<<1|1, mid, r);
    
    t[id] = combine(t[id<<1], t[id<<1|1]);
}

int query(int x, int y, int id = 1, int l = 0, int r = N) {         // query in range [l,r)
    if (x >= r || l >= y) return 0;
    if (x <= l && r <= y) return t[id];

    int mid = (l + r) / 2;
    return combine(query(x,y,id<<1,l,mid), query(x,y,id<<1|1,mid,r));
}

int main() {

    scanf("%d%d",&N,&Q); t.assign(N<<2,0);
    for (int i = 0, op, x, y; i < Q; i++) {
        scanf("%d%d%d",&op,&x,&y);

        if (op) 
            printf("%d\n", query(x-1,y));
        else 
            modify(x-1,y);
            
    }

    return 0;
}

Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
const int MAX = (1e5)+1;

int n, ans;
vector<pair<int,int> > a;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	a.resize(n);
	for(int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i & 1;
	sort(a.begin(), a.end());
	for(int i = 0; i < n; i++) ans += a[i].second ^ (i & 1);
	cout << ans / 2;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int>gcd_l(n,0);
    for(int i = 0; i < n-1; i++){
        gcd_l[i+1] = __gcd(gcd_l[i],a[i]);
    }
    vector<int>gcd_r(n);
    for(int i = n-2; i >= 0; i--){
        gcd_r[i] = __gcd(gcd_r[i+1],a[i+1]);
    }

    int ans = 0;
    rep(i,n){
        ans = max(ans,__gcd(gcd_l[i],gcd_r[i]));
    }
    cout << ans << endl;
    /*rep(i,n){
        cout << gcd_l[i] << " " << gcd_r[i] << endl;
    }*/
}


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

const int D = 2019;
int main() {
    int L, R; cin >> L >> R;

    int vl = L / D, vr = R / D;
    if(vl < vr) cout << 0 << endl;
    else {
        using int64 = long long int;
        int64 ans = D;
        for(int64 i=L; i<R; i++) {
            for(int64 j=i+1; j<=R; j++) {
                ans = min<int64>(ans, i * j % D);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
long long mod;

ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

ll t[400008];
void build(vector<ll>& a, int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

ll maxi(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
}



void update(int v, int tl, int tr, int pos, ll new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

int main() { 
ll n;
cin>>n;
ll a[n];
ll t=0;

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

for(int i=0;i<n;i++)

  cout<<(t^a[i])<<" ";


return 0;
}


Measured memory_bytes: 5168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back

const int maxn = 1e5+1;
int n;
ll C, x[2][maxn], v[2][maxn];
ll sum[3][2][maxn];
int main()
{
  scanf("%d %lld", &n, &C);
  for (int i = 1; i <= n; ++i)
    {
      scanf("%lld %lld", &x[0][i], &v[0][i]);
      x[1][n+1-i] = C-x[0][i];
      v[1][n+1-i] = v[0][i];
    }

  for (int dir = 0; dir < 2; ++dir)
    for (int i = 1; i <= n; ++i)
      v[dir][i] += v[dir][i-1];

  for (int times = 0; times < 2; ++times)
    for (int dir = 0; dir < 2; ++dir)
      for (int i = 1; i <= n; ++i)
	{
	  sum[times][dir][i] = max(sum[times][dir][i-1], v[dir][i]-(times+1)*x[dir][i]);
	}
  ll ans = 0;
  for (int i = 0; i <= n; ++i)
    ans = max(ans, max(sum[0][0][i]+sum[1][1][n-i], sum[0][1][i]+sum[1][0][n-i]));
  printf("%lld\n", ans);
}


Measured memory_bytes: 8064
(let ((n (read))
      (m (read))
      (a (make-array 0 :element-type 'integer
                       :adjustable t
                       :fill-pointer 0))
      (ans 0)
      (pre 1)
      (prepre 0)
      (flg 0))
     (dotimes (i m)
       (vector-push-extend (read) a))
     (loop for i from 1 upto n
           do (cond ((= flg m) (setf ans (rem (+ pre prepre) 1000000007))
                               (setf prepre pre)
                               (setf pre ans))
                    ((= (aref a flg) i) (setf ans 0)
                                        (setf prepre pre)
                                        (setf pre 0)
                                        (incf flg))
                    (t (setf ans (rem (+ pre prepre) 1000000007))
                       (setf prepre pre)
                       (setf pre ans))))
     (princ ans))

Measured memory_bytes: 57700
input()
a = input().split(' ')
b = []
for i in a:
    b.append(int(i))
b.sort()
b.reverse()
out = 0
for i in range(len(b) - 2):
    l = i + 1
    r = len(b) - 1
    while l < r:
        if b[i] < b[l] + b[r]:
            out += r - l
            l += 1
        else:
            r -= 1

print(out)


Measured memory_bytes: 3188
#include <stdio.h>
#define N 100000

int main(void){
    int n;
    int h[N];
    int memo[N];
    int i,p1,p2;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    
    memo[0] = 0;
    memo[1] = ((h[1] - h[0]) > 0) ? (h[1] - h[0]): -(h[1] - h[0]);
    for(i = 2; i < n; i++){
        p1 = memo[i-2] + ((h[i] - h[i-2] > 0) ? (h[i] - h[i-2]): -(h[i] - h[i-2]));
        p2 = memo[i-1] + (((h[i] - h[i-1]) > 0) ? (h[i] - h[i-1]): -(h[i] - h[i-1]));
        if(p1 > p2){
            memo[i] = p2;
        }else{
            memo[i] = p1;
        }
    }
    
    printf("%d\n", memo[n-1]);
    
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int n,W,w[105],v[105],f[105][100005],maxx;
main()
{
    cin>>n>>W;
    for(int i=1;i<=n;i++)
        {cin>>w[i]>>v[i];
        maxx+=v[i];}
        for(int i=0;i<=n;i++)
            for (int j=0;j<=maxx;j++)
            f[i][j]=1000000000;
            f[0][0]=0;
             for(int i=1;i<=n;i++)
            for (int j=maxx;j>=0;j--)
            {
                if(j>=v[i])
                    f[i][j]=min(f[i-1][j],f[i-1][j-v[i]]+w[i]);
                else f[i][j]=f[i-1][j];
            }
            for(int i=maxx;i>=0;i--)
            {
                if(f[n][i]<=W)
                {
                    cout<<i;
                    return 0;
                }
            }


}


Measured memory_bytes: 41216
n = int(input())
dp = [10*9]*100001
dp[0] = 0
for i in range(1, n+1):
  c6 = 0
  c9 = 0
  while 6 ** c6 <= i:
    c6 += 1
  while 9 ** c9 <= i:
    c9 += 1
  dp[i] = min(dp[i-1]+1, dp[i-6**(c6-1)]+1, dp[i-9**(c9-1)]+1)

print(dp[n])

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

int main(){
  string S;
  cin >> S;
  int ln = S.size();
  int Fans = -1;
  int Eans = -1;

  bool flag = true;
  for(int i = 0; i < ln; i++){
    if(!flag) break;
    for(int j = 0; j < 26; j++){
      int cnt = 0;
      for(int k = i; k < i+2; k++){
        if(S[k]=='a'+j) ++cnt;
      }
      if(cnt==2){
        Fans = i+1;
        Eans = i+2;
        flag = false;
        break;
      }
    }
  }

  if(flag){
    for(int i = 0; i < ln; i++){
      if(!flag) break;
      for(int j = 0; j < 26; j++){
        int cnt = 0;
        for(int k = i; k < i+3; k++){
          if(S[k]=='a'+j) ++cnt;
        }
        if(cnt==2){
          Fans = i+1;
          Eans = i+3;
          flag = false;
          break;
        }
      }
    }
  }

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


Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
  int a,b,c,d,sum;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);

  sum=a+b+c+d;

  printf("%d\n",sum/60);
  printf("%d\n",sum%60);

  return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c; cin>>a>>b>>c;
  swap(a,b);
  swap(a,c);
  cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

void solve() {
    int n;cin>>n;
    ve<int> mp(9, 0);
    for(int i=0;i<n;i++) {
        int x;cin>>x;
        mp[min(x,3200)/400]++;
    }
    int mn=0, mx=0;
    for(int i=0;i<8;i++) {
        if(mp[i]) mn++;
    }
    mx = mn + mp[8];
    if(mp[8])  
        mn = max(mn, 1);
    cout<<mn<<" "<<mx<<endl;
}

int main() {
    solve();
    return 0;
}

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

#define N 2100
#define ll long long
#define RG register
#define MOD 998244353

using namespace std;

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

int n,K,dn,dK,mx,sum[N<<1],inv[N<<1];
inline int Pow(int x,int y){ int ans=1;
	while(y) { if(y&1) ans=1LL*ans*x%MOD; x=1LL*x*x%MOD,y>>=1; }
	return ans;
}
inline int Plu(const int &x,const int &y) { return x+y>=MOD?x+y-MOD:x+y; }
inline int C(const int &x,const int &y){
	if(y>x||x<0) return 0; return 1LL*sum[x]*inv[y]%MOD*inv[x-y]%MOD;
}

int main(){
	K=read(),n=read(),dK=K<<1,dn=n<<1,sum[0]=1,inv[0]=1,mx=max(dK,dn);
	for(RG int i=1;i<=mx;++i) sum[i]=1LL*sum[i-1]*i%MOD; inv[mx]=Pow(sum[mx],MOD-2);
	for(RG int i=mx-1;i;--i) inv[i]=1LL*inv[i+1]*(i+1)%MOD;
	
	for(RG int i=2;i<=dK;++i){
		RG int m=0,ed=i/2,ans=0;
		for(RG int j=1;j<=ed;++j)
			if(i-j>0&&i-j<=K) ++m;
		for(RG int j=0,op=1;j<=m;++j,op=-op)
			ans=(1LL*C(m,j)*C(n-2*j+K-1,K-1)%MOD*op+MOD+ans)%MOD;
		printf("%d\n",ans);
	}
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	string s;
	cin >> s;
	int count = 0;
	SREP(i,s){
		if(s[i]=='a') count+=100;
		if(s[i]=='b') count+=10;
		if(s[i]=='c') count+=1;
	}
	if(count == 111) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1000000000;
const int MOD = 1000000007;

int main() {FIN
    
    int n, i, j, sw = 0;
    cin >> n;
    vi ar(n);
    for (i = 0; i < n; i++)
		cin >> ar[i];
		
	for (i = 0; i < n - 1; i++) {
		for (j = 0; j < n - i - 1; j++) {
			if (ar[j] > ar[j + 1]) {
				swap(ar[j], ar[j+1]);
				sw++;
			}
		}
	}
	
	for (i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << ar[i];
	}
	cout << "\n" << sw << "\n";
    
    return 0;
}



Measured memory_bytes: 3160
#include<stdio.h>

int main(){
  int i,north,east,west,south,cen,n,sum,b;
  char str[6];
  do{
    sum=1;
    scanf("%d",&n);
    if(n==0) break;
    north=5;
    cen=1;
    south=2;
    west=4;
    east=3;
    for(i=0;i<n;i++){
      scanf("%s",str);
      if(str[0]=='N'){
	north=cen;
	cen=south;
	south=7-north;
      }else if(str[0]=='E'){
	east=cen;
	cen=west;
	west=7-east;
      }else if(str[0]=='W'){
	west=cen;
	cen=east;
	east=7-west;
      }else if(str[0]=='S'){
	south=cen;
	cen=north;
	north=7-south;
      }else if(str[0]=='R'){
	b=south;
	south=east;
	east=north;
	north=west;
	west=b;
      }else{
	b=east;
	east=south;
	south=west;
	west=north;
	north=b;
      }
      sum+=cen;
    }
    printf("%d\n",sum);
  }while(1);
  return 0;
}
  

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);

    int ans = 0, cur = 1;

    while (cur < b)
    {
        cur--;
        cur += a;
        ans++;
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s, t;
	scans(s);
	scans(t);
	s += s;
	printyn(s.find(t) != string::npos);

	Please AC;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    for (int i = 1; i <= 9; i++) {
        if (n % i == 0) {
            int j = n / i;
            if (j >= 1 && j <= 9) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

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

int n;
string s;

int main(){
    int result = 0;
    cin >> s;
    n = s.length();
    int dp[n+1][2] = {};
    dp[0][0] = 0;
    dp[0][1] = 1;
    for(int i=0; i<n; i++){
        dp[i+1][0] = min(dp[i][0] + (int)(s[i] - '0'), dp[i][1] + 10 - (int)(s[i] - '0'));
        dp[i+1][1] = min(dp[i][1] + 9-(int)(s[i] - '0'), dp[i][0] + (int)(s[i] - '0') + 1);
    }
    cout << min(dp[n][0], dp[n][1]+1);
    return 0;
}

Measured memory_bytes: 9220
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

signed main()
{
	int A, B;
	cin >> A >> B;

	if (A >= 13) cout << B << endl;
	else if (A >= 6) cout << (B / 2) << endl;
	else cout << 0 << endl;
}

//max_element

//int N;
//int A[300010];
//
//signed main()
//{
//	cin >> N;
//	REP(i, N) cin >> A[i];
//
//	int ans = 0;
//	int cur = 0;
//	for (int i = 0; i < N; i++)
//	{
//
//	}
//
//}
//


Measured memory_bytes: 3620
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ABCD = sc.next();

        int[] nums = new int[4];
        for (int i = 0; i < ABCD.length(); i++) {
            nums[i] = Character.getNumericValue(ABCD.charAt(i));
        }

        int bits = 0;
        for (int i = 0; i < 1 << 3; i++) {
            int tmp = nums[0];
            for (int j = 0; j < 3; j++) {
                if ((i >> j & 1) == 1) {  // '+'
                    tmp += nums[j + 1];
                } else {
                    tmp -= nums[j + 1];
                }
            }

            if (tmp == 7) {
                bits = i;
            }
        }

        StringBuilder str = new StringBuilder();
        str.append(ABCD.charAt(0));
        for (int j = 0; j < 3; j++) {
            if ((bits >> j & 1) == 1) {  // '+'
                str.append("+");
            } else {
                str.append("-");
            }
            str.append(ABCD.charAt(j + 1));
        }
        str.append("=7");

        out.println(str.toString());
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
uli gcd(uli a,uli b){ 
  if(b==0)return a;
  return gcd(b,a%b);
}
uli lcm(uli a,uli b){
  uli g=gcd(a,b);
  b/=g;
  return a*b;
}
int main(){
  int n;
  scanf("%d",&n);
  uli mcm;
  scanf("%lld",&mcm);
  for(int i=1;i<n;i++){
    uli v;
    scanf("%lld",&v);
    mcm=lcm(mcm,v);
  }
  printf("%lld\n",mcm);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <string>

using namespace std;

#define U unsigned
#define S short
#define L long
#define LL long long 
#define LLU long long unsigned

//Reading and Printing Arrays

//short int
#define rhd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%hd", &arr[aab]);}
#define phd(arr, n) for(int aab = 0; aab < n; aab++){printf("%hd ", arr[aab]);}
//int
#define rd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%d", &arr[aab]);}
#define pd(arr, n) for(int aab = 0; aab < n; aab++){printf("%d ", arr[aab]);}
//unsigned int
#define ru(arr, n) for(int aab = 0; aab < n; aab++){scanf("%u", &arr[aab]);}
#define pu(arr, n) for(int aab = 0; aab < n; aab++){printf("%u ", arr[aab]);}
//long int
#define rld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%ld", &arr[aab]);}
#define pld(arr, n) for(int aab = 0; aab < n; aab++){printf("%ld ", arr[aab]);}
//unsigned long int
#define rlu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lu", &arr[aab]);}
#define plu(arr, n) for(int aab = 0; aab < n; aab++){printf("%lu ", arr[aab]);}
//long long int
#define rlld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lld", &arr[aab]);}
#define plld(arr, n) for(int aab = 0; aab < n; aab++){printf("%lld ", arr[aab]);}
//unsigned long long int
#define rllu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%llu", &arr[aab]);}
#define pllu(arr, n) for(int aab = 0; aab < n; aab++){printf("%llu ", arr[aab]);}
//float
#define rf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%f", &arr[aab]);}
#define pf(arr, n) for(int aab = 0; aab < n; aab++){printf("%f ", arr[aab]);}
//double
#define rlf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lf", &arr[aab]);}
#define plf(arr, n) for(int aab = 0; aab < n; aab++){printf("%lf ", arr[aab]);}
//char
#define rc(arr, n) for(int aab = 0; aab < n; aab++){scanf("%c", &arr[aab]);}
#define pc(arr, n) for(int aab = 0; aab < n; aab++){printf("%c", arr[aab]);}
//string
#define rs(arr) scanf("%s", arr);
#define ps(arr) puts(arr);

//swap
#define swap(a, b, tip) tip tempswap = a;a = b;b = tempswap;
//freopen
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

/*       ▄▀▄     ▄▀▄
        ▄█░░▀▀▀▀▀░░█▄
    ▄▄  █░░░░░░░░░░░█  ▄▄
   █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█       */

int min(int a, int b){	return a <= b ? a : b;}
int max(int a, int b){	return a >= b ? a : b;}
int findmin(int arr[], int n){int min = 0;for(int i = 1; i < n;min = arr[i] < arr[min] ? i : min, i++);return min;}
int findmax(int arr[], int n){int max = 0;for(int i = 1; i < n;max = arr[i] > arr[max] ? i : max, i++);return max;}
int arrsum(int arr[], int n){int sum = 0;for(int i = 0; i < n; sum += arr[i], i++);return sum;}
	
int main(){

	LL n, toplam = 0;

	scanf("%lld", &n);

	toplam += 1000 * (n / 500);
	n %= 500;
	toplam += 5 * (n / 5);

	printf("%lld", toplam);
}

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

int main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout<<((j<=a&&i<=b)||(j>a&&i>b));
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Megalomania | diff Megalomania.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Megalomania.cpp && ./a.out

/*
 
 6/22/2019
 
 5:18-5:41 WA
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N], B[MAX_N];
int N;

void nope() {
  println("No");
  exit(0);
}
void solve() {
  vector<tuple<LL,LL,int>> X;
  REP(i,N) X.emplace_back(B[i],-A[i], i);
  sort(ALL(X));
//  dumpc(X);
  LL t=0;
  REP(i,N) {
    int j=get<2>(X[i]);
    t=t+A[j];
//    dump(j,t,A[j],B[j]);
    if(t>B[j]) {
//      dump(i,j,t,B[j]);
      nope();
    }
  }
  println("Yes");
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i]>>B[i];
  solve();
  
  return 0;
}


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

int main(){
   int n, b;
   bool cards[4][14];
   char a;

   for(int i = 0; i < 4; i++){
       for(int j = 0; j < 15; j++){
           cards[i][j] = false;
       }
   }

   cin >> n;
    for(int i = 0; i < n; i++){
       cin >> a >> b;
       if (a == 'S') cards[0][b] = true;
       if (a == 'H') cards[1][b] = true;
       if (a == 'C') cards[2][b] = true;
       if (a == 'D') cards[3][b] = true;
    }

    for(int i = 0; i < 4; i++){
       for(int j = 1; j<= 13; j++){
            if(cards[i][j] == false){
                if( i == 0)   a = 'S';
                if( i == 1)   a = 'H';
                if( i == 2)   a = 'C';
                if( i == 3)   a = 'D';
            cout << a << " " << j << endl;
            }
            else continue;
       }

   }

   return 0;
}


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

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(;!isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 2e5;
const int P = 1e9+7;
const llong INV2 = 5e8+4;
int a[N+3];
int cnt[N+3];
llong d[N+3];
int r[N+3];
int num0[N+3];
int n; llong ans,tot;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}
llong mulinv(llong x) {return quickpow(x,P-2);}

struct BITree
{
	llong bit[N+3];
	void add(int u,llong x) {while(u<=n) {bit[u] = (bit[u]+x)%P; u+=(u&(-u));}}
	llong query(int u) {llong ret = 0ll; while(u) {ret = (ret+bit[u])%P; u-=(u&(-u));} return ret;}
	void clear() {for(int i=1; i<=n; i++) bit[i] = 0ll;}
} bit1,bit2;


int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%lld",&a[i]);
	for(int i=1; i<=n; i++) cnt[a[i]]++;
	for(int i=n-1; i>=1; i--) cnt[i] += cnt[i+1];
	for(int i=1; i<=n; i++) cnt[i] -= (n-i);
	tot = 1ll; for(int i=1; i<=n; i++) tot = tot*cnt[i]%P;
	if(tot==0) {puts("0"); return 0;}
	d[0] = 1ll;
	for(int i=1; i<=n; i++)
	{
		llong tmp = (bit1.query(n)-bit1.query(a[i])+P)*tot%P; ans = (ans+tmp)%P;
		bit1.add(a[i],1);
	}
	bit1.clear();
	for(int i=1; i<=n; i++)
	{
		llong tmp = (cnt[i]-1)*mulinv(cnt[i])%P;
		if(tmp) {d[i] = d[i-1]*tmp%P; num0[i] = num0[i-1];}
		else {d[i] = d[i-1]; num0[i] = num0[i-1]+1; r[num0[i-1]] = i-1;}
	}
	r[num0[n]] = n;
	for(int i=n; i>=1; i--)
	{
		llong tmp = (bit1.query(r[num0[a[i]]])-bit1.query(a[i]-1)+P)*mulinv(d[a[i]])%P*INV2%P*tot%P;
		ans = (ans+tmp)%P;
		bit1.add(a[i],d[a[i]]);
	}
	for(int i=n; i>=1; i--) {bit1.add(a[i],P-d[a[i]]);}
	for(int i=1; i<=n; i++)
	{
		llong tmp2 = (bit2.query(r[num0[a[i]]])-bit2.query(a[i])+P)*mulinv(d[a[i]])%P*INV2%P*tot%P;
		ans = (ans-tmp2+P)%P;
		bit2.add(a[i],d[a[i]]);
	}
	for(int i=1; i<=n; i++)
	{
		bit2.add(a[i],P-d[a[i]]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8064
x, y = map(int,input().split())
if y%2 == 1:
    print('No')
else:
    ans = 0
    for a in range(x+1):
        b = x-a
        if 2*a + 4*b == y:
            print('Yes')
            break
        else:
            ans += 1
            pass
    if ans == x+1:
        print('No')

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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;

int waes(int t,int a,int b){
    if(a > b) swap(a,b);
    int i,r = t/a, ans = 0;
    For(i,0,r+1){
        int x = i * a;
        if((t-x) % b == 0) ans++;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    int a,b,c,n,i,ans = 0;
    cin>>a>>b>>c>>n;
    int t = n/c;
    For(i,1,t+1){
        int k = n - (i*c);
        ans += waes(k,a,b);
    }
    ans += waes(n,a,b);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256