akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
	int n; cin >> n;
    vector<P> r(n);
    rep(i, n) {
        int x, l; cin >> x >> l;
        r[i] = make_pair(x + l, x - l);
    }
    sort(all(r));
    int ans = 0, t = -INF;
    rep(i, n) {
        if(t <= r[i].sc) {
            ans ++;
            t = r[i].fr;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 1024
//http://drken1215.hatenablog.com/entry/2019/02/03/224200
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
        
    long long res = 0;
    for (int d = 60; d >= -1; --d) { // d = -1 は X = K の場合//どこをdにするかを全探索
        if (d != -1 && !(K & (1LL<<d))) continue;//XとKのd桁目が一致
        
        long long tmp = 0;
        for (int e = 60; e >= 0; --e) {//各桁の排他的論理和を足し上げる
            long long mask = 1LL<<e;
            int num = 0;
            for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;//e桁目に立っているbitの本数を数えている
            
            if (e > d) {
                if (K & mask) tmp += mask * (N - num);//Kのe桁目が立っているなら、Xのe桁目も立てる　だからAで立っていない分が排他的論理和を取った後に残る
                else tmp += mask * num;//Kのe桁目が立っていないとき
            }
            else if (e == d) {//Xのe桁目は0
                tmp += mask * num;//Aで立っているe桁目のbitは全部排他的論理和を取った後もたっている
            }
            else {
                tmp += mask * max(num, N - num);//Xのe桁目を立てるか立てないかはmaxを取って決める
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr int INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

int h, w, a, b, c[1010][1010];


int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> h >> w >> a >> b;

  int cnt = 0, start = 0;
  REP(i,b) REP(j,a) c[i][j] = 1;
  rep(i,b,h) rep(j,a,w) c[i][j] = 1;


  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) cout << c[i][j];
    cout << '\n';
  }

  return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1;}
    return 0;
}
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout <<r * r << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>

using namespace std;
string expand(string str, int low, int high)
{
	int len = str.length();
	while (low >= 0 && high < len && (str[low] == str[high]))
		low--, high++;	
	return str.substr(low + 1, high - low - 1);
}

string LongestPalindromicSubstring(string str, int len)
{
	string max_str = "", curr_str;

	int max_length = 0, curr_length;

	for (int i = 0; i < len; i++)
	{
		
		curr_str = expand(str, i, i);
		curr_length = curr_str.length();

		if (curr_length > max_length)
		{
			max_length = curr_length;
			max_str = curr_str;
		}

		curr_str = expand(str, i, i + 1);
		curr_length = curr_str.length();

		if (curr_length > max_length)
		{
			max_length = curr_length;
			max_str = curr_str;
		}
	}

	return max_str;
}
void change(char *str)
{
    int i=1;
    int j=1;
    int k;
    int d=0;
 while(str[i]!='\0')
 {
     if(str[i-1]==str[i])
     {
         k=i+1;
        while(str[k]!='\0'&&str[k-1]==str[k])
         {
             k++;
         }
         i=k;
      }
    str[j]=str[i];
     j++;
     i++;
}
 str[j]='\0';
 cout<<strlen(str);
}
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int count=0;
    sort(a.begin(),a.end());
    for(int i=n-1;i>=0;i--){
        int l=0,r=i-1;
        while(l<r){
            if(a[l]+a[r]>a[i]){
                count+=(r-l);
                r--;
            }
            else{
                l++;
            }
        }
        
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  bool xdp[2][16050]={};
  bool ydp[2][16050]={};
  for(int i=0;i<2;i++)
    for(int j=0;j<16050;j++){
      xdp[i][j]=false;
      ydp[i][j]=false;
    }
  string s;cin>>s;
  int x,y;
  cin>>x>>y;
  ydp[0][8010]=true;
  vector<vector<int> >pii(2);
  int cnt=0;
  int popo=0;
  while(s[popo]=='F'){
    cnt++;
    popo++;
  }
  xdp[0][8010+cnt]=true;
  bool flag=true;
  cnt=0;
  int tcnt=0;
  for(int i=popo;i<s.size();){
    tcnt=0;
    cnt=0;
    while(s[i]=='T'&&i<s.size()){
      tcnt++;
      //  cout<<"!"<<endl;
      i++;
    }
    if(i==s.size())
      break;
    if(tcnt%2==0){
      if(flag){
	while(s[i]=='F'&&i<s.size()){
	  cnt++;
	  i++;
	}
	pii[0].pb(cnt);
      }else{
	while(s[i]=='F'&&i<s.size()){
	  cnt++;
	  i++;
	}
	pii[1].pb(cnt);
      }
    }else{
      if(flag){
	while(s[i]=='F'&&i<s.size()){
	  cnt++;
	  i++;
	}
	pii[1].pb(cnt);
	flag=false;
      }else{
	while(s[i]=='F'&&i<s.size()){
	  cnt++;
	  i++;
	}
	pii[0].pb(cnt);
	flag=true;
      }
    }
  }
  for(int i=0;i<pii[0].size();i++){
    for(int j=0;j<16050;j++){
      if(xdp[i%2][j]){
	//	cout<<j<<" ";
	xdp[(i+1)%2][j-pii[0][i]]=true;
	xdp[(i+1)%2][j+pii[0][i]]=true;
      }
      xdp[i%2][j]=false;
    }
  }
  //cout<<endl;
  for(int i=0;i<pii[1].size();i++){
    for(int j=0;j<16050;j++){
      if(ydp[i%2][j]){
	//cout<<j<<" ";
	ydp[(i+1)%2][j-pii[1][i]]=true;
	ydp[(i+1)%2][j+pii[1][i]]=true;
      }
      ydp[i%2][j]=false;
    }
  }
  cout<<endl;
  if((xdp[(pii[0].size())%2][x+8010]==true)&&(ydp[(pii[1].size())%2][y+8010]==true))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 512
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;
using System.Runtime.CompilerServices;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var b = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var t = long.Parse(Console.ReadLine());

            if (a[1] <= b[1]) Console.WriteLine("NO");
            else
            {

                Console.WriteLine(Math.Abs(a[0] - b[0]) <= t * Math.Abs(a[1] - b[1]) ? "YES" : "NO");

            }

        }

    }

}


