akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
//////////////////////////////////////////////////////
int main(){
	int H,W;
	SCD2(H,W);
	int N;
	SCD(N);
	static int grid[102][102];
	queue<int> Q;
	REP(i,N){
		int x;
		SCD(x);
		REP(j,x){
			Q.push(i+1);
		}
	}
	
	FORq(i,1,H){
		if (i % 2 == 1){
			FORq(j,1,W){
				int x = Q.front(); Q.pop();
				grid[i][j] = x;
			}
		}else{
			for(int j = W; j > 0;j--){
				int x = Q.front(); Q.pop();
				grid[i][j] = x;
			}
		}
	}
	
	
	FORq(i,1,H){
		FORq(j,1,W-1){
			printf("%d ",grid[i][j]);
		}
		printf("%d\n",grid[i][W]);
	}
	
	return 0;
}








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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n){
    cin>>a[i];
 }
  rep(i,n){
    b[a[i]-1]=i+1;
  }
  rep(i,n)cout<<b[i]<<" ";
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int n,p;
    char s;
    int card[4][13];
    scanf("%d",&n);
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            card[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        scanf("%s %d",&s,&p);
        if(s=='S'){
            card[0][p-1]=1;
        }else if(s=='H'){
            card[1][p-1]=1;
        }else if(s=='C'){
            card[2][p-1]=1;
        }else if(s=='D'){
            card[3][p-1]=1;
        }
    }

    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(card[i][j]==0){
                if(i==0) printf("S %d\n",j+1);
                if(i==1) printf("H %d\n",j+1);
                if(i==2) printf("C %d\n",j+1);
                if(i==3) printf("D %d\n",j+1);
            }
        }
    }
    return 0;
}

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

#define ll long long int
ll mod=1e9+7;

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        cin >> n;
        // ll arr[n];
        map<string,int> mp;

        for(i=0;i<n;i++)
        {
            // cin >> arr[i];
            string s;
            cin >> s;
            auto it = mp.find(s);
            if(it == mp.end())
            {
                mp[s] = 1;
            }
            else
            {
                mp[s]++;
            }
        }

        int ac=0,wa=0,tle=0,re=0;

        string AC = "AC";
        auto it = mp.find(AC);
        if(it == mp.end())
        {
            ac = 0;
        }
        else
        {
            ac = it->second;
        }

        string WA = "WA";
        it = mp.find(WA);
        if(it == mp.end())
        {
            wa = 0;
        }
        else
        {
            wa = it->second;
        }

        string TLE = "TLE";
        it = mp.find(TLE);
        if(it == mp.end())
        {
            tle = 0;
        }
        else
        {
            tle = it->second;
        }

        string RE = "RE";
        it = mp.find(RE);
        if(it == mp.end())
        {
            re = 0;
        }
        else
        {
            re = it->second;
        }

        cout << AC << " x " << ac << '\n';
        cout << WA << " x " << wa << '\n';
        cout << TLE << " x " << tle << '\n';
        cout << RE << " x " << re << '\n';
        
    }
    
    return 0;
}

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

