akhauriyash/Code-Regression huggingface dataset:
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int color[401][401];
bool board[401][401];

int h, w;

bool valid(pair<int, int>& a){
    return(a.fi >= 0 && a.fi < h && a.se >= 0 && a.se < w);
}

int main(){
    cin >> h >> w;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            char c;
            cin >> c;
            board[i][j] = (c == '#');
        }
    }
    memset(color, -1, sizeof(color));
    int pen = 0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(color[i][j] != -1){
                continue;
            }
            ++pen;
            queue<pair<int, int> > Q;
            Q.push(mp(i, j));
            color[i][j] = pen;
            while(!Q.empty()){
                pair<int, int> at = Q.front();
                Q.pop();
                for(int k=0;k<4;++k){
                    pair<int, int> tmp = mp(at.fi + dx4[k], at.se + dy4[k]);
                    if(!valid(tmp)){
                        continue;
                    }
                    if(color[tmp.fi][tmp.se] != -1){
                        continue;
                    }
                    if(board[at.fi][at.se] != board[tmp.fi][tmp.se]){
                        color[tmp.fi][tmp.se] = pen;
                        Q.push(tmp);
                    }
                }
            }
        }
    }
    map<int, pair<ll, ll> > freq;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(board[i][j]){
                ++freq[color[i][j]].fi;
            }else{
                ++freq[color[i][j]].se;
            }
        }
    }
    ll ans = 0ll;
    for(auto it=freq.begin();it!=freq.end();++it){
        pair<ll, ll> tmp = it->second;
        ans += (tmp.fi * tmp.se);
    }
    cout << ans << endl;
}


