akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int h,w;
ll Cons(ll a,ll b,ll s)
{
	if(a<2&&b<2) return 1e18;
	ll S1,S2;
	if(a%2==0||b%2==0) S1=S2=a*b/2;
	else
	{
		if(a<b)
		{
			S1=a*(b>>1);
			S2=a*(b-(b>>1));
		}
		else
		{
			S1=b*(a>>1);
			S2=b*(a-(a>>1));
		}
	}
	return max(max(S1,S2),s)-min(min(S1,S2),s);
}
int main()
{
	cin>>h>>w; ll ans=1e18;
	for(int i=1;i<h;i++)
	{
		int j=h-i;
		//(j,w) and (i,w)
		ans=min(ans,Cons(j,w,(ll)i*w));
		ans=min(ans,Cons(i,w,(ll)j*w));
	}
	for(int i=1;i<w;i++)
	{
		int j=w-i;
		//(j,h) and (i,h)
		ans=min(ans,Cons(j,h,(ll)i*h));
		ans=min(ans,Cons(i,h,(ll)j*h));
	}
	printf("%lld\n",ans);
}


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

int main(){
    int N;
    cin >> N;
    int num = 0;
    int ans = 0;
    num = N / 2;
    ans = N % 2;
    cout << num + ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    if (x < 1200)
        cout << "ABC";
    else
        cout << "ARC";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
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<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=1e9+7;
const long double PI = acos(0);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	string s;
	cin >> s;
	int ans;
	if(s == "RRR") ans = 3;
	else if(s == "RRS" || s == "SRR") ans = 2;
	else if(s == "SSS") ans = 0;
	else ans = 1;
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    string S;
    cin>>S;
    ll N= S.size();
    bool ans = true;
    rep(i,0,(N-1)/2){
        if(S[i] != S[(N-1)/2-1-i])ans = false;
    }
    rep(i,(N+3)/2-1,N){
        if(S[i] != S[N-1-i])ans = false;
    }
    rep(i,0,N){
        if(S[i] != S[N-1-i])ans = false;
    }

    YN(ans);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vi32 cnt(4);
  int _;
  char __;
  string s;
  while (cin >> _ >> __ >> s) {
    if (s == "A") cnt[0]++;
    if (s == "B") cnt[1]++;
    if (s == "AB") cnt[2]++;
    if (s == "O") cnt[3]++;
  }
  rep(i, 4) cout << cnt[i] << '\n';
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = s.length();
	for (int i = 0; i < n; ++i) {
		if (s[i] == '?') {
			s[i] = 'D';
		}
	}
	cout << s << '\n';
	
	return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, t, a;
    vector<pair<int, int> >v;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d%d", &a, &t);
        v.push_back(make_pair(a, t));
    }
    long long an = v[0].first, tn = v[0].second;
    for(int i = 1; i < n; i++)
    {
        if((v[i].first>=an)&&(v[i].second>=tn))an = v[i].first, tn = v[i].second;
        else
        {
            long long j = max((an+v[i].first-1)/v[i].first, (tn+v[i].second-1)/v[i].second);
            an = j*v[i].first;
            tn = j*v[i].second;
        }
    }
    cout << an+tn;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
priority_queue<int> q1;
priority_queue<int,V<int>,greater<int> > q2;
int sum1,sum2,ans,t,ant;
namespace io {
    #define in(a) a=read()
    #define out(a) write(a),putchar(' ')
    #define outn(a) out(a),putchar('\n')
    #define I_int int 
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; } 
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; } 
        return x * f ;
    } 
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {F[ cnt ++ ] = tmp % 10 + '0' ;tmp /= 10 ;}
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int
}
using namespace io ;
signed main(){
    int q,x,y;
    in(q);
    FOR(i,1,q){
        in(x);
        if(x==2){
            if(!q1.size()){
                puts("0");continue;
            }
            ant=q1.top();out(ant); 
            ans=ant*q1.size()-sum1+sum2-ant*q2.size();
            outn(ans+t);
        }else{
            in(x);in(y);
            if(q1.empty()||q1.top()>=x){
                q1.emplace(x);sum1+=x;
                if(q1.size()>q2.size()+1){
                    q2.emplace(q1.top());
                    sum1-=q1.top();
                    sum2+=q1.top();
                    q1.pop();
                }
            }else{
                q2.emplace(x);sum2+=x;
                if(q2.size()>q1.size()){
                    q1.emplace(q2.top());
                    sum2-=q2.top();
                    sum1+=q2.top();
                    q2.pop();
                }
            }
			t+=y;
        }
    }
    RE 0;
}

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