int main() {
    vector<int> v(9);
    for(int i = 0; i < 9; ++i) {
        cin >> v[i];
    }

    function<int(int)> solve = [&] (int i) {
        int res = 0;
        if(i == 6) {
            int r = v[0] + 10 * v[1] + v[2] + 100 * v[3] + 10 * v[4] + v[5];
            bool b = true;
            vector<int> cnt(10);
            for(int j = 0; j < 6; ++j) {
                cnt[v[j]] += 1;
            }
            for(int j = 0; j < 3; ++j) {
                int d = r % 10;
                r /= 10;
                b &= (d == v[8 - j] || v[8 - j] == -1) && d != 0;
                cnt[d] += 1;
            }
            res = b & (r == 0) & (*max_element(begin(cnt), end(cnt)) <= 1);
        } else {
            if(v[i] == -1) {
                for(int d = 1; d <= 9; ++d) {
                    v[i] = d;
                    res += solve(i + 1);
                    v[i] = -1;
                }
            } else {
                res = solve(i + 1);
            }
        }
        return res;
    };

    cout << solve(0) << endl;
}



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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9
#define LINF (ll)4e18
#define MOD (ll)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    map<int, int> mp;
    int n;
    cin >> n;

    rep(i, n) {
        int d;
        cin >> d;
        mp[d]++;
    }

    int m;
    cin >> m;

    bool can = true;

    rep(i, m) {
        int t;
        cin >> t;
        if (mp[t] == 0) {
            can = false;
            break;
        } else {
            mp[t]--;
        }
    }

    YES(can);

    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc,char *argv[]){
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int dp[n+1];
  dp[0]=dp[1]=0;
  memset(dp,0,(n+1)*sizeof(int));
  if(n>=2){
    dp[2]=abs(arr[1]-arr[0]);
  }
  for(int i=3;i<=n;i++){
    dp[i]=min(dp[i-1]+abs(arr[i-2]-arr[i-1]),dp[i-2]+abs(arr[i-3]-arr[i-1]));
  }
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#define N 2000001
using namespace std;

int main () {

    int n, k, val;
    cin >> n >> k;
    vector<int> v(n);

    for (int i = 0; i < n; i++) {
        cin >> val;
        v[val]++;
    }
    sort(v.begin(), v.end(), greater<int>());

    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += v[i];
    }
    cout << n - sum << endl;
    return 0;

}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, a;
    cin >> N;
    
    if(N < 10)
    {
        a = N;
    }
    else if (10 <= N || N < 100)
    {
        a = N % 10;
    }
    else
    {
        a = N % 100;
    }
    
    if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9)
    {
        cout << "hon" << endl;
    }
    else if(a == 0 || a == 1 || a == 6 || a == 8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3636
#include <stdio.h>

void insertionSort(int A[], int n) {
    int j, v;
    for (int i = 1; i < n; i++) {
        for (int k = 0;k < n; k++) {
            if (k) printf(" ");
            printf("%d", A[k]);
        }
        printf("\n");
        
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
    }
}

int main(void){
    int n, A[100];
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    insertionSort(A, n);
    
    for (int k = 0;k < n; k++) {
        if (k) printf(" ");
        printf("%d", A[k]);
    }
    printf("\n");
        
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {  // 発見できたとき
    return 1;
  } else {  // 発見できなかったとき
    return 0;
  }
}
int main() {
  int n;
  cin >> n;
  int ans;
  ans = 1000 - n % 1000;
  if (n % 1000 == 0) {
    cout << 0;
    return 0;
  }
  cout << ans;
  return 0;
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	a--;
	b--;
	string s;
	cin >> s;
	bool ok = true;
	if (s[a + 1] != '-') ok = false;
	rep(i, s.size()) {
		if (i == a + 1) continue;
		if (s[i] < '0' || s[i] > '9') ok = false;
	}
	if (ok) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}



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

int N;
vector<int> A;

void f(const vector<bool>& b) {
	vector<int> a(N);
	for (int i = 0; i < N; ++ i) a[i] = i;
	vector<int> r;
	int p = 0;
	int cnt = N;
	vector<int> res;
	for (; p < N && !b[p]; ++ p) {
		cnt -= 1;
		res.push_back(1);
	}
	int prev = p;
	++ p;
	for (; p < N; ++ p) {
		if (b[p]) {
			for (int i = 2; i < p - prev; i += 2) {
				res.push_back(3);
				cnt -= 2;
			}
			res.push_back(2);
			cnt -= 2;
			prev = p;
		}
	}
	while (cnt > 1) {
		res.push_back(cnt);
		cnt -= 1;
	}
	cout << res.size() << endl;
	for (auto x : res) cout << x << endl;
}

int main() {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++ i) cin >> A[i];
	vector<bool> b0(N), b1(N);
	long long s0 = 0, s1 = 0;
	for (int i = 0; i < N; ++ i) {
		if (A[i] > 0) {
			if (i % 2 == 0) {
				b0[i] = true;
				s0 += A[i];
			} else {
				b1[i] = true;
				s1 += A[i];
			}
		}
	}
	if (s0 <= 0 && s1 <= 0) {
		int p = 0;
		for (int i = 1; i < N; ++ i) {
			if (A[i] > A[p]) p = i;
		}
		vector<bool> bb(N);
		bb[p] = true;
		cout << A[p] << endl;
		f(bb);
	} else if (s0 > s1) {
		cout << s0 << endl;
		f(b0);
	} else {
		cout << s1 << endl;
		f(b1);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	swap(a, b);
	swap(a, c);
	printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

ll b2(int k) {
    ll rt = 1;
    for (int i = 0; i < k; i++) {
        rt *= 2;
        rt %= 1000000007;
    }
    return rt;
}

int main(void){
    int n, a[100010], b[100010];
    cin >> n;
    for (int i = 0; i < n; i++) b[i] = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    
    for (int i = n - 1; i >= 0; i -= 2) {
        if (i != 0 && b[i] != 2) {
            cout << 0 << endl;
            return 0;
        }
        if (i == 0 && b[i] != 1) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << b2(n/2) << endl;
    
    
}


Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll group[1<<16];
ll dp[1<<16];

ll dfs(ll i){
  if(dp[i]!=-1) return dp[i];
  if(i==0) return dp[i]=0;
  ll res = -INF;
  ll sub = i;
  while(sub!=0){
    res = max(res,group[sub]+dfs(i-sub));
    sub = (sub-1)&i;
  }
  return dp[i] = res;
}

int main(){
  ll n; cin >> n;
  fill(group,group+(1<<n),0);
  fill(dp,dp+(1<<n),-1);
  ll a[n][n];
  REP(i,n) REP(j,n) cin >> a[i][j];
  REP(i,1<<n){
    for(ll k = 0; k < n-1; k++){
      for(ll l = k+1; l < n; l++){
        if((i>>k&1)&&(i>>l&1)) group[i] += a[k][l];
      }
    }
    //cout << group[i] << endl;
  }
  cout << dfs((1<<n)-1) << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
int main()
{
	int N,i,j,t,flag=0;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
	}
	for(i=0;i<N-1;i++)
	{
		for(j=N-1;j>i;j--)
		{
			if(A[j]<A[j-1])
			{
				t=A[j];
				A[j]=A[j-1];
				A[j-1]=t;
				flag++;
			}
		}
	}
	for(i=0;i<N;i++)
	{
		if(i)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n%d\n",flag);
	return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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 ll mod = 1e9+7;

int dp1[60][300005]; // dp[i][j]: i桁目が1の個数の累積
int dp0[60][300005]; // dp[i][j]: i桁目が0の個数の累積

ll two[61];
void init() {
  two[0] = 1ll;
  rep(i, 1, 61) {
    two[i] = (two[i-1] * 2ll) % mod;
  }
};

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

  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i, 0, n) {
    cin >> A[i];
  }

  init();

  for (int i = n-1; i >= 0; i--) {
    ll a = A[i];
    rep(j, 0, 60) {
      if ((a >> j) & 1 == 1) {
        dp1[j][i] = dp1[j][i+1]+1;
        dp0[j][i] = dp0[j][i+1];
      } else {
        dp0[j][i] = dp0[j][i+1]+1;
        dp1[j][i] = dp1[j][i+1];
      }
    }
  }

  ll ans = 0ll;

  rep(i, 0, n-1) {
    ll a = A[i];
    rep(j, 0, 60) {
      int one = dp1[j][i+1]; // j桁目が1の個数
      int zero = dp0[j][i+1];
      if ((a >> j) & 1 == 1) {
        ans += ((ll)two[j] * zero);
        ans %= mod;
      } else {
        ans += ((ll)two[j] * one);
        ans %= mod;
      }
    }
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 143232
import java.util.*;

public class Main {

	public static void main(String[] args) {
		int sum;
		String s;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		}
	}

}

Measured memory_bytes: 18756
#include<bits/stdc++.h>
#define M 27
#define N 5
using namespace std;
int n,c[2][N][N][N],m1,m2,a[M],b[M],num=1;

int Count(int x,int y,int z,int t){
  int d[3]={-1,0,1},res=0;
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++){
	int nx=x+d[i],ny=y+d[j],nz=z+d[k];
	if(!d[i]&&i==j&&j==k)continue;
	if(nx<0||ny<0||nz<0)continue;
	if(N<=nx||N<=ny||N<=nz)continue;
	if(c[t][nx][ny][nz])res++;
      }
  return res;
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    if(num>=2)cout<<endl;
    cout<<"Case "<<num<<':'<<endl;
    string s;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++){
	cin>>s;
	for(int k=0;k<N;k++){
	  c[0][i][j][k]=s[k]-'0';
	}
      }
    cin>>m1;
    for(int i=0;i<m1;i++)cin>>a[i];
    cin>>m2;
    for(int i=0;i<m2;i++)cin>>b[i];
    for(int l=0;l<n;l++){
      int idx=l%2;
      for(int i=0;i<N;i++)
	for(int j=0;j<N;j++){
	  for(int k=0;k<N;k++){
	    int r=Count(i,j,k,idx),f=0;
	    if(!c[idx][i][j][k]){
	      for(int p=0;p<m1;p++)
		if(r==a[p])f=1;
	      if(f)c[!idx][i][j][k]=1;
	      else c[!idx][i][j][k]=0;
	    }else{
	      for(int p=0;p<m2;p++)
		if(r==b[p])f=1;
	      if(!f)c[!idx][i][j][k]=0;
	      else c[!idx][i][j][k]=1;
	    }
	  }
	}
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	for(int k=0;k<N;k++)
	  cout<<c[n%2][i][j][k];
	cout<<endl;
      }
      if(i!=N-1)cout<<endl;
    }
    num++;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	string s;
	cin>>s;
	int c=0,start=0;
	int ans=0;
	for(int i=0;i<3;i++){
		if(s[i]=='R'&&!start){
			c++;
			start=1;
		}
		else if(s[i]=='R'&&start)
		c++;
		else if(s[i]=='S'&&start)
		{
			ans=max(ans,c);
		   start=0;
		   c=0;
		   }
	}
	ans=max(ans,c);
    cout<<ans;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector< pair<int, int> > A(N);

    for(int i=0;i<N;i++){
        cin >> A.at(i).first;
        A.at(i).second = i+1;
    }

    sort(A.begin(), A.end());
    for(int i=0;i<N;i++){
        if(i) cout << " ";
        cout << A.at(i).second;
    }
    cout << endl;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
long long a,b,c,d,c1,d1,ans;
int main() {
    cin >> a >> b >> c >> d;
    c1=b/c-(a-1)/c;
    d1=b/d-(a-1)/d;
    ans=c*d;
    while (max(c,d)%min(c,d)!=0)
   {
       if (c>d) c=c%d;
       else d=d%c;

    }
    ans=ans/min(c,d);
    ans=b/ans-(a-1)/ans;
    ans=c1+d1-ans;
    ans=(b-a+1)-ans;
    cout << ans;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        StringBuilder str = new StringBuilder();
        String[] data;
        int x, y;
        while (true) {
            data = br.readLine().split(" ");
            x = Integer.parseInt(data[0]);
            y = Integer.parseInt(data[1]);
            if (x == 0 && y == 0) {
                break;
            }
            if (x < y) {
                str.append(data[0]).append(" ").append(data[1]).append("\n");
            } else {
                str.append(data[1]).append(" ").append(data[0]).append("\n");
            }
        }
        System.out.print(str);
    }
}

Measured memory_bytes: 26928
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
inline int read(){
	char c=getchar();int x=0,f=1;
	while(c<'0'||c>'9'){ if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
int n,ans,sum[30];
char s[100005];
int main(){
	n=read();scanf("%s",s+1);ans=1;
	for(int i=1;i<=n;++i) sum[s[i]-'a']++;
	for(int i=0;i<26;++i){
		ans=1ll*ans*(sum[i]+1)%mod;
	}
	printf("%d\n",ans-1);
	return 0;
}


Measured memory_bytes: 384
X, N = map(int, input().split())

if N == 0:
  ans = X
else:
  p = list(map(int, input().split()))
  ans = 0
  for i in range(200):
    if i in p:
      continue
    else:
      dis = abs(i - X)
      if dis < abs(ans - X):
        ans = i

print(ans)


Measured memory_bytes: 61924
*l, = map(int, input().split())

ans = 0
while True:
    if l[0]%2 or l[1]%2 or l[2]%2:
        break
    a = (l[1] + l[2]) // 2
    b = (l[0] + l[2]) // 2
    c = (l[0] + l[1]) // 2
    if l == [a, b, c]:
        ans = -1
        break
    l = [a, b, c]
    ans += 1

print(ans)

Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;++i)
    {
        cin>>A[i];
    }
    sort(A,A+n);
    int cnt=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if((A[i]<A[j]+A[k]) && (A[j]<A[i]+A[k]) && (A[k]<A[i]+A[j]))
                {
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N + 1);
  h.at(0) = 100000;
  for (int i = 1; i <= N; i++) {
    cin >> h.at(i);
  }
  vector<int64_t> cost(N + 1, 100000000000000);
  cost.at(0) = 0;
  cost.at(1) = 0;
  for (int i = 2; i <= N; i++) {
    for (int j = 1; j <= K; j++) {
      if (i >= j) {
        cost.at(i) = min(cost.at(i), (cost.at(i - j) + abs(h.at(i - j) - h.at(i))));
      }
    }
  }
  cout << cost.at(N) << endl;
}

Measured memory_bytes: 4276
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int gx[]={0,1,2,3,0,1,2,3,4,1,2,3},gy[]={0,1,1,1,2,2,2,2,2,3,3,3};

struct S{
	int p[5][5];
	int zx[2],zy[2];
	int md;
	S(){}
	S(int a[5][5])
	{
		md=0;
		zx[0]=-1;
		rep(i,5)rep(j,5)
		{
			p[i][j]=a[i][j];
			if(a[i][j]==0)
			{
				if(zx[0]==-1)zy[0]=i,zx[0]=j;
				else zy[1]=i,zx[1]=j;
			}
			if(abs(i-2)+abs(j-2)<=2&&p[i][j])
			md+=abs(gy[p[i][j]]-i)+abs(gx[p[i][j]]-j);
		}
	}
	bool swp(int z,int d)
	{
		int y=zy[z],x=zx[z],nx=x+dx[d],ny=y+dy[d];
		if(abs(nx-2)+abs(ny-2)>2||p[y][x]==p[ny][nx])return 0;
		
		md+=abs(gy[p[ny][nx]]-y)+abs(gx[p[ny][nx]]-x);
		md-=abs(gy[p[ny][nx]]-ny)+abs(gx[p[ny][nx]]-nx);
		swap(p[y][x],p[ny][nx]);
		zy[z]+=dy[d]; zx[z]+=dx[d];
		return 1;
	}
};
S pz; int lim;
bool dfs(int c)
{
	if(pz.md==0)return 1;
	rep(i,2)rep(d,4)
	{
		if(!pz.swp(i,d))continue;
		if(pz.md+c+1<=lim&&dfs(c+1))return 1;
		pz.swp(i,d+2&3);
	}
	return 0;
}
int main()
{
	int t;
	while(scanf("%d",&t),~t)
	{
		int p[5][5];
		rep(i,5)rep(j,5)p[i][j]=-1;
		p[0][2]=t;
		rep(i,3)scanf("%d",p[1]+i+1);
		rep(i,5)scanf("%d",p[2]+i);
		rep(i,3)scanf("%d",p[3]+i+1);
		scanf("%d",p[4]+2);
		
		for(lim=0;lim<=20;lim++)
		{
			pz=S(p);
			if(!dfs(0))continue;
			printf("%d\n",lim); goto END;
		}
		puts("NA"); END:;
	}
	return 0;
}

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

const int maxn = 3e3+100;
char str1[maxn],str2[maxn];
int dp[maxn][maxn];
int len1,len2;

void print(int x,int y) {
    if(!x || !y) return;
    if(dp[x][y-1] == dp[x][y]) {
        print(x,y-1);
    }
    else if(dp[x-1][y] != dp[x][y]) {
        print(x-1,y-1);
        printf("%c",str2[y-1]);
    }
    else print(x-1,y);
    /*
    if(dp[x-1][y] != dp[x][y]) {
        for(int i=1; i<=len2; i++) {
            if(dp[x][i] == dp[x][y]) {
                y = i;
                break;
            }
        }
        print(x-1,y-1);
        printf("%c",str2[y-1]);
    } else print(x-1,y);
    */
    return;
}

int main() {
    scanf("%s",str1);
    scanf(" %s",str2);
    len1 = strlen(str1);
    len2 = strlen(str2);
    for(int i=0; i<len1; i++) {
        for(int j=0; j<len2; j++) {
            if(str1[i] == str2[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else {
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }
    print(len1,len2);
    return 0;
}

Measured memory_bytes: 37248
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define iP pair<int,P>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

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

	int N,M,X,a,A[101];
	cin>>N>>M>>X;
	REP(i,N+1) A[i]=0;
	REP(i,M){
		cin>>a; A[a]=1;
	}

	int result1=0,result2=0;
	REP(i,X) if(A[i]==1) result1++;
	RFOR(i,X+1,N+1) if(A[i]==1) result2++;
	print(min(result1,result2));
	return 0;
}







Measured memory_bytes: 256
a,b,c,k=map(int,input().split())

if a==b:
  print(0)
else:
  ans_0=a-b
  ans_1=b-a
  if abs(ans_0)>=10**18:
    print("Unfair")
  elif k%2!=0:
    print(ans_1)
  elif k%2==0:
    print(ans_0)
  

Measured memory_bytes: 9104
#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>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;

int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>aa[i];
    m=0;
    for(int i=-100;i<=100;i++){
        c=0;
        for(int j=0;j<n;j++){
            c+=(i-aa[j])*(i-aa[j]);
        }
        m=i==-100 ? c:min(m,c);
    }
    C m E;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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 mod= 1e9 + 7;




int main(){
  int n,k;
  cin >>n >>k;
  ll a[n];
  ll maxx=0;
  rep(i,n){
    cin >> a[i];
    chmax(maxx,a[i]);}
  if(k==0){cout << maxx << endl; return 0;}


  ll lb=0,ub=1000000001;
  ll mid;
  while(abs(ub-lb)>1){
    mid=(ub+lb)/2;
    ll count=0;
    rep(i,n){
      if(a[i]>mid){count+=a[i]/mid;}
    }
    if(k<count)lb=mid;
    else ub=mid;
  }
  cout << ub << endl;
}

Measured memory_bytes: 5152
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
 
int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);

	int a,b;
	cin>>a>>b;
	long long int c[b],ct=0;
	forr(i,0,b)
		cin>>c[i], ct+=c[i];
	if(ct>=a)	cout<<"Yes";
	else cout<<"No";
	return 0;	
}

Measured memory_bytes: 1024
def f(x)
    return 0 if x & (x - 1) == 0
    return $memo[x] if $memo[x]
    cand = []
    (0..$m-1).each do |i|
        yes = x & $question[i]
        no = x - yes
        next if yes == 0 || no == 0
        k = f(yes) + 1 
        l = f(no) + 1
        cand << (k > l ? k : l)
    end 
    $memo[x] = cand.min
end 

loop do
    $m, n = gets.split.map(&:to_i)
    break if $m == 0
    rows = (1..n).map { gets.to_i(2) }
    if n == 1
        puts 0
        next 
    end 
    
    $question = (0..$m-1).map do |i|
        x = 0 
        (0..n-1).each do |j|
            x += (1 << j) if rows[j][i] == 1
        end 
        x
    end 
    
    $memo = {}
    p f(2**n-1)
end

Measured memory_bytes: 12804
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

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

    ll a, b;
    cin >> a >> b;

    ll c = max(a, b);
    ll d = min(a, b);

    for(ll i=0; i<c; i++)
    {
        cout << d;
    }
    cout << endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A.back() - A.front() << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>

int dp[1010][1010] = { 0 };

int max(int a, int b)
{
	return a > b ? a : b;
}

void lcs(char *s1, char *s2)
{
	int length1, length2;
	length1 = strlen(s1);
	length2 = strlen(s2);
	for (int i = 1; i <= length1; i++)
	{
		for (int j = 1; j <= length2; j++)
		{
			if (s1[i - 1] == s2[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
}

int main()
{
	int n;
	char s1[1100], s2[1100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s%s", s1, s2);
		for (int i = 0; i < 1009; i++)
			for (int j = 0; j < 1009; j++)
				dp[i][j] = 0;
		lcs(s1, s2);
		printf("%d\n", dp[strlen(s1)][strlen(s2)]);
	}
}


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

int main() {
  int N;
  cin >> N;
  int d = N%10 , c = (N/10)%10 , b = (N/100)%10 , a = N/1000;
  if ((a==b && b==c)||(b==c && c==d))
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int q;
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        long a,b;
        scanf("%ld %ld", &a, &b);
        if(a>b){
            swap(a,b);
        }         
        long n = a * b;
        long s = a;
        long t = b;
        bool bSquare = false;
               
        while(t - s >= 2){
            long u = (s + t) / 2;
            if(u * u > n){
                t = u;
            } else {
                s = u;
            }
        }
        
        if(s * s == n){
            bSquare = true;
        }
        
        long nAns = 0;
        if(!bSquare){
            if(s * (s + 1) >= n){
                nAns = 2 * (s - 1);
            } else {
                nAns = 2 * s - 1;
            }
        } else if(a == s){
            nAns = 2 * (s - 1);
        } else {
            nAns = 2 * (s - 1) - 1;
        }
        printf("%ld\n",nAns);
    }
    
    return 0;
}


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

int main(){
  int n;
  int a[100];
  int ans;
  
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      if (j != i) ans += a[i]*a[j];
    }
  }
  
  cout << ans/2 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;
int a[200001];
int b[200001];
int m,n;
int c[200001];
int d[200001];
int main()
{

   int flog=1;
   cin>>n>>m;
   for(int i=0;i<m;i++)
   {
       scanf("%d%d",&a[i],&b[i]);
       c[a[i]]=b[i];
       d[b[i]]=a[i];
   }
   for(int i=0;i<m;i++)
   {
      if(a[i]==1)
       {
           if(c[b[i]]==n)
            flog=0;
       }
    if(b[i]==1)
       {
          if(d[a[i]]==n)
            flog=0;
       }

   }
   if(flog==0) printf("POSSIBLE");
   else printf("IMPOSSIBLE");
}


Measured memory_bytes: 3328
#!/usr/bin/env python
# -*- coding: utf-8 -*-

coins = [500, 100, 50, 10, 5, 1]

while True:
    x = 1000 - int(input())
    if x == 1000:
        break

    ret = 0
    for coin in coins:
        n = x//coin
        x = x - n*coin
        ret += n

    print(ret)

Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int main(){
  int N;
  cin >> N;
  int X[104][104];
  if(N==2){cout << -1 << endl;return 0;}
  if(false){
    REP(i,N){
      REP(j,N-1){
        cout << (i+j)%N+1 << " ";
      }cout << endl;
    }
  }else{
    REP(i,N){
      REP(j,N-1){
        X[i][j]=j+1;
      }
    }
    REP(i,N){
      X[i][0]=N;
    }
    REP(i,N-1){
      X[i][i]=1;
    }
    X[N-1][0]=1;
    REP(j,N-1){
      X[0][j]=j+2;
    }

    REP(i,N){
      REP(j,N-1){
        if(j!=0){cout << " ";}
        cout << X[i][j];
      }cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin>>n;
  vector<int >nos(n,0);
  for(int i=0;i<n;i++)cin>>nos[i];
  int final=0;
  for(int i=0;i<n;i++)final = (final ^ nos[i]);
  for(int i=0;i<n;i++)cout<<(final ^ nos[i])<<' ';
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll calc(ll n) {
  return n * n * n * n * n;
}

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

  ll x;
  cin >> x;

  ll a = 1;
  while (1) {
    FORR(b, a - 1, -a) {
      if (calc(a) - calc(b) == x) {
        cout << a << ' ' << b << '\n';
        return 0;
      }
    }
    a++;
  }




  
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
using namespace std;

const int M=5;
char s[M],t[M];

int main()
{
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<3;i++)
		ans+=(s[i]==t[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
if n == 0: print(x); exit()
P = [*map(int, input().split())]
for d in range(100): # [0,100)
    a = x - d
    if a not in P: print(a); exit()
    a = x + d
    if a not in P: print(a); exit()


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

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;//2^60
constexpr double kEPS = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

ll N,W;
ll w[110],v[110],dp[110][100010];

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

int main(void) {
  cin >> N >> W;
  rep(i,N) cin >> w[i] >> v[i];

  ll V = 0;
  rep(i,N)V+=v[i];

  rep(i,N + 1) {
    rep(j,V+1) {
      dp[i][j] = kINF;
    }
  }

  dp[0][0] = 0;

  rep (i,N) {
    rep(j,V+1) {
      chmin(dp[i+1][j], dp[i][j]);
      if (j + v[i] <= V) chmin(dp[i+1][j+v[i]], dp[i][j]+w[i]);
    }
  }

  ll ans = 0;
  rep (i,N+1) {
    rep(j,V+1) {
      if (dp[i][j] <= W) chmax<ll>(ans, j);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 80128
import math
def main():
    H = int(input())
    # 全てをそのまま追う場合
    # 10*1->5*2->2*4->1*8
    # 8*1->4*2->2*4->1*8
    # 7*1->3*2->1*4
    # 4*1->2*2->1*4
    # 2**0+2**1+...+2**round(log(H))
    k = int(math.log(H)/math.log(2))
    ans = 1
    tmp = 1
    for i in range(k):
        tmp *= 2
        ans += tmp
    print(ans)

main()


Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
int x;
cin >> x;
  if (x < 600) cout << 8;
  else if (x < 800) cout << 7;
  else if (x < 1000) cout << 6;
  else if (x < 1200) cout << 5;
  else if (x < 1400) cout << 4;
  else if (x < 1600) cout << 3;
  else if (x < 1800) cout << 2;
  else if (x < 2000) cout << 1;
  return 0;
}

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

int main(void)
{
    int n;
    cin >> n;
    vector<vector<int> > G(n+1);
    int distv[n + 1];
    rep(i, n+1)
    {
        distv[i] = -1;
    }

    rep(i, n)
    {
        int num, deg;
        cin >> num >> deg;
        rep(j, deg)
        {
            int v;
            cin >> v;
            G[num].push_back(v);
        }
    }

    distv[1] = 0;
    queue<int> q;
    q.push(1);

    while(!q.empty())
    {
        int v = q.front();
        q.pop();
        for(int nv : G[v])
        {
            if(distv[nv] != -1) continue;
            q.push(nv);
            distv[nv] = distv[v] + 1;
        }
    }

    rep(i, n)
    {
        cout << i+1 << " " << distv[i+1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
    ll n,x,t;
    ll ans=0;
    cin>>n>>x>>t;
    while(n>0){
        n-=x;
        ans+=t;
    }
cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n>>k;
    ll w[n],val[n];
    for(i=0;i<n;i++)cin>>w[i]>>val[i];
    ll dp[100001];
    dp[0]=0;
    for(i=1;i<=100000;i++)dp[i]=inf;
    for(i=1;i<=n;i++)
    {
        for(j=100000;j>=val[i-1];j--)
        {
            dp[j]=min(dp[j],dp[j-val[i-1]]+w[i-1]);
        }
    }
    for(i=100000;i>=0;i--)
    {
        if(dp[i]<=k)
        {
            cout<<i;
            break;
        }
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C')
		{
			for(int j=i+1;j<a.size();j++)
				if(a[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}	
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

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

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  vll H(N);
  ll ans = 0;
  ll tmp = 0;
  REP(i,N){
    IN(H[i]);
    if(i==0) continue;
    if(H[i-1]>=H[i]){
      tmp++;
    }else{
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  OUT(ans);

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    string s;
    bool ok=true;
    cin>>s;
    n=s.size();
    rep(i,n){
        if((i+1)%2==0){
            //cout<<s[i]<<1<<endl;
            if(s[i]=='L' || s[i]=='U' || s[i]=='D'){
                continue;
            }else {
                ok=false;
            }
        }
        else{
            //cout<<s[i]<<2<<endl;
            if(s[i]=='R' || s[i]=='U' || s[i]=='D'){
                continue;
            }else {
                ok=false;
            }
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;



int main() {
ll ans,K,A,B;
cin>>K>>A>>B;
if(A<B){
    ans=max(A+((K-A+1)/2)*(B-A)+(K-A+1)%2,K+1);

}
else{
    ans=K+1;
}
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 256