akhauriyash/Code-Regression huggingface dataset:
//author: zekigurbuz (Zeki Gurbuz) 2020
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;

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

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int N = 1e5 + 10;
const int M = 1e9 + 7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

template<class T>void ckmin(T&a,T b){a=min(a,b);}
template<class T>void ckmax(T&a,T b){a=max(a,b);}




void solve() {
	int n, k, c;
	cin >> n >> k >> c;
	string s; cin >> s;
	vector<int> a(k), b(k);
	int prev = -2147483647;
	int pos = 0;
	for (int i = 0; i < n && pos < k; i++) {
		if (s[i] == 'o' && i > prev + c) {
			a[pos++] = i;
			prev = i;
		}
	}
	prev = 2147483647;
	pos = k - 1;
	for (int i = n - 1; i >= 0 && pos >= 0; i--) {
		if (s[i] == 'o' && i < prev - c) {
			b[pos--] = i;
			prev = i;
		}
	}
	for (int i = 0; i < k; i++) {
		if (a[i] == b[i]) cout << a[i] + 1 << '\n';
	}
}

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

	int t = 1;
    //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3348
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

int
main(int argc, char *argv[])
{
  int a[200020];
  int n;
  scanf("%d", &n);

  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

  for (int i = n / 2; i >= 1; i--) {
    int x = 0;
    int j = 2;
    while (j * i <= n) {
      x += a[j * i];
      j++;
    }
    if (x % 2 != a[i]) a[i] = 1;
    else a[i] = 0;
  }

  int m = 0;
  for (int i = 1; i <= n; i++) m += a[i];
  printf("%d\n", m);
  for (int i = 1; i <= n; i++) if (a[i]) printf("%d ", i);
  if (m > 0) endl;
  return 0;
}
  


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

using namespace std;
using ll = long long;

const int MAX = 1e6 + 1;
const int MOD = 1e9 + 7;

ll pow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        b /= 2;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int &v: p) cin >> v;
    vector<int> div(MAX);
    for (int i = 2; i < MAX; ++i) {
        if (div[i] != 0) {
            continue;
        }
        for (int j = i; j < MAX; j += i) {
            div[j] = i;
        }
    }
    unordered_map<int, int> total;
    unordered_map<int, int> current;
    for (int v : p) {
        current.clear();
        while (v > 1) {
            ++current[div[v]];
            v /= div[v];
        }
        for (auto value : current) {
            total[value.first] = max(total[value.first], value.second);
        }
    }
    ll lcm = 1;
    for (auto value : total) {
        lcm *= pow(value.first, value.second);
        lcm %= MOD;
    }
    ll res = 0;
    for (int v : p) {
        res += lcm * pow(v, MOD - 2) % MOD;
        res %= MOD;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n, k;
  cin >> n >> k;
  long x = n/k;
  long ans = x*x*x;
  if (k%2 == 0) {
    long y = 0;
    for(int i = 1; i <= n; i++) {
      if (i%k == k/2) y++;
    }
    ans += y*y*y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 300005
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0)
        return 0;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}

void solve()
{
    long double d, t, s;
    cin >> d >> t >> s;
    long double tt = d / s;
    if (tt > t)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}
