akhauriyash/Code-Regression huggingface dataset:
#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))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

class Stack{
private:
int m[1000];
int tp;
public:
    Stack(){
    tp=0;
    }
    void push(int x){
        tp++;
        m[tp]=x;
    }
    int pop(){
        tp--;
        return m[tp+1];
    }
}; 
class Queue{
private:
pair<string,int> m[60000];
int head,tail;
public:
    Queue(){
        head=0;
        tail=0;
    }
    bool isEmpty(){
        return head==tail;
    }
    void enqueue(pair<string,int> x){
        m[tail]=x;
        if(tail +1 ==60000)tail=0;
        else tail++;
    }
    pair<string,int> deque(){
        pair<string,int> x=m[head];
        if(head+1==60000)head=0;
        else head++;
        return x;
    } 
};

int main(){
ll m,n;
ll N=1E7;
while(1){
cin>>m>>n;
if(m==0&&n==0)break;

vector<ll> res;    
vector<bool> is_prime(N + 1, true);
for (ll p = m; p <= N; p++) {
    if (!is_prime[p]) continue;

    for (ll k = p * 2; k <= N; k += p) is_prime[k] = false;
    res.push_back(p);
}
cout<<res[n]<<endl;
}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double l; cin>>l;
    cout<<setp(12);
    cout<<(l/3)*(l/3)*(l/3)<<endl;
    return 0;
}


Measured memory_bytes: 256
//
//  A - Strings.cpp
//  Practice
//
//  Created by Hajime Sakamoto on 2019/12/30.
//  Copyright © 2019 Hajime Sakamoto. All rights reserved.
//

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>

using namespace std;

class Strings {
public:
    string s;
    string t;
    string op;
    
    void JoinString(){
        op = t +s;
        
    };
};

int main(){
    Strings prc;
    
    cin >> prc.s;
    cin >> prc.t;
    
    prc.JoinString();
    
    cout << prc.op;
    
    
    return 0;
    
}


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

odd = (m + 1) // 2
even = m - odd

l = 1
r = 2 * odd
while l < r:
    print(l, r)
    l += 1
    r -= 1

