akhauriyash/Code-Regression huggingface dataset:
// 1位の人の解答見て書いた
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair <int, int> P;

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> S(H);
  vector<vector<bool>> use(H, vector<bool>(W));

  for (int i = 0; i < H; i++) {
    cin >> S.at(i);
  }

  ll ret = 0;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (use.at(i).at(j)) continue;

      queue <P> que;
      que.push(P(i, j));

      use.at(i).at(j) = true;

      int w = 0, b = 0;

      while (!que.empty()) {
        P p = que.front();
        que.pop();

        //cout << "(" << p.first << ", " << p.second << ")" << endl;

        if (S.at(p.first).at(p.second) == '.') w++;
        else if (S.at(p.first).at(p.second) == '#') b++;

        for (int t = 0; t < 4; t++) {
          int x = p.second + dx.at(t);
          int y = p.first + dy.at(t);

          if (x >= 0 && x < W && y >= 0 && y < H) {
            if (S.at(p.first).at(p.second) != S.at(y).at(x) && !use.at(y).at(x)) {
              use.at(y).at(x) = true;
              que.push(P(y, x));
            }
          }
        }
      }
      ret += (ll)w * (ll)b;
    }
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 512
s = raw_input()
[a,b,c,d] = [int(t) for t in s]
if a + b + c + d == 7:
    print str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7'
elif a + b + c - d == 7:
    print str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7'
elif a + b - c + d == 7:
    print str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7'
elif a + b - c - d == 7:
    print str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7'
elif a - b + c + d == 7:
    print str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7'
elif a - b + c - d == 7:
    print str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7'
elif a - b - c + d == 7:
    print str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7'
elif a - b - c - d == 7:
    print str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7'


