akhauriyash/Code-Regression huggingface dataset:
n=int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
a=0
for i in range(n):
  if x[i]==y[i]:
    a+=1
    if a==3:
      break
  else:
    a=0
    
if a>=3:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9180
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=2e5+10;
typedef long long LL;

string goods[MR];

int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>goods[i];
	sort(goods,goods+n);
	int cnt=1;
	for(int i=1;i<n;i++){
		if(goods[i]!=goods[i-1]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 10020
def move(board): # 空きを埋める関数
    board = [list(x) for x in zip(*board)]
    for i in range(len(board)):
        row = board[i]
        row = [i for i in row if i!=0]
        n = len(board[i]) - len(row)
        row.extend([0]*n)
        board[i] = row
    board = [list(x) for x in zip(*board)]
    return board

ls_ans = []
while(1):
    ans = 0
    H = int(input())
    if H==0:
        break
    board = []
    for h in range(H):
        C = list(map(int,input().split()))
        board.append(C)
    board = board[::-1]
    for t in range(H):
        for h in range(H):
            C = board[h]
            changed = set()
            old_c = ''
            oldold_c = ''
            streak = 0
            for i,c in enumerate(C):
                if c == old_c and c == oldold_c:
                    if streak == 0:
                        streak += 3*c
                        C[i] = C[i-1] = C[i-2] = 0
                    else:
                        streak += c
                        C[i] = 0
                else:
                    ans += streak
                    streak = 0
                oldold_c = old_c
                old_c = c
            ans += streak
            board[h] = C
        board = move(board)
    ls_ans.append(ans)

for ans in ls_ans:
    print (ans)


Measured memory_bytes: 5776
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n==1 || n==2 || n==3 || n==5 ||n==7 || n==11 || n==13 || n==15 || n==17 || n==19 || n==23 || n==29 || n==31)
  {
    cout<<"1";
  }if(n==4 || n==6 || n==9 || n==10 ||n==14 || n==21 || n==22 || n==25 || n==26)
  {
    cout<<"2";
  }
  if(n==30 || n==28)
  {
    cout<<"4";
  }
  if(n==8 || n==12 || n==18 || n==20 || n==27)
  {
    cout<<"5";
  }
  if(n==16)
  {
    cout<<"14";
  }
  if(n==32)
  {
    cout<<"51";
  }
  if(n==24)
  {
    cout<<"15";
  }
  return 0;
}
  

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

using namespace std;
typedef long long ll;

