akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;

int main() {
    int h,w;
    cin >> h >> w;
    rep(i,w+2) cout << '#' ;
    cout << endl;
    rep(i,h){
        string s;
        cin>>s;
        cout << '#'<<s<<'#' <<endl;
    }
    rep(i,w+2) cout << '#' ;
    cout << endl;
}

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

int main()
{
	int n;
	string s;
	cin>>n;
	cin>>s;
	int ans=0;
	for(int i=1;i<n;i++)
	{
		if(s[i]!=s[i-1])
		{
			ans++;
		}
	}
	ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	sort(a, a + n);
	
	bool ans = true;
	if(n % 3 == 0) {
		int m = n / 3;
		inc(i, n) { ans &= (a[i] == a[i / m * m]); }
		ans &= ((a[0] ^ a[m]) == a[2 * m]);
	} else {
		ans = (a[n - 1] == 0);
	}
	
	cout << (ans ? "Yes" : "No") << endl;	
}


Measured memory_bytes: 640
a, b, c, d = [int(i) for i in input()]
for i in range(8):
    p = ["+"if i & j else"-" for j in[1, 2, 4]]
    line = "{0}{1}{2}{3}{4}{5}{6}".format(a, p[0], b, p[1], c, p[2], d)
    if eval(line) == 7:
        print(line + "=7")
        break


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 1e6 + 5;

int n, a[N], d, cnt[N], mx;
bool ok;

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

int main() {
	cin>>n;
	rep(i, 1, n) scanf("%d", &a[i]), cnt[a[i]]++, mx = max(mx, a[i]);
	d = a[1];
	rep(i, 2, n) d = gcd(d, a[i]);
	if(d > 1) {
		cout<<"not coprime"<<endl;
		return 0;
	}
	rep(i, 2, mx) {
		if(cnt[i] > 1) {
			ok = 1;
			break;
		}
		int tot = cnt[i];
		for(int j = 2; j*i <= mx; j++) 
			if(cnt[j*i]) {
				tot += cnt[j*i];
				if(tot > 1) {
				    ok = 1; 
					break;
				}
			}
		if(ok) break;
	}
	if(ok) cout<<"setwise coprime"<<endl;
	else cout<<"pairwise coprime"<<endl;
}