Measured memory_bytes: 2696
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;


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




    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 998244353
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve(){
    int n;
    cin >> n;
    string ans;
    if(n<=26){
        char an = 'a' + n - 1;
        cout << an;
        return;
    }
    while(n){
        int val = n % 26;
        if(val==0){
            ans.pb('z');
            n -= 26;
            n /= 26;
        }
        else{
            ans.pb( 'a' + val-1);
            n /= 26;

        }
        //cout << ans;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}

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

int main(){
  ll n,m,v,p;
  cin>>n>>m>>v>>p;
  ll a[100005];
  rep(i,n) cin>>a[i];
  sort(a,a+n);
  reverse(a,a+n);
  ll sum1=0,sum2=0;
  rep(i,n){
    if(i<p-1) sum1+=a[i];
    else sum2+=a[i];
  }
  int l=0,r=n;
  while(l+1!=r){
    int mid=(l+r)/2;
    if(a[mid]+m<a[p-1]){
      r=mid;
      continue;
    }
    ll sum=0;
    for(int i=p-1;i<n;i++){
      sum+=min(a[mid]+m-a[i],m);
    }
    if(sum+m*(p-1)<v*m) {
      r=mid;
      continue;
    }
    l=mid;
  }
  cout<<r<<endl;
  return 0;
}




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

int main() {
  string T;
  cin >> T;
  
  for (int i = 0; i < T.length(); i++) {
    if (T.at(i) == '?') {
      T.at(i) = 'D';
    }
  }
  
  cout << T << endl;  
}


Measured memory_bytes: 3720
#include<stdio.h>
int main(){
int n,x[2021],m,i,b,j,a[101];
for(i=0;i<2020;i++){
x[i]=0;
}
scanf("%d\n",&n);
for(i=0;i<n;i++){
scanf("%d",&b);
x[b]=i+1;
a[i+1]=b;
}
scanf("\n");
scanf("%d\n",&m);
for(i=0;i<m;i++){
scanf("%d",&b);
for(j=0;j<2020;j++){
if(x[j]==b){
if(x[j+1]==0){
x[j+1]=b;
x[j]=0;
a[b]=a[b]+1;
}
break;
}
}
}
for(i=0;i<n;i++){
printf("%d\n",a[i+1]);
}
return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {

    string S;
    int K;
    cin >> S >> K;
    vector<string>ans;


    for (int i = 0; i <S.size(); i++) {
        for (int j = 1; j <= K; j++) {
            ans.push_back(S.substr(i, j));
        }
    }

    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());

    cout << ans[K - 1];

    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {

    int n;

    cin >> n;

    if(n < 105) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1; // 105

    for(int i = 107; i <= n; i += 2) {

        int sum = 0;
        // cout << i << " : ";
        for(int j = 1; j * j <= i; ++j) {

            if(i % j != 0)
                continue;

         //   cout << j << " ";

            sum++;
            if(j * j != i)
                sum++;

        }

       // cout << endl;

        if(sum == 8)
            ans++;

    }



    cout << ans << endl;

    return 0;

}

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

using namespace std;
using ll = long long;
using P = pair<int ,int>;
using  vi = vector<int>;
using vii = vector<P>;

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

#define INF 1LL << 62
#define MOD (int)1e9 + 7
#define rep(i,n) for(int i = 0;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back

int main() {

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	s1[0] = toupper(s1[0]);
	s2[0] = toupper(s2[0]);
	s3[0] = toupper(s3[0]);
	cout << s1[0] << s2[0] << s3[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

vector<int> G[100010];
int ans = 0;

bool dfs(int c, int p, bool f = 0) {
	//枝分かれがあるかを返す
	if (G[c].size() == 1 && !f) {
		return 1;
	}
	if (G[c].size() == 2) {
		for (int i : G[c]) {
			if (i == p)continue;
			return dfs(i, c);
		}
	}
	int cnt = 0;
	for (int i : G[c]) {
		if (i == p)continue;
		if (dfs(i, c))cnt++;
	}
	ans += max(cnt - 1, 0);
	return 0;
}

int main() {
	int N, x, y;
	cin >> N;
	for (int i = 1;i < N;i++) {
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	x = -1;
	for (int i = 0;i < N;i++) {
		if (G[i].size() > 2) {
			x = i;break;
		}
	}

	if (x == -1) {
		cout << 1 << endl;
		return 0;
	}

	dfs(x, -1, 1);
	cout << ans << endl;
}

Measured memory_bytes: 6272
#include <stdio.h>


int main() 
{
    int a, b, c, x, f, i, t, min, max, d, sum = 0, bb;
    
	scanf("%d%d%d%d", &a, &b, &c, &x);
	
	x /= 50, bb = b << 1;
	if(x & 1){
		if((c & 1) == 0) c--;	
	}
	else{
		if(c & 1) c--;
	}
    for(i = t = 0; i <= a && t <= x; t += 10, i++){
    	d = x - t;
    	if(bb + c < d) continue;
    	if(d > c) min = (d - c) >> 1;		
		else min = 0;
		if(d - bb >= 0) max = b;
		else max = d >> 1;
		sum += max - min + 1;
	}
	printf("%d\n", sum);
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<int> b(N+2, 0);
    vector<int> ans(N+1, 0);
    for(int i=1; i<=N; i++) cin >> b[i];

    for(int i=N; i>=1; i--){
        bool flg = false;
        for(int j=i; j>=1; j--){
            if(b[j] == j){
                ans[i] = j;
                flg = true;
                for(int k=j; k<=i-1; k++) b[k] = b[k+1];
                break;
            }
        }

        if(!flg){
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=1; i<=N; i++) cout << ans[i] << endl;
}

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

void opera(int n);
int main(void)
{
	int n;
	
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		else {
			opera(n);
		}
	}
	
	return (0);
}

void opera(int n)
{
	int a_sum = 0;
	int b_sum = 0;
	
	
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		
		if (a == b){
			a_sum += a;
			b_sum += b;
		}
		else if (a > b){
			a_sum = a_sum + a + b;
		}
		else {
			b_sum = b_sum + a + b;
		}
	}
	
	printf("%d %d\n", a_sum, b_sum);
}

Measured memory_bytes: 1028
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
elif l % 2019 > r % 2019:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
    print(ans)


Measured memory_bytes: 3060
//https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_b

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (998244353)
#define INF (ll(1e18))

class SegmentTree {
public:
    int N, n;
    vector<ll> value;
    SegmentTree(int n) {
        this->n = n;
        this->N = 1;
        while (N < n) N *= 2;
        this->value = vector<ll>(2 * N - 1, INF);
    }
    
    void update(int i, ll x) {
        i += N - 1;
        value[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            value[i] = min(value[i * 2 + 1], value[i * 2 + 2]);
        }
    }
    
    ll query(int l, int r) {
        return _query(l, r, 0, 0, N);
    }
    
    ll _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b)
            return value[k];
        else {
            ll c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(c1, c2);
        }
    }
};

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;
    vector<ll> A(N);
    ll total = 0;
    REP(i, N) {
        cin >> A[i];
        total += A[i];
    }
    
    ll s = 0;
    ll d = total;
    REP(i, N-1) {
        s += A[i];
        d = min(abs(total-2*s), d);
    }
    
    cout << d << endl;
}


Measured memory_bytes: 1792
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
map<double,double> haha;
double eps=0.01;
double t[1234],v[1234],sumi; 
int update(double lol,double tim,double vel){
	double i;
	for(i=lol;i<=lol+tim+eps;i+=0.5){
		haha[i]=min(haha[i],vel);
	}
	double jjj=vel;
	for(i=lol;i>=0-eps;i-=0.5){
		haha[i]=min(haha[i],jjj);
		jjj+=0.5;
	}
	jjj=vel;
	for(i=lol+tim;i<=sumi+eps;i+=0.5){
		haha[i]=min(haha[i],jjj);
		jjj+=0.5;
	}
	return 0;

}
int main(){
    std::ios::sync_with_stdio(false);
    int i;
    sumi=0;
    int n;
    cin>>n;
    rep(i,n){
    	cin>>t[i];
    	//t[i]*=2;
    	sumi+=t[i];
    }
    rep(i,n){
    	cin>>v[i];
    }
    
   	for(double i=0;i<=sumi+eps;i+=0.5){
    	
    	haha[i]=i;
    	//j++;
    }
    
    for(double i=sumi;i>=0-eps;i-=0.5){
    	haha[i]=min(haha[i],sumi-i);
    	
    }
    double lol=0;
    rep(i,n){	
    	update(lol,t[i],v[i]);
    	lol+=t[i];
    }
    double ans=0;
    for(double i=0;i<sumi-eps;i+=0.5){
    	//cout<<i<<" "<<haha[i]<<endl;
    	ans+=min(haha[i],haha[i+0.5])*0.5;
    	if(fabs(haha[i]-haha[i+0.5])>eps)
    		ans+=0.5*0.5*0.5;
    }
    cout<<setprecision(20)<<ans<<endl;
    return 0;  
    
}



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

int isin(int x, vector<int>& V) {
  for (int v : V) {
    if (v == x) return 1;
  }
  return 0;
}

void f(int N, vector<int> V) {
  int now = 1;
  for (int i = 0; i < 2*N-1; i++) {
    if (N-3 <= i && i <= N) {
      cout << V[i-(N-3)] << endl;
    } else {
      while (isin(now, V)) now++;
      cout << now++ << endl;
    }
  }
}

int main() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == 2*N-1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  if (N == 2) {
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
    return 0;
  }
  if (x == 2) f(N, {3, 2, 1, 4});
  else f(N, {x-1, x, x+1, x-2});
}


Measured memory_bytes: 1536
#include <iostream>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a,b) (((a)-(b))>0?((a)-(b)):((b)-(a)))

using namespace std;

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	int K;
	cin >> K;
	
	int cnt = 0;
	while( B <= A ){
		B *= 2;
		cnt++;
	}
	while( C <= B ){
		C *= 2;
		cnt++;
	}
	if( cnt <= K ) cout << "Yes";
	else cout << "No";
	
	return 0;
}


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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >>N;
    if(N % 10 == 9 || N / 10 == 9){
        out("Yes");
    }else{
        out("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
char c[200003];
int f[200003][3],ans=1;
int main(){
	memset(f,0xaf,sizeof(f));
	cin>>c;
	f[0][1]=f[1][2]=1;
	for(int i=1;c[i];i++){
		if(c[i-1]!=c[i]) if(f[i][1]<f[i-1][1]+1){
			f[i][1]=f[i-1][1]+1;
		}
		if(f[i][1]<f[i-1][2]+1){
			f[i][1]=f[i-1][2]+1;
		}
		if(i>=2){
			if(f[i][2]<f[i-2][1]+1){
				f[i][2]=f[i-2][1]+1;
			}
			if(i>=3)if(c[i-2]!=c[i]&&c[i-3]!=c[i-1]){
				if(f[i][2]<f[i-2][2]+1){
					f[i][2]=f[i-2][2]+1;
				}
			}
		}
		ans=max(f[i][1],f[i][2]);
	}
	cout<<ans<<endl;
}

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

int main() {
	long long H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
		return 0;
    }
	else{
        cout << (H*W+1)/2 << endl;
    }
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 1e5 + 7;
int n, a, b, x[N];
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  cin >> n >> a >> b;
  rep(i, 0, n ) cin >> x[i];
  ll ans = 0;
  rep(i, 0, n - 1) {
  	ans += min(ll(b), ll(a) * (x[i + 1] - x[i]));
	}
	cout << ans;
	return 0;
}

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


long long help(long long x){
	x=x*x*x*x*x;
	return x;
}
void solve(){

long long x;
cin>>x;
long long a=-150;
int flag=0;
for(long long i=a;i<=150;i++){
	long long b=help(i)-x;
	long long k;
	for(long long j=-150;j<=150;j++){
		if(help(j)==b){
		k=j;
			flag=1;
		
			break;
		}
	}	
	if(flag){
			cout<<i<<" ";
			cout<<k;
			break;
	}
}

}

int main() {

solve();

}

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

using namespace std;

int main(){
    int A, B, C, X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    
    int ans=0;
    for(int a=0; a<=A; a++){
        for(int b=0; b<=B; b++){
            for(int c=0; c<=C; c++){
                int sum = 500*a + 100*b + 50*c;
                if(sum == X){ ans++; }
            }
        }
    }
    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,c,i,a[100008],b[100008];
int main() {
    for(scanf("%lld",&n); i<=n; scanf("%lld",a+i++));
    for(c=1; i--; b[i]=a[i]+b[i+1],a[i]+=a[i+1]+1>>1);
    if(a[0]!=1)
        printf("-1\n"),exit(0);
    for(i=0; i++<n; c+=a[i]=min(a[i-1]<<1,b[i]),a[i]+=b[i+1]-b[i])
        if((a[i-1]+a[i-1])<a[i])
            printf("-1\n"),exit(0);
    printf("%lld\n",c),exit(0);
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

#define MAX_N 222

int a[MAX_N][2];
//{x,y}

void solve(int n){
  int s,m,x_max = 0,x_min = 0,y_max = 0,y_min = 0;

  a[0][0] = 0;
  a[0][1] = 0;
  FOR(i,1,n){
    cin>>s>>m;
    switch (m) {
      case 0:
        a[i][0] = a[s][0]-1;
        a[i][1] = a[s][1];
        break;
      case 1:
        a[i][0] = a[s][0];
        a[i][1] = a[s][1]-1;
        break;
      case 2:
        a[i][0] = a[s][0]+1;
        a[i][1] = a[s][1];
        break;
      case 3:
        a[i][0] = a[s][0];
        a[i][1] = a[s][1]+1;
        break;
    }
    x_max = max(x_max,a[i][0]);
    x_min = min(x_min,a[i][0]);
    y_max = max(y_max,a[i][1]);
    y_min = min(y_min,a[i][1]);
  }

  printf("%d %d\n",x_max-x_min+1,y_max-y_min+1);
}


int main(){
  int n;

  while(scanf("%d",&n) == 1){
    if(n == 0) break;
    solve(n);
  }

  return 0;
}


Measured memory_bytes: 3172
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	int a[21], b[21], c[21];
	int i;
	int sol = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n; i++)
	{
		scanf("%d", &b[i]);
	}

	for (i = 0; i < n - 1; i++)
	{
		scanf("%d", &c[i]);
	}

	sol += b[a[0] - 1];

	for (i = 1; i < n; i++)
	{
		sol += b[a[i] - 1];

		if (a[i - 1] + 1 == a[i])
		{
			sol += c[a[i - 1] - 1];
		}
	}

	printf("%d\n", sol);

	return 0;
}

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

int main(){
    ll n,q; cin >> n >> q;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    rep(i,q){
        ll x; cin >> x;
        ll res=0, sum=0;
        int r=0;
        rep(l,n){
            while(r<n && sum+a[r]<=x){
                sum += a[r];
                r++;
            }
            res += (r-l);
            if(l==r) ++r;
            else sum -= a[l];
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3548
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
	int k,i;
	char s[100];
	scanf("%d",&k);
	scanf("%s",s);
	int l = strlen(s);
	if(l>k)
	{
		for(i=0; i<k; i++)
		{
			printf("%c",s[i]);
		}
		printf("...");
	}
	else{
	printf("%s",s);
}
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string();  
int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n,a,b;
    cin>>n>>a>>b;
    cout<<min(b,n*a);

	return 0;

}

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

using namespace std;

int const maxn = 1e6 + 5;
int dp[maxn][2];

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    dp[0][0] = s[0] - '0';;
    dp[0][1] = 10 - dp[0][0];
    for (int i = 1; i < (int)s.size(); ++i) {
        int c = s[i] - '0';
        dp[i][0] = dp[i - 1][0] + c;
        dp[i][0] = min(dp[i][0], dp[i - 1][1] + c + 1);
        dp[i][1] = dp[i - 1][0] + 10 - c;
        dp[i][1] = min(dp[i][1], dp[i - 1][1] + 9 - c);
    }
    int ans = min(dp[(int)s.size() - 1][0], dp[(int)s.size() - 1][1] + 1);
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 9116
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<array>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int INF = (1<<29);
int ms[100][100],n;
int d[100];


void dfs(int a){
    rep(i,n){
        d[i]=INF;
    }
    queue<int> q;
    q.push(a);
    d[a]=0;
    while(!q.empty()){
        int b=q.front();q.pop();
        for(int i=0;i<n;i++){
            if(ms[b][i]!=0&&d[i]==INF){
                d[i]=d[b]+1;
                q.push(i);
                
            }
        }
    }
    
    
    
    rep(i,n){
        cout<<i+1<<" "<<(d[i]==INF?-1:d[i])<<endl;
    }
}


int main(){
    cin>>n;
    rep(i,n){
        int a,b,c;
        cin>>a>>b;
        a--;
        rep(j,b){
            cin>>c;
            c--;
            ms[a][c]=1;
        }
    }
    
    dfs(0);
    return 0;

    
}



Measured memory_bytes: 3124
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
	for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
	return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int K=-1,Z=0;
inline void Ot(){fwrite(sr,1,K+1,stdout),K=-1;}
void print(R int x){
    if(K>1<<20)Ot();if(x<0)sr[++K]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++K]=z[Z],--Z);sr[++K]='\n';
}
const int P=998244353;
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=4e5+5;
char s[N];int n,flag,a,b,c,d,ok1[N],ok2[N];
bool ck(int l,int r,int *ok){
	fp(i,l,r)ok[i]=0;
	ok[l]=1;
	fp(i,l,r-1)if(ok[i]){
		if(s[i+1]!='#')ok[i+1]=1;
		if(s[i+2]!='#')ok[i+2]=1;
	}
	return ok[r];
}
bool qwq(){
	fp(i,b,d)if(ok2[i]&&ok1[i-1]&&ok1[i+1])return true;
	return false;
}
int main(){
	scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,s+1),flag=1;
	flag&=ck(a,c,ok1),flag&=ck(b,d,ok2);
	if(a<b&&c>d)flag&=qwq();
	puts(flag?"Yes":"No");
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int A,B,C;
	cin>>A>>B>>C;
	vector<string> V;
	while(A--) V.push_back("a");
	while(B--) V.push_back("b");
	while(C--) V.push_back("c");
	
	while(V.size()>1) {
		sort(ALL(V));
		V[0]+=V.back();
		V.pop_back();
	}
	
	cout<<V[0]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!


import sys
#sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
#d = [int(i) for i in readline().split()]
s = input()

from itertools import groupby

ans = 0
for i in groupby(s):
    ans += 1


print(ans)















Measured memory_bytes: 3316
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;


int main() {
	int N; cin >> N;
	vector<long long> A(N), B;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	B.push_back(A[0]);
	for (int i = 1; i < N; i++) {
		auto itr = lower_bound(B.rbegin(), B.rend(), A[i]);
		if (itr == B.rbegin())B.emplace_back(A[i]);
		else { itr--; *itr = A[i]; }
		
	}
	
	cout << B.size() << endl;
}





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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a


using ll = long long;

int main() {
    int c = 0;
    IN(int, n);
    IN(string, s);
    REP(i, s.length()-2){
        if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C')) c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    int w=0,e=count(ALL(s),'E');
    int ans=N;
    REP(i,N){
        if(s[i]=='E') e--;
        ans=min(ans,w+e);
        if(s[i]=='W') w++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long H,W;
  cin >> H >> W;
  
  if (H == 1 || W == 1 ){
      cout << 1 <<endl;
  }else if (H % 2 != 0 && W % 2 != 0){
      cout << (H*W+1) / 2 <<endl;
  }else{
      cout << H*W/2 <<endl;
  }
}

Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;
 
  
 
signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i< n; i++)
    cin >> a[i];
  int s = 0;
  for (int i = 0; i< n; i++)
    s += a[i];
  int cnt = 0;
  for (int i = 0; i< n; i++)
    if (a[i] >= (s * (1. / (4 * m))))
      cnt++;
  if (cnt >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n,r,ses=0,tes=0;
string s;

int main(){
    scanf("%d",&n);
    cin>>s;
    r=s.length();
    for(int i=0;i<s.length();i++){
        if(s[i]=='T'){
            tes++;
            if(ses){
                r-=2;
                ses--;
            }
        }
        else{
            ses++;
            tes=0;
        }
    }
    printf("%d\n",r);
}

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

int main(){
	string S,YMD;
	cin>>S;
	YMD ="2019/04/30";
	if (S<=YMD){
		cout<<"Heisei"<<endl;
	}
	else{
		cout<<"TBD"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=410;
const int mod=998244353;

int qpow(int a,int b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

int n,fac[N],ifac[N],f[N][N][N],g[N];

int main() {
	fac[0]=ifac[0]=1;
	for(int i=1;i<N;i++) {
		fac[i]=1ll*fac[i-1]*i%mod;
		ifac[i]=qpow(fac[i],mod-2);
	}
	f[0][0][0]=mod-1;
	cin>>n;
	int s1=0,s2=0;
	for(int i=1;i<=n;i++) {
		int a,b;cin>>a>>b;
		for(int j=0;j<=s1;j++)
			for(int k=0;k<=s2;k++) f[i][j][k]=f[i-1][j][k];
		g[0]=1;
		for(int j=1;j<b;j++) g[j]=1ll*g[j-1]*a%mod;
		for(int j=0;j<b;j++) g[j]=1ll*g[j]*ifac[j]%mod;
		for(int j=0;j<=s1;j++)
			for(int k=0;k<=s2;k++)
				for(int l=0;l<b;l++)
					f[i][j+l][k+a]=(f[i][j+l][k+a]+mod-1ll*f[i-1][j][k]*g[l]%mod)%mod;
		s1+=b-1,s2+=a;
	}
	int ans=0;
	for(int i=0;i<=s1;i++)
		for(int j=1;j<=s2;j++) {
			int val=1ll*f[n][i][j]*fac[i]%mod;
			val=1ll*val*qpow(j,mod-1-i)%mod;
			ans=(ans+1ll*val*s2%mod*qpow(j,mod-2))%mod;
		}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 262400
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	ll x, k, d;
	cin >> x >> k >> d;
	ll tmp = min(abs(x/d), k);
	if (x <= 0) {
		x += tmp*d;
		k -= tmp;
	} else {
		x -= tmp*d;
		k -= tmp;
	}
	// dbg(x,k,d);
	if (k%2==0) {
		cout << abs(x) << "\n";
	} else {
		cout << min({abs(x+d), abs(x-d)}) << "\n";
	}
	return 0;
}

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



void solve() {
    int n,k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int sm = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < k; i++)
        sm += a[i];
    cout << sm << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(){
	int x, y;

	

	while(true){

		cin >> x >> y;
		if(x==0&&y==0){
			break;
		}
		if(x<y){
			cout << x << ' ' << y  << '\n';
		}
		else {
			cout << y <<' ' << x << '\n';
		}

	}

	return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    A.push_back(INF);
    vector<ll> B(M);
    for(int i = 0; i < M; i++) cin >> B[i];
    B.push_back(INF);
    int ans = 0;
    ll tmp = 0;
    for(int i = 0; i <= N; i++) {
        tmp += A[i];
    }
    int j = 0;
    for(int i = N; i >= 0; i--) {
        tmp -= A[i];
        if(tmp > K) continue;
        while(B[j] + tmp <= K) {
            tmp += B[j];
            j++;
        }
        chmax(ans, i + j);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7720
import scala.math.min

object Main {
    def main(args: Array[String]) {
        var input = io.Source.stdin.getLines().mkString("\n");
        var ss = input.split("\n").toList;
        val s = ss(0).sorted;
        println(if (s(0) == s(1) && s(2) == s(3) && s(0) != s(2)) "Yes" else "No");
    }
}


Measured memory_bytes: 27160
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-9
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define siz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define endl '\n'
typedef pair<int,int> pii;
typedef unsigned long long ull;
const long long linf=1LL<<62;
const int iinf=1000000009;
const double dinf=1e15;
const int Mod=1e9+9;
const int base=228;
typedef long long ll;
typedef long double ld;
struct Solver {
	ll cnt=1,crt=1;
	ll n,k;
	ll len[55],num[55];
	void cal(int x) {
		len[x]=cnt;num[x]=crt;
		cnt=cnt*2+3;crt=crt*2+1;
		if(x==n) return ;
		cal(x+1);
	}
	ll dfs(int x,ll xx) {
		ll res=0;
		if(xx==0) return 0;
		if(x==0) return 1;
		if(len[x]<=xx) return num[x];
		//if(xx<=x) return 0;
		if(xx<=len[x]/2) return dfs(x-1,xx-1);
		if(xx==len[x]/2+1) return num[x]/2+1;
		if(xx>len[x]/2+1) return num[x]/2+1+dfs(x-1,xx-len[x]/2-1);
		return 0;
	}
	void solve(){
		iossy;
		cin>>n>>k;cnt=1;
		cal(0);
		cout<<dfs(n,k)<<endl;
	}
};
int main(){
//	p[0]=1;
//	For(i,1,500005) p[i]=p[i-1]*base;
//	while(scanf("%d",&n)!=EOF) solve();
	int t=1;
	Solver solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    string s,t;
    int q;
    void solve(){
        cin >> s >> t >> q;
        vector<int> sa(s.length()+1),sb(s.length()+1),ta(t.length()+1),tb(t.length()+1);
        for(int i=0; i<s.length(); ++i){
            if(s[i]=='A')sa[i+1]=1;
            else sb[i+1]=1;
        }
        for(int i=0; i<t.length(); ++i){
            if(t[i]=='A')ta[i+1]=1;
            else tb[i+1]=1;
        }
        for(int i=0; i<s.length(); ++i){
            sa[i+1]+=sa[i];
            sb[i+1]+=sb[i];
        }
        for(int i=0; i<t.length(); ++i){
            ta[i+1]+=ta[i];
            tb[i+1]+=tb[i];
        }
        for(int i=0; i<q; ++i){
            int sl,sr,tl,tr;
            cin >> sl >> sr >> tl >> tr;
            --sl;--tl;
            int ds= (sa[sr]-sa[sl])*2+(sb[sr]-sb[sl]);
            int dt= (ta[tr]-ta[tl])*2+(tb[tr]-tb[tl]);
            cout << (abs(ds-dt)%3==0?"YES":"NO")<<"\n";
        }

    }
};

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

    Problem p;
    p.solve();
    return 0;
}



Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define mk make_pair
#define endl '\n'

int main()
{
    IOS;
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k)
    {
        cout<<s;
        return 0;
    }

    for (int i = 0; i < k; i++)
    {
        cout<<s[i];
    }
    cout<<"...";
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

constexpr int dx[4] = {1, -1, 0, 0};
constexpr int dy[4] = {0, 0, 1, -1};

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

    int n;
    cin >> n;
    vector<ll> dp(n + 1, -1);
    auto MemoRec = [&](auto&& self, int N) -> ll {
        if(dp[N] != -1) return dp[N];
        if(N <= 1)  return dp[N] = 1;
        return dp[N] = self(self, N - 1) + self(self, N - 2);
    };
    cout << MemoRec(MemoRec, n) << endl;
}


Measured memory_bytes: 3108
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	char c;
  cin>>c;
  if(c=='a' || c=='i' || c=='u'|| c=='e'|| c=='o'){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }

	return 0;
}



Measured memory_bytes: 764
def func():
    pass


def main():
    k, a, b = map(int, input().split())

    # i = 0
    # c = 1
    # while i < k:
    #     if c >= a and (k - i - 1) >= 2:
    #         # print("2:", i, c)
    #         c = c - a + b
    #         i += 1
    #     else:
    #         # print("3:", i, c)
    #         c += 1
    #     i += 1
    #
    # print(max(c, k))

    y = (k - (a - 1)) // 2

    # 2,3 を y回繰り返す
    # y * (b-a)まい増える

    # q = (y * (b - a) + (k - ((a - 1) + 2 * y)))
    # print(max((q + a), k + 1))

    # q = y * (b - a) + (k - 2 * y + 1)
    # print(max(q, k + 1))

    c1 = y * (b - a) + a
    if (k - (a - 1)) % 2 == 0:
        pass
    else:
        c1 += 1

    print(max(c1, k + 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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 gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll solve(ll a , ll c, ll d){
  ll g = gcd(c,d);
  return a - a / c - a / d + a / (c / g * d);
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << solve(b,c,d) - solve(a-1,c,d) << endl;
  return 0;
} 

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int befX = 0, aftX =0, tmp;
    for (int i = 0; i < M; i++){
        cin >> tmp;
        if (tmp < X) {
            befX++;
        }
        else {
            aftX++;
        }
    }
    cout << (befX < aftX ? befX : aftX) << endl;
}

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

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);

	vector Ev(m,vector<int>());
	rep(i,n){
		int a,b; scanf("%d%d",&a,&b);
		if(a<=m) Ev[m-a].emplace_back(b);
	}

	int ans=0;
	priority_queue<int> Q;
	for(int x=m-1;x>=0;x--){
		for(auto b:Ev[x]) Q.emplace(b);
		if(!Q.empty()){
			ans+=Q.top(); Q.pop();
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 8456
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoderSolve
{
    class Solve
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] cnt = new int[100007];
            for(var i = 0; i < 100007; i++)
            {
                cnt[i] = 0;
            }

            for(var i = 0; i < N; i++)
            {
                if (a[i] > 0) { cnt[a[i] - 1]++; }
                cnt[a[i]]++;
                cnt[a[i] + 1]++;
            }
            Console.WriteLine(cnt.Max());

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

int main(){
    string S,T;
    cin >> S >> T;
    int n = S.size(),ans=0;
    for (int i = 0; i < n; i++)
    {
        if(S[i]!=T[i])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3912