Measured memory_bytes: 12932
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
inline void getmin(long long &x, long long y) { if (x > y) x = y; }
int n, X, D, tot, pa[N], sz[N], lim[N];
long long dp[N * N * N], m[N];
inline void _upd(long long X, int Y) {
	tot += Y;
	for (int i = tot; i >= Y; i--) getmin(dp[i], dp[i - Y] + X);
}
inline void upd(int c, long long X, int Y) {
	if (!c) return;
	int pw2 = 1;
	while (pw2 < c) {
		_upd(X * pw2, Y * pw2);
		c -= pw2;
		pw2 *= 2;
	}
	_upd(X * c, Y * c);
}
struct Node {
	long long X;
	int Y, c;
};
vector<Node> vec;
int main() {
	scanf("%d%d%d", &n, &X, &D);
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	tot = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &m[i]);
		if (i > 1) scanf("%d", &pa[i]), lim[i] = D;
		else lim[i] = 0x3f3f3f3f;
		sz[i] = 1;
	}
	for (int i = n; i > 1; i--) {
		sz[pa[i]] += sz[i];
		m[pa[i]] += m[i];
	}
	for (int i = 1; i <= n; i++) {
		upd(min(n, lim[i]), m[i], sz[i]);
		if (lim[i] > n) {
			Node tmp;
			tmp.c = lim[i] - n;
			tmp.X = m[i];
			tmp.Y = sz[i];
			vec.push_back(tmp);
		}
	}
	sort(vec.begin(), vec.end(), [](const Node &t1, const Node &t2) {
		return t1.Y * t2.X > t2.Y * t1.X;
	});
	int ans = 0;
	for (int i = 0; i <= tot; i++) {
		if (dp[i] > X) continue;
		int cur = X - dp[i], sum = i;
		for (int j = 0; j < (int)vec.size() && cur; j++) {
			int t = min((long long)vec[j].c, cur / vec[j].X);
			cur -= t * vec[j].X;
			sum += t * vec[j].Y;
		}
		ans = max(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1536
def main():
    moji=input()
    cycle=int(input())
    flont_or_back=0
    flont=""
    back=""
    for i in range(cycle):
        line=input()
        if line[0]=="1":
            flont_or_back+=1
        else:
            fi=line[2]
            ci=line[4]
            if flont_or_back%2==0:
                if fi=="1":
                    flont=ci+flont
                else:
                    back+=ci
            else:
                if fi=="1":
                    back+=ci
                else:
                    flont=ci+flont
    moji=flont+moji+back
    if flont_or_back%2==0:
        print(moji)
    else:
        print(moji[::-1])
    

if __name__ == '__main__':
    main() 
  

Measured memory_bytes: 4628
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	//エラトステネスの篩でP_max以下の素数vector primeをつくる
	bool *pr;
	ll P_max = 2000000; //10^6くらいまでが現実的か
	pr = (bool*)malloc(sizeof(bool) * (P_max+1));
	REP(i, P_max + 1) pr[i] = true;
	pr[0] = false;
	pr[1] = false;
	for(ll i = 2; i * i <= P_max; i++){ 
		if(pr[i] == true){
			for(ll j = 2 * i; j <= P_max; j+=i){
				pr[j] = false;
			}
		}
	}
	vector<ll> prime;
	for(ll i = 2; i <= P_max; i++){
		if(pr[i]) prime.push_back(i);
	}
	//
	ll n;
	cin >> n;
	//整数Xの素因数分解の結果をmapで返す。上のvector primeはもちろんいる
	ll X = n;
	ll diving = X; //これをどんどん割っていく。dividingが正しい
	map<ll, ll> prf;
	for(ll i = 0; diving > 1 && prime[i] * prime[i] <= X; i++){
		while (diving % prime[i] == 0)
		{
			diving /= prime[i];
			prf[prime[i]]++;
		}
	}
	if(diving > 1)prf[diving]++;
	//これは素因数分解の結果が見たくなったときに使うもの
	//for(auto i = prf.begin(); i!= prf.end(); i++) cout << i->first << "," << i->second << " "; cout << endl;
	//
	ll re = 0;
	ll ans = 0;
	for(auto i = prf.begin(); i!= prf.end(); i++){
		for(re = 1; re <= i->second; re++){
			ans ++;
			i->second -= re;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    if (n == 0)
        cout << 1 << endl;
    else if (n == 1)
        cout << 2 << endl;
    else if (n == 2)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll A, B;
  ll m;
  cin >> A >> B >> m;
  vector<ll> a(A), b(B);
  ll mmin1 = inf, mmin2 = inf;
  rep(i, A) {
    cin >> a[i];
    chmin(mmin1, a[i]);
  }
  rep(i, B) {
    cin >> b[i];
    chmin(mmin2, b[i]);
  }

  ll ans = mmin1 + mmin2;
  vector<ll> x(m), y(m), c(m);
  rep(i, m) {
    cin >> x[i] >> y[i] >> c[i];
    x[i]--, y[i]--;

    ll tt = max(0LL, a[x[i]]) + max(0LL, b[y[i]]) - c[i];
    // cout << max(0LL, a[x[i]] - c[i])  max(0LL, b[y[i]] - c[i]);
    // cout << x[i] << " " << y[i] << tt << endl;
    chmin(ans, tt);
  }

  cout << ans << endl;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define P (1'000'000'007)

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

template<int MOD=P>
struct Mod {
public:
    long long signed value;

    Mod(long long signed val): value(val % MOD) {
        if (value < 0) value += MOD;
    }

    constexpr Mod& operator+=(const Mod& other) noexcept { 
        value += other.value;
        value %= MOD;
        return *this;
    }
    constexpr Mod& operator-=(const Mod& other) noexcept {
        value -= other.value;
        if (value < 0) value += MOD;
        return *this;
    }
    constexpr Mod& operator*=(const Mod& other) noexcept {
        value *= other.value;
        value %= MOD;
        return *this;
    }

    constexpr Mod operator-() noexcept {
         return value == 0 ? 0 : MOD - value;
    }

    constexpr Mod operator+(const Mod& other) const noexcept { return Mod(*this) += other; }
    constexpr Mod operator-(const Mod& other) const noexcept { return Mod(*this) -= other; }
    constexpr Mod operator*(const Mod& other) const noexcept { return Mod(*this) *= other; }
    constexpr bool operator==(const Mod& other) const noexcept { return this->value == other.value; }
    constexpr bool operator!=(const Mod& other) const noexcept { return this->value != other.value; }
};

inline int modinv(int a, int m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

signed main() {
    capi(n);
    auto l = Mod(1);

    vector<int> v(1000001, 0);
    vector<int> va;

    rep(i, n) {
        capi(a);
        va.push_back(a);

        for (int j = 2; j <= sqrt(a); ++j) {
            int r = 0;
            while (a % j == 0) {
                a /= j;
                ++r;
            }
            chmax(v[j], r);
        }

        if (a > 1) chmax(v[a], 1ll);
    }

    rep(i, 1000001) {
        rep(j, v[i]) {
            l *= i;
        }
    }

    Mod ans(0);

    rep(i, n) {
        auto inv = modinv(va[i], P);
        ans += l * inv;
    }

    cout << ans.value;

    return 0;
}

Measured memory_bytes: 10908
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t,m;
  getline(cin,s);
  getline(cin,t);
  m = t;
  int c=0, x=0;
   auto i = t.rbegin();
 int y= m.size();
 for(int a=0;a<y-1;a++)
  {
      
      if(m[a]!=s[a]){
        c++; x=1;
        cout<<"No";
      break; return 0;
  }}
    
        
 if(c==0 && ('a'<=(*i)) && ((*i)<='z')){ x=1;
    cout<<"Yes";}
    
    else if(x==0)
    cout<<"No";
  
return 0;}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 100000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int nCr(int n, int r) {
	int ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
bool is_even(ll x) {return x % 2==0 ? 1 : 0; }
int main() {
	int n;
	cin >> n;
	ll a[110000];
	int i;
	int mainasu = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 0) {
			mainasu++;
		}
	}
	ll ans = 0;
	ll mini = inf;
	int cheak;
	if (is_even(mainasu)) {
		for (i = 0; i < n; i++) {
			ans += abs(a[i]);
		}
	}
	else {
		for (i = 0; i < n; i++) {
			ans += abs(a[i]);
			mini = min(mini, abs(a[i]));
		}
	}
	if (is_even(mainasu)) cout << ans;
	else cout << ans - mini * 2;
	return(0);
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

bool palin(string s) {
  int n = s.size();
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1]) return 0;
  }
  return 1;
}

signed main() {
#ifdef _DEBUG
  freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  bool res = palin(s)
    && palin(s.substr(0, n / 2))
    && palin(s.substr(n / 2 + 1, n / 2));
  cout << (res ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int H = cin.nextint;
        int W = cin.nextint;
        var S = new string[H];
        for (int i = 0; i < H; i++)
        {
            S[i] = ReadLine();
        }
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (S[i][j] == '#')
                {
                    bool flag = true;
                    for (int r = 0; r < 4; r++)
                    {
                        int y = i + dd[r];
                        int x = j + dd[r + 1];
                        if (y < 0 || y >= H || x < 0 || x >= W) continue;
                        if (S[y][x] == '#')
                        {
                            flag = false;
                        }
                    }
                    if (flag)
                    {
                        WriteLine("No");
                        return;
                    }
                }
            }
        }
        WriteLine("Yes");
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include <string>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	while (a!=0&&b!=0){
		if (a > b)
			a %= b;
		else
			b %= a;
	}
	if (a == 0)
		a = b;
	cout << a << endl;
	return 0;
}

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

int main(){

  int a, b, n, sum;
  
  while(cin >> a >> b >> n){
    sum = 0;
    for(int i=1; i<=n; i++){
      sum += a % b * 10 / b;
      a = a % b * 10 % b;
    }
    
    cout << sum << endl;
  }

  return 0;

}

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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < int > a (n);
  for (auto &i : a) cin >> i;
  sort (a.begin(), a.end());
  ll ans = a[n - 1];
  int idx = n - 2;
  for (int i = 1; i < n - 1; i += 2) {
    ans += (ll) 2 * a[idx];
    idx--;
  }

  if (n & 1) {
    ans -= a[idx + 1];
  }

  cout << ans << '\n';
}