int main(){

    int H, N;
    cin >> H >> N;
    long long int A = 0; 
    rep(i, N){
        int a;
        cin >> a;
        A += a;
    }

    if(H <= A) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main()
{
    fastio;
    std::string S;
    cin >> S;

    constexpr char acgt[] = "ACGT";

    int start_pos = 0;
    int end_pos = 0;
    int max_len = 0;

    while ((start_pos = S.find_first_of(acgt, end_pos)) != string::npos)
    {
        end_pos = S.find_first_not_of(acgt, start_pos);
        end_pos = (end_pos != string::npos) ? end_pos : S.size();
        max_len = max(max_len, end_pos - start_pos);
    }

    cout << max_len << endl;

    return 0;
}


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

using namespace std;

const int MAX = 1e5;
const int INF = 2e9;
typedef long long ll;

int k;

void solve(int kth) {
    queue<ll> q;
    for (int i = 1; i < 10; ++i)
    {
        q.push(i);
    }

    int index = 0;
    while (!q.empty()) {
        auto cur = q.front();
        q.pop();

        if (++index == kth) {
            cout << cur;
            return;
        }

        ll last = cur % 10;
        for (int i = 0; i < 3; ++i)
        {
            ll offset = -1;
            if (last == 0) {
                offset = 0;
            }

            q.push(cur * 10ll + last + i + offset);
            if ((last == 9 || last == 0) && i == 1) break;
        }

    }
}

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

    cin >> k;
    solve(k);

    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[]A = new string[N];
		long ans = 0;
		long za = 0;
		long ba = 0;
		long bz = 0;
		for(var i=0;i<N;i++){
			A[i] = Console.ReadLine();
			for(var j=0;j<A[i].Length-1;j++){
				if(A[i].Substring(j,2)=="AB"){
					ans++;
				}
			}
			if(A[i].Substring(0,1)=="B"){
				if(A[i].Substring(A[i].Length-1,1)=="A"){
					ba++;
				} else {
					bz++;
				}
			} else if(A[i].Substring(A[i].Length-1,1)=="A"){
				za++;
			}
		}
		if(za>0){
			za--;
			ans+=ba;
			ba=0;
			if(bz>0){
				ans++;
				bz--;
			}
			ans += Math.Min(za,bz);
		} else {
			if(ba>0){
				ans += ba-1;
				ba = 0;
				if(bz>0){
					ans++;
					bz--;
				}
			}
		}
		Console.WriteLine(ans);
	}
}

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

int main(){
    int n;cin>>n;
    int h[100010];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    reverse(h,h+n);
    int m=1e9;
    for(int i=0;i<n;i++)
    {
        m=min(m,h[i]);
        if(h[i]-m>=2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] line = Console.ReadLine().Split(' ');
		int X = int.Parse(line[0]);
		int Y = int.Parse(line[1]);
		int Z = int.Parse(line[2]);

		Console.WriteLine(Z + " " + X + " " + Y);
	}
}



Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=201;
typedef long long LL;
const LL mod=998244353;

int n,x[maxn],y[maxn];
LL ans;
bool f;

LL pw(int p)
{
	if (p==1) return 2ll;
	LL ans=pw(p/2);
	if (p%2) return (ans*ans*2ll)%mod;
	else return (ans*ans)%mod;
}

