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


int main(){
    
    int x;
    cin >> x;
    
    int start_x = 400;
    int start_y = 599;
    for(int i = 8; i >= 1; i--){
        if(x <= start_y && x >= start_x){
            cout << i << endl;
            return 0;
        }
        start_x += 200;
        start_y += 200;
    } 
    
    
    return 0;
    
    
}


Measured memory_bytes: 3628
#include <iostream>
#include <list>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;
template <class T>
using Vec = std::vector<T>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int BitI(int k){return 1 << k;}
inline lli BitL(int k){return 1L << k;}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





int main(void){
  std::string s; cin >> s;
  const int sz = s.size();
  int cnt = 0;
  REP(i, sz) if(((i & 1) == 0)^(s.at(i) == '0')) cnt++;
  printf("%d\n", std::min(cnt, sz - cnt));
  return 0;
}

Measured memory_bytes: 512
import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    private static void nCombination3(int c) {
        int count = c;
        int num = 0;
        for (int i = 0; i < count - 2; i++) {
            for (int j = i + 1; j < count - 1; j++) {
                for (int k = j + 1; k < count; k++) {
                    num++;
                }
            }
        }
    }

    static List<Long> list = new ArrayList<Long>();
    static void solve(char a,String temp,int N){
        if(N>10) {
            return;
        }
        temp+=a;
        //System.out.println(temp);
        long value = Long.valueOf(temp);
        list.add(value);
        if(a>'0') {
            solve((char)((int)a-1),temp,N+1);
        }
        solve(a,temp,N+1);
        if(a<'9') {
            solve((char)((int)a+1),temp,N+1);
        }
    }


    public static void main(String[] args) {
        // write your code here
        Scanner sc=new Scanner(System.in);
        for(char c='1';c<='9';c++){
            solve(c,"",1);
        }
        Collections.sort(list);
        int a=sc.nextInt()-1;
        System.out.println(list.get(a));


    }
}


Measured memory_bytes: 54824
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int N, tmpP, res=0;
  vector<int> P;
  scanf("%d\n",&N);
  for(int i=0;i<N;i++){
    scanf("%d\n",&tmpP);
    P.push_back(tmpP);
  }
  sort(P.begin(),P.end());
  *(P.end()-1)/=2;
  
  for(auto &num:P)
  	res+=num;
  printf("%d\n",res);
	return 0;
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;

const int	MAX = 1e5 + 1;
const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int			is_prime[MAX];

int		main(void)
{
	std::ios_base::sync_with_stdio(false);

	for (int i(2); i < MAX; ++i)
		is_prime[i] = 1;

	for (int i(2); i < MAX; ++i)
		if (is_prime[i])
			for (int j(2 * i); j < MAX; j += i)
				is_prime[j] = 0;

	is_prime[0] = is_prime[1] = 0;
	int		summ[MAX] = {};

	for (int i(3); i < MAX; i += 2)
		summ[i] = summ[i - 2] + (is_prime[i] and is_prime[(i + 1) / 2]);
	int		Q;
	std::cin >> Q;
	while (Q--)
	{
		int	l, r;
		std::cin >> l >> r;
		if (l >= 3)
			pnl(summ[r] - summ[l - 2]);
		else
			pnl(summ[r]);
	}

}



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

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