Measured memory_bytes: 3988
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]+[[0,0,1]]
al=[]
mati=0
for i in range(n):
  now=l[i][1]+l[i][0]
  for j in range(i+1,n):
    now=l[j][0]+l[j][1]-(-max(0,now-l[j][1])//l[j][2])*l[j][2]
  al.append(now)
print(*al,sep="\n")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int a,ans=0;
  REP(i,n) {
    cin >> a;
    while(a%2==0) {
      ans++;
      a/=2;
    }
  }
  COUT(ans);
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = INF;
    rep(i, 200005) {
        ll ga = i / 2;
        ll gb = i / 2;
        ll cost = i * C;
        if (X - ga > 0) {
            cost += A * (X - ga);
        }
        if (Y - gb > 0) {
            cost += B * (Y - gb);
        }
        ans = min(ans, cost);
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.LinkedList;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        Object[] ship = new Object[200001];
        for(int i = 0; i < 200001; i++){
            ship[i] = new LinkedList<Integer>();
        }
        boolean[] seen = new boolean[200001];
        int[] moveCount = new int[200001];
        Queue<Integer> todo = new ArrayDeque<>();

        // input
        int num = scan.nextInt();
        int shipNum = scan.nextInt();
        for(int i = 0; i < shipNum; i++){
            int a = Integer.parseInt(scan.next());
            int b = Integer.parseInt(scan.next());
            LinkedList<Integer> shipTmp = (LinkedList)ship[a];
            shipTmp.add(b);
        }

        // search
        boolean arrive = false;
        int pos = 1;
        seen[pos] = true;
        LinkedList<Integer> shipTmp = (LinkedList)ship[pos];
        while(shipTmp.size() > 0){
            moveCount[shipTmp.peek()] = 1;
            todo.add(shipTmp.poll());
        }
        while(todo.size() > 0){
            while(todo.size() > 0){
                if(seen[todo.peek()] == false){
                    pos = todo.poll();
                    seen[pos] = true;
                    break;
                } else {
                    todo.poll();
                }
            }
            if(pos == num && moveCount[pos] <= 2){
                arrive = true;
                break;
            }
            shipTmp = (LinkedList)ship[pos];
            while(shipTmp.size() > 0){
                if(moveCount[shipTmp.peek()] == 0){
                    moveCount[shipTmp.peek()] = moveCount[pos] + 1;
                }
                todo.add(shipTmp.poll());
            }
        }

        // answer
        if(arrive){
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }

    }
}