bool line(int p,int q,int r)
{
	return (y[q]-y[p])*(x[r]-x[q])==(y[r]-y[q])*(x[q]-x[p]);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
		scanf("%d%d",&x[i],&y[i]);
	ans=(pw(n)-1ll-(LL)n-(LL)n*(n-1)/2)%mod;
	
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			f=true;
			for(int k=1;k<j;k++)
				if (k!=i && line(i,j,k))
				{
					f=false;
					break;
				}
			if (!f) continue;
			
			int cnt=2;
			for(int k=j+1;k<=n;k++)
				if (line(i,j,k)) cnt++;
			LL tmp=(pw(cnt)-1ll-(LL)cnt-(LL)cnt*(cnt-1)/2)%mod;
			ans-=tmp;
		}
	}
	
	ans=(ans%mod+mod)%mod;
	printf("%I64d\n",ans);
	return 0;
}

Measured memory_bytes: 128
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0008
  * Sum of 4 Integers
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.toInt)
      .map((n) => {
        (for (a <- 0 to 9; b <- 0 to 9; c <- 0 to 9; d <- 0 to 9)
          yield {
            a + b + c + d
          })
          .count(_ == n)
      })
      .foreach(println)
  }
}

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


int X[10][10];

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

    int N, D;
    cin >> N >> D;

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            // if (i == j) continue;
            int z  = 0;
            for (int k = 0; k < D; ++k) {
                z += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            for (int k = 1; k <= 200; ++k) {
                if (k * k == z) {
                    ans++;
                    break;
                }
            }
        }
    }
    
    cout << ans << '\n';

    return 0;
}


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

using namespace std;

class Solution {
public:
	void solve() {
		int n, m, d;
		cin >> n >> m >> d;
		int ans = 0;
		for (int i = n; i <= m; i++) {
			if (i % d == 0) ans++;
		}
		cout << ans << "\n";

		return;
	};
};

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

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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  if(B-K<A+K){
    for(int i=A;i<B+1;i++)cout << i << endl;
  }
  else{
    for(int i=A;i<A+K;i++)cout << i << endl;
    for(int i=B-K+1;i<B+1;i++)cout << i << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int K,N;
    cin >> K >> N;
    vector<int> A(N);
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i] -= K/2;
    }
    int L = 0;
    for(int i = 0; i < N-1; i++) L = max(L,abs(A[i] - A[i+1]));
    cout << min((K-L),(A[N-1]-A[0])) << endl;
}


Measured memory_bytes: 1024
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var W = one[1];
	var dp = {};
	dp[0] = 0;
	var list = new Array(N);
	for(var i = 0; i < N; i++){
		list[i] = nextIntArray();
	}
	for(var i = 0; i < N; i++){
		var newDp = makeClone(dp);
		var keys = Object.keys(dp).map(Number);
		var tmp = list[i];
		var inW = tmp[0];
		var inV = tmp[1];
		for(var j = 0; j < keys.length; j++){
			var sumW = keys[j];
			var max;
			if(dp[sumW + inW] != null){
				var mae = dp[sumW + inW];
				var ato = dp[sumW] + inV;
				max = Math.max(mae, ato);
			}else{
				max = dp[sumW] + inV;
			}
			newDp[sumW + inW] = max;
		}
		dp = newDp;
	}
	var output = 0;
	var keys = Object.keys(dp);
	for(var i = 0; i < keys.length; i++){
		if(keys[i] <= W){
			output = Math.max(output, dp[keys[i]]);
		}
	}
	myout(output);
}


Measured memory_bytes: 53288
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 210;
const int M = 1e9+7;
int n,m,k;

char s[maxn+1];
int a[maxn];
int dp[maxn][4];

int dfs(int bit,int gs,bool limit)
{   
    if(gs > k) return 0;
    if(bit == n)
    {
        if(gs == k) return 1;
        else return 0;
    }
    if(!limit && dp[bit][gs]) return dp[bit][gs];
    int up = limit?a[bit]:9;
    int ans = 0;
    for(int i = 0; i <= up; i++)
    {
        ans += dfs(bit+1,gs + (i!=0), limit && i == a[bit]);
    }
    if(!limit) dp[bit][gs] = ans;
    return ans;
}

