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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 3e5 + 5;

int  Set( int N , int pos )    { return N |= ( 1 << pos ); }
bool Check( LL N , int pos )  { return (bool)( N & ( 1LL << pos ) );}

LL a[ N ];
LL cnt[ 65 ];

int main( ) {
        IO;
        #ifdef LOCAL
            freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        for( int i = 0; i <= 60; i++ ) {
                cnt[i] = Check( a[n] , i ) ? 1 : 0;
        }
        LL ans = 0;
        for( int i = n - 1; i >= 1; i-- ) {
                for( int j = 0; j <= 60; j++ ) {
                        if( Check( a[i] , j ) ) {
                                ans = (ans%MOD + ( 1LL << j )%MOD * ( n - i - cnt[j] )%MOD )%MOD;
                        }
                        else {
                                ans = (ans%MOD + ( 1LL << j )%MOD * ( cnt[j] )%MOD )%MOD;
                        }
                }
                for( int j = 0; j <= 60; j++ ) {
                        cnt[j] += Check( a[i] , j ) ? 1 : 0;
                }
        }
        cout << ans << endl;
        return 0;
}










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

using namespace std;

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

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

#define Maxi                      10000000000000000
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                            long long
 
#define vll                          vector<ll>
#define vi                           vector<long long>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
//#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first  
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
#define endl                           '\n'
 
 
// Debug //
 
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
 
using namespace std;






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


	
	ll n,m;
	cin>>n>>m;

	ll sum=0;
	ll i,j;
	for(i=0;i<m;i++)
	{
		ll x;
		cin>>x;
		sum+=x;
	}

	cout<<max(n-sum,-1LL)<<endl;


	



	
	




}

Measured memory_bytes: 3648
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	LL a, b;
	scanf("%d%lld%lld", &n, &a, &b);
	vector<LL> hs(n);
	for(int i = 0; i < n; ++i){
		scanf("%lld", &hs[i]);
	}
	LL d = a - b;
	
	LL lt = 1, rt = 1010101010;
	while(lt < rt){
		LL md = (lt + rt) >> 1;
		LL sum = 0;
		for(int i = 0; i < n; ++i){
			LL r = hs[i] - md * b;
			if(r > 0){ sum += (r + d - 1) / d; }
		}
		if(sum <= md){
			rt = md;
		}
		else{
			lt = md + 1;
		}
	}
	printf("%lld\n", lt);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

int A[110000];
int cnt1=0;
int cnt2=0;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&A[i]);
    
    for(int i=0;i<n;i++){
        if(A[i]%4==0){
            cnt1++;
        }
        if(A[i]%2==1)
            cnt2++;
    }
    if(cnt1>=n/2 || cnt1>=cnt2){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define lll bignum
#define ls(x) ( x << 1 )
#define rs(x) ( x << 1 | 1 )
//#define mid ( ( l + r ) >> 1 )
#define lowbit(x) ( x & -x )
#define debug(x) (cout << "#x = " << x << endl)
#define re register
#define For(i, j, k) for(re int i = (j); i <= (k); i++)
#define foR(i, j, k) for(re int i = (j); i >= (k); i--)
#define Cross(i, j, k) for(re int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll inf = 0x3f3f3f3f3f3f;

ll n, m, k, x, a[N], b[N], c[N], B[N];
double res = 0;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = (x << 3) + (x << 1) + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write( ll x ) {
		if ( x < 0 ) putchar ( '-' ), x = -x;
		if ( x > 9 ) write ( x / 10 ); putchar ( x % 10 | 48 );
	}

	inline void wrn ( ll x ) { write (x); putchar ( ' ' ); }

	inline void wln ( ll x ) { write (x); putchar ( '\n' ); }

	inline void wlnn ( ll x, ll y ) { wrn (x), wln (y); }

}

using namespace IO;

inline void Redouble ( ll x ) {
	for (; x; x >>= 1) {
		if (x & 1) {
			For ( i, 1, n ) B[i] = a[b[i]]; 
			For ( i, 1, n ) a[i] = B[i];
		}
		For ( i, 1, n ) B[i] = b[b[i]]; 
		For ( i, 1, n ) b[i] = B[i];
	}
}

int main() 
{
	n = read(); 
	For ( i, 1, n ) a[i] = read(), b[i] = i;
	foR ( i, n, 1 ) a[i] = a[i] - a[i - 1];
	m = read(), k = read();
	For ( i, 1, m ) x = read(), swap ( b[x], b[x + 1] );
	Redouble (k);
	For ( i, 1, n ) 
		res += a[i], printf ("%.1lf\n", res);
	return 0;
}

/*

*/