Measured memory_bytes: 89316
def N(x,y,n): # no of x...y < n
    if n<100:
        r=0
        for i in range(1,n+1):
            if str(i)[0]==str(x) and str(i)[-1]==str(y):
                r+=1
        return r
    
    r=N(x,y,99)
    d=len(str(n))
    for i in range(1,d-2):
        r+=10**i
    top=int(str(n)[0])
    if top<x:
        r+=0
    elif top==x:
        r+=int(str(n)[1:-1])
        if str(n)[-1]>=str(y):
            r+=1
    else:
        r+=10**(d-2)

        
    return r


ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
print(ans)


Measured memory_bytes: 39408
N,M=map(int,input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
a=str(0)*N
A=[a[i] for i in range(len(a))]
x=0
#print(sc)
b=[]
c=[]
for i in range(M):
    if (sc[i][0] == 1) and (sc[i][1]==0) and (N!=1):
        x=-1
        break
    else:
        if (sc[i][0]) in b:#左から何桁目の情報が既にある場合、既に登録されているその桁の値と新たに登録しようとしてるその桁の値が異なるとき弾く
            if sc[i][1]!=int(c[b.index(sc[i][0])]):
                #print(c[b.index(sc[i][0])])
                x=-1
                break
        else:
            A[sc[i][0]-1]=str(sc[i][1])
            b.append(sc[i][0])
            c.append(sc[i][1])
if x==-1:
    print(-1)      
elif b==[] and (N!=1):
    if N==2:
        print(10)
    elif N==3:
        print(100)
elif (1 not in b) and(N!=1):
    A[0]=str(1)
    a="".join(A)
    print(a)
elif  (1 not in b) and (2 not in b) and (N==3):
    A[0]=str(1)
    A[1]=str(0)
    a="".join(A)
    print(a)

else:
    a="".join(A)
    print(a)

Measured memory_bytes: 3188
import numpy as np

S = input()
T = input()

npS =  np.array(list(S))
npT =  np.array(list(T))

must_sym_i = npS != '?'

accepted = []
for i in range(len(S)-len(T)+1):
    and_ = npS[i:i+len(T)] == npT
    if all(and_[must_sym_i[i:i+len(T)]]):
        temp = np.copy(npS)
        temp[i:i+len(T)] = npT
        temp[temp == '?'] = 'a'
        accepted.append(temp)

acc = [''.join(list(accepted[i])) for i in range(len(accepted))]

if len(acc) > 0:
    print(sorted(acc)[0])
else:
    print("UNRESTORABLE")


Measured memory_bytes: 12448
#include <iostream>
#include <algorithm>
#include <functional>

int main(void){
    int p, q, r;
    std::cin >> p >> q >> r;

    int d1 = p + q;
    int d2 = p + r;
    int d3 = q + r;

    std::cout << std::min({d1, d2, d3}) << std::endl;
    return 0;
}

Measured memory_bytes: 256
let x = read_int ()
let _ = (
  if x < 600 then "8" else
  if x < 800 then "7" else
  if x < 1000 then "6" else
  if x < 1200 then "5" else
  if x < 1400 then "4" else
  if x < 1600 then "3" else
  if x < 1800 then "2" else
  "1"
) |> print_endline

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

i=0
while sum(a)%2==0:
    end=False

    for x in a:
        if x%2!=0:
            end=True
            break

    if end: 
        break
        
    a=list(map(lambda x: x/2, a))
    i+=1

print(i)

Measured memory_bytes: 2940
from collections import defaultdict
h,w,k = map(int,input().split())

s = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    s[i] = [int(s) for s in list(input())]

#入力終了

def num_to_g(num):
    #10進数から2進数に変換し、縦向きのグループ分けをする(num < 2**(h-1))
    g_index = {}
    index = 1
    for i in range(h+1):
        g_index[i] = index
        bl = (num>>i)%2
        if(bl == 1):
            index += 1
    
    return g_index
    


def get_white(choco_tmp,w,group_num):
    
    for i in range(h):
        if(s[i][w]==1):
            choco_tmp[group_num[i]] += 1
    
    return choco_tmp


def greedy(num):
    div = num_to_g(i)
    res = max(div.values())-1
    choco = defaultdict(int)
    for j in range(w):
        choco = get_white(choco,j,div)
        
        if any(c>k for c in choco.values()):
            choco = defaultdict(int)
            choco = get_white(choco,j,div)
            
            if any(c>k for c in choco.values()):
                return 10**9 + 1
            else:
                res += 1
       
    return res        
            
                
        
#print(greedy(2))

mx = 2**(h-1)                
ans = h+w-1
for i in range(mx):
    ans = min(ans,greedy(i))

print(ans)


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

bool ispal(ll x)
{

    string ss;
    while(1)
    {

        if(x==0) break;
        char c = '0'+(x%10);
        x/=10;
        ss.pb(c);
    }
    string kk = ss;
    reverse(all(ss));
    return (ss==kk);
}

int main()

{

    ll a, b;
    cin >> a >> b;
    ll cnt = 0;
    for(ll i = a; i <= b; i++)
    {

        if(ispal(i)) cnt++;
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
  ll n;
  cin >> n;
  ll a[100010];
  ll ans=0;
  FOR(i,n){
    cin >> a[i];
    ans+=abs(a[i]);
  }

  sort(a,a+n);
  
  if(a[n-1]<0){

    cout << ans-abs(a[n-1])*2 << endl;

    for(int i=0;i<n-1;i++){
      cout << a[n-1] << " " << a[i] << endl;
      a[n-1]-=a[i];
    }
    
  }else if(a[0]<0 && a[n-1]>=0){
    cout << ans << endl;
    int kyoukai;
    FOR(i,n){
      if(a[i]>=0){
        kyoukai=i;
        break;
      }
    }
    for(int i=kyoukai;i<n-1;i++){
      cout << a[0] << " " << a[i] << endl;
      a[0]-=a[i];
    }
    for(int i=0;i<kyoukai;i++){
      cout << a[n-1] << " " << a[i] << endl;
      a[n-1]-=a[i];
    }
    
  }else if(a[0]>=0){
    if(n==2){
      cout << a[1]-a[0] << endl;
      cout << a[1] << " "<<  a[0] << endl;
      return 0;
    }
    cout << ans-a[0]*2 << endl;
    cout << a[0] << " " << a[n-1] << endl;
    a[0]-=a[n-1];
    for(int i=1;i<n-2;i++){
      cout << a[0] << " " << a[i] << endl;
      a[0]-=a[i];
    }
    cout << a[n-2] << " " << a[0] << endl;
  }
  
}


Measured memory_bytes: 2688
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  Printf.printf "\n";
  preorder (fun e -> print_string " "; print_int e) t;
  Printf.printf "\n"

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    match read_line () |> split_on_char ' ' with
    | ["insert"; n] -> t := insert (int_of_string n) !t
    | ["find"; n] -> print_endline (if find (int_of_string n) !t then "yes" else "no")
    | _ -> print !t
  done

Measured memory_bytes: 27256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
const int N = 2e5+5, mod = 998244353;	
int n, seg[N*4];
vector<pair<int, int>> p;
vector<int> vec;
ll power(ll x, ll y)
{
	if(!y) return 1;
	ll temp = power(x, y/2);
	temp *= temp, temp %= mod;
	if(y%2) temp *= x, temp %= mod;
	return temp;
}
void upd(int i, int l=0, int r=n-1, int id=1)
{
	if(l == r)
	{
		seg[id] = 1;
		return ;
	}
	int mid = (l+r)>>1;
	if(i <= mid) upd(i, l, mid, id*2);
	else upd(i, mid+1, r, id*2+1);
	seg[id] = seg[id*2]+seg[id*2+1];
}
int query(int x, int y, int l=0, int r=n-1, int id=1)
{
	if(l >= x && r <= y) return seg[id];
	if(l > y || r < x) return 0;
	int mid = (l+r)>>1;
	return query(x, y, l, mid, id*2) + query(x, y, mid+1, r, id*2+1);
}
int main() 
{
	cin >> n;
	for(int i=0, x, y; i<n; i++) cin >> x >> y, p.push_back({x, y}), vec.push_back(y);
	sort(p.begin(), p.end());
	sort(vec.begin(), vec.end());
	ll ans = 0;
	
	for(int i=0; i<p.size(); i++)
	{
		int x = p[i].f, y = p[i].s;
		ll cur = power(2, n)-1;
		ll l = lower_bound(vec.begin(), vec.end(), y)-vec.begin();
		cur = (cur - power(2, i) + 1 + mod)%mod;
		cur = (cur - power(2, l) + 1 + mod)%mod;
		cur = (cur - power(2, n-i-1) + 1 + mod)%mod;
		cur = (cur - power(2, n-l-1) + 1 + mod)%mod;
		cur = (cur + power(2, query(0, l)) - 1 + mod)%mod;
		cur = (cur + power(2, query(l, n-1)) - 1 + mod)%mod;
		cur = (cur + power(2, n-l-1-query(l, n-1)) - 1 + mod)%mod;
		cur = (cur + power(2, l-query(0, l)) - 1 + mod)%mod;
		ans = (ans + cur + mod)%mod;
		upd(l);
	}
	cout << ans << endl;
}

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

int main(){
  int N, W;
  cin>>N>>W;
  int v[1000], w[1000];
  for(int i=0; i<N; i++)cin>>v[i]>>w[i];
  int dp[10001];
  memset(dp, 0, sizeof(dp));
  for(int i=0; i<N; i++)
    for(int j=W; w[i]<=j; j--){
      dp[j]=max(dp[j], dp[j-w[i]]+v[i]);
    }
  cout<<dp[W]<<endl;
  return 0;
}

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

int main()
{
    vector<int> num = {1,
                       1,
                       1,
                       2,
                       1,
                       2,
                       1,
                       5,
                       2,
                       2,
                       1,
                       5,
                       1,
                       2,
                       1,
                       14,
                       1,
                       5,
                       1,
                       5,
                       2,
                       2,
                       1,
                       15,
                       2,
                       2,
                       5,
                       4,
                       1,
                       4,
                       1,
                       51};
    int k;
    cin >> k;
    cout << num[k - 1];
}


Measured memory_bytes: 256
# カードを左から順に赤、緑、青色の順に並べ、
# 左から整数を読んだときにこれが 4 の倍数であるか判定
val = gets.chomp.split(" ").join.to_i
ans = val % 4

# AtCoDeer君が作った 3 桁の整数が
# 4 の倍数ならば YES、そうでないならば NO を出力しなさい。
if ans == 0
  puts 'YES'
else
  puts 'NO'
end

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b+c>=22) cout << "bust" << endl;
  else cout << "win" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
f=[]
for i in range(n):
    tmp=0
    op=list(map(int,input().split()))
    for j in range(10):
        tmp+=op[j]<<j
    f.append(tmp)

p=[]
for i in range(n):
    p.append(list(map(int,input().split())))

ans=-10**12
for i in range(1, 1<<10):
    tmp=0
    for j in range(n):
        consist=f[j]&i
        cnt=0
        for k in range(10):
            if (consist>>k)%2:
                cnt+=1
        tmp+=p[j][cnt]
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 73916
import sys
l = list(map(int, input().split(' ')))
N = l[0]
N_ = l[0] + 1
M = l[1]
y = []
u = set()

for i in range(M):
    k = list(map(int, input().split()))
    a = k[0]
    b = k[1]
    if (a == 1):
        y.append(b)
    elif (b == N):
        u.add(a)

for i in y:
    if (i in u):
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')


Measured memory_bytes: 15580
N = int(input())

mod = 10 ** 9 + 7
dp = [[0, 0, 0, 0] for _ in range(N)]

# dp[上から何桁目か][事象を4つに区分]
# dp[0][0]: 0も9も含まない
# dp[0][1]: (9は含むが)0を含まない
# dp[0][2]: (0を含むが)9を含まない
# dp[0][3]: 0も9も含む
dp[0][0] = 8
dp[0][1] = 1
dp[0][2] = 1
dp[0][3] = 0

for i in range(N - 1):
    dp[i + 1][0] = (dp[i][0] * 8) % mod
    dp[i + 1][1] = (dp[i][1] * 9 + dp[i][0]) % mod
    dp[i + 1][2] = (dp[i][2] * 9 + dp[i][0]) % mod
    dp[i + 1][3] = (dp[i][3] * 10 + dp[i][1] + dp[i][2]) % mod

print(dp[N-1][3])


Measured memory_bytes: 238744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            int k = (X - (500 * i + 100 * j)) / 50;
            if (0 <= k && k <= C) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
	char s[20], temp[20];
	
	scanf("%s", s);
	
	int length = strlen(s);
	
	int i = 0, j = 0;
	
	while(length--){
		if(s[j]=='B'){
			if(i > 0){
				i--;
			}
			temp[i] = ' ';
			j++;
		}
		else{
			temp[i] = s[j];
			i++;
			j++;
		}
	}
	
	temp[i] = '\0';
	printf("%s\n",temp);
	return 0;
}