signed main()
{
    scanf("%s",s+1);
    cin>>k;
    for(n = 1; s[n]; n++) 
    {
        a[n] = s[n] - '0';
    }
    int ans = dfs(0,0,1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
student = list(map(int,input().split()))
 
ans = [0] * n   #登校した順番を記録するためのリスト
 
for i in range(n):
    s = student[i]   #出席番号iの生徒が登校した順番をメモ
    ans[s-1] = i+1    #ansに出席番号を書き込む
 
print(*ans)

Measured memory_bytes: 13880
#include<bits/stdc++.h>
#define MOD 1000000007
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
string k;
int d;
int dp[10010][101];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>k>>d;
	int l=k.size();
	int he=0;
	for(int i=1;i<=l;i++){
		for(int j=0;j<k[i-1]-'0';j++)
			dp[i][(j+he)%d]++;
		he+=(k[i-1]-'0');
	}
	dp[l][he%d]++;
	//dp
	for(int i=1;i<=l;i++){
		for(int j=0;j<d;j++){
			for(int cur=0;cur<=9;cur++){
				dp[i][j]=(dp[i][j]+dp[i-1][((j-cur)%d+d)%d])%MOD;
			}
		}
	}
	cout<<(dp[l][0]-1+MOD)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

	if (b % a == 0) {
		printf("%d\n", a + b);
	} else {
		printf("%d\n", b - a);
	}
	return 0;
}


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

int main() {
int a,b,c;
cin >> a >> b;
c = 0;
for(int i=a ; i <= b;i++){
 if(i/10000 == i%10 && i/10%10 == i/1000%10)
  c++;
}
 cout << c << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    ans = 0
    b = -1
    cnt = 0
    for a in A:
        if b == a:
            cnt += 1
        else:
            ans += cnt // 2
            cnt = 1
            b = a
    ans += cnt // 2

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func joinInts(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func divUp(x, y int64) int64 {
	return (x + y - 1) / y
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	N, K := nextInt(), nextInt()
	out(int64(float64(K) * math.Pow(float64(K-1), float64(N-1))))
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <set>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using P = std::pair<int, int>;

std::string s;
std::set<int> vs;
std::vector<P> ps;

int main()
{
  std::cin >> s;

  int n = s.size();

  rep( i, n ) if( s[i] == '1' )
  {
    vs.emplace( i+1 );

    if( i == n-1 )
    {
      puts("-1");

      return 0;
    }
  }

  if( vs.empty() )
  {
    puts("-1");

    return 0;
  }

  vs.emplace( n );

  int ptr = 1, pnxt = 0;

  for( auto it = vs.begin(); it != vs.end(); ++it )
  {
    if( *it-n && !vs.count(n-*it) )
    {
      puts("-1");

      return 0;
    }

    int diff = *it;
    int cnt = ptr;
    
    rep( d, diff-cnt )
      ps.emplace_back( P( pnxt, ptr++ ) );

    if( *it-n )
      ps.emplace_back( P( pnxt, ptr ) );

    pnxt = ptr++;
  }

  for( auto p : ps )
    printf( "%d %d\n", p.first+1, p.second+1 );

  return 0;
}

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

using namespace std;


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

	vector<int> value(N);
	vector<int> cost(N);

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


	int X, Y, max = 0;

	for (int i = 0; i < N; i++) {
		if (value[i] > cost[i])max += value[i] - cost[i];
	}
	cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        int total = 1;
        for (int i = 0; i < n; i++) {
            if (k < total) {
                total += k;
            } else {
                total *= 2;
            }
        }

        System.out.println(total);
    }
}


Measured memory_bytes: 22996
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define SIZE 100000

struct WORD {
	char value[15];
	struct WORD *next;
};

struct WORD* HashTable[SIZE];	//default: all NULL

int HashFunc(char s[]) {
	long long hash = 0;
	for (int i = 0; s[i] != '\0'; i++) {
		hash += s[i] * (i + 1);
	}
	return (int)(hash * 13 % SIZE);
}

void AddWord(char s[], int hashNum) {
	struct WORD* newWord = (struct WORD*)malloc(sizeof(struct WORD));
	strcpy(newWord->value, s);
	newWord->next = NULL;
	if (HashTable[hashNum] == NULL) HashTable[hashNum] = newWord;
	else {
		newWord->next = HashTable[hashNum];
		HashTable[hashNum] = newWord;
	}
}

void Insert(char s[]) {
	int hash = HashFunc(s);
	AddWord(s, hash);
}

void Find(char s[]) {
	int hash = HashFunc(s);
	struct WORD* pos;
	for (pos = HashTable[hash]; pos != NULL; pos = pos->next) {
		if (!strcmp(s, pos->value)) {
			printf("yes\n");
			return;
		}
	}
	printf("no\n");
	return;
}

int main() {
	int n;
	char command[10], value[15];
	for (int i = 0; i < SIZE; i++) {
		HashTable[i] = NULL;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %s", command, value);
		if (!strcmp(command, "insert")) Insert(value);
		else if (!strcmp(command, "find")) Find(value);
	}

	return 0;
}


Measured memory_bytes: 20268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.valueOf(reader.readLine());
        int maxFreq = 0;
        HashMap<String, Integer> map = new HashMap<>();

        for (int i = 0; i < N; i++){
          String word = reader.readLine();
          if (map.containsKey(word)){
            map.put(word, map.get(word) + 1);
          } else {
            map.put(word, 1);
          }
          maxFreq = Math.max(maxFreq, map.get(word));
        }

        List<String> words = new ArrayList<>();
        for (String j : map.keySet()) {
          if (map.get(j) == maxFreq){
            words.add(j+"\n");
          }
        }
        Collections.sort(words);

        for (String k : words){
          System.out.print(k);
        }
    }
}