l = n - 2 * even
r = n
while l < r:
    print(l, r)
    l += 1
    r -= 1


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  vector<int> black(N+1,0);
  vector<int> white(N+1,0);
  int cnt1 = 9999999,cnt2 = 9999999;
  int ans = 999999;
  for(int i = 0; i < N; i++){
    if(S[i] == '#'){
      black[i + 1] = black[i] + 1;
      white[i + 1] = white[i];
    }
    else{
      black[i + 1] = black[i];
      white[i + 1] = white[i] + 1;
    }
  }
  for(int i = 0; i < N + 1; i++){
    cnt1 = black[i] - black[0];
    cnt2 = white[N] - white[i];
    ans = min(ans,cnt1 + cnt2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int maxcount = 0;
    for( int i = 1; i < n; i++){
        int count = 0;
        for(char m = 'a'; m <= 'z'; m++){
            for(int j = 0; j<i; j++){
                for(int k = i; k < n; k++){
                    if(m==s[j] && m==s[k]){
                        count += 1;
                        goto last;
                    }
                }
            }
            last:
            continue;
        }
        maxcount = max(maxcount,count);
    }
    cout << maxcount << endl;

    return 0;
}

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

int toInt(string s){
  int h = (s[0] - '0') * 10 + (s[1] - '0');
  int m = (s[3] - '0') * 10 + (s[4] - '0');
  return h * 60 + m;
}

int main(){
  int n, m;
  int st_time[12], ar_time[12];
  string st_name[12], ar_name[12];

  while(cin >> n >> m){
    for(int i = 0; i < n; i++){
      string s;
      cin >> s;
      st_time[i] = toInt(s);

      cin >> st_name[i];

      cin >> s;
      ar_time[i] = toInt(s);

      cin >> ar_name[i];
    }

    vector<string> ans;
    vector<int> ansTime;

    for(int i = 1; i < n; i++){
      if(st_time[i] - ar_time[i - 1] >= m){
        ans.push_back(st_name[i]);
        ansTime.push_back(st_time[i] - ar_time[i - 1]);
      }
    }

    cout << ans.size() << endl;

    for(int i = 0; i < ans.size(); i++){
      cout << ans[i] << " " << ansTime[i] << endl;
    }
  }
}

Measured memory_bytes: 1236
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x;
    cin>>x;
    ll sum=0;
    for(ll i=1;;i++)
    {
        sum+=i;
        if(sum>=x)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

int menu[5];

int main() {
    for (int i=0; i<5; ++i) {
        std::cin >> menu[i];
    }
    
    int min = 11;
    int temp;
    int minidx;
    
    for (int i=0; i<5; ++i) {
        if (menu[i] % 10 == 0) {
            temp = 10;
        } else {
            temp = menu[i] % 10;
        }
            
        if (temp < min) {
            min = temp;
            minidx = i;
        }
    }
    
    int ans = 0;
    for (int i=0; i<5; ++i) {
        if (i != minidx) {
            ans += menu[i];
            while (ans % 10 != 0) {
                ans++;
            }
        }
    }
    std::cout << ans + menu[minidx] << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    //cout << "Hello world!" << endl;
    ll t,i,j,k,m,n,a,b,d;
    cin>>d>>n;
    if(n==100)
    {
        n++;
    }
    j=pow(100,d);
    cout<<j*n;
  /* cin>>n;
    ll ar[n];
for(i=0;i<n;i++)
{
    cin>>ar[i];
}
vector<ll>v;
   for(i=0;i<n;i++)
   {
       k=ar[i];j=0;
       while(k%2==0)
       {
           j++;
           k/=2;
           v.push_back(j);

       }
   }
   ll an=0;
   for(i=0;i<v.size();i++)
   {
     an+=v[i];  cout<<v[i]<<" ";;
   }*/
   //cout<<an;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int X=sc.nextInt();
	int Y=sc.nextInt();
	int ans=0;
	if(X<4) {
		switch (X) {
		case 1:
			ans+=300000;
			break;
		case 2:
			ans+=200000;
			break;
		case 3:
			ans+=100000;
			break;
		}

	}
	if(Y<4) {
		switch (Y) {
		case 1:
			ans+=300000;
			break;
		case 2:
			ans+=200000;
			break;
		case 3:
			ans+=100000;
			break;
		}
	}
	if(X==1&&Y==1) {
		ans+=400000;
	}
	System.out.println(ans);
}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll m = 1000000000;
    rep(i,100){
        ll sum = 0;
        rep(j,n){
            sum += (a[j]-(i+1))*(a[j]-(i+1));
        }
        m = min (m,sum);
    }
    cout << m;

    return 0;
}

Measured memory_bytes: 3560
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e15;

ll n, m;
ll l, r, a;
vector<pll> Interval[220000];

struct Seg{
    vector<ll> sum;
    vector<ll> mx;
    Seg(){
        sum.resize(1 << 19, 0);
        mx.resize(1 << 19, 0);
    }

    void add_val(ll l, ll r, ll val, ll bottom = 0, ll top = (1 << 18), ll pos = 1){
        if(l <= bottom && top <= r){
            sum[pos] += val; //区間加算
            return;
        }
        if(r <= bottom || top <= l){
            return;
        }
        ll mid = (bottom + top) / 2;
        add_val(l, r, val, bottom, mid, pos * 2);
        add_val(l, r, val, mid, top, pos * 2 + 1);
        mx[pos] = max(mx[pos*2] + sum[pos*2], mx[pos*2+1] + sum[pos*2+1]); //最大値を更新
    }

    ll max_val(ll l, ll r, ll bottom = 0, ll top = 1 << 18, ll pos = 1){
        if(l <= bottom && top <= r){
            return sum[pos] + mx[pos];
        }
        if(r <= bottom || top <= l){
            return -INF;
        }
        ll mid = (bottom + top) / 2;
        return max(max_val(l, r, bottom, mid, pos * 2),
                   max_val(l, r, mid, top, pos * 2 + 1)) + sum[pos];
    }    
};

int main(){
    cin >> n >> m;
    for(ll i = 0;i < m;i++){
        cin >> l >> r >> a;
        Interval[r].push_back(pll(l, a));
    }
    Seg seg;
    for(ll i = 1;i <= n;i++){
        ll mx = seg.max_val(0,i);
        seg.add_val(i, i+1, mx);
        for(auto p: Interval[i]){//iが区間の右端になるものを見ていく
            ll l = p.first;
            ll a = p.second;
            seg.add_val(l, i+1, a);
        }
    }

    cout << seg.max_val(0,n+1) << endl;
    
    return 0;
}


Measured memory_bytes: 19840
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main(){
	long long n,h,a,sum=0;
	cin>>h>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		sum+=a;
	}
	if(sum>=h){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

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

using namespace std;
int main(){
    int gyou,retu;
    cin>>gyou>>retu;
    vector<string>word(gyou);
    for(int i=0;i<gyou;i++){
        cin>>word.at(i);
    }

    for(int i=0;i<retu+2;i++){
        cout<<"#";
    }
    cout<<endl;

    for(int i=0;i<gyou;i++){
        cout<<"#"<<word.at(i)<<"#"<<endl;
    }

    for(int i=0;i<retu+2;i++){
        cout<<"#";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int A, B, C;
  scanf("%d" "%d" "%d", &A, &B, &C);
  int ans = C - (A - B);
  if(ans < 0){
    printf("0\n");
  }else{
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int t1, t2; cin >> t1 >> t2;
    ll a1, a2, b1, b2; 
    cin >> a1 >> a2 >> b1 >> b2;
    ll v1 = a1 - b1, v2 = a2 - b2;
    ll dis = v1*t1 + v2*t2;
    if ((v1 > 0 && dis > 0) || (v1 < 0 && dis < 0)) cout << 0 << endl;
    else if (v1*dis == 0) cout << "infinity" << endl;
    else {
        ll ans;
        dis = abs(dis);
        v1 = abs(v1);
        if ((v1*t1) % dis == 0) ans = (v1*t1/dis+1)*2 - 2;
        else ans = (v1*t1/dis+1)*2 - 1;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

const int mod = 1000000007;

typedef pair <int, int> pii;

vector <pii> from[310];
int f[310][310][310];

bool alive(int a, int b, int c) {
	for (int i = 0; i < from[a].size(); i++) {
		int l = from[a][i].fi, x = from[a][i].se;
		int xx = l > b ? 1 : l > c ? 2 : 3;
		if (xx != x) return 0;
	}
	return 1;
}

void add(int &a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

int main () {
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int l, r, x; scanf("%d%d%d", &l, &r, &x);
		from[r].push_back(mp(l, x));
	}
	f[0][0][0] = 1;
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = 0; k <= j; k++) {
				if (!f[i][j][k]) continue;
				if (alive(i, j, k)) {
					if (i == n) ans = (ans + f[i][j][k]) % mod;
					else {
						add(f[i + 1][j][k], f[i][j][k]);
						add(f[i + 1][i][k], f[i][j][k]);
						add(f[i + 1][i][j], f[i][j][k]);
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 112896
import numpy as np
N = int(input())

X = [int(i) for i in input().split()]

med_1up = int(np.median(X+[10e9+1]))
med = np.median(X)
med_1down = int(np.median(X+[0]))
for i in range(N):
    if X[i] > med:
        print(med_1down)
    else:
        print(med_1up)

Measured memory_bytes: 34164
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main(void){
    long long int X,Y;
    cin >> X >> Y;
    if(abs(X-Y)<=1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int Dice(int n[6],int k[6]){
  int g = 1;
  int sou = 2;
  int east = 3;
  int west = 4;
  int nor = 5;
  int t = 0;
  string str;
  if (k[0] == n[1]){
    str = 'N';
  }else if(k[0] == n[2]){
    str = 'W';
  }else if(k[0] == n[3]){
    str = 'E';
  }else if(k[0] == n[4]){
    str = 'S';
  }else if(k[0] == n[5]){
    str = "NN";
  }else{
    str = 'Y';
  }

  for(int i = 0;i < str.length(); i++){
    if(str[i] == 'E'){
      east = g;
      g = west;
      west = 7-east;
    }else if(str[i] == 'W'){
      west = g;
      g = east;
      east = 7-west;
    }else if(str[i] == 'N'){
      nor = g;
      g = sou;
      sou = 7-nor; }else if(str[i] == 'S'){ sou = g; g = nor; nor = 7-sou; }else{
    }
  }

  for(int i = 0; i < 5;i++){
    int temp = nor;
    nor = east;
    east = sou;
    sou = west;
    west = temp;
    //cout << n[nor-1] << " " << n[east-1] << " " << n[sou-1] << " " << n[west-1]  << " " << n[g-1] << " " << n[7-g-1]<< endl;
    //cout << k[4] << " " << k[2] <<" " << k[1] << " " << k[3] << " " << k[0] <<" " << k[5]<< endl;
    //cout << endl;
    if(n[g-1] == k[0] && n[sou-1] == k[1] && n[nor-1] == k[4] && n[east-1] == k[2] && n[west-1] == k[3] && n[6-g] == k[5]){
      //cout << "error line" << endl;
      t = 1;
    }
  }
  return t;
}

int main(void){
  int n[200][6];
  int a;
  int t = 0;
  cin >> a;
  for(int i = 0;i < a;i++){
    for(int j = 0;j < 6;j++){
      cin >> n[i][j];
    }
  }
  for(int i = 0;i < a;i++){
    for(int j = 0;j < a;j++){
      if( i != j){
       //cout << Dice(n[i],n[j]) << " " << i << " " << j << endl;
       //cout << " here is end" << endl;
      if(Dice(n[i],n[j])== 1){
        t = 1;
        break;
      }
      }
    }
    if(t == 1){
      break;
    }
  }
  if( t == 1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int n, m, x;
    cin >> n >> m >> x;
    int A[200];
    rep(i, 0, m) cin >> A[i];
    int l = 0, r = 0;
    rep(i, 0, m) {
        A[i] < x ? l++ : r++;
    }
    cout << min(l, r) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
typedef unsigned int uint;

inline static uint gl(void){
    uint x = 0;
    for(;;){
        const uint c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

#define H 200000
uint v[H] __attribute__((aligned(64)));
int main(void){
    memset(v, 0x33, sizeof(uint)*H);
    {
        const uint h = gl();
        gl();
        const uint n = gl();
        for(uint i=0; i<n; i++){
            const uint x = gl()-1;
            const uint y = gl()-1;
            v[x] = y<v[x] ? y : v[x];
        }
        v[h] = 0;
    }
    {
        uint right = 0;
        uint x = 1;
        for(; ; x++){
            const auto b = v[x];
            const auto r = right+1;
            if(b<r){
                break;
            }else if(b>r){
                right=r;
            }
        }
        printf("%d\n", x);
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int H,W;
    cin >> H >> W;
    int m=0;
    rep(i,H){
        rep(j,W){
            char x;
            cin >> x;
            if(x=='#') m++;
        }
    }
    string ans="Possible";
    if(m-(H+W-1)!=0) ans="Impossible";
    cout << ans << endl;







}


Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split())

graph = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

que = deque()
que.append(0)

visited = [0 for _ in range(n)]
visited[0] = 1
ans = [None for _ in range(n)]

print('Yes')
while len(que) > 0:
    c = que.popleft()
    for ne in graph[c]:
        if visited[ne] == 1:
            continue
        que.append(ne)
        ans[ne] = c
        # print(f'ans[{ne}] = {c}')
        visited[ne] = 1

for i in range(1, n):
    print(ans[i] + 1)


Measured memory_bytes: 34976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int A, B;
	cin >> A >> B;
	int now = 1;
	int cnt = 0;
	while(true){
		if(now >= B)break;
		now--;
		now += A;
		cnt++;
	}
	cout << cnt << endl;
}


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

int GCD(int a,int b){
  if(a<b){swap(a,b);}  
  if(a%b==0){return b;}
  else{return GCD(a%b,b);} 
}

int main(){
  int a,b,k;cin>>a>>b>>k;
  int g=GCD(a,b);
  int d=1;
  while (true){
    if(g%d==0){k--;}
    if(k==0){cout<<g/d;break;}
    d++;
  }
  
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i] = i+1;

    map<vector<int>, int> mp;
    do {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));
    int ans = abs(mp[p]-mp[q]);
    cout << ans << endl;
}

Measured memory_bytes: 8588
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<functional>

using namespace std;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template<typename T>
bool chmin(T& l, T r) {
	bool res = l > r;
	if (res)l = r;
	return res;
}
int f(int x, int y, int z) {
	return x + y + z;
}
int main() {
	int e;
	while (cin>>e,e) {
		int res = e;
		REP(y, 1001)REP(z, 101) {
			int x = e - y*y - z*z*z;
			if (x >= 0)chmin(res, x + y + z);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}
 
void solve() {
    int n;
    cin >> n;
    vector<double> c(n);
    REP(i, n) cin >> c[i];
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 1.0));

    REP1(i, n) REP(j, i + 1) {
        if (j == 0) dp[i][j] = dp[i - 1][0] * c[i - 1];
        else if (j == i) dp[i][j] = dp[i - 1][i - 1] * (1.0 - c[i - 1]);
        else dp[i][j] = dp[i - 1][j - 1] * (1.0 - c[i - 1]) + dp[i - 1][j] * c[i - 1];
    }
    double ans = 0.0;
    REP(i, (n + 1) / 2) ans += dp[n][i];
    cout << ans << EOL;
}


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

using namespace std;

int main()
{
	vector<int> train;
	int a;
	vector<int>::iterator it;
	for(;cin >> a;)
	{
		if(a!=0)
			train.push_back(a);
		else
		{
			it=train.end()-1;
			cout << *it << endl;
			train.pop_back();
		}
	}
}

Measured memory_bytes: 0
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47360
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

typedef
tree<
	pair<int, int>,
	null_type,
	less<pair<int, int>>,
	rb_tree_tag,
	tree_order_statistics_node_update>
ordered_set;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

struct tr{
    tr* nxt[26];
    ll c=0;
};

ll n,k;
        
void insert(tr* p, string s)
{
    tr *cur=p;
    repf(i,0,s.length())
    {
        if(!cur->nxt[s[i]-'A']) 
        {
            cur->nxt[s[i]-'A']=new tr();
        }
        cur=cur->nxt[s[i]-'A'];
        cur->c++;
    }
}

ll f(tr *p)
{
    if(!p) return 0;
    ll ans=p->c/k;
    repf(i,0,26)
    {
        if(p->nxt[i]) ans+=f(p->nxt[i]);
    }
    return ans;
}

bool ispalin(string s)
{
    repf(i,0,s.length()/2)
    {
        if(s[i]!=s[s.length()-i-1]) return false;
    }
    return true;
}

int main()
{
    IOS;
    ll n;
    cin>>n;
    map<ll,ll> mp;
    ll a[n];
    repf(i,0,n) 
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    ll s=0;
    for(auto i:mp)
    {
        s+=(i.se*(i.se-1))/2;
    }
    repf(i,0,n)
    {
        ll ans=s-(mp[a[i]]*(mp[a[i]]-1))/2+((mp[a[i]]-1)*(mp[a[i]]-2))/2;
        cout<<ans<<endl;
    }
}   

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

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;

    while(true) {
        c -= b;
        if(c <= 0) {
            cout << "Yes";
            break;
        }
        a -= d;
        if(a <= 0) {
            cout << "No";
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3592
#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() {
    in(string, s);
    if ((s[0]==s[1])&&(s[2]==s[3])&&(s[0]!=s[2])) {
        cout << "Yes" << endl;
    }else if ((s[0]==s[2])&&(s[1]==s[3])&&(s[0]!=s[1])) {
        cout << "Yes" << endl;
    }else if ((s[0]==s[3])&&(s[2]==s[1])&&(s[0]!=s[1])) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N;
    cin >> N;
    long long sum = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        else sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
using graph = vector<vector<int>>;

int main() {
  int h, w, res=0;
  cin >> h >> w;
  int n = (h+1)*(w+1);
  vector<vector<char>> m(h+1, vector<char>(w+1, '#'));
  graph g(n);
  int a, b;
  for(int i=1;i<=h;++i) for(int j=1;j<=w;++j) {
    cin >> m[i][j];
    if(m[i][j]=='.'){
      a=i*w+j;
      if(m[i-1][j]=='.'){
        b=(i-1)*w+j;
        g[a].push_back(b);
        g[b].push_back(a);
      }
      if(m[i][j-1]=='.'){
        b=i*w+j-1;
        g[a].push_back(b);
        g[b].push_back(a);
      }
    }
  }
  auto dfs = [&](int start){
    int res=0;
    vector<int> dist(n,-1);
    queue<int> q;
    dist[start] = 0;
    q.push(start);
    while(!q.empty()) {
      int v=q.front();
      q.pop();
      for(int p:g[v]) {
        if(dist[p]!=-1) continue;
        dist[p]=dist[v]+1;
        q.push(p);
      }
    }
    for(int d:dist) res=d>res?d:res;
    return res;
  };
  for(int i=1;i<=h;++i) for(int j=1;j<=w;++j) {
    if(m[i][j]=='#') continue;
    res=max(res,dfs(i*w+j));
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import sys
# sys.stdin = open('input.txt')

def dfs(r, c):
    S = []
    S.append(r)
    color[r] = c
    while len(S) > 0:
        u = S.pop()
        for v in G[u]:
            if color[v] is None:
                color[v] = c
                S.append(v)

def assignColors():
    colorId = 0
    for i in range(n):
        if color[i] is None:
            dfs(i, colorId)
            colorId += 1

n, m  = map(int, input().split())
G = [[] for _ in range(n)]
color = [None] * n

for i in range(m):
    s, t = map(int, input().split())
    # Doubly link
    G[s].append(t)
    G[t].append(s)

assignColors()

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    if color[s] is not None and color[s] == color[t]:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 23388
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = Integer.parseInt(scanner.next());
        int K = 0;

        scanner.close();
        if (360 % X == 0){
            K = 360 / X;
        } else {
            K = lcm(360, X);
            K /= X;
        }
        

        System.out.println(K);
    }

    static int lcm (int a, int b) {
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a % b) !=0 ) {
            a = b;
            b = tmp;
        }
        return (int)(c / b);
    }
}


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

using namespace std;

int main(){
int N; cin >> N;
  vector<int> X(N); vector<int> Y(N); vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> X[i] >> Y[i] >> H[i];}
  
  for(int cx = 0; cx <= 100; cx++){
    for(int cy = 0; cy <= 100; cy++){
      
      int hight = -1;
      for(int i = 0; i < N; i++){
      if(H[i] > 0){
        int tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy);
         if(hight == -1){ hight = tmp;}
        else{
          if( hight != tmp){ hight = -2; break;}}
       }}
     if(hight == -2){ continue;}
      for(int j = 0; j < N; j++){
        if(H[j] == 0){
          int dist = abs(X[j] - cx) + abs(Y[j] - cy);
          if(dist < hight){ hight = -2; break;}}}
      if(hight == -2){ continue;}
      
      cout <<cx<< " "<< cy << " " << hight << endl; return 0;}}
  
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
#define mp make_pair

namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
	out << '(' << a.fi << ", " << a.se << ')';
	return out;
}
}


int main() {
	int t, d, l;
	while (cin >> t >> d >> l) {
		if (t == 0 && d == 0 && l == 0) break;
		vi x(t);
		rep(i, t) cin >> x[i];
		int cnt = 0, prv = -1;
		rep(i, t) {
			if (x[i] < l) continue;
			if (prv != -1) {
				int dif = prv + d - i;
				if (dif > 0) cnt -= dif;
			}
			cnt += d;
			prv = i;
		}
		if (prv != -1 && ++prv + d > t) cnt -= prv + d - t;
		cout << cnt << endl;
	}
	return 0;
}

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

int main(){
    string s, p;
    int num = 0;
    bool check = false;
    
    getline(cin, s);
    getline(cin, p);
    
    for(int i = 0; i < s.size(); i++){
        num = 0;
        for(int j = 0; j < p.size(); j++){
           if(p[j] == s[(i + j) % s.size()]){
               num++;
               if(num == p.size()){
                   check = true;
                   break;
               }
           }
           else{
               num = 0;
           }
       }
    }
    
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3204
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N, T, L, B;
  while(cin>>N>>T>>L>>B && N){
    bool lose[105] = {};
    bool back[105] = {};
    REP(i, L) {
      int k; cin>>k;
      assert(k < 100);
      lose[k] = true;
    }
    REP(i, B) {
      int k; cin>>k;
      assert(k < 100);
      back[k] = true;
    }
    double dp[105][105] = {};
    dp[0][0] = 1;
    REP(t, T + 1){
      REP(x, N)if(dp[t][x] > 0){
        for(int d = 1; d <= 6; d++){
          int next = x + d;
          if(next > N) next = N - (next - N);
          if(lose[next]){
            dp[t + 2][next] += dp[t][x] * 1.0 / 6.0;
          }else if(back[next]){
            dp[t + 1][0] += dp[t][x] * 1.0 / 6.0;
          }else{
            dp[t + 1][next] += dp[t][x] * 1.0 / 6.0;
          }
        }
      }
      //dp[t + 1][N] += dp[t][N];
    }
    double ans = 0;
    REP(t, T) ans += dp[t + 1][N];
    printf("%.10lf\n", ans);
    //cout<<dp[T][N]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <utility>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if (a > b)
    swap(a, b);
  rep(i, b) cout << a;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    typedef struct question_ {	
	    long p;
	    long c;
	    long cp;
    } Question;	

    int main(){
        long d , g;
        cin >> d >> g;
        vector<Question> v;
        long pt , ct; 
        for(int i = 0 ; i < d ; i++){
            cin >> pt >> ct;
            Question *q = new Question; 
            q->p = pt;
            q->c = ct;
            q->cp = (i + 1) * pt * 100 + ct ;
            v.push_back(*q);
            //cout << q->p << ":" << q->c << ":" << q->cp << endl;
        }
        // bit all search 
        long ans = 2000000000;
        long sump;
        long temp_ans;
        for(int i = 0 ; i < (1<<d) ; i++){
            sump = 0;
            temp_ans = 0;
            for(int j = 0 ; j < d ; j++){
                if( i>>j & 1){
                    Question q2 = v[j];
                    sump += q2.cp;
                    temp_ans += q2.p; 
                }
            }
            //cout << i << ":" << sump << ":" << temp_ans << endl;
            for(int j = d - 1 ; j >= 0  ; j--){
                if(!(i>>j & 1)){
                    Question q3 = v[j];
                    //cout << q3.c << endl;
                    for(int k = 0 ; k < q3.p  ; k++){
                        if(sump >= g) break;
                        sump += (j + 1 ) * 100;
                        temp_ans += 1; 
                    } 
                    break;
                }
                //cout << j << endl;
            }
            if(sump >= g){
               ans = min(ans, temp_ans); 
               //cout << i << ":" << sump << ":" << temp_ans << endl;
            }  
        }
        
        cout << ans << endl;
              
        return 0;
    }

Measured memory_bytes: 256
// AOJ 2165: Strange String Manipulation
// 2017.10.6 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define EPS 1.0e-8
#define M 255

int t[257];
int f[256];

int main()
{
	int n, s, a, c, i, r, ss, aa, cc;
	double h, hh;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d", t+i); 

        hh = 1.0e8;
		for (s = 0; s <= 15; s++) for (a = 0; a <= 15; a++) for (c = 0; c <= 15; c++) {
			memset(f, 0, sizeof(f));
			r = s;
            for (i = 0; i < n; i++) r = (a * r + c) & M, f[(t[i] + r) & M]++;
            h = 0;
			for (i = 0; i <= M; i++) if (f[i]) {
				double x = (double)f[i] / n;
				h -= x * log(x);
			}
	        if (h + EPS < hh) hh = h, ss = s, aa = a, cc = c;
        }
		printf("%d %d %d\n", ss, aa, cc);
    }
	return 0;
}

Measured memory_bytes: 1928
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<m; i++) cin >> b[i];
    
    bool ans;
    for (int y=0; y<=n-m; y++) {
        for (int x=0; x<=n-m; x++) {
            ans = true;
            for (int i=0; i<m; i++) {
                if (a[y+i].substr(x, m) == b[i]) continue;
                ans = false;
            }
            if (ans) break;
        }
        if (ans) break;
    }
    
    cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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 (b<a) { a=b; return 1; } return 0; }

const ll MOD = 998244353;
const ll inf = 1e18;

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

    ll n, s;
    cin >> n >> s;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }

    // dp[i][x] : R == i のとき和が x になる場合の数
    vll dp(3010);
    ll res = 0;
    REP(i, n) {
        REPR(j, s + 1) {
            if (j == 0) {
                // L \in [0, i], R == i をまとめる
                dp[a[i]] += i + 1;
                dp[a[i]] %= MOD;
            }
            // j != 0 からの推移では L を固定済
            else if (j + a[i] <= s) {
                dp[j + a[i]] += dp[j];
                dp[j + a[i]] %= MOD;
            }
        }
        res += dp[s];
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,X;
  cin>>N>>X;
  vector<int>m(N);
  REP(i,N)cin>>m[i];
  int sum=accumulate(ALL(m),0), mi=*min_element(ALL(m));
  cout<<(X-sum)/mi+N<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,h,w,n;
  n=1;
  while(n=1){
    scanf("%d",&h);
    scanf("%d",&w);
    if(h==0 && w==0) break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(i%2==0){
          if(j%2==0) printf("#");
          else printf(".");
        }
        else{
          if(j%2==0) printf(".");
          else printf("#");
        }
        }
        printf("\n");
      }

      printf("\n");

    }
return 0;
}



Measured memory_bytes: 1968
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn solve(n: i64, a: &[i64], b: &[i64]) -> i64 {
    let mut upppers: Vec<_> = a.iter().zip(b.iter()).map(|(&a, &b)|
        (if b > a { n/a } else { 0 }, a, b)
    ).collect();
    upppers.sort();

    let mut ans = n;
    for i in 0..upppers[0].0+1 {
        for j in 0..upppers[1].0+1 {
            let &(_, ai, _) = &upppers[0];
            let &(_, aj, _) = &upppers[1];
            let &(_, ak, bk) = &upppers[2];

            let rem = n - ai*i - aj*j;
            if rem < 0 {
                break;
            }
            let k =  if bk > ak { rem/ak } else { 0 };
            ans = max(
                ans,
                n + [i,j,k].into_iter().zip(upppers.iter()).map(|(n, &(_, a, b))| n * (b-a)).sum::<i64>(),
            );
        }
    }
    ans
}

fn main() {
    input!{
      n: i64,
      a: [i64; 3],
      b: [i64; 3],
    }
    let m = solve(n, &a, &b);
    let ans = solve(m, &b, &a);
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        for(int i=0;i<n;i++){
            int t = sc.nextInt();
            if(t%2==0) pq.add(t);
        }
        int c= 0;
        while(pq.size()>0){
            int r = pq.poll();
            c++;
            r/=2;
            if(r%2==0) pq.add(r);
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 35760
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];

    ll ans = -1;

    ll x = 0;
    srep(i,2,n)x ^= a[i];

    bitset<50> f(x);

    ll yy = a[0] + a[1];
    ll zz = 0;
    ll two[55] = {};
    two[0] = 1;
    srep(i,1,55)two[i] = two[i-1]*2;
    drep(i,50){
        if(f[i] == 1){
            yy -= two[i];
        }else{
            if(two[i]*2 <= yy){
                yy -= two[i]*2;
                zz += two[i];
            } 
        }
    }

    if(yy != 0 || zz > a[0]){
        cout << -1 << endl;
        return 0;
    }

    ans = 0;

    drep(i,50){
        if(f[i] == 1){
            if(zz + two[i] <= a[0]){
                zz += two[i];
            }
        }
    }

    ans = a[0] - zz;
    if(ans == a[0]){
        cout << -1 << endl;
        return 0;
    }

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




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

static int output[100][100];

static void nurinuri(int a, int x, int y, int W, int H)
{
	int i, j;

	switch (a) {
	case 1:
		// ai=1 のときは長方形の x<xi をみたす領域
		for (i = 0; i < H; i++) {
			for (j = 0; j < x; j++) {
				output[i][j] = -1;
			}
		}
		break;
	case 2:
		// ai=2 のときは長方形の x>xi をみたす領域
		for (i = 0; i < H; i++) {
			for (j = x; j < W; j++) {
				output[i][j] = -1;
			}
		}
		break;
	case 3:
		// ai=3 のときは長方形の y<yi をみたす領域
		for (i = 0; i < y; i++) {
			for (j = 0; j < W; j++) {
				output[i][j] = -1;
			}
		}
		break;
	case 4:
	default:
		// ai=4 のときは長方形の y>yi をみたす領域
		for (i = y; i < H; i++) {
			for (j = 0; j < W; j++) {
				output[i][j] = -1;
			}
		}
		break;
	}
}

int main(void)
{
	int W, H, N, i, x, y, a, j, cnt;

	scanf("%d%d%d", &W, &H, &N);

	for (i = 0; i < N; i++) {
		scanf("%d%d%d", &x, &y, &a);
		nurinuri(a, x, y, W, H);
	}

	for (i = 0, cnt = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (output[i][j] < 0) {
				cnt++;
			}
		}
	}

	printf("%d", (W*H - cnt));

	return 0;
}


Measured memory_bytes: 256
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <chrono>
#include <random>
#include <numeric>
using namespace std;

int main()
{
  int N, A, B;
  int tmp;
  cin >> N >> A >> B;
  int p1, p2, p3;
  p1 = p2 = p3 = 0;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    if(tmp <= A)
      p1++;
    else if(tmp <= B)
      p2++;
    else
      p3++;
  }
  cout << min(p1, min(p2, p3)) << endl;
  
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,k,f[200005],s[200005],l[25],r[25];
int main(){
	cin>>n>>k;
	for(int i=1;i<=k;i++)cin>>l[i]>>r[i];
	f[1]=s[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(l[j]>=i)continue;
			int o=l[j],oo=min(r[j],i-1);
			f[i]=(0ll+f[i]+s[i-o]-s[i-oo-1]+mod)%mod;
		}
		s[i]=s[i-1]+f[i];
		s[i]%=mod;
	}
	cout<<f[n];
    return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int ma = max(max(a,b),c);
    int mi = min(min(a,b),c);
    cout << ma-mi << endl;
}


Measured memory_bytes: 3660