Measured memory_bytes: 3840
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int count = 0;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                if(500*i + 100*j + 50*k == x) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long int n;
	cin>>n;
	long long int x;
	cin>>x;
	long long int arr[n];
	for(long long int j=0;j<n;j++){
		cin>>arr[j];
		//cout<<arr[j]<<endl;
	}
	long long int eat= 0;
	long long int d=0;
	for(long long int i=0;i<n-1;i++){
		if(arr[i]+arr[i+1]>x){
			eat+=arr[i]+arr[i+1]-x;
			arr[i+1] =max(d,x-arr[i]);
		}
	}
	cout<<eat<<endl;
}

Measured memory_bytes: 1024
# 解説見た

# Segment Tree
class Segment:
    def __init__(self, N, init_val, segfunc, identity_element):
        """
        segfunc : min, +, *, xor, gcd など
        identity_element : 単位元(min:inf, 和:0, 積:1, xor:0, gcd:0)
        """
        self.segfunc = segfunc
        self.identity_element = identity_element
        self.N0 = 2 ** (N - 1).bit_length()
        # 0-indexedで管理
        self.dat = [self.identity_element] * (2 * self.N0)

        # 値を代入
        for i in range(N):
            self.dat[i + self.N0 - 1] = init_val[i]
        # 構築
        for i in range(self.N0 - 2, -1, -1):
            self.dat[i] = self.segfunc(self.dat[2 * i + 1], self.dat[2 * i + 2])

    # k番目の要素の値をxに変更
    def update(self, k, x):
        k += self.N0 - 1
        self.dat[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.dat[k] = self.segfunc(self.dat[2 * k + 1], self.dat[2 * k + 2])

    # 区間[l,r)の最小値を求める
    def query(self, l, r):
        L = l + self.N0
        R = r + self.N0
        s = self.identity_element
        # 区間を列挙しながら最小値などをを求める
        while L < R:
            if R & 1:
                R -= 1
                s = self.segfunc(s, self.dat[R - 1])
            if L & 1:
                s = self.segfunc(s, self.dat[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return s


import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline

n, k = map(int, input().split())
seg = Segment(300000, [0] * 300000, max, 0)
ans = 0
for i in range(n):
    a = int(input())
    l = max(a - k, 0)
    r = min(a + k, 300000) + 1
    res = seg.query(l, r) + 1
    ans = max(res, ans)
    seg.update(a, res)

print(ans)


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

using namespace std;

#ifdef Adrian
#include "debug.h"
#else
#define debug(...) 9999
#endif

typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second
#define ii pair<ll,ll>
template <typename G>
struct triple{G F, S, T;
    bool operator < (triple<G> o)
    { return F < o.F; }
};
#define iii triple<int>



int main()
{

#ifdef Adrian
    //freopen("test.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#endif


    int n, k;
    cin>>n>>k;
    vector<int> v(n);
    for(auto &i:v)
        cin>>i;

    sort(v.begin(), v.end());
    int ans = 0;
    for(int i=0; i<k; i++)
        ans += v[i];

    cout<<ans<<'\n';


    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template <int Mod, bool IsPrime = false>
class mod_int {
    using ll = long long;

public:
    constexpr mod_int() : n(0) {}
    constexpr mod_int(int n_) : n(n_) {
        if(n >= Mod)     n %= Mod;
        else if(n < 0) n = (n % Mod + Mod) % Mod;
    }
    constexpr mod_int(ll n_) : n(n_) { n = (n + Mod) % Mod; }

    constexpr operator int() const { return n; }
    constexpr operator ll() const  { return n; }

    constexpr bool operator==(mod_int const& other) const { return n == other.n; }
    constexpr mod_int& operator+=(mod_int const& other) {
        if((n += other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator-=(mod_int const& other) {
        if((n += Mod - other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator*=(mod_int const& other) {
        n = (unsigned long long)n * other.n % Mod;
        return *this;
    }
    constexpr typename std::enable_if<IsPrime, mod_int>::type& operator/=(mod_int const& other) {
        return *this *= other.inverse();
    }
    constexpr mod_int operator+(mod_int other) const { return mod_int(*this) += other; }
    constexpr mod_int operator-(mod_int other) const { return mod_int(*this) -= other; }
    constexpr mod_int operator*(mod_int other) const { return mod_int(*this) *= other; }
    constexpr mod_int operator/(mod_int other) const { return mod_int(*this) /= other; }

    constexpr typename std::enable_if<IsPrime, mod_int>::type inverse() const {
        ll a = n, b = Mod, u = 1, v = 0;
        while(b) {
            ll t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        return mod_int(u);
    }

private:
    ll n;
};

template <int Mod, bool IsPrime>
std::ostream& operator<<(std::ostream& os, mod_int<Mod, IsPrime> const& n) {
    os << (int)n;
    return os;
}

constexpr int default_mod = 1000000007;

template <int Mod = default_mod>
mod_int<Mod, true> fact(int n) {
    static std::vector<mod_int<Mod, true>> v = {1};
    if(n >= static_cast<int>(v.size())) {
        const int from = v.size(), to = n + 1024;
        v.reserve(to);
        for(int i = from; i < to; ++i) {
            v.push_back(v.back() * mod_int<Mod, true>(i));
        }
    }
    return v[n];
}

template <int Mod = default_mod>
mod_int<Mod, true> comb(int n, int r) { // nCr
    if(r < 0 || r > n) return 0;
    return fact<Mod>(n) / fact<Mod>(r) / fact<Mod>(n - r);
}

using mint = mod_int<default_mod, true>; // default

int main() {
    int x, y; cin >> x >> y;

    int i = - x + (2 * y), j = (2 * x) - y;

    if (i % 3 || j % 3) {
        cout << 0 << endl;
        return 0;
    }
    
    i /= 3; j /= 3;

    cout << comb(i + j, i) << endl;    

    return 0;
}


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

int main() {
    int N, i, cnt = 0;
    cin >> N;
    vector<int> dfc(N);
    for (i = 0; i < N; i++) {
        cin >> dfc.at(i);
    }
    sort(dfc.begin(), dfc.end());
    for (i = dfc.at(N / 2 - 1); i < dfc.at(N / 2); i++) cnt++;
    cout << cnt << endl;
}

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

const int64_t MOD = 1000000007;
struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main()
{
    int N;
    cin >> N;
    vector<int64_t> A(N), B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i) >> B.at(i);
    }

    map<pair<int64_t, int64_t>, pair<int, int>> m;
    int zz = 0;
    for (int i = 0; i < N; i++)
    {
        int64_t Ai = A.at(i), Bi = B.at(i);
        if (Bi < 0)
        {
            Ai *= -1;
            Bi *= -1;
        }
        if (Ai == 0 && Bi == 0)
        {
            zz++;
            continue;
        }
        else if (Ai == 0)
        {
            Bi = 1;
        }
        else if (Bi == 0)
        {
            Ai = 1;
        }
        else
        {
            int64_t d = gcd(Ai, Bi);
            Ai /= d;
            Bi /= d;
        }
        bool pos = true;
        if (Ai <= 0)
        {
            pos = false;
            int64_t tmp = Ai;
            Ai = Bi;
            Bi = -tmp;
        }
        if (pos)
            m[make_pair(Ai, Bi)].first += 1;
        else
            m[make_pair(Ai, Bi)].second += 1;
    }

    mint res = 1;
    for (auto p : m)
    {
        int pos = p.second.first, neg = p.second.second;
        mint t = 1;
        t += mint(2).pow(pos) - 1;
        t += mint(2).pow(neg) - 1;
        res *= t;
    }
    res -= 1;
    res += zz;
    cout << res.x << endl;
}

Measured memory_bytes: 18740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication27
{
    class Program
    {
        static void Main()
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(a);
            Console.WriteLine("{0} {1} {2}",a[0],a[1],a[2]); 
        }
    }
}

Measured memory_bytes: 9688
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100005][4];
ll n,a[100005][4];

ll helper(ll day, ll chose)
{
    if(day == n) return 0;

    if(dp[day][chose] != -1) return dp[day][chose];

    ll maxi = 0;
    if(chose == 0)
    {
        maxi = max(maxi, a[day][1]+ helper(day+1, 1));
        maxi = max(maxi, a[day][2]+ helper(day+1, 2));
        maxi = max(maxi, a[day][3]+ helper(day+1, 3));
    }
    else if(chose == 1)
    {
        maxi = max(maxi, a[day][2] + helper(day+1, 2));  
        maxi = max(maxi, a[day][3] + helper(day+1, 3));
    }
    else if(chose == 1)
    {
        maxi = max(maxi, a[day][2]+ helper(day+1, 2));  
        maxi = max(maxi, a[day][3]+ helper(day+1, 3));
    }
    else if(chose == 2)
    {
        maxi = max(maxi, a[day][1]+ helper(day+1, 1));  
        maxi = max(maxi, a[day][3]+ helper(day+1, 3));
    }
    else 
    {
        maxi = max(maxi, a[day][2]+ helper(day+1, 2));  
        maxi = max(maxi, a[day][1]+ helper(day+1, 1));
    }
    return dp[day][chose] = maxi;
}
int main() {

    cin >> n;
    memset(dp, -1, sizeof dp);

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

    cout<<helper(0,0);
}

Measured memory_bytes: 17648
#pragma GCC optimize ("O3", "unroll-loops")
#pragma GCC target ("avx")
#include <stdio.h>

constexpr char* S_OUT[31] = {
    "0\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n",
    "11\n", "12\n", "13\n", "14\n", "15\n", "16\n", "17\n", "18\n", "19\n", "20\n",
    "21\n", "22\n", "23\n", "24\n", "25\n", "26\n", "27\n", "28\n", "29\n", "30\n"
};

constexpr unsigned int InputSize = 1e6;
constexpr unsigned int OutputSize = 3e5;
char Input[InputSize];
char* pointer = Input;
char Output[OutputSize];
char* m_buffer = Output;

inline unsigned int getInt(void){
    unsigned int res = 0;
    do{ res = 10 * res + (*(pointer++) - '0'); } while(*pointer >= '0');
    return res;
}

inline void out(int v){
    char* str = S_OUT[v];
    while(*str) *(m_buffer++) = *(str++);
}

unsigned int n;
unsigned int N;
constexpr unsigned int SIZE = (1U << 19) + 1;
unsigned int data[2 * SIZE];

inline void set(void){
    n = getInt(); N = 1U << (31 - __builtin_clz(n)); while(N < n) N <<= 1;
    ++pointer; // \n
    unsigned int i, j;
    for(i = 0, j = N; i < n; ++i, ++j) data[j] = 1U << (*(pointer++) - 'a');
    for(i = N - 1; i ; --i) data[i] = data[i << 1] | data[(i << 1) | 1U];
}

inline void query(void){
    pointer += 3;
    if(*(pointer - 2) == '1'){
        unsigned int index = getInt() - 1;
        unsigned char idx = *((++pointer)++) - 'a';
        data[index += N] = 1U << idx;
        while(index >>= 1) data[index] = data[index << 1] | data[(index << 1) | 1U];
    }
    else{
        unsigned int l = getInt() + N - 1; pointer++;
        unsigned int r = getInt() + N;
        unsigned int res = 0;
        while(l < r){
            if(l & 1) res |= data[l++]; l >>= 1;
            if(r & 1) res |= data[--r]; r >>= 1;
        }
        out(__builtin_popcount(res));
    }
}

int main(void){
    fread(Input, sizeof(char), InputSize, stdin);
    set(); ++pointer;
    unsigned int q = getInt();
    while(q--) query();
    setvbuf(stdout, 0, _IONBF, 0);
    fputs(Output, stdout);
    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int int_sort(const void *a, const void *b){
  if(*(int *)a < *(int *)b){
    return 1;
  }else if(*(int *)a == *(int *)b){
    return 0;
  }
  return -1;
}

int main(void){
  int n, h, ma=0, c=0, a[100000], b[100000], l, i;
  scanf("%d %d",&n, &h);
  l = h;
  for(i=0;i<n;i++){
    scanf("%d %d",&a[i],&b[i]);
    if(a[ma]<a[i] || (a[ma]==a[i] && b[ma]>=b[i])) ma = i;
  }
  for(i=0;i<n;i++) if(l>0 && i!=ma && b[i]>a[ma]){l-=b[i];  c++;}
  if(l<=0){
    int sum=0;
    qsort((void *)b, n, sizeof(b[0]), int_sort);
    for(i=0;i<n;i++){
      sum+=b[i];
      if(sum>=h) break;
    }
    printf("%d\n",i+1);
  }else{
    //printf("l: %d  ma: %d c: %d\n",l,ma,c);
    l-=b[ma]; c++;
    if(l>0){
      c+=l/a[ma];
      if(l%a[ma]!=0) c++;
    }
    printf("%d\n",c);
  }
  return 0;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  long long N,K; cin >> N >> K;
  vector<int> A(N);
  rep(i,N){
    int buffer;
    cin >> buffer;
    --buffer;
    A[i] = buffer;
  }
  vector<bool> seen;
  seen.assign(N+10,false);
  vector<int> count(N+10);

  int v,pre_v=0,flag = 0;
  v = 0;
  count[0] = -1;
  while(!seen[v]){
    seen[v] = true;
    count[v] = count[pre_v]+1;
    int next_v = A[v];
    pre_v = v;
    v = next_v;
  }

  if(K>N){
    long long KK = (K-count[v])%(count[pre_v]-count[v]+1);

    int dest = v;
    rep(i,KK){
      dest = A[dest];
    }
    cout << dest+1 << endl;
  }
  else{
    int dest = 0;
    rep(i,K){
      dest = A[dest];
    }
    cout << dest+1;
  }
  return 0;
}


Measured memory_bytes: 4848
n = int(input())

l = [[0, 0, 0]]
for i in range(n):
    l.append(list(map(int, input().split())))

for i in range(1, n+1):
    if (abs(l[i][1]-l[i-1][1]) + abs(l[i][2]-l[i-1][2]) - (l[i][0]-l[i-1][0])) % 2 != 0 or abs(l[i][1]-l[i-1][1]) + abs(l[i][2]-l[i-1][2]) > (l[i][0]-l[i-1][0]):
        print("No")
        exit() 

print("Yes")

Measured memory_bytes: 27300
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,n,i,j,k,x,y;
    cin>>n;
    string s[n+2];
    map<string,ll>m;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        m[s[i]]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 6756
#include <cstdio>
#include <stack>
#include <vector>
using namespace std;

using i64 = long long;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

const int is = 1 << 17;
char ib[is], *ip = ib + is, it;
inline char getc() {
	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }
	return *ip++;
}
inline int read() {
	int r = 0;
	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
	else while ((it = *ip++) & 16) r = r * 10 + it - '0';
	return r;
}

const int os = 1 << 17;
char ob[os], *op = ob, ot;
inline void putc(const char c) {
	*op++ = c;
	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }
}
// x shoud be greater than or equal to zero
inline void write(int x) {
	char d[6];
	int i = 0;
	while (true) {
		d[i] = x % 10 + 48;
		x /= 10;
		++i;
		if (x <= 0) break;
	}
	while (i--) {
		putc(d[i]);
	}
	putc(' ');
}

signed main() {
  i64 N = read(), Q = read();
  vector<vector<i64>> G(N);
  REP(_, N - 1) {
    i64 a = read(), b = read();
    a -= 1;
    b -= 1;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<i64> cnt(N);
  REP(_, Q) {
    i64 p = read(), x = read();
    p -= 1;
    cnt[p] += x;
  }
  vector<bool> used(N, false);
  stack<i64> st;
  st.push(0);
  while (st.size()) {
    i64 a = st.top();
    st.pop();
    used[a] = true;
    for (i64 b : G[a]) {
      if (!used[b]) {
        cnt[b] += cnt[a];
        st.push(b);
      }
    }
  }
  REP(i, N) {
    printf("%d ", cnt[i]);
//    write(ans[i]);
  }
//  fwrite_unlocked(ob, 1, op - ob, stdout);
}


Measured memory_bytes: 18032
n, m = map(int, input().split())

d = [[1001] * n for i in range(n)]

es = []
for i in range(m):
    es.append(list(map(int, input().split())))

for (i, j, w) in es:
    d[i - 1][j - 1] = w
    d[j - 1][i - 1] = w


for k in range(n):
    for i in range(n):
        for j in range(n):
            l = d[i][k] + d[k][j]
            if d[i][j] > l:
                d[i][j] = l

c = 0
for (i, j, w) in es:
    if d[i - 1][j - 1] < w:
        c += 1

print(c)

Measured memory_bytes: 3556
from collections import deque
h, w=map(int, input().split())
a=[]
need_visited=[[0 for i in range(w)] for j in range(h)]
stack=deque()
for i in range(h):
    a.append(list(input()))

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            stack.append([i, j])



dx=[1, -1, 0, 0]
dy=[0, 0, 1, -1]


while len(stack)!=0:
    now_point=stack.popleft()
    for i in range(4):
        target_h=now_point[0]+dx[i]
        target_w=now_point[1]+dy[i]
        if 0<=target_h<h and 0<=target_w<w:
            if a[target_h][target_w]==".":
                need_visited[target_h][target_w]=need_visited[now_point[0]][now_point[1]]+1
                a[target_h][target_w]="#"
                stack.append([target_h, target_w])
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans, need_visited[i][j])
print(ans)


Measured memory_bytes: 177756
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

#import sys
#sinput = sys.stdin.readline

n = input()
if n=="AAA" or n=="BBB":
    print("No")
else:
    print("Yes")

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

struct UnionFind {
	vector <int> par;

	UnionFind( int n ) : par( n, -1 ) {
	}
	int root( int x ) {
		if (par[ x ] < 0) return x;
		else return par[ x ] = root( par[ x ] );
	}
	bool issame( int x, int y ) {
		return root( x ) == root( y );
	}
	bool merge( int x, int y ) {
		x = root( x ); y = root( y );
		if (x == y) return false;
		if (par[ x ] > par[ y ]) swap( x, y );	// merge technique
		par[ x ] += par[ y ];
		par[ y ] = x;
		return true;
	}
	int size( int x ) {
		return -par[ root( x ) ];
	}
};
int main( void ){
	// initialize();
	int N, M;
	cin >> N >> M;
	UnionFind uf( N );
    rep(i,0,M){
        int a, b; cin >> a >> b;
        uf.merge( a-1, b-1 );
    }
    int maximum = 0;
    rep(i,0,N){
        maximum = max(maximum, uf.size(i));
    }
    cout << maximum << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 4060
from bisect import bisect_right
N, M = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


divisors = make_divisors(M)
print(divisors[bisect_right(divisors, M // N) - 1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>

#include <stdio.h>
using namespace std;

int main(void) {
	int n;
	double x[100], y[100];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < n; i++)
		cin >> y[i];
	double minkowski_1 = 0;
	double minkowski_2 = 0;
	double minkowski_3 = 0;
	double minkowski_inf = 0;
	double max = 0;
	for (int i = 0; i < n; i++) {
		minkowski_1 += abs(x[i] - y[i]);
		minkowski_2 += (x[i] - y[i]) * (x[i] - y[i]);
		minkowski_3 += abs(x[i] - y[i]) * abs(x[i] - y[i]) * abs(x[i] - y[i]);
		if (abs(x[i] - y[i]) > max)
			max = abs(x[i] - y[i]);
	}
	minkowski_2 = sqrt(minkowski_2);
	minkowski_3 = pow(minkowski_3, 1. / 3.);
	minkowski_inf = max;

	printf("%.9f\n", minkowski_1);
	printf("%.9f\n", minkowski_2);
	printf("%.9f\n", minkowski_3);
	printf("%.9f\n", minkowski_inf);
	return 0;
}



Measured memory_bytes: 3416
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define sc scanf
#define pf printf
#define r0 return 0
int main()
{
    ll a,b;
    cin >> a >> b;
    for(ll n = 0;n<10000;++n){
        ll p = n*8/100;
        ll q = n*10/100;
        if(a==p && b==q)
        {
            cout << n << endl;
            r0;
        }
    }
    cout << -1 << endl;
    r0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision

typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
ll W = 1000000007;

using namespace std;
void omajinai() {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}

class Main{
public:
    long N;
    vector<int> A;
    Main(){
        cin>>N;
        A = vector<int>(N,0);
        REP(i,N){int t; cin>>t; A[t]++;}
    }
    void run(){
        int p = N%2 == 1 ? 2:1;
        int counter =0;
        for(long i = p; i<N ; i+= 2) counter++;
        for(long i = p; i<N ; i+= 2) if(A[i] != 2){cout<<0<<endl; return;}
        if(N%2 == 1 && A[0] != 1){ cout<<0<<endl; return;}
        ll ans = 1;
        REP(i,counter) ans*=2, ans%=W;
        cout<<ans<<endl;
    }
};

int main(){
    omajinai();
    Main().run();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,k;
    cin >> n >> k;
    int d;
    int cnt[110]={};
    rep(i,k){
        cin >> d;
        int a[110]={};
        rep(j,d){
            cin >> a[j];
            cnt[a[j]]++;
        }
    }
    
    int ans=0;
    rep2(i,1,n+1){
       if(cnt[i]==0)ans++; 
    }
    
    cout << ans;
    
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m1 = Integer.parseInt(sc.next());
		int d1 = Integer.parseInt(sc.next());
		int m2 = Integer.parseInt(sc.next());
		int d2 = Integer.parseInt(sc.next());
		 
		if(m1 == m2) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}

	}



}


Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <time.h>
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> ipair;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define ln length()
#define rep(i,n) for(i=0;i<n;i++)
#define fu(i,a,n) for(i=a;i<=n;i++)
#define fd(i,n,a) for(i=n;i>=a;i--)
#define all(a)  a.begin(),a.end() 
#define gi(n) scanf("%d",&n)
#define gl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pl(n) printf("%lld",n);
#define pp printf(" ")
#define pn printf("\n")

int main() {
	ll a;
	ll b;
	gl(a);
	gl(b);
	a = (a + b + 1) >> 1;
	pl(a);
	pn;
	return 0;
}

Measured memory_bytes: 256
n,k,q = list(map(int,input().split()))
a = [int(input()) for i in range(q)]
np = [0]*n

for i in range(q):
    np[a[i]-1] += 1

for i in range(n):
    if k- (q - np[i]) >= 1:
        print('Yes')
    else:
        print('No')

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    long X;
    scanf("%ld",&X);

    long ans=0;
    long sum=0;
    while(1){
        if(sum>=X){
            printf("%ld\n",ans);
            break;
        }
        ans++;
        sum+=ans;
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}


int main(){

    ll n;
    cin>>n;
    string s(n,'a'),q(n,'b'),so(n,'s'),qo(n,'2');
    rep(i,0,n,1){
        ll temp;
        cin>>temp;
        s[i]=(temp +'0');
        so[i]=s[i];
    }
    rep(i,0,n,1){
        ll temp;
        cin>>temp;
        q[i]=(temp+'0');
        qo[i]=q[i];
    }

    sort(s.begin(),s.end());
    sort(q.begin(),q.end());
    ll a=0,b=0;
    if(s==so)a=1;
    if(s==qo)b=1;
    ll i=1;
    while(next_permutation(s.begin(),s.end())){
          i++;

        if(s==so)a=i;
         if(s==qo)b=i;

    }


    cout<<abs(a-b)<<endl;
}


Measured memory_bytes: 81208
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N,Q;
  while(cin >> N >> Q){
    string s; cin >> s;

    vector<int> count(N+1);
    FOR(i,1,N){
      if(s[i-1] == 'A' and s[i] == 'C'){
	count[i] = 1;
      }
    }
    REP(i,N) count[i+1] += count[i];
    dump(count);

    REP(i,Q){
      int l,r; cin >> l >> r;
      cout << count[r-1] - count[l-1] << endl;
    }
  }
  
  return 0;
}


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

using namespace std;

int main()
{
    int n;  string s;
    cin >> n >> s;
    for(int i = 0;i<s.size();i++){
        int x = s[i] - 'A';
        x+=n;
        x%=26;
        char c = 'A' + x;
        cout << c;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int n,r;

struct block{
	short x1,x2,y,f;
};

block b[20002];
short fie[10002][2];

bool comp(const block &b1,const block &b2){
	return b1.y<b2.y;
}

int main(void){
	while(1){
		scanf("%d%d",&n,&r);
		if(n==0 && r==0)break;
		memset(fie,0,sizeof(fie));
		memset(b,0,sizeof(b));
		for(int i=0;i<n;i++){
			int y1,y2;
			scanf("%d%d%d%d",&b[i*2].x1,&y1,&b[i*2].x2,&y2);
			b[i*2].x2--;
			b[i*2+1].x1=b[i*2].x1;
			b[i*2+1].x2=b[i*2].x2;
			b[i*2].y=y1;
			b[i*2+1].y=y2;
			b[i*2].f=1;
			b[i*2+1].f=-1;
		}
		sort(b,b+n*2,comp);
		int ny=0;
		int now=0,prev=1;
		int res=0,res2=0;
		for(int i=0;i<n*2;i++){
			if(ny!=b[i].y){
				swap(now,prev);
				int cnt=0;
				int cnt2=0,bt=0,cnt3=0;
				for(int j=0;j<=10000;j++){
					if(fie[j][now]>0 && fie[j][prev]==0)cnt3++;
					if(fie[j][now]==0 && fie[j][prev]>0)cnt3++;
					fie[j][now]=fie[j][prev];
					if(fie[j][now]>0){
						cnt++;
						if(bt==0)cnt2++,bt=1;
					}else bt=0;
				}
				res+=cnt*(b[i].y-ny);
				res2+=cnt2*2*(b[i].y-ny)+cnt3;
			}
			ny=b[i].y;
			for(int j=b[i].x1;j<=b[i].x2;j++)fie[j][now]+=b[i].f;
			//printf("%d\n",res2);
			
		}
		printf("%d\n",res);
		if(r==2){
			swap(now,prev);
			int cnt3=0;
			for(int j=0;j<=10000;j++){
				if(fie[j][now]>0 && fie[j][prev]==0)cnt3++;
				if(fie[j][now]==0 && fie[j][prev]>0)cnt3++;
				fie[j][now]=fie[j][prev];
			}
			res2+=cnt3;
			printf("%d\n",res2);
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
map<int, int>m;
int main(){
  int n;
  int x;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x;
    m[x]++;
  }
  priority_queue<int>Q;
  for(auto it:m)
    Q.push((it.second));
  while(true){
    if(Q.top() == 1)
      break;
    n-=2;
    if(Q.size() == 1){
      int a = Q.top();
      Q.pop();
      Q.push(a - 2);
      continue;
    }
    int a = Q.top();
    Q.pop();
    int b = Q.top();
    Q.pop();
    a--;
    b--;
    if(a)
      Q.push(a);
    if(b)
      Q.push(b);
  }
  cout << n << endl;


  return 0;
}


Measured memory_bytes: 5628
#include <stdio.h>
int main(void){
    // Your code here!
    int X,Y;
    
    scanf("%d%d",&X,&Y);
    
    if(Y >= 2 *X && Y <= 4 *X && Y % 2 == 0){
        printf("Yes\n");
         return 0;
    }
    
    printf("No\n");
}

Measured memory_bytes: 1628
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = sorted(getlist())
	cnt = 0

	while True:
		if A[-1] <= N - 1:
			print(cnt)
			return
		if (A[-1] - (N - 1)) % N == 0:
			K = int((A[-1] - (N - 1)) // N)
		else:
			K = int((A[-1] - (N - 1)) // N) + 1
		
		#処理
		cnt += K
		A[-1] -= K * N
		for i in range(N - 1):
			A[i] += K
		A = sorted(A)

	print(cnt)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3436
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  
  string s, t;
  vector<int> map(256, -1), inv(256, -1);
  
  cin >> s >> t;
  
  for (int i = 0, l = s.size(); i < l; i++) {
    if (map[s[i]] != -1 || inv[t[i]] != -1) {
      if (map[s[i]] != t[i] || inv[t[i]] != s[i]) {
        cout << "No" << endl;
        return 0;
      }
    } else {
        map[s[i]] = t[i];
        inv[t[i]] = s[i];
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	V := make([]int, N)
	for i := range V {
		fmt.Scan(&V[i])
	}
	C := make([]int, N)
	for i := range C {
		fmt.Scan(&C[i])
	}

	res := 0
	for i := 0; i < (1 << uint(N)); i++ {
		x := 0
		y := 0
		for j := 0; j < N; j++ {
			if (i >> uint(j)) & 1 > 0 {
				x += V[j]
				y += C[j]
			}
		}
		if x - y > res {
			res = x - y
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
// Problem : D - Median of Medians
// Contest : AtCoder Regular Contest 101
// URL : https://atcoder.jp/contests/arc101/tasks/arc101_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using ll = long long;
using namespace std;
#define cerr if(1)cerr
#define size(x) (int)x.size()
 
const int N = 1e5 + 1, inf = 1e9;																																																																																								void read(int&n){n=0;while(1){char c=getchar();if(c==' '||c=='\n')break;n=(n<<1)+(n<<3)+c-'0';}}void read(ll&n){n=0;while(1){char c=getchar();if(c==' '||c=='\n')break;n=(n<<1)+(n<<3)+c-'0';}}void write(int n){if(n>9)write(n/10),putchar(n%10+'0');else putchar(n+'0');}void write(ll n){if(n>9)write(n/10),putchar(n%10+'0');else putchar(n+'0');}template<class F,class... Ts>void read(F&f,Ts&...ts){read(f);read(ts...);}template<class F,class... Ts>void write(F&f,Ts&...ts) {write(f);putchar(' ');write(ts...);}template<class...Ts>void writeln(const Ts&...ts){write(ts...);putchar('\n');}

int n, r[N], a[N], p[N], _cnt[2 * N + 1];
int* cnt = _cnt + N;

bool check(int k) {
	ll ans = 0;
	for (int i = -1e5; i <= 1e5; i++) {
		cnt[i] = 0;
	}
	k++;
	int now = 1, sum = 0;
	cnt[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] >= k) {
			sum++;
			now += cnt[sum];
		} else {
			now -= cnt[sum];
			sum--;
		}
		cnt[sum]++;
		ans += now;
		now++;
	}
	return 1ll * n * (n + 1) / 2 - ans >= 1ll * n * (n + 1) / 4 + 1;
}
 
int main() { cin.tie(0)->sync_with_stdio(0);
	read(n);
	map<int, int> m;
	int ca = 0;
	for (int i = 1; i <= n; i++) {
		read(a[i]);
		m[a[i]] = 0;
	}
	for (auto& x : m) {
		x.second = ++ca;
	}
	for (int i = 1; i <= n; i++) {
		r[m[a[i]]] = a[i];
		a[i] = m[a[i]];
	}
	int ans = 0;
	for (int j = log2(n); j >= 0; j--) {
		ans += 1 << j;
		if (check(ans)) {
			ans -= 1 << j;
		}
	}
	cout << r[ans + 1];
}

Measured memory_bytes: 6528
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

const int MAX_N = 100009;
const int MAX_LOG = 20;
int G[MAX_N][MAX_LOG];
int N, L, Q;
vector<ll> nums;

void doubling(){
    rep1(p,MAX_LOG-1){
        rep(i,N){
            G[i][p] = G[G[i][p-1]][p-1];
        }
    }
}

int calc(int a, int b){
    int res=0;
    rrep(i,19) if(G[a][i]<b){
        a = G[a][i];
        res+=1<<i;
    }
    return res+1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    nums.resize(N);
    rep(i,N) cin>>nums[i];
    
    cin>>L;
    rep(i,N){
        ll d = nums[i] + L;
        int idx = upper_bound(nums.begin()+i,nums.end(),d) - nums.begin()-1;
        G[i][0] = idx;
    }
    
    doubling();
    
    cin>>Q;
    rep(i,Q){
        int a,b; cin>>a>>b;
        a--; b--;
        if(a>b) swap(a,b);
        cout1(calc(a,b));
    }
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    ll n;cin>>n;
    ll ans = 1e12;
    for(ll i=1;i*i<=n;i++){
        if(n%i!=0)continue;
        else ans = min(ans, (n/i)-1+i-1);
    }
    co(ans);
}

Measured memory_bytes: 256
a = int(input())

t = 0
h = 0
for i in range(a):
    x, y = input().split()
    if(x < y):
        t +=3
    elif(y < x):
        h +=3
    else:
        t +=1
        h +=1
print("{0} {1}".format(h, t))


Measured memory_bytes: 5600