Measured memory_bytes: 86272
import java.util.*;

public class Main {

    /* チェックリスト
     * SNSに結果を書き込むときはACかWAかのみ(半分だけACとかは書かないこと)
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String[] args) {
        /*
         * 前のマスが現在のマスと等しいか現在のマスより小さい場合 => YES
         * 前のマスは可能であれば小さくする
         * -1した時に前の値と等しいか、それ以上であることを確認
         */
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] ss = s.nextLine().split(" ");
        int prev = 0;
        boolean r = true;
        for(int i = 0;i < n;i++) {
            int current = Integer.parseInt(ss[i]);
            if(prev <= current -1){
                prev = current - 1;
                continue;
            }
            if(prev <= current){
                prev = current;
                continue;
            }else{
                r = false;
                break;
            }
        }
        System.out.println(r ? "Yes":"No");
    }
}

Measured memory_bytes: 48252
#解説
N, K = [int(nk) for nk in input().split()]

ans = 0
for a in range(1, N+1):
  bK_mod = K - a%K
  cK_mod = K - a%K
  bcK_mod = bK_mod + cK_mod
  if bcK_mod % K == 0:
    howmany_b = (N - bK_mod)//K + 1
    howmany_c = (N - cK_mod)//K + 1
    ans += (howmany_b * howmany_c)

print(ans)

Measured memory_bytes: 3064
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> breads >>= print . solve 

solve :: [Int] -> Int
solve = sum . map pred

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