int main()
{

    speed;

    ll kk;
    kk = 1;
    // cin >> kk;
    while (kk--)
    {

        solve();
    }
    return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int H, W;

void init()
{
	cin >> H >> W;
}

void solve()
{
	rep(i, H) {
		CIN(string, s);
		cout << s << endl << s << endl;
	}
}



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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

void solve(int test)
{
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}

int main()
{
    int T = 1, t;
    //cin >> T;
    FOR(t, 0, T) solve(t);
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        if ((i+1)%3!=0 && (i+1)%5!=0) ans += (i+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline

def main():
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    a = [list(map(int, input().split())) for i in range(n)]

    ans = 0
    for i in a:
        cnt = c
        for j in range(m):
            cnt += i[j] * b[j]
        
        if cnt > 0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{ //USE LONGS TO AVOID OVERFLOW THEN CAST
 
	public static void main(String[] args) { 
		FastScanner input = new FastScanner();
		OutPut O = new OutPut();
		int N = input.nextInt();
		int K = input.nextInt();
		long S = input.nextLong();
		int L = 1;
		long inf = (long)(1e9);
		if (S==inf) inf=1;
		for (int i = 1; i <= K; i++) {
			O.p(S+" ");
			L=i+1;
		}
		for (int i = L; i <= N; i++) {
			O.p(inf+" ");
		}
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 46740
#include <cstdio>

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

	if (N == 1)
		printf("%d\n", M);
	else {
		for (gcd = M/N; gcd > 0; gcd--) {
			if (M % gcd)
				continue;
			else {
				printf("%d\n", gcd);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 128
// abc057_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  int n, m, current, nmin, ans;
  cin >> n >> m;
  int a[n], b[n], c[m], d[m];
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, m) cin >> c[i] >> d[i];
  rep(i, n) {
    nmin = inf;
    rep(j, m) {
      current = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (current < nmin) {
        nmin = current;
        ans = j;
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 )
	   a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
			return false;
	return true;
}

const int MAXN = 1e5 + 10;

int n;
int A[ MAXN ];
vii graph[ MAXN ];
int vis[ MAXN ];
int sol[ MAXN ];

void dfs( int node, int c )
{
	vis[ node ] = 1; 
	int b = 1;
	FOR( i, 0, ( int )graph[ node ].size() )
	{
		if ( b == c )
			b++;
		int where = graph[ node ][ i ].X;
		if ( vis[ where ] )
			continue;
		sol[ graph[ node ][ i ].Y ] = b;
		dfs( where, b );
		b++;
	}
}

int main()
{
	cin >> n;
	vii v;
	FOR( i, 0, n - 1 )
	{
		int a, b;cin >> a >> b;a--;b--;
		v.pb( mp( a, b ) );
		graph[ a ].pb( mp( b, i ) );
		graph[ b ].pb( mp( a, i ) ); 
		A[ a ]++;
		A[ b ]++;
	}
	int so = 0;
	FOR( i, 0, n )
		so = max( so, A[ i ] );
	cout << so << "\n";
	
	dfs( 0, 0 );
	FOR( i, 0, n - 1 )
		cout << sol[ i ] << "\n";
	return 0;
}


Measured memory_bytes: 10232
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(x) cout<<x<<endl
#define printyes cout<<"YES"<<endl
#define printno cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,A,B,C,ans=0;
  cin>>A>>B>>C;
  C-=A;
  if(C<=B&&C>=0)printyes;
  else printno;
  return 0;
}


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

using namespace std;

string s;

int main(void)
{
	cin >> s;
	string cs = "CODEFESTIVAL2016";
	
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != cs[i]) ans++;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  string c,d,e;
  cin >> c >> d >> e;

  char c1 = c.at(0);
  char d1 = d.at(0);
  char e1 = e.at(0);
  
  cout << c1 << d1 << e1 << endl;
}

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

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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



int main(){
    bool flag=true;
    ll ans=0,sum=0,mn=INF;

    int n;
    string s;
    cin >>n>>s;

    for (int i = 0; i < n; i++){

        mn = min(mn,ans);

        if(s[i] == '#'){
            ans += 1;
        }else{
            sum += 1;
            ans -= 1;
        }
    }
    mn = min(mn,ans);
    
    ans = mn + sum;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    char q;
    cin >> q;
    if(q == 'A')
    {
        cout << "T";
    }
    if(q == 'C')
    {
        cout << "G";
    }
    if(q == 'G')
    {
        cout << "C";
    }
    if(q == 'T')
    {
        cout <<"A";
    }
}


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

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

  if (a == b && a != c) {
    cout << "Yes" << endl;
    return 0;
  }

  if (b == c && b != a) {
    cout << "Yes" << endl;
    return 0;
  }

  if (a == c && a != b) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define readi(x) scanf("%d", &x)
#define reads(s) scanf("%s", s)
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 1001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n, x;
  int m[MAX];
  readi(n);
  readi(x);
  rep(i, 0, n) readi(m[i]);

  rep(i, 0, n) x -= m[i];
  qsort(m, n, sizeof(int), acs);
  int ans = n + x / m[0];
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
/*
    NEVER GIVE UP !!
    DON'T MESS WITH ME !!!
    "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ll n,k;
    cin >> n >> k;
    n%=k;

    cout << min (n,k-n) << endl;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

struct Node{
  struct Node *right;
  struct Node *left;
  struct Node *parent;
  int key;
};

Node *root,*NIL;

Node *treeMinimum(Node *x){
    while(x->left!=NIL)x=x->left;
    return x;
}

Node *treeMaximum(Node *x){
    while(x->right!=NIL)x=x->right;
    return x;
}

Node *treeSearch(Node *u, int k){
    while(u!=NIL && k!=u->key){
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}

Node *treeSuccessor(Node *x){
    if(x->right!=NIL)return treeMinimum(x->right);
    Node *y=x->parent;
    while(y!=NIL&&x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;
  
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);
  
  if(y->left!=NIL){
      x=y->left;
  }else{
      x=y->right;
  }
  
  if(x!=NIL){
      x->parent=y->parent;
  }
  
  if(y->parent==NIL){
      root=x;
  }else{
      if(y==y->parent->left){
          y->parent->left=x;
      }else{
          y->parent->right=x;
      }
  }
  
  if(y!=z){
      z->key=y->key;
  }
  
  free(y);
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node*)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  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 inorder(Node *u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node *t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 21868
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	int A[3][110];
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> A[i][j];
		}
	}
	int dp[3][110];
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < N; ++j) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = A[0][0];
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < N; ++j) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A[i + 1][j]);
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + A[i][j + 1]);
		}
	}
	cout << dp[1][N - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, p;
    cin >> n >> p;

    ll flag = false;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a%2 == 1) {
            flag = true;
        }
    }

    ll x = 1;
    rep(i, n-1) {
        x *= 2;
    } 

    if(flag) {
        out(x);
    }
    else {
        if(p == 0) {
            out(2*x);
        }
        else {
            out(0);
        }
    }
    
    re0;
}

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

int main(void){

  int n, m; cin >> n >> m;
  vector<int> c(m);
  for(int i = 0; i < m; i++) cin >> c[i];

  int dp[22][50010];

  for(int i = 0; i <= n; i++) dp[0][i] = i;

  for(int i = 1; i < m; i++){
    for(int j = 0; j <= n; j++){
      if(j - c[i] >= 0){ 
	dp[i][j] = min(dp[i][j-c[i]] + 1, dp[i-1][j]);
      }else{
	dp[i][j] = dp[i-1][j];
      }
    }
  }

  cout << dp[m-1][n] << endl;
  return 0;
}

Measured memory_bytes: 7012
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
 
int main() {
  string s;
  cin >> s;
  int count = 0;
  for(char x : s){
    if(x == '1') count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
# frozen_string_literal: true

# Fenwick Tree
class FenwickTree
  def initialize(arg)
    case arg
    when Array
      @size = arg.size
      @data = Array.new(@size + 1, 0)
      arg.each.with_index(1) { |e, i| add(i, e) }
    when Integer
      @size = arg
      @data = Array.new(@size + 1, 0)
    else
      raise ArgumentError
    end
  end

  def add(i, x)
    while i <= @size
      @data[i] += x
      i += (i & -i)
    end
  end

  def sum(l, r)
    _sum(r) - _sum(l)
  end

  def _sum(i)
    res = 0
    while i > 0
      res += @data[i]
      i -= (i & -i)
    end
    res
  end
end

FeTree            = FenwickTree
BinaryIndexedTree = FenwickTree

n, q = gets.split.map { |e| e.to_i }
a    = gets.split.map { |e| e.to_i }
 
ft = FeTree.new(a)
 
q.times do
  t, u, v = gets.split.map { |e| e.to_i }
 
  if t == 0
    ft.add(u + 1, v)
  else
    puts ft.sum(u, v)
  end
end


Measured memory_bytes: 57332
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int N, M; cin >> N >> M;
    vector<int> s(M), c(M);
    rep(i,M) cin >> s[i] >> c[i];
    rep(i,M) --s[i];
    vector<int> num(N, -1);
    bool ok = true;
    rep(i,M) {
        if(num[s[i]] != -1 && num[s[i]] != c[i]) {
            ok = false;
            continue;
        }
        num[s[i]] = c[i];
    }
    if(N != 1 && num[0] == 0) ok = false;
    if(!ok) cout << -1 << endl;
    else {
        if(num[0] == -1) {
            if(N == 1) num[0] = 0;
            else num[0] = 1;
        }
        repi(i,1,N) if(num[i] == -1) num[i] = 0;
        int ans = 0;
        int p = 1;
        rrep(i,N) {
            ans += num[i] * p;
            p *= 10;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;
import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int k = in.nextInt();
        int ans = 0;
        if (k > a) {
            ans += a;
            k -= a;
        } else {
            ans += k;
            k = 0;
        }
        if (k > b) {
            k -= b;
        } else {
            k = 0;
        }
        if (k > c) {
            ans -= c;
            k -= c;
        } else {
            ans -= k;
            k = 0;
        }
        out.println(ans);
   }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 32784
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
int main()
{           
    IOS;
    vector<ll> v[5];
    for(ll i=0;i<3;i++)
    {
    	ll x,y;
    	cin>>x>>y;
    	v[x].push_back(y);
    	v[y].push_back(x);
    }
    ll two=0;
    ll one=0;
    for(ll i=1;i<=4;i++)
    {
    	if(v[i].size()==1)
    		one++;
    	if(v[i].size()==2)
    		two++;
    }
    if(one==two&&one==2)
    	cout<<"YES";
    else
    	cout<<"NO";
}   	

Measured memory_bytes: 256
x,k,d=list(map(int,input().split()))
x=abs(x)
if k*d<x:
    print(x-k*d)
else:
    if x-x//d*d>abs(x-(x//d+1)*d):
        base=x//d
        dist=x-(x//d)*d
    else:
        base=x//d+1
        dist=x-(x//d+1)*d
    if (k-base)%2==1:
        print(abs(abs(dist)-d))
    else:
        print(abs(dist))

Measured memory_bytes: 9200
s=list(input())
s.reverse()
MOD=10**9+7
dp = [[0 for _ in range(13)] for _ in range(len(s)+1)]
dp[0][0]=1
for i in range(len(s)):
    nd=s[i]
    p=pow(10,i,13)
    for mod in range(13):
        dp[i][mod] %=MOD
        for d in range(10):
            if nd != "?" and str(d)!=nd:
                continue
            nmod=(d*p + mod) % 13
            dp[i+1][nmod] += dp[i][mod]

print(dp[-1][5]%MOD)

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    int n, W;
    cin >> n >> W;

    vi w(n), v(n);
    REP(i, 0, n)
    {
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));
    REP(i, 1, n + 1)
    {
        REP(j, 0, W + 1)
        {
            if (j - w[i - 1] >= 0)
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        }
    }

    cout << *max_element(dp[n].begin(), dp[n].end());
    return 0;
}

Measured memory_bytes: 80256
require 'pp'
a = []
3.times do
  a << gets.split.map{|x| [x.to_i, false] }
end
n = gets.to_i
b = []
n.times do
  b << gets.to_i
end

b.each do |bb|
  3.times do |i|
    3.times do |ii|
      a[i][ii][1] = true if a[i][ii][0] == bb
    end
  end
end

c = Array.new(3) {Array.new(3, nil)}

3.times do |i|
  3.times do |ii|
    c[i][ii] = a[i][ii][1]
  end
end


if (c[0][0] && c[0][1] && c[0][2]) || \
   (c[1][0] && c[1][1] && c[1][2]) || \
   (c[2][0] && c[2][1] && c[2][2]) || \
   (c[0][0] && c[1][0] && c[2][0]) || \
   (c[0][1] && c[1][1] && c[2][1]) || \
   (c[0][2] && c[1][2] && c[2][2]) || \
   (c[0][0] && c[1][1] && c[2][2]) || \
   (c[0][2] && c[1][1] && c[2][0])
  puts 'Yes'
else
  puts 'No'
end

# Yes No Yes
#
#
#
#


Measured memory_bytes: 4092
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A[100][100];
ll B[100];
ll C[100];
ll N;
ll M;
ll X;
ll total[100]={};
ll cnt=0;

ll getAns(int index,ll learn[],ll ans){
    if(index<N){
        ll tmp1,tmp2;
        ll tmpl[M];
        rep(mi,M) tmpl[mi]=learn[mi];
        tmp1 = getAns(index+1,tmpl,ans);
        rep(mi,M) tmpl[mi]+=A[index][mi];
        ans += C[index];
        tmp2 = getAns(index+1,tmpl,ans);
        if(tmp1==-1){
            //cout << "m1" << endl;
            return tmp2;
        }else if(tmp2==-1){
            //cout << "m2" << endl;
            return tmp1;
        }else{
            return min(tmp1,tmp2);
        }

    }else{
        ll mintotal=X;
        rep(mi,M){
            mintotal = min(mintotal,learn[mi]);
            //cout << learn[mi] << " ";
        }
        //cout << endl;
        //cout << ans << endl;
        if(mintotal>=X){
            //cout << "bust" << endl;
            return ans;
        }else{
            return -1;
        }
    }


}

int main(){

    

    cin >> N;
    cin >> M;
    cin >> X;

    rep(ni,N){
        cin >> C[ni];
        rep(mi,M){
            cin >> A[ni][mi];
            total[mi]+=A[ni][mi];
        }
    }
    ll mintotal=X;
    rep(mi,M){
        if(total[mi]<mintotal) mintotal=total[mi];
    }
    if(mintotal>=X){
        //cout << "marl" << endl;
        ll ans = 0;
        ll learn[M]={};
        ans = getAns(0,learn,ans);
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3648
import kotlin.comparisons.compareValues

fun main(arg: Array<String>) {
    val (N, X) = listOfInt()
    var A = listOfLong().toLongArray()
    var ans = 0L
    for (n in 1 until N) {
        var s = (A[n - 1] + A[n]) - X
        if (s <= 0) continue
        if (A[n] >= s) {
            ans += s
            A[n] -= s
        } else {
            ans += s
            s -= A[n]
            A[n] = 0
            A[n - 1] -= s
        }
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 57052
#include <iostream>
#include <string>
#include <array>
#include <map>

using namespace std;

int main(void)
{
    int n;
    long int k;
    std::array<int, 200000> next_town;
    cin >> n >> k;

    for (int i = 0; i < n; i++)
    {
        int next;
        cin >> next;
        next_town[i] = next - 1;
    }

    int current_index = 0;
    
    std::map<int, int> arrive_time;
    bool dumped = false;
    for (long int i = 0; i < k; i++)
    {
        arrive_time[current_index] = i;
        current_index = next_town[current_index];

        if(!dumped && arrive_time.find(current_index) != arrive_time.end())
        {
            int roop_start = arrive_time[current_index];
            int roop_length = i - roop_start + 1;
            i = k - (k - roop_start) % roop_length - 1;
            dumped = true;
        }
    }
    cout << current_index + 1;
}

Measured memory_bytes: 11828
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    vector<int> ans;
    int p=n;
    while(1){
        if(p<=m){
            ans.PB(p);
            break;
        }
        int a=-1;
        for(int i=p-m;i<p;i++){
            if(s[i]=='0'){
                a=i;
                break;
            }
        }
        if(a!=-1){
            ans.PB(p-a);
            p=a;
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i]<<" ";
    }cout<<endl;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	long long h[N];
	for (int i = 0; i < N; i++) cin >> h[i];
	long long dp[N];
	const long long INF = 1000000000000;
	for (int i = 0; i < N; i++) dp[i] = INF;
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		if (i <= K) {
			for (int j = 0; j < i; j++) {
				long long x = dp[j] + llabs(h[i] - h[j]);
				if (x < dp[i]) {
					dp[i] = x;
				}
			}
		}
		else {
			for (int j = i - K; j < i; j++) {
				long long x = dp[j] + llabs(h[i] - h[j]);
				if (x < dp[i]) {
					dp[i] = x;
				}
			}
		}
	}
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done
	let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
end open MyInt64

let () =
	let n,x = get_2_i64 0 in
	let a = input_i64_array n
	in
	let a = Array.map (fun v -> labs (v - x)) a in
	Array.fold_left (fun u v ->
		gcd u v
	) a.(0) a
	|> printf "%Ld\n"

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
 
 int main(){
 	vector<int> v(3);
 	for (int i =0; i<3; i++){
 		cin >>v.at(i);
 	}
 	sort(v.begin(),v.end());
 	if (v.at(0)==v.at(1) and v.at(1)==v.at(2)){
 		cout <<"Yes"<<endl;
 	}
 	else{cout <<"No"<<endl;}
 }



Measured memory_bytes: 256
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

d1 = (a1-b1)*t1
d2 = (b2-a2)*t2

if d1 == d2:
    print('infinity')
 
if d1 * (d2 - d1) < 0:
    print(0)

if d1*(d2-d1)>0:
    if d1%(d1-d2)==0:
        print((d1//(d2-d1))*2)
    else:
        print((d1//(d2-d1))*2+1)

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

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


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int a, b, p, q, r;
    cin >> a >> b >> p >> q >> r;

    auto f = [&](double val){
        double e8 = 0;
        e8 += p * b;
        e8 -= (val - b) * r;
        double sq = (val - a) * q;
        return e8 >= sq;
    };

    double ok = b;
    double ng = 1e9;
    for(int i = 0; i < 100; ++i){
        double mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    vll coins;
    coins.push_back(1);
    ll n;
    cin>>n;
    ll num1=6;
    while (num1<=n){
        coins.push_back(num1);
        num1*=6;
    }
    ll num2=9;
    while (num2<=n){
        coins.push_back(num2);
        num2*=9;
    }
    vll dp(n+1,100000);
    dp[0]=0;
    for (int i=1;i<n+1;i++){
        for (int x:coins){
            if (i-x>=0){
                dp[i]=min(dp[i],dp[i-x]+1);
            }
        }
    }
    cout<<dp[n]<<endl;

    return 0;
}

Measured memory_bytes: 1024
d = int(input())
c = [0] + list(map(int, input().split()))

s = [0]
for i in range(d):
  s.append([0] + list(map(int, input().split())))
  
t = [0]
for i in range(d):
  t.append(int(input()))
  
sati = [0] * (d+1)
last = [0] * 27

for i in range(1, d+1):
  sati[i] = sati[i-1] + s[i][t[i]]
  unsati = 0
  last[t[i]] = i
  for j in range(1, 27):
    unsati += c[j] * (i - last[j])
  sati[i] -= unsati
  
for i in range(1, d+1):
  print(sati[i])

Measured memory_bytes: 9288
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {   
    string s;
    cin >> s;
    cout << count(s.begin(), s.end(), '1') << endl;
}




Measured memory_bytes: 3568
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**18
MIN = -MAX

def main():
  n, k = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  As.sort()

  Ans, Aps, Azs = [], [], []
  for A in As:
    if A > 0:
      Aps.append(A)
    elif A == 0:
      Azs.append(A)
    else:
      Ans.append(A)

  def count(xs, ys, ub):
    c = 0
    r = len(ys) - 1
    for l in range(len(xs)):
      while  r >= 0 and xs[l] * ys[r] > ub:
        r -= 1
      c += r+1
    return c 

  def bs(l, r):
    while True:
      mid = (l+r) // 2
      if r - l <= 1:
        return r
      
      tot = 0      
      tot += count(Aps, Aps, mid) - sum([1 for A in Aps if A**2 <= mid])
      tot += count(Ans[::-1], Ans[::-1], mid) - sum([1 for A in Ans if A**2 <= mid])
      tot //= 2

      if mid >=0:
        tot += (len(Aps) + len(Ans)) * len(Azs) + (len(Azs) * (len(Azs) - 1)) // 2
      tot += count(Aps[::-1], Ans, mid)
      
      if tot < k:
        l = mid
      else:
        r = mid
  
  print(bs(MIN-1, MAX+1))
    
    
if __name__=='__main__':
  main()



Measured memory_bytes: 139024