int main()
{
	while(1)
	{
		ll b;
		pair<int,int> ans=make_pair(0,0);
		cin>>b;
		if(b==0)
			break;
		for(int i=1;i<sqrt(2*b)+1;i++)
		{
			ll tmp=b-i*(i+1)/2;
			if(tmp<0)
				break;
			if(tmp%i==0)
				ans=max(ans,make_pair(i,(int)tmp/i));
		}
		cout<<ans.second+1<<" "<<ans.first<<endl;
	}
	return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b; cin>>a>>b;
    string s; cin >>s;
    bool p =1;
    for (int i=0; i<a+b+1; ++i){
		if (i == a) { 
			if (s[i] != '-')p=0;
		}else {
			if(s[i] < '0' || s[i]  > '9') p=0;
		}
    }
    cout<<(p ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,A,B;
	while(cin>>N>>A>>B) {
		ll ans=0;
		if(A%2==B%2) ans=abs(A-B)/2;
		else {
			ans=min(min(A-1,B-1)+1+abs(A-B)/2, min(N-A,N-B)+1+abs(A-B)/2);
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
//abc105_b.cpp
//Sat Aug 18 12:09:37 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (n%4 == 0 || n%7 == 0){
		cout << "Yes" << endl;
	}else{
		int count = 1;
		int flag = 0;
		while (count*7<n){
			if ((n-count*7)%4 == 0){
				cout << "Yes" << endl;
				flag = 1;
				break;
			}
			count++;
		}
		if (flag == 0){
			cout << "No" << endl;
		}
	}
}

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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "file"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

vector<int> g1[200010], g2[200010];
bool used[200010];
int where1[200010], where2[200010];
int numComp = 0;
vector<int> comp1[200010], comp2[200010];
bool flag1[200010], flag2[200010];
int ans[200010];
bool found[200010];

void dfs1(int v)
{
    used[v] = 1;
    for(int to: g1[v])
        if(!used[to])
            dfs1(to);
    where1[v] = numComp;
    comp1[numComp].pb(v);
}

void dfs2(int v)
{
    used[v] = 1;
    for(int to: g2[v])
        if(!used[to])
            dfs2(to);
    where2[v] = numComp;
    comp2[numComp].pb(v);
}

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k, l;
    cin >> n >> k >> l;
    for(int i = 0; i < k; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g1[a].pb(b);
        g1[b].pb(a);
    }
    for(int i = 0; i < l; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g2[a].pb(b);
        g2[b].pb(a);
    }
    for(int i = 0; i < n; i++)
    {
        if(!used[i])
        {
            dfs1(i);
            numComp++;
        }
    }
    for(int i = 0; i < numComp; i++)
        sort(all(comp1[i]));
    memset(used, 0, sizeof(used));
    numComp = 0;
    for(int i = 0; i < n; i++)
    {
        ans[i] = 1;
        if(!used[i])
        {
            dfs2(i);
            numComp++;
        }
    }
    for(int i = 0; i < numComp; i++)
        sort(all(comp2[i]));
    for(int i = 0; i < numComp; i++)
    {
        map<int, vector<int>> smallc;
        for(int j: comp2[i])
            smallc[where1[j]].pb(j);
        for(auto k: smallc)
            for(int j: k.second)
                ans[j] = k.second.size();
    }
    for(int i = 0; i < n; i++)
        cout << ans[i] << " ";
    return 0;
}


Measured memory_bytes: 40824
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long ans = x / 11;
        long mod = x % 11;
        ans *= 2;
        if (mod > 0) {
            ans++;
        }
        if (mod > 6) {
            ans++;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b[1007],c[1007],e,d[1007],f,t,i,j,k=0;
    cin>>t>>a;
    for(i=0;i<t;i++){
        cin>>b[i]>>c[i];
        if(c[i]<=a){
            d[k]=b[i];
            k++;}}
            sort(d,d+k);
            if(k==0)
                cout<<"TLE"<<endl;
            else
            cout<<d[0]<<endl;
            return 0;}




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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

struct ConvexHullTrick {
    struct Line {
        long long a, b;
        long long get(long long x) { return a * x + b; }
    };
    deque<Line> que;
    bool check(Line a, Line b, Line c) {
        return (b.b - c.b) * (b.a - a.a) <= (a.b - b.b) * (c.a - b.a);
    }
    void add(long long a, long long b) {
        Line l{a, b};
        while(que.size() > 1 && check(que[que.size() - 2], que.back(), l))
            que.pop_back();
        que.push_back(l);
    }
    long long query(long long x) {
        if(que.empty()) return INT64_MAX;
        while(que.size() > 1 && que[0].get(x) >= que[1].get(x))
            que.pop_front();
        return que[0].get(x);
    }
};

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

	int N,C;
	cin>>N>>C;
	vector<int> H(N);
	rep(i,0,N)cin>>H[i];

	vector<int> DP(N+1,INF);
	DP[0]=0;

	ConvexHullTrick cht;

	cht.add(-2*H[0],H[0]*H[0]+DP[0]);
	rep(i,1,N)
	{
		DP[i]=cht.query(H[i])+H[i]*H[i]+C;
		cht.add(-2*H[i],H[i]*H[i]+DP[i]);
	}

	cout<<DP[N-1]<<endl;

	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(100 <= n && n<= 111){
    cout << 111 << endl;
  }else if(112 <= n && n <= 222){
    cout << 222 << endl;
  }else if(223 <= n && n <= 333){
    cout << 333 << endl; 
  }else if(334 <= n && n <= 444){
    cout << 444 << endl; 
  }else if(445 <= n && n <= 555){
    cout << 555 << endl; 
  }else if(556 <= n && n<= 666){
    cout << 666 << endl; 
  }else if(667 <= n && n<= 777){
    cout << 777 << endl; 
  }else if(778 <= n && n<= 888){
    cout << 888 << endl; 
  }else{
    cout << 999 << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <deque>
using namespace std;
int n; deque<int> dq;
int main() {
  scanf("%d", &n);
  for(int i = 0, a; i < n; ++i) {
    scanf("%d", &a);
    if(i%2 == 0) dq.push_back(a);
    else dq.push_front(a);
  }
  if(n%2 == 0) {
    while(!dq.empty()) printf("%d ", dq.front()), dq.pop_front();
  } else {
    while(!dq.empty()) printf("%d ", dq.back()), dq.pop_back();
  }
}

Measured memory_bytes: 2944
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)

#define MAX 1000000000

//まず町ごとの最短コストを求める
//道ごとに更に求める

int main(){
    iostream::sync_with_stdio(false);
    
    int N,M,K;
    cin >> N >> M >> K;
    vector<pair<int,int> > road[3000];
    vector<pair<pair<int,int>,int> > r;
    for(int i=0; i<M; i++){
        int a,b,l;
        cin >> a >> b >> l;
        a--; b--;
        road[a].push_back(MP(b, l));
        road[b].push_back(MP(a, l));
        r.push_back(MMP(a, b, l));
    }

    int cost[3000];
    for(int i=0; i<N; i++) cost[i] = MAX;
    priority_queue<pair<int,int> > que;
    for(int i=0; i<K; i++){
        int tmp;
        cin >> tmp;
        tmp--;
        cost[tmp] = 0;
        que.push(MP(MAX, tmp));
    }

    while(!que.empty()){
        int now = que.top().second;
        int c = MAX - que.top().first;
        for(int i=0; i<road[now].size(); i++){
            int next = road[now][i].first;
            int l = road[now][i].second;
            if(cost[next] > c+l){
                cost[next] = c+l;
                que.push(MP(MAX-cost[next], next));
            }
        }
        que.pop();
    }
    //for(int i=0; i<N; i++) cout << cost[i] << endl;

    int ans = 0;
    for(int i=0; i<M; i++){
        int a = r[i].first.first;
        int b = r[i].first.second;
        int l = r[i].second;
        int d = abs(cost[a] - cost[b]);
        if(d >= l) ans = max(ans, max(cost[a], cost[b]));
        else{
            int add = round((double)(l - d)/2);
            ans = max(ans, max(cost[a]+add, cost[b]+add));
        }
    }
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 6980
/*input
2 999983
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=1000005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e15+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<int> p;
bitset<maxn> isp;
int main()
{

	for(int i=2;i<maxn;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<maxn;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}

	IOS;
	ll n,D;
	cin>>n>>D;

	if(n==1){
		cout<<D<<'\n';
		return 0;
	}
	ll ans=1;
	for(int i:p){
		if(i*i>D) break;
		int cnt=0;
		while(D%i==0){
			D/=i;
			cnt++;
		}
		ans*=mypow(i,cnt/n);
		if(D==1) break;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1020
n = int(input())
a =[int(i) for i in input().split()]
j = 1
ans = 0
k =0
l = -1
if 1 not in a:
	ans = -1
else:
		for i in range(k,n):
			if k>=n:
				break
			elif a[i] == j:
				ans+=i-k
				k = i+1
				j +=1
				l = i

if l!=-1:
	ans+=n-1-l
print(ans)
"""
k  =1
j =0
for  i in range(k,10):
		if i !=2:
			print(i)
		else:
			k = 3
			break
		j +=1
"""


Measured memory_bytes: 26268
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}

int N;

int main()
{
	cin >> N;
	int p[N];
	REP(i,0,N){
		cin >> p[i];
		p[i]--;
	}
	int c = 0;
	bool flag = true;
	while (1)
	{
		flag = true;
		REP(i, 0, N)
		{
			if(p[i]==i){
				if(i!=N-1){
					int tmp = p[i];
					p[i] = p[i + 1];
					p[i + 1] = tmp;
				}else{
					int tmp = p[i];
					p[i] = p[i -1];
					p[i - 1] = tmp;
				}
				c++;
				flag = false;
			}
		}
		if(flag){
			break;
		}
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n, m, p = 1000000007;
long long v[100020];
long long f[100020];
long long ans;
long long C(int n, int m) {
	return f[n] * v[m] % p * v[n - m] % p;
}
int main() {
	v[0] = v[1] = f[0] = f[1] = 1;
	for (int i = 2; i <= 100010; i++) {
		v[i] = v[p % i] * (p - p / i) % p;
	}
	for (int i = 2; i <= 100010; i++) {
		f[i] = f[i - 1] * i % p;
		v[i] = v[i - 1] * v[i] % p;
	}
	scanf("%d%d", &n, &m);
	ans = n + 1;
	for (int i = 1; i < m; i++) {
		if (m - i > n) {
			continue;
		}
		for (int j = 1; j <= m - i; j++) {
			if ((m - i) + (m - i - j) > n) {
				continue;
			}
			ans += C(m - 1, i - 1) * C(m - i - 1, j - 1) % p * C(n - (m - i) - (m - i - j) + 2, 2) % p;
			ans %= p;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import queue
K = int(input())
q = queue.Queue()
for i in range(1,10):
  q.put(i)
    
    
for i in range(K-1):
  x = q.get()
  if x%10 != 0:
    q.put(10*x + (x%10 -1) )
  q.put(10*x+x%10)
  if x%10 != 9:
    q.put(10*x + (x %10 + 1) )
print(q.get())

Measured memory_bytes: 13016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   string s;
   cin >> s;
   if(s == "a"){
     cout << "b";
   }
   if(s == "b"){
     cout << "c";
   }
      if(s == "c"){
     cout << "d";
   }
      if(s == "d"){
     cout << "e";
   }
      if(s == "e"){
     cout << "f";
   }
      if(s == "f"){
     cout << "g";
   }
      if(s == "g"){
     cout << "h";
   }
      if(s == "h"){
     cout << "i";
   }
      if(s == "i"){
     cout << "j";
   }
      if(s == "j"){
     cout << "k";
   }
      if(s == "k"){
     cout << "l";
   }
      if(s == "l"){
     cout << "m";
   }
      if(s == "m"){
     cout << "n";
   }
      if(s == "n"){
     cout << "o";
   }
      if(s == "o"){
     cout << "p";
   }
      if(s == "p"){
     cout << "q";
   }
      if(s == "q"){
     cout << "r";
   }
      if(s == "r"){
     cout << "s";
   }
      if(s == "s"){
     cout << "t";
   }
      if(s == "t"){
     cout << "u";
   }
      if(s == "u"){
     cout << "v";
   }
      if(s == "v"){
     cout << "w";
   }
      if(s == "w"){
     cout << "x";
   }
      if(s == "x"){
     cout << "y";
   }
      if(s == "y"){
     cout << "z";
      }
}



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

long long int gcd(long long int a,long long int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    long long int n,k,r,s,p,ans=0;
    cin>>n>>k>>r>>s>>p;
    string q;
    cin>>q;
    for(long long int i=0;i<n;i++){
        
        
            if(q[i]=='r'){
                ans+=p;
            }
            else if(q[i]=='s'){
                ans+=r;
            }
            else if(q[i]=='p'){
                ans+=s;
            }
            if(i<n-k&&q[i]==q[i+k]){
                q[i+k]='z';
                
            }
            
            
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		sb.append("");//??????????????\???????????????
		int h, w;
		
		// h??¨w?????¨??????0????????£?????¨??????????????????????????????
		while (true) {
			h = scan.nextInt();// ????????????
			w = scan.nextInt();// ?¨??????????
			
			if((h == 0) & (w == 0)){break;}

			// for?????§????????????h??§????????????
			for (int count = 0; count < h; count++) {
				// for?????§?¨???????????????§????????????
				for (int count2 = 0; count2 < w; count2++) {
					// #???StringBuilder?????\????????????
					sb.append("#");
				}
				sb.append("\n");
			}
			System.out.println(new String(sb));
			//StringBuilder????????????????????????
			sb.delete(0, sb.length());
		}
		

	}
}

Measured memory_bytes: 27716
#include <stdio.h>

int main(){

    int a, b, c, ans=0;
    scanf("%d %d %d", &a, &b, &c);

    if (a == b && b == c) ans = 1;

    if (ans == 0){
        printf("No");
    }else{
        printf("Yes");
    }

    return 0;
}

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

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

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

int main() {
    string c;
    cin >> c;

    if (c[0] == 'a' || c[0] == 'e' || c[0] == 'i' || c[0] == 'o' || c[0] == 'u') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,fibonacci,f[44]={0};

int makefibnacci(int n){
  f[0]=1;
  f[1]=1;
  for(int i = 2; i <=n; i++){
    f[i]=f[i-2]+f[i-1];
  }
  return f[n];
}

int main(){
  cin >> n;
  fibonacci = makefibnacci(n);
  cout << fibonacci << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	ll sz = 0;
	rep(i, n) chmax(sz, a[i]);
	sz++;

	set<ll> st;
	rep(i, n) st.insert(a[i]);
	unordered_map<ll, ll> ump;
	rep(i, n) ump[a[i]]++;

	VecB ok(sz, true);

	for(ll i : st){
		if (!ok[i]) continue;
		for (ll j = 2; j * i < sz; ++j){
			ok[j * i] = false;
		} 
	}

	ll ans = 0;
	rep(i, n){
		if (ok[a[i]] && ump[a[i]] == 1) ans++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 22524
import java.util.Scanner;

class Main{
     public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int H;
    	int W;
    	
    	for(;;){
    		H = scan.nextInt();
        	W = scan.nextInt();
        	if(H == 0 && W == 0){
        		break;
        	}
        	
        	for(int y = 0; y < H; y++){
        		for(int x = 0; x < W; x++){
        			if((x+y) % 2 != 0){
        				System.out.print(".");
        			}else{
        				System.out.print("#");
        			}
        		}
        		System.out.println("");
        	}
        	System.out.println("");
    	}
    	
     }
}

Measured memory_bytes: 35088
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬╬╬██╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#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 ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  bool f = true;
  REP(i,n) if(a[i] %2 == 1) f = false;

  if(!f) cout << "first" << endl;
  else cout << "second" << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int A, B, C;
	int K;
	int asumisu;
	if (scanf("%d%d%d", &A, &B, &C) != 3) return 1;
	if (scanf("%d", &K) != 1) return 1;
	asumisu = A;
	if (asumisu < B) asumisu = B;
	if (asumisu < C) asumisu = C;
	printf("%d\n", A + B + C + (asumisu << K) - asumisu);
	return 0;
}


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

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

using Point = complex<double>;
using Polygon = vector<Point>;

inline int sgn(const double &a) { return (a < -EPS ? -1 : (a > EPS ? 1 : 0)); }

inline bool eq(const Point &a, const Point &b) { return abs(a - b) < EPS; }

namespace std {
inline bool operator<(const Point &a, const Point &b) {
    if (sgn(a.real() - b.real()))
        return sgn(a.real() - b.real()) < 0;
    return sgn(a.imag() - b.imag()) < 0;
}
} // namespace std

double dot(const Point &a, const Point &b) { return real(conj(a) * b); }

double det(const Point &a, const Point &b) { return imag(conj(a) * b); }

struct Line {
    Point p1, p2;

    Line(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator<(const Line &rhs) const {
        if (eq(p2, rhs.p2))
            return p1 < rhs.p1;
        return p2 < rhs.p2;
    }
    bool operator==(const Line &rhs) const {
        return (eq(p1, rhs.p1) && eq(p2, rhs.p2)) ||
               (eq(p1, rhs.p2) && eq(p2, rhs.p1));
    }
};

Point projection(Line line, Point p){
    Point a = line.p2 - line.p1, b = p - line.p1;
    double r = dot(a, b) / norm(a);
    return line.p1 + r * a;
}

Point reflection(Line line, Point p){
    Point proj = projection(line, p);
    return p + (proj - p) * 2.;
}

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Point p1 = Point(x1, y1), p2 = Point(x2, y2);
    Line line = Line(p1, p2);
    int q;
    cin >> q;
    for(int i=0;i<q;++i){
        double x, y;
        cin >> x >> y;
        Point p = Point(x, y);
        Point ans = reflection(line, p);
        printf("%.10f %.10f\n", ans.real(), ans.imag());
    }

    return 0;
}



Measured memory_bytes: 3340
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    TF = 'No'
    for i in range(25):
        if N-4*i<0:
            break
        elif (N-4*i)%7==0:
            TF='Yes'
            break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, MINN, len(0LL);
	cin >> n;
	for(int i = sqrt(n); i >= 1; i --) {
		if(n % i == 0) {
			MINN = i;
			break;
		}
	} string s = to_string(max(MINN, n / MINN));
	cout << s.size() << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define mem(a) memset(a,0,sizeof(a))

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

const int mn=3e5+5;
const int mod=1e7;

int n;
int a[mn];

int main() {
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
	clock_t cc=clock();
#endif
	scanf("%d",&n);
	int u,cnt=0;
	int ans=0;
	for(int i=1;i<=n;i++) {
		int v;
		scanf("%d",&v);
		if (u==v) cnt++;
		else u=v,ans+=cnt/2,cnt=1;
	}
	ans+=cnt/2;
	printf("%d\n",ans);
#ifdef LOCAL
	cout<<"time:"<<(double)(clock()-cc)/CLOCKS_PER_SEC;
#endif
	return 0;
}

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

int nn[55][55];
int num[55],low[55],flag[55],index;
int s=0;
void gbdfs(int cur,int fa,int n)
{
	int i,j;
	
	index++;
	num[cur] = index;
	low[cur] = index;
	
	for(i=1;i<=n;i++)
	{
		if(nn[cur][i] == 1)
		{
			if(num[i] == 0)
			{
				gbdfs(i,cur,n);
				low[cur] = min(low[cur],low[i]);
				if(low[i] > num[cur])
					s++;
			}
			else if(i != fa)
				low[cur] = min(low[cur],num[i]);
		}
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int t;
	for(t=0;t<m;t++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		nn[a][b] = nn[b][a] = 1;
	}
	gbdfs(1,1,n);
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int X, Y, Z;
int main() {
	cin >> X >> Y >> Z;
	int cur = 0, ret = 0;
	while (cur + Y + Z <= X - Z) cur += Y + Z, ret++;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

int main()
{
    int d,t,s;
    cin>> d >> t >> s;
    if(s*t<d) cout<< "No" <<endl;
    else cout<< "Yes" <<endl;
    return 0;
}

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

#define MOD (ll)(1e9+7)
#define ll long long 

int dp[1001][1001] = {0};
char grid[1001][1001];

int main() {
    int h,w;
    cin>>h>>w;
    for (int i = 0; i < h; ++i)
    {
        cin >> grid[i];
    }

    dp[0][0] = 1;
    for (int i = 1; i < h; ++i)
    {
        if(grid[i][0] != '#')
            dp[i][0] = dp[i-1][0];
        else
            dp[i][0] = 0;
    }
    // cout << "ok1";
    for (int j = 1; j < w; ++j)
    {
        if(grid[0][j] != '#')
            dp[0][j] = dp[0][j-1];
        else
            dp[0][j] = 0;
    }

    // cout << "ok2";
    for (int i = 1; i < h; ++i)
    {
        for (int j = 1; j < w; ++j)
        {
            if(grid[i][j]=='#')
                dp[i][j] = 0;
            else {
                dp[i][j] = ((ll)dp[i-1][j] % MOD+ (ll)dp[i][j-1] % MOD) % MOD;
            }
        }
    }

    // for (int i = 0; i < h; ++i)
    // {
    //     for (int j = 0; j < w; ++j)
    //     {
    //         cout << dp[i][j]  << " ";
    //     }
    //     cout << endl;
    // }

    cout << dp[h-1][w-1] % MOD << "\n";

    return 0;
}

Measured memory_bytes: 5120
#include <iostream>

#define INFTY 1000000001

using namespace std;

int cnt=0;

void merge(int a[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++) L[i]=a[left+i];
  for(int i=0;i<n2;i++) R[i]=a[mid+i];
  L[n1]=INFTY; R[n2]=INFTY;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      a[k]=L[i];
      i++;
    }else{
      a[k]=R[j];
      j++;
    }
  }
}

void mergeSort(int a[],int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(a,left,mid);
    mergeSort(a,mid,right);
    merge(a,left,mid,right);
  }
}

int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  mergeSort(a,0,n);
  for(int i=0;i<n;i++){
    if(i) cout << " " << a[i];
    else cout << a[i];
  }
  cout << endl << cnt << endl;
}

Measured memory_bytes: 6924
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#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 ll = long long;
const ll INF = 1ll<<60;

ll N, M;
std::string S;
std::vector<ll> vs;

int main()
{
  std::cin >> N >> M >> S;

  ll p = N;

  while( p > 0 )
  {
    bool upd = false;

    for( int i = M; i >= 1; --i )
    {
      if( p-i >= 0 && S[p-i] == '0' )
      {
        vs.emplace_back( i );
        p -= i;
        upd = true;
        break;
      }
    }

    if( !upd )
    {
      std::cout << -1 << std::endl;
      
      return 0;
    }
  }

  if( p )
  {
    std::cout << -1 << std::endl;

    return 0;
  }

  std::reverse( all(vs) );

  rep( i, vs.size() )
    std::cout << vs[i] << (i==vs.size()-1?'\n':' ');

  return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>

#define sz(a) (int)((a).size())

using namespace std;

typedef long long ll;
typedef long double ld;

int solve()
{
    ios::sync_with_stdio(0);
    int n;
    if (!(cin >> n))
    {
        return 1;
    }
    int k;
    cin >> k;
    ll ans = 0;
    for (int i = k + 1; i <= n; i++)
    {
        int q = n / i;
        ans += (ll)q * (ll)(i - k);
        ans += max(0, n % i - k + 1);
        if (k == 0)
        {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

int32_t main()
{
    int T = 1;
    #ifdef ONPC
        freopen("in.txt", "r", stdin);
    #endif
    for (int i = 1;; i++)
    //cin >> T; for (int i = 0; i < T; i++)
    {
        #ifdef ONPC
            cout << "Test #" << i << ":\n";
        #endif
        if (solve())
            break;
        #ifdef ONPC
            cerr << "_______________________________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1000LL / CLOCKS_PER_SEC << " ms" << endl;
    #endif
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int n;
    int result[31];
    result[0] = 1;
    result[1] = 1;
    result[2] = 2;
    for(int i = 3; i < 31; i++){
    result[i] = result[i - 3] + result[i - 2] + result[i - 1];
    }
    while(1){
        cin >> n;
        if(n == 0) break;
        int ans = 0;
        // cout << result[n] << endl;
        if(result[n] % 10 == 0) ans = result[n] / 10;
        else ans = result[n] / 10 + 1;
        if(ans % 365 == 0) ans = ans / 365;
        else ans = ans / 365 + 1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
/*input
54
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"
//order_of_key #of elements less than x
// find_by_order kth element 
#define ll long long 
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (int)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const int maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
vector<int> ans[maxn];
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	map<int,int> cnt;
	int stp=0;
	while(true){
		if(cnt[n]==1){
			cout<<stp+1;
			return 0;
		}
		cnt[n]++;
		if(n&1) n=n*3+1;
		else n=n/2;
		++stp;
	}

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n;
int dp[3010][3010];
int a[3010];

int calc(int l, int r){
    if(l > r) return 0;
    if(dp[l][r] != -1) return dp[l][r];
    int turn = (l + n - 1 - r) % 2;
    int score = 0;
    if(turn == 0){
        score = max(calc(l + 1, r) + a[l], calc(l, r - 1) + a[r]);
    }else{
        score = min(calc(l + 1, r) - a[l], calc(l, r - 1) - a[r]);
    }
    return dp[l][r] = score;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) rep(j, 0, n) dp[i][j] = -1;
    cout << calc(0, n - 1) << endl;
}

Measured memory_bytes: 70912
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

    long MOD = 998244353;

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();

        long ans = 0;
        long col = m;

        Combi cb = new Combi(n-1, MOD);


        for (int x=n-1; 0<=x; x--) {
            long now = col % MOD;
//            System.out.println(now);
            now *= cb.nck(n-1, x);
            now %= MOD;
//            System.out.println(now);
            if (x <= k) {
                ans += now;
                ans %= MOD;
            }
            col *= (m - 1);
            col %= MOD;
        }

        System.out.println(ans);

//        System.out.println(new Combi(n, MOD).facts[n]);


    }

    public class Combi {
        int n;   //　要素数
        long MOD;
        long[] facts;

        public Combi(int n, long MOD){
            this.n = n;
            this.MOD = MOD;
            facts = new long[n+1];
            facts[0] = 1;
            for (int i=1; i<n+1; i++){
                facts[i] = facts[i-1]*i%MOD;
            }
        }

        public long modpow(long a, long b){  // 計算量はlog(MOD);
            if (b==0) return 1;
            else if (b==1) return a;
            long x = modpow(a, b/2);
            return b%2==0 ? x*x%MOD : x*(x*a%MOD)%MOD;
        }
        public long inv(long n){ // 逆元。x^(-1)≡x^(p-2) (MOD p)
            return modpow(n, MOD-2);
        }
        public long nck(int n, int k){
            return n<k ? 0: facts[n]*(inv(facts[n-k])*inv(facts[k])%MOD)%MOD;
        }
    }

}


Measured memory_bytes: 38476
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (a > b ||(n==1&&a<b))cout << 0 << endl;
	else if (a == b)cout << 1 << endl;
	else if (n == 2 && b - a == 1)cout << 1 << endl;
	else cout << (n-1) * b + a - ((n-1)* a + b) +1<< endl;
	ll
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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



int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15)cout << "+";
	else if (a*b == 15)cout << "*";
	else cout << "x";
}

Measured memory_bytes: 256