Measured memory_bytes: 764
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for(int i=0; i<n; i++) h[i] = sc.nextInt();
        sc.close();

        long[] dp = new long[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for(int i=2; i<n; i++){
            dp[i] = Math.min(dp[i-1] + Math.abs(h[i]-h[i-1]), dp[i-2] + Math.abs(h[i]-h[i-2]));
        }

        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 51396
#include<stdio.h>
#include<stdlib.h>
 struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
typedef struct node * NodePointer;

void insert(int);
void preorder(NodePointer);
void inorder(NodePointer);
NodePointer createNode(void);
NodePointer root = NULL;
NodePointer NIL = NULL;

main(){
  int m, i, k;
  char order[10];
  scanf("%d", &m);
  for(i = 0; i < m; i++){
    scanf(" %s", order);
    if(order[0]=='i'){
      scanf(" %d",&k);
      insert(k);
    }
    else if(order[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


NodePointer createNode(){
  NodePointer node = malloc(sizeof(struct node));
  node->left = NULL;
  node->right = NULL;
  node->parent = NULL;
  node->key = 0;
  return node;
}


void insert(int key){
  NodePointer z = createNode();
  NodePointer x = root;
  NodePointer y = NIL;
  z->key = key;
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}


void preorder(NodePointer p){
  printf(" %d", p->key);
  if(p->left != NULL) preorder(p->left);
  if(p->right != NULL) preorder(p->right);
}

void inorder(NodePointer p){
  if(p->left != NULL) inorder(p->left);
  printf(" %d", p->key);
  if(p->right != NULL) inorder(p->right);
}

Measured memory_bytes: 24040
#include<bits/stdc++.h>
#define mxn 1000010
#define LL long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
using namespace std;
int n,K,sl,fh;
vector<pii> E;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd();K=rd();if(K>(n-1)*(n-2)/2) {puts("-1"); return 0;}
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			E.pb(mp(i,j));
	for(;K;--K) E.ppb();
	printf("%d\n",K=E.size());
	for(int i=0;i<K;++i) printf("%d %d\n",E[i].fr,E[i].sc);
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

void Main() {
  //自動整形防止用コメント
  int a, b;
  std::cin >> a >> b;
  int hole = 1;
  int counter = 0;
  while (b > hole) {
    hole--;
    hole += a;
    counter++;
  }

  std::cout << counter << '\n';
  return;
}

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


Measured memory_bytes: 256
H,W = map(int, input().split())
L = [[x if x=='#' else 0 for x in input()] for _ in range(H)]

for i in range(H):
  l = L[i]
  l_before=None
  l_after=None
  if i>0:
    l_before=L[i-1]
  if i<H-1:
    l_after=L[i+1]
    
  for j in range(W):
    if l[j] != '#':
      try:
        if j>=1 and l_before[j-1]=='#':
          l[j]+=1
      except:
        pass
      try:
        if l_before[j]=='#':
          l[j]+=1
      except:
        pass
      try:
        if l_before[j+1]=='#':
          l[j]+=1
      except:
        pass
      try:
        if j>=1 and l[j-1]=='#':
          l[j]+=1
      except:
        pass
      try:
        if l[j+1]=='#':
          l[j]+=1
      except:
        pass
      
      try:
        if j>=1 and l_after[j-1]=='#':
          l[j]+=1
      except:
        pass
      try:
        if l_after[j]=='#':
          l[j]+=1
      except:
        pass
      try:
        if l_after[j+1]=='#':
          l[j]+=1
      except:
        pass


for i in range(H):
  for j in range(W):
    print(str(L[i][j]),end='')
  else:
    print()

      

  

Measured memory_bytes: 9280
n = int(input())
if n%2 == 0:
	print(n*(n-2)//2)
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			if i+j != n+1:
				print(i, j)
else:
	print((n*(n-2)+1)//2)
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			if i+j != n:
				print(i, j)

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var S = Read();
            var ans = new bool[1000];
            var right = new int[N][];
            var chk = new int[10];
            for (int i = N - 1; i >= 0; i--)
            {
                right[i] = new int[10];
                for (int j = 0; j < 10; j++)
                {
                    right[i][j] = chk[j];
                }
                chk[int.Parse(S[i].ToString())] = 1;
            }
            var first = new bool[10];
            for (int i = 0; i < N - 2; i++)
            {
                if (first.All(b => b == true)) break;
                if (first[int.Parse(S[i].ToString())]) continue;
                first[int.Parse(S[i].ToString())] = true;
                var second = new bool[10];
                for (int j = i + 1; j < N - 1; j++)
                {
                    if (second.All(b => b == true)) break;
                    if (second[int.Parse(S[j].ToString())]) continue;
                    second[int.Parse(S[j].ToString())]= true;
                    for (int k = 0; k < 10; k++)
                    {
                        if (right[j][k] == 1)
                        {
                            ans[int.Parse(S[i].ToString() + S[j].ToString() + k.ToString())] = true;
                        }
                    }
                }
            }

            Console.WriteLine(ans.Count(b => b == true));
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 19812
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main(void) {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;
  int anss = 2 * c * max(x, y);
  if(a + b > c * 2) {
    int m = min(x, y);
    ans += c * 2 * m;
    x -= m;
    y -= m;
  }
  ans += a * x;
  ans += b * y;
  cout << min(ans, anss) << endl;

  return 0;
}

Measured memory_bytes: 3548
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSumOfLargeNumbers solver = new DSumOfLargeNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSumOfLargeNumbers {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            long n = s.nextInt(), k = s.nextInt();
            long mod = (long) 1e9 + 7;
            long res = 0;
            for (long i = k; i <= n + 1; i++) {
                long l = i * (i - 1) / 2;
                long r = n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2;
                res = (res + (r - l + 1) % mod) % mod;
            }
            w.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

vector<int> solve(int N, int M, const string& s)
{
    int R = N, L = R - 1;
    vector<int> ans;

    while (R > 0)
    {
        int free = -1;

        while (L >= 0 and (R - L <= M))
        {
#ifdef DEBUG
//cout << "Aqui 1: L = " << L << ", s[L] = " << s[L] << "\n";
#endif
            if (s[L] == '0')
            {
                free = L;
            }
            --L;
        }
#ifdef DEBUG
    cout << "R = " << R << ", L = " << L << ", s[L] = " << s[L] << ", free = " << free << ": "
        << (free == -1 ? 'x' : s[free]) << endl;
#endif
        if (free == -1)
            return { };

        ans.push_back(R - free);
        R = free;
    }

    reverse(ans.begin(), ans.end());

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    string s;
    cin >> s;

    auto ans = solve(N, M, s);
    int size = ans.size();

    if (size == 0)
        cout << -1 << endl;
    else
        for (int i = 0; i < size; ++i) 
            cout << ans[i] << (i + 1 == size ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 1096
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 3;

template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int digit[N];

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

	int d, k, n, m;
	cin >> n >> m;
	vector<vector<int>> adj(n);
	
	for (int i = 0; i < m; ++i) {
		cin >> k >> d;
		adj[k - 1].push_back(d);
	}

	for (int i = (n - 1 == 0 ? 0: pow(10, n-1)); i < pow(10, n); ++i) {
		int tmp = i;
		for (int j = 0; j < n; ++j) {
			digit[j] = tmp % 10;
			tmp /= 10;
		}
		bool ok = true;
		for (int j = 0; j < n; ++j) {
			for (int l = 0; l < adj[j].size(); ++l) {
				ok = ok && adj[j][l] == digit[n -j -1];
			}
		}
		if (ok) {
			cout << i << '\n';
			return 0;
		}
	}

	cout << -1 << '\n';
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
string n;
int main(){
    cin>>n;
    for(int s=2;s<n.size();s++){
        if(n[s]==n[s-1]&&n[s]==n[s-2]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
    int n,x,m,min=99999999,count=0;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>m;
        x-=m;
        if(min>m){
            min=m;
        }
    }
    while(true){
        if(x<min){
            break;
        }
        x=x-min;
        count++;
    }

    cout<<n+count<<'\n';
	return 0;
}


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

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

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

Measured memory_bytes: 764
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>
#include <cassert>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s.back() == 's')cout << s << "es" << endl;
	else cout << s << "s" << endl;
}

Measured memory_bytes: 3624
n,k=gets.split.map(&:to_i)
as=gets.split.map(&:to_i)

b = 2
b *= 2 while b <= k
b /= 2
c = 0
while b > 0
  t = 0
  as.each do |a|
    t += (a & b == 0) ? -1 : 1
  end
  if t < 0
    c += b
  end
  b /=2
end

b = 2
b *= 2 while b <= k
b /= 2
d = 0
if k < c
  while b > 0
    if (k&b != 0) && (c&b != 0)
      d += b
      b /= 2
    elsif (k&b !=0) && (c&b == 0)
      d += (b-1)&c
      break
    else
      b /= 2
    end
  end
else
  d = c
end

ret = 0

as.each do |a|
  ret += d^a
end

p ret

Measured memory_bytes: 8844