Measured memory_bytes: 1612
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int k;

void input(){
    cin >> k;
    return;
}

void solve(){
    int ans;
    if(k % 2 == 0){
        ans = (k/2) * (k/2);
    }
    else {
        ans = (k/2) * ((k+1)/2);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { rep(i,v.size()) is >> v[i]; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int hogeeee1;
  char hogeeee2;
  string s;
  vi t(4);
  while (cin >> hogeeee1 >> hogeeee2 >> s) t[(s == "B") + 2 * (s == "AB") + 3 * (s == "O")]++;
  rep(i, 4) cout << t[i] << endl;
}

Measured memory_bytes: 3096
# ABC105D

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n,m,q = map(int, input().split())
lr = [None] * m
qs = [None] * q

for i in range(m):
    lr[i] = tuple(map(lambda x: int(x)-1, input().split()))
    
t = [[0]*(n+1) for _ in range(n+1)]

for x,y in lr:
    t[y][x] += 1
    
for i in range(n):
    for j in range(i,n):
        t[j][j-i] += t[j-1][j-i] + t[j][j-i+1] - t[j-1][j-i+1]
        
ans = [None] * q
for i in range(q):
    l, r = tuple(map(lambda x: int(x)-1, input().split()))
    ans[i] = t[r][l]
write("\n".join(map(str, ans)))

Measured memory_bytes: 87004
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;


int main() {
  int r, D, x_tt;
  cin >> r >> D >> x_tt;
  
  for (int i=0; i<10; i++) {
    x_tt = r * x_tt - D;
    cout << x_tt << endl;
  }
  
  return 0;
  
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a[3];
  for(int i=0; i<3; i++) cin >> a[i];
  sort(a, a+3);
  int ans=0;
  ans = a[2] - a[1];
  ans += a[1] - a[0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 int main(){
     int n;
     cin>>n;
     string s;
     cin>>s;
     int c=0;
     for(int i=0;i<n;i++){
        if(s[i]!=s[i+1]){
            c+=1;
        }


     }
     cout<<c;

 }


Measured memory_bytes: 512
while True:   
    n = int(input())
    if n ==0:
        break
    s_list=list(map(float,input().split()))
    
    m = (sum(s_list))/n
    
    ss = 0
    for i in s_list:
        si =((i-m)**2)
        ss += si  
    print((ss/n)**0.5) 


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

int p[202], q[202], cnt;
long long n;

void solve(long long n){
    if (!n) return;
    if (~n&1) 
        q[++q[0]] = cnt++, solve(n-1);
    else
        p[++p[0]] = cnt++, solve(n>>1);
}

int main(){
   	cin>>n;
	solve(n); 
	cout<<cnt+100<<endl;
    for (int i = 1; i <= q[0]; ++i) 
		cout<<cnt-q[i]<<" ";
    for (int i = p[0]; i; --i) 
    	cout<<cnt-p[i]<<" ";
    for (int i = 1; i <= 100; ++i) 
    	cout<<i<<" ";
    cout<<endl;;
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N;
int A[2][200100], B[2][200100];
int nxt;

int f(int b){
    int x = 1 << b;
    int j = 0, k = 0, j2 = 0, k2 = 0;
    int res = 0;
    
    for(int i=N-1;i>=0;--i){
        int a = A[nxt][i];
        while(j < N && B[nxt][j] < x - a){++j;}
        while(k < N && B[nxt][k] < 2 * x - a){++k;}
        while(j2 < N && B[nxt][j2] < 3 * x - a){++j2;}
        while(k2 < N && B[nxt][k2] < 4 * x - a){++k2;}

        res ^= j ^ k ^ j2 ^ k2;
    }

    return res & 1;
}

void merge(int (&X)[2][200100], int b){
    int x = 1 << b;
    auto it = lower_bound(X[nxt], X[nxt]+N, x);

    int l = 0, r = it - X[nxt], l2 = r, r2 = N;
    for(int i=0;i<N;++i){
        if(l == r){
            X[!nxt][i] = X[nxt][l2] % x;
            ++l2;
        }else if(l2 == r2){
            X[!nxt][i] = X[nxt][l];
            ++l;
        }else if(X[nxt][l] < X[nxt][l2] % x){
            X[!nxt][i] = X[nxt][l];
            ++l;
        }else{
            X[!nxt][i] = X[nxt][l2] % x;
            ++l2;
        }
    }

    // std::cout << "Case " << b << std::endl;
    // for(int i=0;i<N;++i){
    //     std::cout << X[!nxt][i] << " \n"[i+1==N];
    // }
}

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

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

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

    sort(A[0], A[0]+N);
    sort(B[0], B[0]+N);

    int res = f(28) << 28;

    for(int b=27;b>=0;--b){
        res |= f(b) << b;

        if(b > 0){
            merge(A, b);
            merge(B, b);
            nxt = !nxt;
        }
    }

    printf("%d\n", res);
}


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

int main() {
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string S,T;
	cin>>S>>T;
	bool check=true;
	int len=S.size(),len_t=T.size();
	if(len_t==len+1)
		for(int i=0;i<len;i++){
			if(S[i]!=T[i]){
				check=false;
				break;
			}
		}
	else
		check=false;
	if(check==false)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<int>rev(n);
	for(int i=0;i<n;i++){
		rev[a[i]-1]=i+1;
	}
	for(int i=0;i<n;i++){
		cout<<rev[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int A[200010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int l = 0, r = 0;
  int tmp = 0;
  ll ans = 0;
  while (l < N) {
    while (r < N && (tmp | A[r]) == tmp + A[r]) {
      tmp += A[r];
      r++;
    }
    ans += r - l;
    tmp -= A[l];
    l++;
  }
  cout << ans << endl;

  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int P[N];
    for (int i = 0; i < N; i++) cin >> P[i];
    int Q[N];
    for (int i = 0; i < N; i++) cin >> Q[i];

    int array[N];
    for (int i = 0; i < N; i++) {
        array[i] = i + 1;
    }
    int count = 0;
    int countP, countQ;
    bool sameFlgP, sameFlgQ;
    do{
        sameFlgP = sameFlgQ = true;
        for (int i = 0; i < N; i++) {
            if (array[i] != P[i]) sameFlgP = false;
            if (array[i] != Q[i]) sameFlgQ = false;
        }
        if (sameFlgP) countP = count;
        if (sameFlgQ) countQ = count;
        count++;
    } while (next_permutation(array, array + N));

    cout << abs(countP - countQ) << endl;
    return 0;
}

Measured memory_bytes: 3644
d, n = map(int, input().split())
x = 100 ** d
y = 0
cnt = 0
while cnt < n:
    y += x
    if y % (100 ** (d + 1)) == 0:
    #if y % 100 == 0:
        continue
    cnt += 1
    #print("x={}, y={}, cnt={}".format(x, y, cnt))
print(y)


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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e17
#define int long long

const int N = 1e5 + 5;
int n , k;
int dp[N] , a[N];
/// dp[i] là giá nhỏ nhất để tới được hòn đá thứ i.

main()
{
    //freopen("B.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    FOR(i , 1 , n)
        cin >> a[i];
    FOR(i , 2 , n)
    {
        dp[i] = 1e16;
        FOR(j , max((ll)1 , i - k) , i - 1)
            dp[i] = min(dp[i] , dp[j] + abs(a[i] - a[j]));
    }
    cout << dp[n];
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  String s = sc.nextLine();
	  String ans = "Yes";
	  for(int i=0;i<s.length();i++){
	  	if(i%2==0&&s.substring(i,i+1).equals("L"))ans="No";
	  	if(i%2==1&&s.substring(i,i+1).equals("R"))ans="No";
	  }
	  System.out.println(ans);
	}
}

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

int main(){
  int N;
  cin >> N;
  int num=0;
  vector<pair<int,int>> v(N);
  
  for(int i=0; i<N; i++){
    cin >> v.at(i).first;
    v.at(i).second = i+1; //1-index
  }
  
  sort(v.begin(), v.end());
  
  for(int i=0; i<N; i++){
    if(i != N-1){
      cout << v.at(i).second << " " ;
    }else{
      cout << v.at(i).second << endl;
    }
  }
  
}

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

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,cnt=0,ans=1e9;
string s;

int main()
{
	cin>>n>>s;
	rep(i,n) if(s[i]=='.') cnt++;
	ans=min(ans,cnt);
	rep(i,n)
	{
		if(s[i]=='.') cnt--;
		else cnt++;
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 640
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int b1,b2,b3;
        b1=sc.nextInt();
        b2=sc.nextInt();
        b3=sc.nextInt();
        if((b1==1&&b2==0&&b3==0)||(b1==0&&b2==1&&b3==0)||(b1==0&&b2==0&&b3==0)){
            System.out.println("Close");
        }else{
            System.out.println("Open");
        }
    }
}


Measured memory_bytes: 26232