Measured memory_bytes: 11444
#include<stdio.h>
#include<math.h>
int main()
{
     int i,x,j,k,y,z,r,l,n,m,count=0,c=0;

    scanf("%d %d",&n,&m);
    for(i=n; i<=m; i++)
    {
        l=5;
        x=i;
        c=0;
        while(x!=0)
        {
            l--;
            r=x%10;
            c=(c*10)+r;
            x=x/10;
        }
        if(c==i)
            count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		String ans = "";

		if ( A <=C && C <=B ) {
			ans = "Yes";
		} else {
			ans = "No";
		}

		System.out.println( ans );
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#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(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(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=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  int ans=0;
  REP(i,1,n+1) {
    string s;
    stringstream ss;
    ss << i;
    ss >> s;
    if(s.size()%2) ans++;
  }
  pr(ans);
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
stack<int> st;
int n,m;
vector<int> v[100010];
int d[100010];
int ind[100010];
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		v[x].push_back(y);
		ind[y]++;
	}
	for (int i=0;i<n;i++) if (!ind[i]) st.push(i);
	fill(d,d+n,0);
	while (!st.empty())
	{
		int x=st.top();
		st.pop();
		for (int i=0;i<v[x].size();i++)
		{
			int xi=v[x][i];
			d[xi]=max(d[xi],d[x]+1);
			ind[xi]--;
			if (!ind[xi]) st.push(xi);
		}
	}
	cout <<*max_element(d,d+n);
	return 0; 
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    map<string, int> mp;
    string S[110], T[110];
    cin >> N;
    rep(i, N) {
        cin >> S[i];
        mp[S[i]]++;
    }
    cin >> M;
    rep(i, M) {
        cin >> T[i];
        mp[T[i]]--;
    }
    int ans = 0;
    rep(i, N) {
        ans = max(ans, mp[S[i]]);
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    int N;
    pair<int, int> T[200000];
    int L[200000]={};
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> T[i].second >> T[i].first;
    }
    sort(T, T+N);
    L[0] = T[0].second;
    if(L[0] > T[0].first){
        cout << "No" << endl;
        return 0;
    }
    for(int i=1;i<N;i++){
        L[i] += L[i-1] + T[i].second; 
        if(L[i] > T[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#define MAX 2000000

int H , A[MAX+1];

void maxHeapify(int i)
{
	int tmp;
	int l , r , largest;
	l = 2*i;
	r = 2*i+1;
	
	if( l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	if(r <= H && A[r] > A[largest] ) largest = r;
	
	if(largest != i)
	{
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(largest);
	}
}

int main(void)
{
	scanf("%d",&H);
	
	for( int i = 1; i <= H; i++) scanf("%d",&A[i]);
	for( int i = H/2; i >= 1; i--) maxHeapify(i);
	for( int i = 1; i <= H; i++)
	{
		printf(" %d",A[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int a, b, x;

	scanf("%d", &x);
	scanf("%d", &a);
	scanf("%d", &b);

	if (abs(x-a) > abs(x-b)) {
		printf("B");
	}
	else {
		printf("A");
	}
}

Measured memory_bytes: 128
const lines=readlines(open("/dev/fd/0"))
let
    state=0
    global input
    input()=lines[state+=1]
end
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    s=int(input())
    print(["NA","MMYY","YYMM","AMBIGUOUS"][1+(9<s<1e3)+(0<s%100<13)*2])
end
main()

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

const int INF = 987654321;
const int SIZE = 200001;
int RMQ[2][4 * SIZE];
int p[SIZE];
int idx[SIZE];
int N;

struct range {
	int m;
	int l;
	int r;
};

struct Cmp {
	bool operator() (range &a, range &b) {
		return a.m > b.m;
	}
};

int min(int a, int b) {
	return a < b ? a : b;
}

int init(int node, int left, int right, int parity)
{
	int &ret = RMQ[parity][node];
	if (left == right)
		return ret = ((left % 2) == parity ? p[left] : INF);
	int mid = (left + right) / 2;
	return ret = min(init(2 * node, left, mid, parity), init(2 * node + 1, mid + 1, right, parity));
}

int query(int left, int right, int node, int nLeft, int nRight, int parity)
{
	if (right < nLeft || nRight < left)
		return 987654321;
	if (left <= nLeft && nRight <= right)
		return RMQ[parity][node];
	int nMid = (nLeft + nRight) / 2;
	return min(query(left, right, 2 * node, nLeft, nMid, parity),
		query(left, right, 2 * node + 1, nMid + 1, nRight, parity));
}

int q(int left, int right, int parity) {
	if (left > right)
		return INF;
	return query(left, right, 1, 0, N - 1, parity);
}
	
int main()
{
	int p1 = 0, p2 = 1;
	range tmp;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		idx[p[i]] = i;
	}
	init(1, 0, N - 1, 0);
	init(1, 0, N - 1, 1);
	priority_queue<range, vector<range>, Cmp> pq;
	tmp.l = 0;
	tmp.r = N - 1;
	tmp.m = q(0, N - 1, 0);
	pq.push(tmp);
	while (!pq.empty()) {
		range now = pq.top();
		pq.pop();
		if (now.m == INF)
			continue;
		int second = q(idx[now.m] + 1, now.r, (idx[now.m] + 1) % 2);
		printf("%d %d ", now.m, second);
		tmp.l = now.l;	tmp.r = idx[now.m] - 1; 
		if (tmp.l < tmp.r) {
			tmp.m = q(tmp.l, tmp.r, tmp.l % 2);
			pq.push(tmp);
		}
		tmp.l = idx[now.m] + 1;	tmp.r = idx[second] - 1; 
		if (tmp.l < tmp.r) {
			tmp.m = q(tmp.l, tmp.r, tmp.l % 2);
			pq.push(tmp);
		}
		tmp.l = idx[second] + 1; tmp.r = now.r; 
		if (tmp.l < tmp.r) {
			tmp.m = q(tmp.l, tmp.r, tmp.l % 2);
			pq.push(tmp);
		}
	}
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;
int main()
{
    // cout << (ll)ceilf128(1000000000000.262) << endl;
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, l = 1, r = 1, l1, r1, tmp, l_tmp, r_tmp;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> l1 >> r1;
        // if (l1 >= l and r1 >= r)
        // {
        //     l = l1;
        //     r = r1;
        // }
        // else
        // {
        l_tmp = mod_ceil(l, l1);
        r_tmp = mod_ceil(r, r1);
        // l_tmp = (l % l1) ? l / l1 + 1 : l / l1;
        // r_tmp = (r % r1) ? r / r1 + 1 : r / r1;
        tmp = max(l_tmp, r_tmp);
        l = tmp * l1;
        r = tmp * r1;
        // }
    }
    tmp = l + r;
    cout << tmp << endl;
}

Measured memory_bytes: 256
x,y,n = gets.split.map(&:to_i)
z = 0
w = 0

n.times do
  a,b,c = gets.split.map(&:to_i)

  if c == 1
    z = a if a > z
  elsif c == 2
    x = a if x > a
  elsif c == 3
    w = b if b > w
  elsif c == 4
    y = b if y > b
  end
end

x = z = 0 if (x < z)
y = w = 0 if (y < w)

puts (x-z)*(y-w)


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

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

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in(),A=in(),B=in();
	vll H=vecin(N);

	sort(ALL(H),greater<ll>());

	ll ng = 0;
	ll ok = 1ll<<32;
	while (abs(ok - ng) > 1ll) {
		ll mid = (ok + ng) / 2ll;
		ll K=0;
		REP(i,N){
			ll R=max(H[i]-mid*B,0ll);
			K += (R+A-B-1ll)/(A-B);
		}
		if(K<=mid) ok = mid;
		else ng = mid;
	}

	out(ok);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
/*英小文字からなる文字列Sが与えられます。 
Tが空文字列である状態から始め、以下の操作を好きな回数繰り返すことで 
S=Tとすることができるか判定してください。
Tの末尾に dream dreamer erase eraser のいずれかを追加する。*/
using namespace std;

int main() {
	string s;
	cin >> s;
	string dreamer = "dreamer";
	string dream = "dream";
	string erase = "erase";
	string eraser = "eraser";
	reverse(begin(dreamer), end(dreamer));
	reverse(begin(dream), end(dream));
	reverse(begin(erase), end(erase));
	reverse(begin(eraser), end(eraser));
	
	reverse(begin(s), end(s));
	while (1) {
		/*if (s.size() == 0) {
			break;
		} else if (s.substr(0, 5) == dream) {
			s = s.substr(5, s.size() - 5);
		} else if (s.substr(0, 7) == dreamer) {
			s = s.substr(5, s.size() - 7);
		} else if (s.substr(0, 5) == erase) {
			s = s.substr(5, s.size() - 5);
		} else if (s.substr(0, 6) == eraser) {
			s = s.substr(6, s.size() - 6);
		} else {
			cout << "NO" << endl;
			return 0;
		}*/
		if(s.size()==0)break;
		else if(s.substr(0,5)=="maerd")s=s.substr(5,s.size()-5);
		else if(s.substr(0,7)=="remaerd")s=s.substr(7,s.size()-7);
		else if(s.substr(0,5)=="esare")s=s.substr(5,s.size()-5);
		else if(s.substr(0,6)=="resare")s=s.substr(6,s.size()-6);
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,ll> P;

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

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

// N^P mod M（ただしM == -1の時はmodを取らない）
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

ll d[500][500]; //d[u][v]は辺e=(u,v)のコスト（存在しない場合はINF、ただしd[i][i]=0とする）
int V; //頂点数

void init() {
    for(int i = 0;i < 500;i++) {
        for(int j = 0;j < 500;j++) {
            if(i == j) {
                d[i][j] = 0;
            }
            else {
                d[i][j] = INF;
            }
        }
    }
}

void warshall_floyd() {
	for(int k = 0;k < V;k++) {
		for(int i = 0;i < V;i++) {
			for(int j = 0;j < V;j++) {
				d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
			}
		}
	}
}

int main() {  
    cin >> V;
    int M;
    ll L;
    cin >> M >> L;
    init();
    for(int i = 0;i < M;i++) {
        int A,B;
        ll C;
        cin >> A >>  B >> C;
        A--;
        B--;
        d[A][B] = C;
        d[B][A] = C;
    }
    warshall_floyd();
    ll cnt[500][500];
    for(int i = 0;i < 500;i++) {
        for(int j = 0;j < 500;j++) {
            cnt[i][j] = d[i][j];
        }
    }
    init();
    for(int i = 0;i < V;i++) {
        for(int j = 0;j < V;j++) {
            if(cnt[i][j] <= L) {
                d[i][j] = 1;
            }
        }
    }
    warshall_floyd();
    int Q;
    cin >> Q;
    for (int i = 0;i < Q;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        if(d[A][B] == INF) {
            cout << -1 << endl;
        }
        else {
            cout << d[A][B] - 1 << endl;
        }
    }
}       
          
        

Measured memory_bytes: 7544
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    for(int i = 1; i <= 5; i++){
        int x;
        cin >> x;
        if(x ==0) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define in insert
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d ",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
//#define scan(v) for(int i = 0; i<n; i++){int x;cin>>x;v.pb(x);}
#define pi 2 * acos (0.0)
#define inf 1e9
#define co cout
#define en '\n'
#define re return
#define con continue
#define dbg cout<<"___________ok____________"<<endl;
#define yes() printf("YES\n");
#define no() puts("NO");
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(j-1); i>=k; i--)
#define all(v) v.begin(), v.end()
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
#define prn(v) for(auto x: v)cout<<x<<" ";
//typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 2e5 + 5;


int main()
{

    FAST_IO;
    char c;cin>>c;
    co<<char(c + 1)<<en;
    return 0;
}


Measured memory_bytes: 256
def collatz(n):
    if n % 2 == 0:
        return n // 2
    else:
        return n * 3 +1
while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    while n != 1:
        n = collatz(n)
        a += 1
    print(a)


Measured memory_bytes: 5588
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int n=sc.nextInt();
    	int a=sc.nextInt();
    	int b=sc.nextInt();


    	int ret=n-a;

    	System.out.println(ret%b);



    }

}







Measured memory_bytes: 20560
import itertools
n, m = map(int, input().split())
G = [set() for _ in range(n)]
for _ in range(m):
    a,b = map(lambda x:int(x)-1, input().split())
    G[a].add(b)
    G[b].add(a)

P = [*itertools.permutations(range(1,n))]
ans = 0
for p in P:
    nw = 0
    for nx in p:
        if nx in G[nw]:
            nw = nx
        else:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 9360
s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
flag_no = 0
i = 0
n = len(s)
m = len(t)
while True:
  if s[i] > t[i]:
    flag_no = 1
    break
  elif s[i] < t[i]:
    flag_no = 0
    break
  else:
    if i == n-1:
      if n < m:
        flag_no = 0
        break
      else:
        flag_no = 1
        break
    elif i == m-1:
      flag_no = 1
      break
  i += 1
if flag_no == 1:
  print("No")
else:
  print("Yes")
  


Measured memory_bytes: 3064
import operator
N, C = map(int, input().split())
stc = [[int(x) for x in input().split()] for _ in range(N)]

united = []
pc,ps,pt = 0,0,0
for x in sorted(stc, key=operator.itemgetter(2,0,1)):
    s, t, c = x
    if c == pc and s == pt:
        united[-1][1] = t
    else:
        united.append([s, t, c])
    ps, pt, pc = x
cnt = [0] * (10**5 + 1)
for x in united:
    s,t,c = x
    for i in range(s - 1, t):
        cnt[i] += 1
print(max(cnt))

Measured memory_bytes: 32692
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vec(v, n) vector<int> v(n, 0);
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	int A,B;
	cin>>A>>B;
	if((A+B)%2){
		cout<<"IMPOSSIBLE"<<endl;
	}
	else{
		cout<<(A+B)/2<<endl;
	}
}

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


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

int main() {
  int H, W;
  cin >> W >> H;
  vector<char> sharp(H+2);
  for (int i=0;i<H+2;i++)
    sharp.at(i)='#';
  for(int m=0;m<H+2;m++)
  	cout << sharp.at(m);
  cout << endl;
  for (int j=0;j<W;j++){
    vector <char> vec(H+2);
    for (int k=0;k<H;k++)
      cin >> vec.at(k+1);
    vec.at(0)='#';
    vec.at(H+1)='#';
    for (int l=0;l<H+2;l++)
    	cout << vec.at(l);
    cout << endl;
  }
  for (int o=0;o<H+2;o++)
  	cout << sharp.at(o);
  cout << endl;
}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


int cnt = 0;

void insertionsort(int a[], int n, int g){
	for (int i = g; i < n; i++){
		int v = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > v){
			a[j + g] = a[j];
			j -= g;
			cnt++;
		}
		a[j + g] = v;
	}
}

signed main(){

	int n;
	int a[1000000];
	int g[100];

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

	g[0] = 1;
	int m;
	for (m = 0; g[m] <= n; m++){
		g[m + 1] = g[m] * 3 + 1;
	}

	for (int i = m-1; i >= 0; i--)
		insertionsort(a, n, g[i]);

	cout << m << endl;
	for (int i = m-1; i >= 0; i--)
		cout << g[i] << " ";
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < n; i++)
		cout << a[i] << endl;

	return 0;
}



Measured memory_bytes: 10904
import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		Integer[] mn = new Integer[n], mx = new Integer[n];
		
		for(int i = 0; i < n; i++) {
			mn[i] = sc.nextInt();
			mx[i] = sc.nextInt();
		}
		
		Arrays.sort(mn);
		Arrays.sort(mx);
		
		if(n % 2 == 1) {
			int lo = mn[n/2], hi = mx[n/2];
			out.println(hi - lo + 1);
		}else {
			int lo = mn[(n - 1)/2] + mn[n / 2];
			int hi = mx[(n - 1)/2] + mx[n / 2];
			out.println(hi - lo + 1);
		}
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}

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

#define SEG_NUM (1<<20)

int seg[SEG_NUM*2];

int getSum(int x, int y){
    x += SEG_NUM;
    y += SEG_NUM;
    int ans = 0;
    while(x < y){
        if(x % 2 == 1){
            ans += seg[x];
            x++;
        }
        x /= 2;
        if(y % 2 == 1){
            ans += seg[y - 1];
            y--;
        }
        y /= 2;
    }
    return ans;
}

void add(int x, int y){
    x += SEG_NUM;
    seg[x] += y;
    while(x > 0){
        x /= 2;
        seg[x] = seg[2*x] + seg[2*x+1];
    }
}

int main() {
    int n, q;
    cin>>n>>q;
    int com, x, y;
    for(int i=0;i<q;++i){
        cin>>com>>x>>y;
        if(com){
            cout<<getSum(x, y+1)<<endl;
        }
        else {
            add(x, y);
        }
    }
}


Measured memory_bytes: 3892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n, a;
    cin >> n >> a;
    if(n%500<=a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int N, a, now = 0, cnt = 0;
	cin >> N;
	vector<int> A;
	rep(i, N) {
		cin >> a;
		a--;
		A.push_back(a);
	}

	while (1) {
		if (now == 1) {
			cout << cnt << endl;
			return 0;
		}
		if (cnt >= N) {
			cout << -1 << endl;
			return 0;
		}
		cnt++;
		now = A[now];
	}

	return 0;
}

Measured memory_bytes: 892
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(int, X, N);
    set<int> p;
    rep(i, 0, N) {
        var(int, e);
        p.insert(e);
    }

    int ans = -1;
    int diff = INF;
    repc(i, 0, 101) {
        if (p.count(i)) continue;
        if (chmin(diff, abs(X - i))) ans = i;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2==0){
        cout << a-b << endl;
    }else{
        cout << b-a << endl;
    }
    return 0; 
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 200002
using namespace std;

// 5 = 12+3 = 15/5 = 3
// 6*2.5 = 15/5 = 3
// 4 = 10/4 = 2.5

// 6 = 7*3 = 21/6 = 3.5
// 5 = 6*2.5 = 15 /5 =3
// 4 = 5*2 = 10/4 = 2.5
// 2 = 3*1 = 3/2 = 1.5
// 1 = 2*0.5 = 1/1 =1

int main(){
    int n,k;
    cin>>n>>k;
    vector<double> A(n+1);
    for(int i=0; i<n; i++){
        double a;
        cin>>a;
        a = (a+1) * (a/2) /a;
        A[i] = a;
    }
    double sum = 0;
    for(int i = 0; i< k; i++){
        sum+= A[i];
    }
    double ans;
    ans = sum;
    for(int i = k; i<n; i++){
        int j = i-k; 
        sum += A[i];
        sum -= A[j];
        ans = max(sum, ans);
    }
    cout<< fixed << setprecision(10) << ans <<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min({a+b,b+c,c+a})<<endl;
    return 0;
}

Measured memory_bytes: 256
n, a = map(int, input().split())
x = list(map(int, input().split()))

# dp[添え字][枚数][合計] = 選び方
total = sum(x)
dp = [[[0] * (total + 1) for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(total + 1):
            if k + x[i] <= total:
                dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]
            dp[i + 1][j][k] += dp[i][j][k]

ans = 0
for j in range(1, n + 1):
    for k in range(total + 1):
        if k / j == a:
            ans += dp[n][j][k]
print(ans)


Measured memory_bytes: 93148
N,M=map(int, input().split())
G=[list() for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
ans=0
index=-1
for i in range(1,N):
    for p in G[i]:
        if index<p<i:
            ans+=1
            index=i-1
print(ans)


Measured memory_bytes: 21424
import sys
input = sys.stdin.readline
def gcd(a, b):
    while b: a, b = b, a % b
    return a

N = int(input())
S = 0
Y = []
for i in range(N):
    a, b = map(int, input().split())
    if b > a:
        S += b-a
        Y.append((b, b, b-a, 0))
    else:
        Y.append((a, b, 0, a-b))

Y = sorted(Y)
YY = [0] * (N+1)
for i in range(N):
    YY[i+1] = YY[i] + Y[i][0]

def f(i, n):
    if Y[i][2]:
        return S - YY[n] if n <= i else S - (YY[n+1] - Y[i][0])
    return S - Y[i][3] - YY[n] if n <= i else S - Y[i][3] - (YY[n+1] - Y[i][0])

maa, mab = 0, 1
for i in range(N):
    l = 0
    r = N
    while r - l > 1:
        m = (l+r) // 2
        if f(i, m) >= 0:
            l = m
        else:
            r = m

    a = l * Y[i][1] + min(f(i, l), Y[i][1])
    b = N * Y[i][1]
    if a * mab > b * maa:
        maa, mab = a, b

g = gcd(maa, mab)
print(maa//g, mab//g)

Measured memory_bytes: 64200
#include<iostream>

using namespace std;

int main(void){

  int N;

  cin >> N;

  long long A[N];
  long long S[N];
  long long m =1e9+7;

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

  long long sum = 0;


  S[0]=A[0] % m;

  for(int i = 1;i < N;i++){
    S[i] = (S[i-1] + A[i]) % m;
  }


  for(int i = 0;i < N-1;i++){
    sum += A[i]*(S[N-1]-S[i]+m) % m;
    sum = sum % m;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 6748
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;
int n;
int main() {
	read(n);rep(i,0,18)if((1<<i)==n){puts("No");return 0;}
	puts("Yes");
	for(int i=1;i*2+1<=n;i++){
		printf("%d %d\n",1,i*2);
		printf("%d %d\n",1,i*2+1);
		printf("%d %d\n",i*2,i*2+1+n);
		printf("%d %d\n",i*2+1,i*2+n);
	}
	printf("%d %d\n",1+n,2+n);
	if(n%2==0){
		int c=n^1;
		rep(i,2,n)if((c^i)<=n){
			printf("%d %d\n",n,i);
			printf("%d %d\n",n*2,c^i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <complex>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
using namespace std;

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

	int a, b, q; cin >> a >> b >> q;
	vector<ll> s(a), t(b);
	ll x = 0;
	rep(i, 0, a) cin >> s[i];
	rep(i, 0, b) cin >> t[i];
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	s.push_back(INF);
	t.push_back(INF);

	rep(i, 0, q) {
		ll ans = INF;
		cin >> x;
		ll al = upper_bound(s.begin(), s.end(), x) - s.begin();
		ll ar = upper_bound(s.begin(), s.end(), x) - s.begin();
		ll bl = upper_bound(t.begin(), t.end(), x) - t.begin();
		ll br = upper_bound(t.begin(), t.end(), x) - t.begin();
		--bl; --al;


		ll c = abs(x - (al < 0 ? INF : s[al]));
		ll d = abs(x - t[br]);
		ll e = abs(x - s[ar]);
		ll f = abs(x - (bl < 0 ? INF : t[bl]));

		ll k1 = c + d + min(c, d);
		ll k2 = max(c, f);
		ll k3 = max(d, e);
		ll k4 = f + e + min(f, e);
		ans = min(ans, min(k1, min(k2, min(k3, k4))));
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 5584
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int ans = 0;

      if (N >= 10) {
        ans += 9;
      } else {
        ans += N;
      }

      if (N >= 1000) {
        ans += 900; // 100 ~ 999
      } else if (N >= 100) {
        ans += N - 100 + 1;
      }

      if (N >= 100000) {
        ans += 90000; // 10000 ~ 99999
      } else if (N >= 10000) {
        ans += N - 10000 + 1;
      }

      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

ll n, cnt[300009] = {}, cnt2[300009] = {}, mx[300009] = {};

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

    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    rep(i, n + 1) cnt2[cnt[i]]++;
    FOR(i, 1, n + 1) mx[i] = mx[i - 1] + i * cnt2[i];
    ll sum = 0;
    for(int i = n - 1; i > 0; i--)
        (mx[i] += i * (sum += cnt2[i + 1])) /= i;
    mx[n] /= n;
    mx[0] = 1e18;

    int x = n;
    FOR(i, 1, n + 1) {
        while(mx[x] < i)
            x--;
        cout << x << endl;
    }
}

Measured memory_bytes: 7936
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }

int N, W;
vector<int> v;
vector<int> w;
vector<int> dp;

// dp[i][u]: Maximum value using products (<i) under the weight limit <=u
//   dp[i][u] = max_k(dp[i-1][u - k * w[i]] + k * v[i])

// int knapsack() {
//     for (int i = 0; i < N; ++i)
//         for (int u = 0; u <= W; ++u)
//             for (int k = 0; k * w[i] <= u; ++k)
//                 dp[i+1][u] = max(dp[i+1][u], dp[i][u - k * w[i]] + k * v[i]);
//     return dp[N][W];
// }

// int knapsack() {
//     for (int i = 0; i < N; ++i)
//         for (int u = 0; u <= W; ++u)
//             dp[i+1][u] = w[i] <= u ? max(dp[i][u], dp[i+1][u - w[i]] + v[i]) : dp[i][u];
//     return dp[N][W];
// }

int knapsack() {
    for (int i = 0; i < N; ++i)
        for (int u = w[i]; u <= W; ++u)
            dp[u] = max(dp[u], dp[u - w[i]] + v[i]);
    return dp[W];
}

int main() {
    cin >> N >> W;
    int s, t;
    for (int i = 0; i < N; ++i) {
        cin >> s >> t;
        v.push_back(s);
        w.push_back(t);
    }
    dp = vector<int>(W + 5, 0);
    int ans = knapsack();
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <math.h>
int i,j,k,count1=0;
using namespace std;
void ABC110(void);
void ABC111(void);
void ABC112(void);
void ABC113(void);
void ABC114(void);
void ABC115(void);
void ABC116(void);
void ABC117(void);
void ABC118(void);
void ABC119(void);

int main(void){
    ABC116();
}

void ABC116(){
    int ans,s,min;
    cin>>s;
    vector<int> vec(10000,0);
    vec[s]++;
    for(i=2;1;i++){
        if(s%2==1)s=3*s+1;
        else s/=2;
        cerr<<s<<" ";
        vec[s]++;
        if(vec[s]>=2){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
typedef long long ll;
using namespace std;
ll ans=0;
int main(){
	map<string,int> m;
	string s;
	int n;
	cin>>n;
	while(n--){
		cin>>s;
		sort(s.begin(),s.end());
		ans=ans+m[s]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int d, t, s;
  cin >> d >> t >> s;

  double ds = d;
  double time = ds / s;
  if (time <= t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  
  if(S == "SUN"){
    cout << 7 << endl;
  }
  
   if(S == "MON"){
    cout << 6 << endl;
  }
  
   if(S == "TUE"){
    cout << 5 << endl;
  }
  
   if(S == "WED"){
    cout << 4 << endl;
  }
  
   if(S == "THU"){
    cout << 3 << endl;
  }
  
   if(S == "FRI"){
    cout << 2 << endl;
  }
  
   if(S == "SAT"){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
a,b,q=map(int,input().split())
import bisect
inf=10**18
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
x=[int(input()) for _ in range(q)]
s=[-inf]+s+[inf]
t=[-inf]+t+[inf]
for q in x:
    c,d=bisect.bisect_left(s,q),bisect.bisect_left(t,q)
    ans=float("inf")
    for i in [c,c-1]:
        for j in [d,d-1]:
            ans=min(ans,abs(s[i]-t[j])+abs(q-s[i]),abs(s[i]-t[j])+abs(q-t[j]))
    print(ans)
    

Measured memory_bytes: 16772
import itertools
N = int(input())
L = list(map(int,input().split()))
tri_list = list(itertools.combinations(L,3))
num = 0
for i in range(len(tri_list)):
    combi = tri_list[i]
    if (combi[0] != combi[1]) and (combi[1] != combi[2]) and (combi[2] != combi[0]):
        if ((abs(combi[0] - combi[1])) < combi[2]) and (combi[2] < (combi[0] + combi[1])):
            num += 1
print(num)

Measured memory_bytes: 20536
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(10000)

"""考え方
L0 : P
L1 : BPPPB
L2 : BBPPPBPBPPPBB
L3 : BBBPPPBPBPPPBBPBBPPPBPBPPPBBB
L4 : ...

・レベルが1上がると、Pの数は2倍+1になる
・レベルが1上がると、総数は2倍+3になる


レベルiバーガーの厚さ（層の総数）をa_iとする
レベルiバーガーに含まれるパティの総数をp_iとする
「レベルNバーガーの下からX層に含まれるパティの枚数」をf(N,X)とする。

・N = 0のとき
f(0,X) = 1

・N >= 1のとき
f(N-1, Y)がわかると仮定すると、

(1) X = 1のとき、f(N,X) = 0 (一番下のバンだけ)

(2) 1 < X <= 1 + a_{i-1} のとき、f(N,X) = f(N-1, X-1)

i=2のとき、L2のときで
BBPPPB PBPPPBB
BPPPBB|ここまでのとき

(3) X = 2 + a_{i-1}のとき、f(N,X) = p_{i-1}+1
???


https://www.youtube.com/watch?v=1ONpCPN-IR8
"""
def solve():
    N, X = list(map(int, sys.stdin.readline().split()))

    As = [1]  # レベルiバーガーの厚さ（層の総数）
    Ps = [1]  # レベルiバーガーのパティの総数

    for i in range(N):
        As.append(As[i]*2 + 3)  # レベルが1上がると、総数は2倍+3になる
        Ps.append(Ps[i]*2 + 1)  # レベルが1上がると、パティの数は2倍+1になる


    def _dfs(depth, x):
        """ レベルdepthバーガーの、下からX層に含まれるパティの枚数を返す """
        if depth == 0:
            return 0 if x <= 0 else 1
        elif x <= 1 + As[depth-1]:
            # 一番下のパン + その上のレベル N-1 バーガー + その上のパティ
            return _dfs(depth-1, x-1)
        else:
            # (前略) + その上のパティ + その上のレベル N-1 バーガーの下から x-2-As[depth-1]層
            return Ps[depth-1] + 1 + _dfs(depth-1, x-2-As[depth-1])

    ans = _dfs(N, X)

    print(ans)


def solve2():
    N, X = list(map(int, sys.stdin.readline().split()))

    As = [1]  # レベルiバーガーの厚さ（層の総数）（必ず奇数）
    Ps = [1]  # レベルiバーガーのパティの総数

    for i in range(N):
        As.append(As[i]*2 + 3)  # レベルが1上がると、総数は2倍+3になる
        Ps.append(Ps[i]*2 + 1)  # レベルが1上がると、パティの数は2倍+1になる

    def f(n, x):
        """レベルnバーガーの下からx層食べたときの、食べたパティの総数"""
        if n == 0:
            return 0 if x <= 0 else 1

        median = (As[n]+1)//2

        if x < median:
            return f(n-1, x-1)
        elif x == median:
            return Ps[n-1] + 1
        elif x > median:
            return Ps[n-1] + 1 + f(n-1, x-median)

    ans = f(N, X)

    print(ans)


def solve3():
    As = [1]  # レベルiバーガーの厚さ（層の総数）（必ず奇数）
    Ps = [1]  # レベルiバーガーのパティの総数

    for i in range(N):
        As.append(As[i]*2 + 3)  # レベルが1上がると、総数は2倍+3になる
        Ps.append(Ps[i]*2 + 1)  # レベルが1上がると、パティの数は2倍+1になる

    # dpでもいけるはず？


if __name__ == "__main__":
    solve2()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1ll << 60

using namespace std;
typedef long long ll;

ll Binary_search(const vector<ll>& d, const vector<ll> &a, ll l, ll r, const ll k) {
	if (l > r)
		return l;
	ll i, sum = 0, p = (r + l) >> 1;
	for (i = 0; i < d.size(); i++) {
		sum += max(0ll, d[i] - p / a[i]);
	}
	if (sum <= k) {
		return min(p, Binary_search(d, a, l, p - 1, k));
	}
	else
		return Binary_search(d, a, p + 1, r, k);
}

int main(void) {
	int num;
	ll i, k;
	cin >> num >> k;
	vector<ll> d(num), a(num);
	for (i = 0; i < num; i++)
		scanf("%lld", &d[i]);
	for (i = 0; i < num; i++)
		scanf("%lld", &a[i]);
	sort(d.begin(), d.end(), greater<ll>());
	sort(a.begin(), a.end());
	cout << Binary_search(d, a, 0, d[0] * a[num - 1], k) << "\n";
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int ans = 0;
    int N; cin >> N;
    string S; cin >> S;
    for(int i = 0; i <= 999; i++){
        int val = i;
        int chk[3];
        chk[0] = val%10; val/=10;
        chk[1] = val%10; val/=10;
        chk[2] = val%10; val/=10;
        int idx = 0;
        for(int j = 0; j < S.length(); j++){
            if(chk[idx] == S[j]-'0') idx++;
            if(idx == 3) break;
        }
        if(idx == 3) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	string s;
	cin >> s;
	bool b = true, p = false;
	for(int i=0; i< s.size(); i++){
		if(b && s[i] == 'A'){b = false;}
		if(!b && s[i] == 'Z'){b = true; cout << "AZ"; p = true;}
	}
	if(!p) cout << -1 << endl;
	if(p) cout << endl;
}

Measured memory_bytes: 1184