long long N, T, R = 1;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> T;
		long long U = gcd(T, R);
		R /= U; R *= T;
	}
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
    if(m1 == m2) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main(){
    int n,a,b,c,d;
    string s;
    bool ans=true;
    cin>>n>>a>>b>>c>>d>>s;
    for(int i=a-1;i<max(c,d)-1;i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(c>d){
        ans = false;
        for(int i=b-2;i<min(c,d)-1;i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') ans = true;
        }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    cin>>a>>b;
    ll sol=0;
    while(a<=b)
        sol++, a*=2;
    cout << sol;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


int main(){
	int x, y;
	cin >> x >> y;
	map<int, int> k;
	hei(int) a(y);
	rep(i, 0, y) {
		cin >> a[i];
		k[a[i]] = 1;
	}
	int s=100000, z;
	for (int i = 101; i >= 0; i--) {
		if (k[i] == 0 && s >= abs(x - i)) {
			z = i;
			s = abs(x - i);
		}
	}
	cout << z << endl;

	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const int maxn = 1000007;
int a[2][maxn];
int n,m,k;
int main()
{
    cin>>n;
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    int ans = 0;
    int now = 0;
    for(int i=0;i<n;i++)
    {
        now+=a[0][i];
        int s = now;
        for(int j=i;j<n;j++)
        {
            s+=a[1][j];
        }
        ans=max(ans,s);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

struct Edge{
  int to,id;//辺，何番目の辺か
};
vector<vector<Edge>> g;
vector<int> ans;//ans[i]:i番目の辺の色

void dfs(int v, int c=-1,int p=-1){// v:現在注目しているエッジ，p:親の辺（どこから来たか）
  int k=1;
  rep(i,sz(g[v])){
    int u=g[v][i].to,ei=g[v][i].id;
    if(u==p) continue;//親の方に行ったら逆流なので防ぐ
    //親以外の色を与える
    if(k==c) k++;//親と同じ色なら色を変える
    ans[ei]=k; k++;
    dfs(u,ans[ei],v);
  }
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  g.resize(n);
  ans.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--,b--;
    g[a].pb((Edge){b,i});
    g[b].pb((Edge){a,i});
  }

  dfs(0);//0を根としてスタート

  int mx=0;
  rep(i,n) chmax(mx,(int)sz(g[i]));
  cout << mx << endl;
  rep(i,n-1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

template<typename T>
class ConvexHullTrick{
public:
    deque<pair<T,T> > dq;
    ConvexHullTrick(){};
    //min
    //x:monotonic
    T get(T x){
        while(dq.size()>=2){
            T l=dq[0].first*x+dq[0].second;
            T r=dq[1].first*x+dq[1].second;
            if(l<=r) break;
            dq.pop_front();
        }
        return dq[0].first*x+dq[0].second;
    }
    //x:other
    T getg(T x){
        int l=-1,r=dq.size()-1;
        while(r-l>1){
            int mid=(r+l)/2;
            T tl=dq[mid].first*x+dq[mid].second;
            T tr=dq[mid+1].first*x+dq[mid+1].second;
            if(tl<=tr) r=mid;
            else l=mid;
        }
        return dq[r].first*x+dq[r].second;
    }
    void add(pair<T,T> x){
        while(dq.size()>=2){
            pair<T,T> l=dq[dq.size()-1];
            pair<T,T> r=dq[dq.size()-2];
            if((x.second-l.second)*(r.first-l.first)>=(l.first-x.first)*(l.second-r.second)) break;
            dq.pop_back();
        }
        dq.pb(x);
    }
};
ll h[200001];
ll dp[200001];
int main(){
    ll n,c;
    cin>>n>>c;
    rep(i,n) cin>>h[i];
    ConvexHullTrick<ll> cht;
    dp[0]=0;
    cht.add({-h[0]*2,h[0]*h[0]});
    FOR(i,1,n){
        dp[i]=cht.get(h[i])+h[i]*h[i]+c;
        cht.add({-h[i]*2,h[i]*h[i]+dp[i]});
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int dp[2][3001][3001];
int p2;

int Pow(int a, int b) {
    int res = 1;
    while(b) {
        if(b&1) {
            res = (1LL * res * a) % mod;
        }
        b >>= 1;
        a = (1LL * a * a) % mod;
    }
    return res;
}

int div1(int a, int b) {
    a %= mod;
    return (1LL * a * p2) % mod;
}

int main() {
    int n, q;
    cin>>n>>q;
    vector<int> A(n);
    for(int i = 0; i < n; ++i) {
        cin>>A[i];
    }
    p2 = Pow(2, mod - 2);
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(A[i] > A[j]) {
                dp[1][i][j] = 1;
            }
        }
    }

    for(int i = 1; i <= q; ++i) {
        int x, y;
        cin>>x>>y;
        x--, y--;
        for(int j = 0; j < n; ++j) {
            if(j != x && j != y) {
                dp[1][j][x] = dp[1][j][y] = div1(dp[1][j][x] + dp[1][j][y], 2);
                dp[1][x][j] = dp[1][y][j] = div1(dp[1][x][j] + dp[1][y][j], 2);
            }
        }
        dp[1][x][y] = dp[1][y][x] = div1(dp[1][x][y] + dp[1][y][x], 2);
    }
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            ans = (ans + dp[1][i][j]) % mod;
        }
    }
    ans = (1LL * ans * Pow(2, q)) % mod;
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B;
    rep(i, N) { cin >> A[i]; }

    bool judge = 1;
    rep(j, N) {
        int cur = -1;
        rep(i, A.size()) {
            if (A[i] == i + 1)
                cur = i;
        }

        if (cur == -1) {
            judge = 0;
            break;
        } else {
            B.push_back(A[cur]);
            A.erase(A.begin() + cur);
        }
    }

    if (judge) {
        reverse(B.begin(), B.end());
        for (auto b : B)
            cout << b << endl;
    } else
        cout << -1 << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b, c;
set<int> st;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    if (st.size() == 2) cout << "Yes" << E;
    else cout << "No" << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u){
    int v;
    color[u]=GRAY;
    d[u]=++tt;
    for(v=0; v<n; v++){
        if(M[u][v]==0){
            continue;
        }
        if(color[v]==WHITE){
            dfs_visit(v);
        }
    }
    color[u]=BLACK;
    f[u]=++tt;
}

void dfs(){
    int u;

    for(u=0; u<n; u++){
        color[u]=WHITE;

    }
    tt=0;

    for(u=0; u<n; u++){
        if(color[u]==WHITE){
            dfs_visit(u);
        }
    }
    for(u=0; u<n; u++){
        printf("%d %d %d\n", u+1, d[u], f[u]);
    }
}

int main(void){
    int u, v, k, i, j;

    scanf("%d", &n);
    for(i=0; i<N; i++){
        for(j=0; j<n; j++){
            M[i][j]=0;
        }
    }
    for(i=0; i<n; i++){
        scanf("%d %d", &u, &k);
        u--;
        for(j=0; j<k; j++){
            scanf("%d", &v);
            v--;
            M[u][v]=1;
        }
    }

    dfs();

    return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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

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


int X, Y, Z, K;
ll a[1100];
ll b[1100];
ll c[1100];
ll pos[1100];
vector<ll> kouho;


int main () {
  cin >> X >> Y >> Z >> K;
  Rep(i, X) cin >> a[i];
  Rep(i, Y) cin >> b[i];
  Rep(i, X) cin >> c[i];

  Rep(i, X) {
    Rep(j, Y) {
      kouho.push_back(a[i] + b[j]);
    }
  }

  sort(All(kouho), greater<ll>());

  Rep(i, K) {
    ll tmp = 0;
    int tmp_index = 0;

    Rep(j, Z) {
      if ((kouho[pos[j]] + c[j]) > tmp) {
        tmp = kouho[pos[j]] + c[j];
        tmp_index = j;
      }
    }

    cout << tmp << "\n";
    pos[tmp_index]++;
  }

}

Measured memory_bytes: 10476
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, S);
    string T = "CODEFESTIVAL2016";
    ll ans = 0;
    REP(i, S.size())
    {
        ans += T[i] != S[i];
    }
    OUT(ans);
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
using namespace std;
int a[40009],miku;
int main()
{
    for(int i=1;i<=3;i++)
    cin>>a[i];
    sort(a+1,a+1+3);
    for(int i=1;i<=2;i++){
    	 miku+=a[i];
    }cout<<miku<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll N, K;
    cin >> N >> K;
    vector<set<ll>> t(N);
    rep(i, N-1){
        ll a, b;
        cin >> a >> b;
        t[a-1].insert(b-1);
        t[b-1].insert(a-1);
    }
    function<ll(ll, ll, ll)> solve = [&](ll current, ll last, ll last2){
        ll count = last>=0? (K-1-last2) : K;
        ll total = 1;
        ll i = 0;
        for(ll n : t[current]){
            if(n==last) continue;
            total = (total * solve(n, current, last2>=0? (i+1) : i)) % 1000000007;
            ++i;
        }
        return (count*total) % 1000000007;
    };
    cout << solve(0, -1, -1) << endl;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int n,m;
int INF = 2000000000;
int cost[1005];
int open[1005];
int dp[1005][1<<12];
int all_opened;

int calculate(int a,int b){
	for(int i=0; i<n; i++){
		if((1<<i)&a && (1<<i)&b) a-=(1<<i);
	}
	return a;
}
int f(int key,int opened){
	int&ret = dp[key][opened];
	if(~ret) return ret;
	ret = INF;
	int new_opened = calculate(opened,open[key]);
	if(new_opened == 0) ret = cost[key];
	if(key==m) return ret;
	
	ret = min(ret,f(key+1,opened)); //이번 키를 안쓰고 다음 키부터 고려하는 경우  
	if(f(key+1,new_opened)!=INF && new_opened) ret = min(ret,f(key+1,new_opened)+cost[key]); //이번 키를 사용한 경우  
	return ret;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	all_opened = (1<<n)-1;
	
	for(int i=1; i<=m; i++){
		int c,o;
		cin>>c>>o;
		cost[i] = c;
		int bit = 0;
		while(o--){
			int num;
			cin>>num;
			num--;
			bit |= (1<<num);
		}
		open[i] = bit;
	}
	int mincost = f(1,all_opened);
	if(mincost==INF) cout<<-1;
	else cout<<mincost;
}

Measured memory_bytes: 19792
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <math.h>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


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

    vector<char> st;

    rep(i,s.size()){
        if(!st.empty() && s[i] == 'B'){
            st.pop_back();
        }else if(s[i]!='B'){
            st.push_back(s[i]);
        }
    }


    rep(i,st.size()){
        cout << st[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
H,W=map(int, input().split())
S=[list(input()) for i in range(H)]

dh = [0,1,-1,0,1,-1,-1,1]
dw = [1,0,0,-1,1,1,-1,-1]

for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        else:
            cnt = 0
            for k in range(8):
                next_h = h+dh[k]
                next_w = w+dw[k]
                if not(0<= next_h <= H-1) or not(0<= next_w <= W-1):
                    continue
                elif S[next_h][next_w] == "#":
                    cnt += 1
        S[h][w] = str(cnt)
        
for s in S:
    print("".join(s))

Measured memory_bytes: 9184
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll nl, nm;

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

  int n;
  cin >> n;
  int cur_x, cur_y;
  bool f = true;
  cur_x = 0; cur_y = 0;
  REP(i, n){
    int t, x, y;
    cin >> t >> x >> y;
    int v = abs(x-cur_x) + abs(y-cur_y);
    if(v > t || (v-t)%2 != 0) f = false;   
  }
  
  cout << ( f ? "Yes" : "No" ) << endl;
  
  return 0;
}


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

#define ll            long long
#define pb            push_back
#define si            set <int>
#define F             first
#define S             second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define fr(i,a,b)     for(int  i=a;i<=b;i++)
#define loop(i,n)     for(int i=0;i<n;i++)
#define all(v)        v.begin(),v.end()
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define mp            make_pair
#define input(arr,n)  loop(i,n) cin>>arr[i]
#define output(arr,n) loop(i,n) cout<<arr[i]<<" "
#define mod           998244353
#define sof           sizeof
using namespace std;
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

bool isPrime(int num){
    
    if(num==2) return true;
    if(num<2 || num%2==0) return false;
    for(int i = 3; i*i <=num; i+=2) {
       if(num % i == 0) {
          
          return false;
       }
    }
    return true;
   
}

bool comp(const pair<int,int> &a,const pair<int,int> &b){
  return a.F>b.F;
}

vector<vector<int>> L(3005,vector<int>(3005,-1));
string a,b;


const int N=3000;
double dp[N][N];
void solve(){
  
  int n;
  cin>>n;
  double p[n];
  input(p,n);
  dp[0][0]=1-p[0];
  dp[0][1]=p[0];

  fr(i,1,n-1){
    fr(j,0,n){
      dp[i][j]+=dp[i-1][j]*(1-p[i]);

      if( j>0 )
        dp[i][j]+=dp[i-1][j-1]*p[i];
    }
  }
  double ma=0;
  fr(i,n/2+1,n){
    ma+=dp[n-1][i];
  }
  
  cout<<fixed<<setprecision(12)<<ma;
  
}




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

  int t;
  t=1;
  //cin>>t;
  loop(i,t){

      solve();
      if(i<t-1) cout<<"\n";
  }

  
  
  //directed graph
    



}
  


  



Measured memory_bytes: 109400
#include<stdio.h>
int main(){
	int x[10000],y[500],i,j,s,n,m;
	s=0;
	scanf("%d",&n);
	for(i=0;i<=n-1;i=i+1){
		scanf("%d",&x[i]);
	}
	scanf("%d",&m);
	for(j=0;j<=m-1;j=j+1){
		scanf("%d",&y[j]);
	}
	for(j=0;j<=m-1;j=j+1){
		for(i=0;i<=n-1;i=i+1){
			if(x[i]==y[j]){
				s=s+1;
				break;
			}
		}
	}
	printf("%d\n",s);
}


Measured memory_bytes: 2716
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

int sum(int n){
    int ans = 0;
    while(n > 0){
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

void solve(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += (sum(i) >= a && sum(i) <= b) ? i : 0;
    }
    cout << ans;
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
/*配列Aに含まれる要素の異なる数字毎にカウントし、奇数個ある数字の個数が答え*/
int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	for(int i = 0;i<N;i++){
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	A.push_back(-1);
	int c = 1;//配列Aの同じ要素毎の個数
	int ans = 0;//奇数個あるAの要素数
	for(int i = 0;i<N;i++){
		if(A[i] == A[i+1]){
			c++;
		}
		else{
     if(c%2 != 0) ans++;
     c = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;

using ci = const int;
using ld = long double;
using llint = long long;
using ullint = unsigned long long;
using pii = pair <int,int>;
using pcc = pair <char,char>;
using pll = pair <llint,llint>;
using pss = pair <string,string>;
using vi = vector <int>;
using vb = vector <bool>;
using vll = vector <llint>;
using vii = vi::iterator;

#define INF (1<<30)
#define MOD 1000000007
#define mt make_tuple
#define all(c) c.begin(), c.end()
#define ms(name,val) memset(name, val, sizeof name)
#define np nullptr
// inline functions



ci V = (1e5)+5;
int n, w;
llint ww[105], vv[105], dp[V];

int main()
{
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin >> n >> w;

    for (int t1 = 1; t1 < V; ++t1)
        dp[t1] = INF;

    for (int t1 = 1; t1 <= n; ++t1)
    {
        cin >> ww[t1] >> vv[t1];

        for (int val = V-1-vv[t1]; val >= 0; --val)
        {
            if (dp[val] != INF)
                dp[val+vv[t1]] = min(dp[val+vv[t1]], dp[val] + ww[t1]);
        }
    }

    for (int t1 = V-1; t1 >= 0; --t1)
    {
        if (dp[t1] <= w)
        {
            cout << t1 << '\n';
            break;
        }
    }

































    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;
void print(vector<int>& values)
{
  for(int i=0;i<values.size()-1;i++) cout<<values[i]<<" ";
  cout<<values[values.size()-1]<<endl;
}
void insertionSort(std::vector<int>& numbers)
{
  int key;
  for(int i=1; i<numbers.size();i++){
    print(numbers);
    key = numbers[i];
    int j = i-1;
    while( (j>=0) and (numbers[j]>key) ){
      numbers[j+1]=numbers[j];
      j--;
    }
    numbers[j+1]=key;
  }
}
int main(void)
{
  int n;
  std::vector<int> numbers;
  std::cin >> n; numbers.resize(n);
  for(int i=0; i<n; i++) std::cin>>numbers[i];
  insertionSort(numbers);
  print(numbers);
  return 0;
}


Measured memory_bytes: 3116
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  	int n,k;
  	set<int>s;
  	cin >> n >> k;
  	for (int i = 0; i < k; ++i)
  	{
  		int a;
  		cin >> a;
  		s.insert(a);
  	}
  	while(true)
  	{
  		int m = n;
  		bool j = true;
  		while(m > 0){
  			if(s.count(m%10)){
  				j = false;
  			}
  			m /= 10;
  		}
  		if(j){
  			cout << n << endl;
  			break;
  		}
  		n++;
  	}
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int ans =0;
		Main main = new Main();

		int[][]list = new int[N][D];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				list[i][j]= sc.nextInt();
			}
		}

		for (int i = 0; i < N; i++) {
			for (int j = i; j < N; j++) {
				if (i==j) {
					continue;
				}else {
					long con =0;
					for (int k = 0; k < D; k++) {
						con+=Math.pow(Math.abs(list[i][k] - list[j][k]), 2);
					}
					if (main.chkSquearNum(con)) {ans++;}
				}
			}
		}

		System.out.println(ans);

	}

	public boolean chkSquearNum(long N) {
		if (N<0) {
			throw new IllegalArgumentException();
		}

		double sqrtNum = Math.sqrt(N);
		return isLong(sqrtNum);
	}

	public boolean isLong(double N) {
		return (N == Math.floor(N));
	}
}



Measured memory_bytes: 36140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin>>n;
    
    if(n==1)
    {
        cout<<0<<endl;
        return 0;
    }
    
    vector<ll> factors;
    while(n%2==0)
    {
        factors.push_back(2);
        n /= 2;
    }
    for(ll i=3;i<=sqrt(n);i+=2)
    {
        while(n%i==0)
        {
            factors.push_back(i);
            n /= i;
        }
    }
    if(n>2) factors.push_back(n);
    
    ll ans=1,taken=1;
    
    for(ll i=1;i<(ll)factors.size();i++)
    {
        if(factors[i]==factors[i-1])
        {
            ll j=i,f=1,cur = factors[i],count=0;
            for(j=i;j<=(i+taken)&&j<(ll)factors.size();j++)
            {
                if(factors[j]!=cur) break;
                count++;
            }
            if(count==taken+1)//(f && j<(ll)factors.size())
            {
                ans++;
                taken++;
            }
            
            i = j-1;
            
        }
        else
        {
            ans++;
            taken=1;
        }
    }
    cout<<ans<<endl;
    
    //for(ll i:factors) cout<<i<<" ";
}

Measured memory_bytes: 3676
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a,b = LI()
    c,d = LI()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    ans = float("inf")
    for w in range(1,1000):
        ans = min(ans, abs(a%w-b%w)+abs(a//w-b//w)+abs(c%w-d%w)+abs(c//w-d//w))
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()



Measured memory_bytes: 8240
using System;

namespace abc169
{
    class B
    {
        static void Main()
        {
            var n  = int.Parse(Console.ReadLine());
            var aList = ReadNumList();
            foreach (var a in aList)
            {
                if (a == 0)
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            Decimal total = 1;
            try
            {
                foreach (var a in aList)
                {
                    total = Decimal.Multiply(total, a);
                }
                if (total > 1000000000000000000L)
                {
                    Console.WriteLine(-1);
                }
                else
                {
                    Console.WriteLine(total);
                }
            }
            catch (OverflowException)
            {
                Console.WriteLine(-1);
            }
        }
        static long[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new long[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = long.Parse(line[i]);
            }
            return numList;
        }
    }
}


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

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    int min = 1000;
    int count = 0;
    for(int i=0;i<n;i++){cin >> m[i];}
    for(int j=0;j<n;j++){
        x = x-m[j];
        count++;
        if(m[j] < min){min = m[j];}
    }
    count = count + x/min;
    cout << count << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define rep(i,beg,end) for(int i=(beg);i<(end);i++)
using namespace std;

int main(){
	long long ans=0;
	long long h;
	cin>>h;
	long long times=1;
	while(h){
		
		ans+=times;
		h/=2;
		times*=2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct AddT {
	vector<UL> n;
	UL Sz;
	AddT(UL sz) {
		Sz = 1; while (Sz < sz) Sz <<= 1;
		n.resize(Sz * 2 - 1);
	}
	void upd(UL p, UL v) {
		p = Sz - 1 + p;
		n[p] = v;
		while (p != 0) {
			p = (p - 1) >> 1;
			n[p] = n[(p << 1) + 1] | n[(p << 1) + 2];
		}
	}
	UL query(UL l, UL r, UL a = -1, UL b = -1, UL p = -1) {
		if (a == -1) { a = 0; b = Sz; p = 0; }
		if (l <= a && b <= r) return n[p];
		if (b <= l || r <= a) return 0;
		return query(l, r, a, (a + b) >> 1, p + p + 1) |
			query(l, r, (a + b) >> 1, b, p + p + 2);
	}
};

struct Problem {

	void Solve() {
		UL N; cin >> N;
		string S; cin >> S;
		AddT G(N);
		rep(i, N) {
			G.n[G.Sz - 1 + i] = (1 << (S[i] - 'a'));
		}
		rep(i, G.Sz - 1) {
			UL ix = G.Sz - 2 - i;
			G.n[ix] = G.n[(ix << 1) + 1] | G.n[(ix << 1) + 2];
		}
		UL Q; cin >> Q;
		rep(i, Q) {
			UL c; cin >> c;
			if (c == 1) {
				UL p; cin >> p; p--;
				char h; cin >> h; 
				UL H = 1 << (h - 'a');
				G.upd(p, H);
			}
			else {
				UL l, r; cin >> l >> r; l--;
				UL buf = G.query(l, r);
				UL ans = 0;
				rep(i, 26) if (buf & (1 << i)) ans++;
				cout << ans << endl;
			}
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

// const ll mod = static_cast<int>(1e9 + 7);





int main() {
	int a;
	string s;

	cin >> a;
	cin >> s;

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


Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N){
  int i,j,key;
  for(i=1;i<N;i++){
    key = A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
    trace(A,N);
  }
}

int main(){
  int N,i,j;
  int A[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  trace(A,N);
  insertionSort(A,N);

  return 0;
}




  
  
  



Measured memory_bytes: 2084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int i,f[300]={};
	char s[100010];
	chin(s);
	rep(i,strlen(s))f[s[i]]++;
	for(i='a';i<='z';i++){
		if(!f[i]){
			putchar(i);
			return 0;
		}
	}
	puts("None");
	return 0;
}

Measured memory_bytes: 384
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const a1: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const a2: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const a3: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const map = {
      [a1[0]] : 0,
      [a1[1]] : 1,
      [a1[2]] : 2,
      [a2[0]] : 3,
      [a2[1]] : 4,
      [a2[2]] : 5,
      [a3[0]] : 6,
      [a3[1]] : 7,
      [a3[2]] : 8,
    };
    const n: number = tmp.shift().split(" ").map(int => parseInt(int))[0];
    const hole = [];
    for (let i = 0; i < n; i++) {
      const b = tmp.shift().split(" ").map(int => parseInt(int))[0];
      hole.push(map[b]);
    }
    const is0 = hole.indexOf(0) != -1;
    const is1 = hole.indexOf(1) != -1;
    const is2 = hole.indexOf(2) != -1;
    const is3 = hole.indexOf(3) != -1;
    const is4 = hole.indexOf(4) != -1;
    const is5 = hole.indexOf(5) != -1;
    const is6 = hole.indexOf(6) != -1;
    const is7 = hole.indexOf(7) != -1;
    const is8 = hole.indexOf(8) != -1;
    return `${
      (is0 && is1 && is2)
      || (is3 && is4 && is5)
      || (is6 && is7 && is8)
      || (is0 && is3 && is6)
      || (is1 && is4 && is7)
      || (is2 && is5 && is8)
      || (is0 && is4 && is8)
      || (is3 && is4 && is5)
      || (is2 && is4 && is6) ? "Yes" : "No"
    }`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7500
(defun parse-int-ex (n)
  (cond ((stringp n) (parse-integer n))
        ((char= n #\1) 1)
        ((char= n #\2) 2)
        ((char= n #\3) 3)
        ((char= n #\4) 4)
        ((char= n #\5) 5)
        ((char= n #\6) 6)
        ((char= n #\7) 7)
        ((char= n #\8) 8)
        ((char= n #\9) 9)
        ((char= n #\0) 0)))
(defun f (k)
  (reduce #'+ (mapcar #'parse-int-ex (concatenate 'list (format nil "~A" k)))))
(let* ((n (read)))
  (if (= 0 (mod n (f n))) (princ "Yes") (princ "No")))


Measured memory_bytes: 7272
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll ans=0;
  REP(i,1,n+1) ans+=i;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
			const int COIN = 500;
			var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
			var _K = input[0];
			var _X = input[1];
			Console.WriteLine(COIN * _K >= _X ? "Yes" : "No");

#if DEBUG
			Console.ReadKey();
#endif
        }
		#region 最大公約数、最小公倍数
		static long Lcm(long a, long b) => a * b / Gcd(a, b);
		static long Gcd(long a, long b) => a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
		static long GcdRecursive(long a, long b) => b == 0 ? a : GcdRecursive(b, a % b);
		#endregion
	}
}

Measured memory_bytes: 13268