Measured memory_bytes: 28256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int p=max(max(a,b),c);
  p*=3;
  int sum=a+b+c;
  int ans=0;
  while((p-sum)%2==1){
    p+=3;
  }
  cout << (p-sum)/2;
}
    

Measured memory_bytes: 3636
import sys

def main():
  input = sys.stdin.readline
  H, W = map(int, input().split())
  A = [str(input().strip()) for _ in range(H)]
  B = []
  for i in range(len(A)):
    if A[i] != '.'*W:
      B.append([str(c) for c in A[i]])

  C = [[0 for _ in range(len(B))] for _ in range(len(B[0]))]
  for i in range(len(B)):
    for j in range(len(B[0])):
      C[j][i] = B[i][j]
  
  D = []
  for i in range(len(C)):
    if ''.join(C[i]) != '.' * len(C[0]):
      D.append([str(c) for c in C[i]])
  
  E = [[0 for _ in range(len(D))] for _ in range(len(D[0]))]
  for i in range(len(D)):
    for j in range(len(D[0])):
      E[j][i] = D[i][j]

  for i in range(len(E)):
    print(''.join(E[i]))


if __name__ == '__main__':
  main()

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

void solve(long long N, std::vector<long long> d) {
  sort(d.begin(), d.end());
  if (d[N / 2] - d[N / 2 - 1] == 0) {
    cout << "0" << endl;
  } else {
    cout << d[N / 2] - d[N / 2 - 1] << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> d(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &d[i]);
  }
  solve(N, std::move(d));
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n;
char ch[10];

vector <int> v;

void ask(int st) {
	printf("? ");
	for (int i=st ; i<st+n ; i++) {
		printf("%d ", i);
	}
	printf("\n");
	fflush(stdout);
}

void ask2(int l, int r, int x) {
	printf("? %d ", x);
	for (int i=l ; i<=r ; i++) {
		printf("%d ", i);
	}
	printf("\n");
	fflush(stdout);
}

void ask3(int x) {
	printf("? %d ", x);
	for (int i=0 ; i<v.size() ; i++) {
		printf("%d ", v[i]);
	}
	printf("\n");
	fflush(stdout);
}

int main() {
	scanf("%d", &n);
	string sol = "";
	for (int i=0 ; i<=n*2 ; i++) {
		sol += "-";
	}
	string s;
	ask(1);
	scanf("%s", ch);
	s = ch;
	int l = 2;
	int r = n+1;
	string ans;
	int mid;
	while (l <= r) {
		mid = (l+r)/2;
		ask(mid);
		scanf("%s", ch);
		ans = ch;
		if (ans == s) {
			l = mid+1;
		} else {
			r = mid-1;
		}
	}
	if (ans != s) {
		mid--;
	}
	l = mid+1;
	r = mid+n-1;
	for (int i=1 ; i<=2*n ; i++) {
		if (i>=l and i<=r) continue;
		ask2(l, r, i);
		scanf("%s", ch);
		sol[i] = ch[0];
	}
	int red = (n-1) / 2;
	int blue = (n-1) / 2;
	for (int i=1 ; i<=n*2 ; i++) {
		if (sol[i] == 'R' and red) {
			red--;
			v.push_back(i);
		}
		if (sol[i] == 'B' and blue) {
			blue--;
			v.push_back(i);
		}
	}
	for (int i=1 ; i<=2*n ; i++) {
		if (sol[i] == '-') {
			ask3(i);
			scanf("%s", ch);
			sol[i] = ch[0];
		}
	}
	printf("! ");
	for (int i=1 ; i<=2*n ; i++) {
		printf("%c", sol[i]);
	}
	printf("\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 724
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
	string s;

	cin >> s;

	if (s == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;

	return 0;
}


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

int fr[26];
char s[101];

void no() { printf("No\n"), exit(0); }

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 0, n){
		scanf("%s", s);
		f(j, 0, m)++fr[s[j] - 'a'];
	}
	int z = 0, b = 0;
	f(i, 0, 26){
		fr[i] &= 3;
		if (fr[i] == 0)continue;
		if (fr[i] == 1)++b;
		else if (fr[i] == 2)++z;
		else ++b, ++z;
	}
	int od = (n & 1) + (m & 1);
	if (od == 0 && (z || b))no();
	else if (od == 1){
		if (n & 1 && (z > m >> 1 || b))no();
		else if (m & 1 && (z > n >> 1 || b))no();
	}
	else if (od == 2 && (b != 1 || z > (n >> 1) + (m >> 1)))no();
	printf("Yes\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  ll cnt = 100;
  while (1) {
    if (cnt >= x) {
      break;
    } else {
      cnt += cnt / 100;
      ans++;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 2000000009
int a[50],n;
ll ans=0,cur=1;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		if (a[i]%2) cur*=1;
		else cur*=2;
	}
	ans=pow(3,n)-cur;
	cout<<ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

// http://noshi91.hatenablog.com/entry/2019/03/31/174006
template <uint_fast64_t Mod>
struct modint {
  using u64 = uint_fast64_t;

  u64 n;

  modint(const u64 x = 0) : n(x % Mod) {}
  modint operator+(const modint r) const { return modint(*this) += r; }
  modint operator-(const modint r) const { return modint(*this) -= r; }
  modint operator*(const modint r) const { return modint(*this) *= r; }
  modint operator/(const modint r) const { return modint(*this) /= r; }
  modint &operator+=(const modint r) {
    n += r.n;
    if (n >= Mod) n -= Mod;
    return *this;
  }
  modint &operator-=(const modint r) {
    if (n < r.n) n += Mod;
    n -= r.n;
    return *this;
  }
  modint &operator*=(const modint r) {
    n = n * r.n % Mod;
    return *this;
  }
  modint &operator/=(modint r) {
    n = n * inv();
    return *this;
  }
  modint pow(u64 x) const {
    modint<Mod> ret(1), tmp(*this);
    while (x) {
      if (x&1) ret *= tmp;
      tmp *= tmp;
      x >>= 1;
    }
    return ret;
  }
  modint inv() const {
    return pow(Mod-2);
  }
};

// T modint
template<class T>
struct Combination {
  vector<T> fact, inv_fact;
  Combination(ll n) : fact(n+1), inv_fact(n+1) {
    fact[0] = T(1);
    for (ll i = 1; i <= n; i++) fact[i] = fact[i-1] * static_cast<T>(i);
    inv_fact[n] = fact[n].inv();
    for (ll i = n; i > 0; i--) inv_fact[i-1] = inv_fact[i] * static_cast<T>(i);
  }

  T P(ll n, ll k) const {
    return fact[n] * inv_fact[n-k];
  }

  T C(ll n, ll k) const {
    if (n-k < 0) return T(0);
    return fact[n] * inv_fact[n-k] * inv_fact[k];
  }

  T H(ll n, ll k) const {
    return C(n+k-1, n-1);
  }
};

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

  constexpr ll mod = 1e9+7;
  using mint = modint<mod>;
  mint n, k;
  cin >> n.n >> k.n;
  Combination<mint> c(10000);
  ll x = n.n-k.n;
  for (ll i = 1; i <= k.n; i++) {
    auto a = c.C(k.n-1, i-1);
    auto b = c.C(x+1, i);
    //cout << a.n << " " << b.n << endl;
    cout << (a*b).n << endl;
  }
}



Measured memory_bytes: 384
/*
    Problem 91
    https://atcoder.jp/contests/abc144/tasks/abc144_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double y = 2 * x / (a * b * b);
    double z = (a * a * a) / (2 * (a * a * b - x));
    if (a * a * b / 2 >= x)
        cout << fixed << setprecision(9) << 90 - atan(y) * 180 / pi << '\n';
    else
        cout << fixed << setprecision(9) << 90 - atan(z) * 180 / pi << '\n';
}

Measured memory_bytes: 4088
use std::io;

fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut s = read_one::<String>().chars().collect::<Vec<_>>();
    s.reverse();
    let mut path = Vec::new();
    let mut idx = 0;
    while idx < n {
        if (1..m + 1).all(|i| s[idx + i] == '1') { println!("-1"); return; }
        for i in (0..m + 1).rev() {
            if idx + i > n { continue; }
            if s[idx + i] == '0' { idx += i; path.push(i); break; }
        }
    }
    path.reverse();
    for i in 0..path.len() {
        if i == path.len() - 1 { println!("{}", path[i]); }
        else { print!("{} ", path[i]); }
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4476
x = int(input())
if x == 1:
    print(1)
else:
    lst = []
    for i in range(2,6):
        for j in range(2,10):
            num = i**j
            if num <= x:
                lst.append(num)

    for i in range(6,33):
        for j in range(2,4):
            num = i**j
            if num <= x:
                lst.append(num)
    lst.sort()
    ans = lst[-1]
    print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 42;
vector<int> g[N];
bool used[N];
int cur = 0, ans = 0;
void dfs(int v) {
  used[v] = true;
  cur++;
  ans = max(ans, cur);
  for(auto& x : g[v])
    if(!used[x]) dfs(x);
}
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int n = 0, m = 0;

  cin >> n >> m;

  for(int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].pb(v);
    g[v].pb(u);
  }

  for(int i = 0; i < n; i++)
    if(!used[i]) {
      cur = 0;
      dfs(i);
    }

  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 21024
n,m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]

box = [1]*(n+1)
red = [0]*(n+1)
red[1] = 1
for x,y in xy:
    box[x] -= 1
    box[y] += 1
    if red[x] == 1: red[y] = 1
    if box[x] == 0: red[x] = 0
print(red.count(1))

Measured memory_bytes: 28800
import java.util.Scanner;

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

	private void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		int last_color = -1;
		for (int i = 0; i < N; i++) {
			int color = sc.nextInt();
			if (color == last_color) {
				count++;
				last_color = -1;
			} else
				last_color = color;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22868
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int n;
	cin >> n;

	int y;
	y = 1;
	int ans = 1;


	for (int i = 0; i < 12; i++) {
		y = y * 2;
		if (y <= n) {
			ans = y;
		}
		
	}

	cout << ans << endl;





	return 0;
}


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

int main () {
  int D, G;
  cin >> D >> G;
  G /= 100;
  vector<int> p(D), c(D);
  rep(i,D) {
    cin >> p[i] >> c[i];
    c[i] /= 100;
  }

  int ans = 1000;

  for(int i = 0; i < (1<<D); i++) {
    int s = 0;
    int cnt = 0;
    int l = 0;
    for(int j = 0; j < D; j++) {
      if((i >> j) & 1) {
        s += (j+1)*p[j] + c[j];
        cnt += p[j];
      } else {
        l = j;
      }
    }
    if(s < G) {
      int k = (G - s + (l+1) - 1) / (l+1);
      if(k >= p[l]) continue;
      s += k * (l+1);
      cnt += k;
    }

    ans = min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int k , s;
  scanf("%d %d",&k,&s);
  
  int count=0;
  
  for(int i = 0;i <= k;i ++){
    for(int j = 0;j <= k; j ++){
      if(s-i-j>=0&&s-i-j<=k){
           count ++;
        }}}
  
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 128
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    if(n<m){
        for(int i=1;i<=m;++i)
            cout<<n;
    }
    else{
        for(int i=1;i<=n;++i)
            cout<<m;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int n;

int main(int argc, const char * argv[]) {
    
    /////////
    //write//
    /////////
    
    cin >> n;
    int arr[100][100];
    for(int i=0; i<100; i++){
        for(int j=0; j<100; j++){
            arr[i][j] = 0;
        }
    }
    
    for(int i=0; i<n; i++){
        int node, degree; cin >> node >> degree;
        for(int j=0; j<degree; j++){
            int tmp; cin >> tmp;
            arr[node-1][tmp-1] = 1;
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j)cout << " ";
            cout << arr[i][j];
        }
        cout << endl;
    }
    
    return 0;
}



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll gcd(ll a, ll b) {
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

int main() {
    ll A, B;
    cin >> A >> B;

    ll T = gcd(A, B);
    cout << A / T * B << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
  {int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==5&&b==5&&c==7)
  {
      printf("YES\n");
  }
  else if(a==5&&b==7&&c==5)
  {
      printf("YES\n");
  }
   else if(a==7&&b==5&&c==5)
  {
      printf("YES\n");
  }
  else
     printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h,w;
  cin >> n >> h >> w;
  int ans = (n-h+1)*(n-w+1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
  cout << "Yes\n";
  int n,m; cin >> n >> m;

  Graph G(n);
  for (int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  vector<int> dist(n, -2);
  queue<int> que;
  dist[0] = 0;
  que.push(0);

  while (!que.empty()) {
    int v = que.front();
    que.pop();
    // cout << "checking" << v << endl;

    for (int nv : G[v]) {
      // cout << nv << endl;
      if (dist[nv] != -2) continue;
      dist[nv] = v;
      que.push(nv);
    }
  }
  for (int i = 1; i < n; i++) {
    cout << dist[i] + 1 << endl;
  }
}


Measured memory_bytes: 10192
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;



int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    if (n == m){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


    

    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int a;
ll b,ans=0;
ll arr[55];
ll brr[55];
void f(int c){
    if(b==brr[c]){
        ans += arr[c];
        return ;
    }
    else if(b){
        b--;
        if(b>brr[c-1]){
            b -= brr[c-1];
            ans += arr[c-1];
            b--;
            ans++;
            if(b)f(c-1);
        }
        else
            f(c-1);
    }

}

int main()
{
    arr[0]=1;//汉堡中肉饼的层数
    brr[0]=1;//汉堡中肉饼加面包的层数
    for(int i = 1;i < 51;i++){
        arr[i]=2*arr[i-1]+1;
        brr[i]=2*brr[i-1]+3;
    }
    scanf("%d %lld",&a,&b);
    f(a);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
using System;

namespace Atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);

                if (k % 2 != 0)
                {
                    int x = k;
                    int b = 0;
                    while (x <= n)
                    {
                        b++;
                        x += k;
                    }
                    Console.WriteLine((long)b * b * b);
                }
                else
                {
                    int x = k / 2;
                    int b = 0;
                    int sp = 0;
                    bool isbaisuu = false;
                    while (x <= n)
                    {
                        if (isbaisuu)
                        {
                            b++;
                            isbaisuu = false;
                        }
                        else
                        {
                            sp++;
                            isbaisuu = true;
                        }
                    x += (k / 2);
                    }
                    Console.WriteLine((long)b * b * b + (long)sp * sp * sp);
                }
            }
        }

}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long

int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0;}
#define fr(n) for(int i=1;i<=n;i++)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define M 100005
//////////////////////////////////////////


int main() {

    int n=Int,y=Int;
    ll p= 10000, q=5000,r=1000;
    for(int i=0; i<=y/p; i++) {

        for(int k=0; k<=y/q; k++) {

                ll ans=(p*i)+(q*k);
                ll d=y-ans;
                if(d<0 || d%r!=0) continue;
                if(i+(d/r)+k==n) {
                    // cout<<ans<<"\n";
                    printf("%d %d %d\n",i,k,d/r);
                    done;
                }
                // if(i+j+k>n || ans>n) break;

        }
        if(i>n) break;
    }
    printf("-1 -1 -1\n");
    done;
}




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

int main () {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> height(N);
  for (int i = 0; i < N; i++) cin >> height.at(i);
  
  int ans = 0;
  vector <int> dt(N);
  for (int i = 0; i < N; i++) {
    int temp = 1000*T-height.at(i)*6;
    if (1000*A > temp) dt.at(i) = 1000*A - temp;
    else  dt.at(i) = temp - 1000 * A;
    }
  int min = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      ans = 1;
      min = dt.at(0);
    }
    if (min > dt.at(i)) {
      ans = i+1;
      min = dt.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
char a[1005];
int b[1005];
int main()
{
	int n,m;
	int x,y; 
	cin>>n>>m>>x>>y;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int j=0;j<m;j++)
		scanf("%d",&b[j]);
	sort(a,a+n);
	sort(b,b+m);
	if(a[n-1]>=b[0]||a[n-1]>=y||b[0]<=x)
	{
		cout<<"War"<<endl;
		return 0;
	}
	cout<<"No War"<<endl;
	return 0;
	
} 

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

int main() {
    int n;
    cin >> n;
    int cnt = 0;

    vector<char> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        if(i == 0 || a[i - 1] != a[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

int main()
{
  int H, W;
  cin>>H>>W;
  vector<string> A(H);
  for(int i=0; i<H; i++)
    cin>>A[i];

  vector<string> Ans(H+2);
  for(int i=0; i<H+2; i++){
    if(i==0||i==H+1)
      Ans[i] += string(W+2, '#');
    else{
      Ans[i] += '#';
      Ans[i] += A[i-1];
      Ans[i] += '#';
    }
  }

  for(int i=0; i<H+2; i++)
    cout<<Ans[i]<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict
from itertools import combinations


def main():
    N = int(input())
    S = [input() for _ in range(N)]

    name = defaultdict(int)
    march = ['M', 'A', 'R', 'C', 'H']

    for s in S:
        if s[0] in march:
            name[s[0]] += 1

    ans = 0
    for c in combinations(march, 3):
        tmp = 1
        for cc in c:
            tmp *= name[cc]
        ans += tmp

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10112
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=200005;
int n,k;
ll a[maxn],b[maxn];
ll ans;

void solve(int l,int r){
	if(l==r)return;
	
	int mid=(l+r)>>1;
	solve(l,mid);
	solve(mid+1,r);
	
	int k1=l,k2=mid+1,cur=l;
	while(cur<=r){
		if(k1<=mid&&a[k1]<=a[k2]||(k1<=mid&&k2==r+1))
		b[cur++]=a[k1++];
		else b[cur++]=a[k2++],ans+=(ll)mid-(ll)k1+1; 
	}	
	for(int i=l;i<=r;i++)a[i]=b[i];
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
		a[i]-=k;
		if(i)a[i]+=a[i-1];
		if(a[i]<0)ans++;
	}
	solve(0,n-1);
	cout<<(ll)n*(ll)(n+1)/2-ans;
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

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

		int[][] c = new int[3][3];

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				c[i][j] = sc.nextInt();
			}
		}

		String msg = "Yes";
		for (int i = 1; i < 3; i++) {
			int a = c[0][1] - c[0][0];
			if (c[i][1] - c[i][0] != a) {
				msg = "No";
				break;
			}
			a = c[0][2] - c[0][1];
			if (c[i][2] - c[i][1] != a) {
				msg = "No";
				break;
			}
			a = c[1][0] - c[0][0];
			if (c[1][i] - c[0][i] != a) {
				msg = "No";
				break;
			}
			a = c[2][0] - c[1][0];
			if (c[2][i] - c[1][i] != a) {
				msg = "No";
				break;
			}
		}

		System.out.println(msg);
		sc.close();
	}
}

Measured memory_bytes: 21844
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

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

int cnt[1001000];

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    rep(i, 1001000) cnt[i] = 0;
    int g = 0;
    rep(i, n) {
        cin >> a[i];
        g = gcd(g, a[i]);
        cnt[a[i]] ++;
    }
    bool ok = 1;
    for(int x = 2; x <= 1000000; ++ x) {
        int co = 0;
        for(int y = x; y <= 1000000; y += x) {
            co += cnt[y];
        }
        if(co > 1) ok = 0;
    }
    if(ok) {
        cout << "pairwise coprime" << endl;
    } else if(g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 18700
#include <bits/stdc++.h>
/*
	Karya anak bangsa yang paling agung
	Author : Yohandi or... bukan..
*/

#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define endl "\n"

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a)
#define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d)
#define res(a,x,y) for(int a=(int)x;a>=(int)y;--a)
#define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d)

// Ordered Set, Ordered Multiset
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
// .order_of_key(x) -> Number of elements less than x
// * .find_by_order(k) -> Kth smallest element (0-based)
// .erase(x) -> Remove all elements equal to x

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using lint=long long;

mt19937 rng(time(NULL));

lint Power(lint A,lint B,lint C){
	if(!B) return 1LL;
	lint tmp=Power(A,B>>1,C);
	return tmp*tmp%C*(B&1?A:1)%C;
}

int T;

int main(){
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
	T=1;
//	cin>>T;
	rep(t,1,T){
        for(int i=1;i<=5;++i){
            int X;
            cin>>X;
            if(X==0){
                cout<<i<<endl;
                return 0;
            }
        }
	}
	return 0;
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ppb pop_back
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	long long biscuit=1,yen=0;
	for (int i=1;i<=a;i++)
	{
		if ((biscuit<b && yen==0) || (i==a && yen==0)) biscuit++;
		else {
			if (c-b>=2) {
				if (yen==1) {
					biscuit+=c;
					yen--;
				}
				else if (i<a) {
					biscuit-=b;
					yen++;
				}
			}
			else biscuit++;
		}
	}
	cout<<biscuit;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
int h,w;
int sum[105][105];
int state[105][105];
int state1[105][105];
char board[105][105];
bool check(int i, int j) {
	return (i >= 0) && (i < h) && (j >= 0) && (j < w);
}
int dx[]={1,0};
int dy[]={0,1};

int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>board[i][j];
            if(board[i][j]=='.'){
                state[i][j]=0;
                state1[i][j]=0;
            }
            else {
                state[i][j]=1;
                state1[i][j]=1;
            }
            sum[i][j]=10000;
        }
    }
    int state_begin = 0;
    if(board[0][0]=='#')state_begin=1;
    sum[0][0]=1;
    queue<P>que;
    que.push(P(0,0));
    while(!que.empty()){
        P p =que.front();
        que.pop();
        int nowx = p.first;
        int nowy = p.second;
        int s_now = state[nowx][nowy];
        for(int i=0;i<2;i++){
            int nextx = nowx+dx[i];
            int nexty = nowy+dy[i];
            if(check(nextx,nexty)){
                int s_next = 0;
                if(board[nextx][nexty]=='#')s_next=1;
                if(s_now == s_next){
                    if(sum[nextx][nexty]>sum[nowx][nowy]){
                        sum[nextx][nexty]=sum[nowx][nowy];
                        state1[nextx][nexty]=s_next;
                        que.push(P(nextx,nexty));
                    }
                }
                else
                {
                    if(sum[nextx][nexty]>sum[nowx][nowy]+1){
                        sum[nextx][nexty]=sum[nowx][nowy]+1;
                        state1[nextx][nexty]=s_next;
                        que.push(P(nextx,nexty));
                    }
                }
                
            }
        }
    }
    
    if(state_begin == 0){
        if(sum[h-1][w-1]==1)cout<<0<<endl;
        else{
            if(sum[h-1][w-1]%2==0)cout<<sum[h-1][w-1]/2<<endl;
            else cout<<sum[h-1][w-1]/2<<endl;
        }
    }
    else{
        if(sum[h-1][w-1]==1)cout<<1<<endl;
        else{
            if(sum[h-1][w-1]%2==0)cout<<sum[h-1][w-1]/2<<endl;
            else cout<<sum[h-1][w-1]/2+1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
package main
 
import (
	"fmt"
    "math"
    "sort"
)

func main() {

  var list []float64
  for i := 0 ; i< 3; i++ {
    var a float64
    fmt.Scan(&a)
    list = append(list,a)
  }
  sort.Float64s(list)
  
  
  fmt.Printf("%g",math.Abs(list[2]-list[1])+math.Abs(list[1]-list[0]))
}

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

using namespace std;

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

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

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

std::string S;

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

    std::cin >> S;

    int sum = 0;
    ll res = 0;
    for(auto &c : S){
        if(c == 'W'){
            res += sum;
        }else{
            sum += 1;
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 720
#include <stdio.h>
#include<math.h>
int main(void){
   double x1,x2,y1,y2, a;
   scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
   a=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
   a=sqrt(a);
   printf("%f", a);
   return 0;
}




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

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

    int N, K, h;
    cin >> N >> K;
    int res = 0;
    for(int i = 0; i < N; ++i){
        cin >> h;

        if(h >= K) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
# include <iostream>


using namespace std;


int main() {
    int h, w, n; cin >> h >> w >> n;
    double ret = (double)n / max(h, w);

    if (ret == (int)ret) {
        cout << ret << endl;
    }
    else {
        cout << (int)(ret+1.0) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<P> v(N);
    rep(i, N) {
        ll x, y;
        cin >> x >> y;
        v[i] = make_pair(x, y);
    }
    sort(all(v));
    vector<P> diff;
    rep(i, N) {
        rep(j, N) {
            if (i == j)continue;
            diff.push_back(make_pair(v[i].first - v[j].first, v[i].second - v[j].second));
        }
    }
    //print(diff.size());
    map<P, ll> m;
    rep(i, diff.size()) {
        //print(diff[i].first << " * " << diff[i].second);
        m[diff[i]]++;
    }
    ll ma = 0;
    for(pair<P, ll> p : m) {
        ma = max(p.second, ma);
    }
    print(N - ma);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    int w, n;
    int d[31];
    char s[30];
    while(~scanf("%d %d", &w, &n)){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            scanf("%s", s);
            int a, b;
            sscanf(s, "%d,%d", &a, &b);
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

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

int mypartition(vector<int> &A, int p, int r) {
  int x = A[r], i = p - 1, tmp;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      tmp = A[j];
      A[j] = A[i];
      A[i] = tmp;
    }
  }

  tmp = A[++i];
  A[i] = A[r];
  A[r] = tmp;

  return i;
}
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (size_t i = 0; i < n; i++) {
    cin >> A.at(i);
  }

  int idx = mypartition(A, 0, n - 1);
  for (size_t i = 0; i < n; i++) {
    if (i == idx) {
      cout << '[' << A[i] << "] ";
    } else if (i == n - 1) {
      cout << A[i] << endl;
    } else {
      cout << A[i] << ' ';
    }
  }
}


Measured memory_bytes: 3136
def is_integer_string?(str)
  Integer(str)
  true
rescue ArgumentError
  false
end

array = gets.split(' ').map do |i|
  if is_integer_string? i
    i.to_i
  else
    i
  end
end
stack = []
array.each do |value|
  if value.is_a?(String)
    pops = [stack.pop, stack.pop]
    eval("stack << #{pops[1]} #{value} #{pops[0]}")
    next
  end
  stack << value
end

puts stack



Measured memory_bytes: 8948