akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli N;

double dp[310][310][310];

double rec(int i,int j,int k){
	if(dp[i][j][k]>=0)return dp[i][j][k];
	if(i==0 && j==0 && k==0)return 0.0;

	double res = 0.0;
	if(i>0)res += rec(i-1,j,k) * i;
	if(j>0)res += rec(i+1,j-1,k) * j;
	if(k>0)res += rec(i,j+1,k-1) * k;
	res += N;
	res *= 1.0/(i+j+k);

	return dp[i][j][k] = res;

}

signed main(){

	cin>>N;
	vector<lli> a(N);
	lli d[3]={0};
	REP(i,0,N){
		cin>>a[i];
		a[i]--;
		d[a[i]]++;
	}

	memset(dp,-1,sizeof(dp));

	cout<<fixed<<setprecision(10)<<rec(d[0],d[1],d[2])<<endl;

	return 0;
}

Measured memory_bytes: 233088
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int H[6][6] = {
	{1,5,2,3,0,4}, // North : 奥へ移動   ( y:-1 )
	{3,1,0,5,4,2}, // East  : 右へ移動   ( x:+1 )
	{2,1,5,0,4,3}, // West  : 左へ移動   ( x:-1 )
	{4,0,2,3,5,1}, // South : 手前へ移動 ( y:+1 )
	{0,2,4,1,3,5}, // Right : 右回りに回転 (移動なし)
	{0,3,1,4,2,5}  // Left  : 左回りに回転 (移動なし)
};

// サイコロライブラリ
// d[0] := top,   d[1] := front 
// d[2] := right, d[3] := left
// d[4] := back,  d[5] := bottom
enum{TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};
struct Cube{
	vector<string> d;
	// コンストラクタで初期化
	Cube(vector<string> v){
		if( v.size() == 6 ){
			d = v;
		}else{
			d = vector<string>(6);
		}
	}
	Cube(){ d = vector<string>(6); }
	// dirの方向に回転 (副作用なし)
	Cube roll(int dir){
		Cube result = (*this);
		vector<string> d_(6);
		for(int i = 0 ; i < 6 ; i++ ){
			d_[i] = d[ H[dir][i] ];
		}
		result.d = d_;
		return result;
	}
	void debug(){
		for(int i=0 ; i < 6 ; i++ ){
			cout << (*this).d[i] << " ";
		}
		cout << endl;
	}
	bool operator==(const Cube& c){
		for(int i=0 ; i < 6 ; i++ ){
			if( c.d[i] != (*this).d[i] )
				return false;
		}
		return true;
	}
	bool is_same(Cube c){
		Cube c_[24];
		c_[0] = c;
		c_[1] = c.roll(0);
		c_[2] = c.roll(1);
		c_[3] = c.roll(2);
		c_[4] = c.roll(3);
		c_[5] = (c.roll(0)).roll(0);
		
		for(int i=6 ; i < 12 ; i++ ){
			c_[i] = c_[i-6].roll(4);
		}
		for(int i=12 ; i < 18 ; i++ ){
			c_[i] = c_[i-6].roll(4);
		}
		for(int i=18 ; i < 24 ; i++ ){
			c_[i] = c_[i-6].roll(4);
		}
		
		for(int i=0 ; i < 24 ; i++ ){
			if( c_[i] == (*this) )
				return true;
		}
		return false;
	}
};

int main(){
	int n;
	while( cin >> n , n ){
		vector<Cube> v;
		 
		for(int i=0 ; i < n ; i++ ){
			Cube c;
			for(int j=0 ; j < 6 ; j++ ){
				string s;
				cin >> s;
				c.d[j] = s;
			}
			bool flag = true;
			for(int j=0 ; j < v.size() ; j++ ){
				if( c.is_same( v[j] ) ) flag = false;
			}
			
			if( flag ){
				v.push_back( c );
			}
		}
		cout << (n - v.size()) << endl;
	}
}

Measured memory_bytes: 940
A,B,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
min = 100000000
x = []
y = []
c = []
m.times do |i|
    x[i],y[i],c[i] = gets.split.map(&:to_i)
    if min >= a[x[i]-1]+b[y[i]-1]-c[i]
        min = a[x[i]-1]+b[y[i]-1]-c[i]
    end
end
if a.min+b.min < min
  min = a.min+b.min
end
puts min


Measured memory_bytes: 21524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1e9+7;
 
int main(){
    int n;cin>>n;
    int a[n];rep(i,n)cin>>a[i];
    vector<int> b(n);rep(i,n)b[i]=a[i];
    sort(all(b));
    rep(i,n){
        int zipa=lower_bound(all(b),a[i])-b.begin();
        a[i]=zipa;
    }
    vector<int> odd,even;
    rep(i,n){
        if(i%2)odd.push_back(a[i]);
        else even.push_back(a[i]);
    }
    int ans=0;
    rep(i,even.size()){
      if(even[i]%2)++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1660
x,n=list(map(int,input().split()))
if n:
  A=list(map(int,input().split()))
else:
  print(x)
  exit()
  
for i in range(n+1):
  if x-i in A and x+i in A:
    continue
  elif x+i in A or (not x-i in A and not x+i in A):
    print(x-i)
    break
  else:
    print(x+i)
    break

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

using Graph = vector<vector<ll>>;

void dfs(ll now, ll par, ll d, Graph &G, vector<ll> &dist){
	dist[now] = d;
	for(auto next: G[now]){
		if(next == par) continue;
		dfs(next, now, d+1, G, dist);
	}
	return;
}

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

    ll N;
    cin >> N;
    Graph G(N);

    REP(i, N-1){
    	ll x, y;
    	cin >> x >> y;
    	x--, y--;
    	G[x].push_back(y);
    	G[y].push_back(x);
    }

    vector<ll> dist1(N, 0), dist2(N, 0);
    dfs(0, -1, 0, G, dist1);
    dfs(N-1, -1, 0, G, dist2);

    ll fen = 0;
    REP(i, N){
    	if(dist1[i]<=dist2[i]) fen++;
    }
    /*
    cout << dist1 << endl;
    cout << dist2 << endl;
    dump(fen)
    */
    cout << (fen >= N/2+1 ? "Fennec" : "Snuke") << endl;
    return 0;
}

Measured memory_bytes: 15104
/*=======Kaihatsu========*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int h[n];
    int dis[n];
    for(int i=0;i<n;++i)
    {
        cin>>h[i];
    }
    dis[0]=0;
    dis[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;++i)
    {
        dis[i]=min(dis[i-1]+abs(h[i]-h[i-1]),dis[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dis[n-1];
    return 0;
}

Measured memory_bytes: 1024
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma gcc target ("avx2")
#pragma gcc optimization ("Ofast")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	ll n, m, k;
	scanf("%lld%lld%lld", &n, &m, &k);
	vector<ll> a(n), b(m), c(n + 1), d(m + 1);
	rep(i, n)scanf("%lld", &a[i]);
	rep(i, m)scanf("%lld", &b[i]);
	rep(i, n)c[i + 1] = c[i] + a[i];
	rep(i, m)d[i + 1] = d[i] + b[i];
	ll ans = 0;
	rep(i, n + 1) {
		ll x = k - c[i];
		int l = -1, r = m + 1;
		while (abs(r - l) > 1) {
			int mid = (l + r) / 2;
			if (d[mid] <= x)l = mid;
			else r = mid;
		}
		if(x >= 0)ans = max<ll>(ans, i + l);
	}
	printf("%lld\n", ans);

	Please AC;
}

Measured memory_bytes: 9648
long long a,b,c,z,strtoll();i,j;main(m,p){for(;i=scanf("%d%s",&m,p),m;printf("%lld\n",z))for(z=9e18,a=strtoll(p,0,m);m>1;++i)if(m%i<1){for(c=j=0;m%i<1;++j)m/=i;for(b=a;b;)c+=b/=i;z>c/j?z=c/j:0;}}

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

using namespace std;

class Dice{
private:
  int D1;
  int D2;
  int D3;
  int D4;
  int D5;
  int D6;

public:
  Dice()
  {
  D1=1;
  D2=2;
  D3=3;
  D4=4;
  D5=5;
  D6=6;
  }
  Dice(int d1,int d2,int d3,int d4,int d5,int d6){
  D1=d1;
  D2=d2;
  D2=d2;
  D3=d3;
  D4=d4;
  D5=d5;
  D6=d6;
  }

  void roll(char dire){
  int dd1=D1;
  int dd2=D2;
  int dd3=D3;
  int dd4=D4;
  int dd5=D5;
  int dd6=D6;
  
  if(dire=='E')
    {
    D1=dd4;
    D3=dd1;
    D4=dd6;
    D6=dd3;
    }
  if(dire=='N')
  {
    D1=dd2;
    D2=dd6;
    D5=dd1;
    D6=dd5;
  }
  if(dire=='S')
  {
    D1=dd5;
    D5=dd6;
    D6=dd2;
    D2=dd1;
  }
  if(dire=='W')
  {
    D1=dd3;
    D3=dd6;
    D6=dd4;
    D4=dd1;
  }
  
  }
  
  int ue(){
  return D1;
  }
  
  int light(int up,int mae){
    int i;
    int j;
    int k;
    int l;
      for(i=0;i<4;i++)
      {
      roll('E');
     for(j=0;j<4;j++)
     {
      roll('S');
     for(k=0;k<4;k++)
     {
        roll('E');
        for(l=0;l<4;l++)
        {
        roll('S');
          if(up==D1 && mae==D2)
          return D3;
        }
     }
     }
    }
  }
  
  
  int check1(){
    return D1;
  }
  int check2(){
    return D2;
  }
  int check3(){
    return D3;
  }
  int check4(){
    return D4;
  }
  int check5(){
    return D5;
  }
  int check6(){
    return D6;
  }

 void in(int d1,int d2,int d3,int d4,int d5,int d6){
  D1=d1;
  D2=d2;
  D2=d2;
  D3=d3;
  D4=d4;
  D5=d5;
  D6=d6;
  }
};

int main()
{
  int di[100][6]={};
  int i;
  int j;
  int k;
  int l;
  int n;
  int a;
  int b;
  int ch=0;
  
  cin >> n;
  
  for(i=0;i<n;i++)
    {
      for(j=0;j<6;j++)
        cin >> di[i][j];
    }
    
    
    
    Dice dice[n];
    
  for(i=0;i<n;i++)
  {
     //Dice dice[i](di[i][0],di[i][1],di[i][2],di[i][3],di[i][4],di[i][5]);
     dice[i].in(di[i][0],di[i][1],di[i][2],di[i][3],di[i][4],di[i][5]);
  }
  
  
  for(a=0;a<n;a++)
  {
  for(b=a+1;b<n;b++)
  {
  for(i=0;i<4;i++)
  {
    dice[a].roll('E');
    for(j=0;j<4;j++)
    {
      dice[a].roll('S');
      
      for(k=0;k<4;k++)
      {
         dice[a].roll('E');
         for(l=0;l<4;l++)
         {
          dice[a].roll('S');
          if(dice[a].check1()==dice[b].check1() &&dice[a].check2()==dice[b].check2() &&dice[a].check3()==dice[b].check3()&&dice[a].check4()==dice[b].check4()&&dice[a].check5()==dice[b].check5() &&dice[a].check6()==dice[b].check6() )
              {
                
                goto Exit;
              }
         }
         
      }
    }
  }
  }
  }


    cout <<"Yes\n";
    return 0;
Exit:;
    cout << "No\n";
  
  
}

Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
const int INF = 1e9;
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
} 
int32_t main() 
{
	fastio();
	int n,k;
	cin>>n>>k;
	int a[n],sm=0;
	f(i,0,n)
	{
		cin>>a[i];
		sm+=a[i];
	}
	if(sm<=k)
	{
		cout<<sm;
		return 0;
	}
	sort(a,a+n);
	vector<int>vc;
	for(int i=1;i<=sqrt(sm);i++)
	{
		if(sm%i==0)
		{
			int aa=sm/i;
			if(aa==i)
			{
				vc.pb(aa);
			}
			else
			{
				vc.pb(i);
				vc.pb(aa);
			}
		}
	}
	int mx=1;
	sort(vc.begin(),vc.end());
	f(i,0,vc.size())
	{
		int tp=0,tn=0,bc[n];
		f(j,0,n)
		{
			bc[j]=a[j]%vc[i];
		}
		int in[n],dc[n];
		sort(bc,bc+n);
		in[0]=bc[0];
		f(j,1,n)
		{
			in[j]=in[j-1]+bc[j];
		}
		dc[n-1]=vc[i]-bc[n-1];
		for(int j=n-2;j>=0;j--)
		{
			dc[j]=dc[j+1]+vc[i]-bc[j];
		}
		int mn=1e12;
		f(j,0,n-1)
		{
			if(in[j]==dc[j+1])
			{
				mn=min(mn,in[j]);
			}
		}
		if(mn<=k)
		{
			if(mx<vc[i])
				mx=vc[i];
		}
	}
	cout<<mx;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int llint;
llint dp[3005][3005],mod=1e9+7,sum2[3005][3005];
llint sum(llint a,llint b) {
	return ((a%mod)+(b%mod))%mod;
}
llint diff(llint a,llint b) {
	return ((a%mod)-(b%mod)+2*mod)%mod;
}
int main()
{
	int n;
	string str;
	cin >> n >> str;
	dp[0][1]=1;
	for(int i=1;i<=n;i++) {
		sum2[0][i]=1;
	}
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1;j++) {
			if(str[i-1]=='>') {
				/*for(int k=j;k<=i+1;k++) {
					dp[i][j]=sum(dp[i][j],dp[i-1][k]);
				}*/
				dp[i][j]=diff(sum2[i-1][i+1],sum2[i-1][j-1]);
			}
			else {
				/*for(int k=1;k<=min(i+1,j-1);k++) {
					dp[i][j]=sum(dp[i][j],dp[i-1][k]);
				}*/
				dp[i][j]=diff(sum2[i-1][min(i+1,j-1)],sum2[i-1][0]);
			}
			sum2[i][j]=sum(dp[i][j],sum2[i][j-1]);
		}
		for (int j=i+2; j<=n; ++j) sum2[i][j]=sum2[i][j-1];
	}
	llint sol=0;
	for(int i=1;i<=n;i++) {
		sol=sum(sol,dp[n-1][i]);
	}
	/*for(int i=0;i<n;i++) {
		for(int j=1;j<=n;j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	for(int i=0;i<n;i++) {
		for(int j=1;j<=n;j++) {
			cout << sum2[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;*/
	cout << sol;
	return 0;
}


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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> b = a;
    dsort(b, int);
    for(int i = 0; i < n; i++) {
        if(a[i] != b[0]) {
            cout << b[0] << endl;
        } else {
            cout << b[1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4776
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,K; R(N,K);
    if(K==1)W(0);
    else W(N-K);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    int b[n],kai;
    if(n%2==0){
        kai=n-1;
        rep(i,n){
            b[i]=a[kai];
            kai-=2;
            if(i==n/2-1){
                kai=0;
                break;
            }
        }
        for(int i=n/2;i<n;i++){
            b[i]=a[kai];
            kai+=2;;
        }
        rep(i,n){
            cout<<b[i]<<" ";
        }
        cout<<endl;
    }
    else{
        kai=n-1;
        rep(i,n){
            b[i]=a[kai];
            kai=kai-2;
            if(i==n/2){
                kai=1;
                break;
            }
        }
        for(int i=n/2+1;i<n;i++){
            b[i]=a[kai];
            kai+=2;
        }
        rep(i,n){
            cout<<b[i]<<" ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 5248
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int a, b, c;
  ci(a, b, c);
  co(a + b + c - max(a, max(b, c)));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

int N,A[100000+10]={},L[100000+10]={},R[100000+10]={},maxi=0;

signed main(){
  cin >> N;
  for(int i=1;i<=N;i++) cin >> A[i];
  for(int i=1;i<=N;i++) L[i+1]=gcd(L[i],A[i]);
  for(int i=N;i>=1;i--) R[i]=gcd(R[i+1],A[i]);
  for(int i=N;i>=1;i--){
    int M=gcd(L[i],R[i+1]);
    chmax(maxi,M);
  }
  cout << maxi << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>

#include<set>
#include<algorithm>

using namespace std;

int main(){
	int n,co=0,ans=400000;
	string s;
	cin>>n>>s;
	for(int i=1;i<n;i++){
		if(s[i]=='E')co++;
	}
	for(int i=0;i<n;i++){
		if(s[i-1]=='W' && i!=0)co++;
		if(s[i]=='E' && i!=0)co--;
		ans=min(co,ans);
	}
	cout<<ans<<endl;	
}



Measured memory_bytes: 900
#include <iostream>

using namespace std;

int main(void)
{
  string steps;
  
  cin >> steps;
  
  for(int i = 0; i < steps.size(); i++){
    if(i % 2 == 0){
      if(steps[i] == 'L'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(steps[i] == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var a, b, c, d, e int

	fmt.Scan(&a, &b, &c, &d, &e)

	if a == 0 {
		fmt.Println(1)
	} else if b == 0 {
		fmt.Println(2)
	} else if c == 0 {
		fmt.Println(3)
	} else if d == 0 {
		fmt.Println(4)
	} else if e == 0 {
		fmt.Println(5)
	}
	return
}


Measured memory_bytes: 1812
def main():
    N  = int(input())
    A,B  = map(int, input().split()) 
    P = list(map(int, input().split()))  
    c1 = 0
    c2 = 0
    c3 = 0

    for i in range(len(P)):
        if P[i]<=A:
            c1 +=1
        elif P[i]<=B:
            c2 +=1
        else:
            c3 +=1
    print(min([c1,c2,c3]))




if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	int m = (1 << n);
	vector<ll> cnt(m), dp(m);
	for (int s = 0; s < m; s++)
		for (int i = 0; i < n; i++)
			if (s & (1<<i))
				for (int j = i; j < n; j++)
					if (s & (1<<j))
						cnt[s] += a[i][j];
	for (int s = 0; s < m; s++)
		for (int sub = s; sub > 0; sub = (sub-1) & s)
			dp[s] = max(dp[s], dp[s-sub] + cnt[sub]);
	cout << dp[m-1] << "\n";
	return 0;
}

Measured memory_bytes: 1280
# include "cstdio"
# include "iostream"

using namespace std;

inline int n_lowbit(int x){    //取出含有质因子2的个数 
    int count=0;
    while(x){
        if(x&1){
            return count; 
        }
        count++; 
        x>>=1; 
    }
    return count; 
} 

int
    ans, //记录答案 
    N, 
    a; 

int main(){
    scanf("%d",&N);
    while(N--){
        scanf("%d",&a);
        ans+=n_lowbit(a); //更新答案 
    }
    printf("%d",ans); 
    return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()

ll P[10] = {1000000000,2,5,5,4,5,6,3,7,6};

int main() {
    ll N,M; scanf("%lld%lld",&N,&M);
    ll A[M];
    rep(i,M) scanf("%lld",&A[i]);
    sort(A,A+M);
    reverse(A,A+M);
    ll dp[10000] = {-1000000000};
    dp[0] = 0;
    repi(i,1,N+1){
        ll Max = -1000000000;
        rep(j,M){
            if ((i - P[A[j]]) >= 0){
                Max = max(Max,dp[i - P[A[j]]]);
            }
        }
        dp[i] = Max + 1;
    }
    ll n = dp[N];
    ll rem = N;
    rep(i,n){
        rep(j,M){
            if (dp[rem-P[A[j]]] == n - i - 1) {
                rem -= P[A[j]];
                cout << A[j];
                break;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	const char A=10,B=11,C=12,D=13,E=14,F=15;
	char x,y;
	while(~scanf(" %c %c",&x,&y)){
		if(x>y)
			printf(">\n");
		if(x<y)
			printf("<\n");
		if(x==y)
			printf("=\n");
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
char c[4]={'E','W','N','S'};
int gcd(int a ,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	llt n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				ans+=gcd(i,gcd(j,k));
			}
		}
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 3632
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val ab = Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" ").map(_.toLong))
    .toArray
    .sortBy(e => e(0))
  
  var ans = 0L
  var cnt = 0L
  for(i <- 0 until n if cnt < m) {
    if(cnt+ab(i)(1) < m) {
      ans += ab(i)(0) * ab(i)(1)
      cnt += ab(i)(1)
    }
    else {
      val rem = m - cnt
      ans += ab(i)(0) * rem
      cnt += rem
    }
  }
  // println(m + " " + cnt)
  println(ans)
}

Measured memory_bytes: 76604
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main(){
    string S;
    cin >> S;
    int num_0=0;
    int num_1=0;
    int L=S.length();
    for(int i=0;i<L;++i){
        if(S[i]=='0'){
            ++num_0;
        }
        else{
            ++num_1;
        }
    }
    int num_res=0;
    if(num_0>=num_1){
        num_res=num_0-num_1;
    }
    else{
        num_res=num_1-num_0;
    }
    int num_bro=0;
    if(num_0>=num_1){
        num_bro=num_0-num_res;
    }
    else{
        num_bro=num_1-num_res;
    }
    cout << num_bro*2;
}

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

#define M 1000000000
#define N 13

void changCode(char *num, int *a);
void addCode(int *a, int *b);

int main(void){
  int i, j, n, a[N], b[N];
  char num1[101], num2[101];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s %s", num1, num2);
    changCode(num1, a);
    changCode(num2, b);
    addCode(a, b);
    if(a[0] >= 9 && a[9] >= M/10){
      printf("overflow\n");
    }else{
      for(j = a[0]; j > 0; j--){
	if(j != a[0]){
	  printf("%09d", a[j]);
	}else{
	  printf("%d", a[j]);
	}
      }
      printf("\n");
    }
  }
  return 0;
}


void changCode(char *num, int *a){
  int i, j, len;
  char tmp[10];

  len = strlen(num);
  a[0] = (len%9==0) ? len/9 : len/9+1;
  for(i = 1; i < N; i++){
    a[i] = 0;
  }
  len--;
  tmp[9] = '\0';
  for(i = 1; i <= a[0]; i++){
    for(j = 8; j >= 0; j--){
      if(len >= 0){
	tmp[j] = num[len];
	len--;
      }else{
	tmp[j] = '0';
      }
    }
    a[i] = atoi(tmp);
  }
}


void addCode(int *a, int *b){
  int i;

  a[0] = (a[0] < b[0]) ? b[0] : a[0];
  for(i = 1; i <= a[0]; i++){
    a[i] += b[i];
    if(a[i] >= M){
      a[i] -= M;
      a[i+1]++;
      if(i >= a[0]){
	a[0] = i+1;
      }
    }
  }
}

Measured memory_bytes: 624
#include<stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	int height[n];
	for(int i=0; i<n; i++){
		scanf("%d", &height[i]);
	}
	
	int max = 0, count = 0;
	for(int i=0; i<n; i++){
		if(max <= height[i]){
			max = height[i];
			count++;
		}
	}
	printf("%d", count);
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
    char weather[5];
    scanf("%c%c%c",&weather[0],&weather[1],&weather[2]);
    int i,ans,key;
    ans = 0;
    key = 0;
    for(i=0;i<3;i++){
        if(weather[i] == 'R'){
            key++;
            if(i == 2 && key>ans){
                ans = key;
            }
        }else{
            if(key>ans){
                ans = key;
            }
            key = 0;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1668
#define FNAME ""

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < (n); i++)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long LL;
typedef LL ll;
typedef unsigned long long ULL;
typedef ULL ull;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
#ifdef LOCAL
    freopen(FNAME".in", "r", stdin);
    freopen(FNAME".out", "w", stdout);
#endif
    int n;
    int sum = 0;
    cin >> n;
    for (int i =0; i < n; i++) {
        int x;
        cin >> x;
        sum += (x % 2);
    }
    puts(sum % 2 ? "NO" : "YES");

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int x1,Y1,x2,y2;
int n;
struct Node
{
    int x;
    int y;
}node[200005],a[200005];
int tot;
double pi=3.141592653589793238462643383279;
int f[200005];

bool cmp(Node a,Node b)
{
    return a.x<b.x;
}

int work()
{
    int maxn=0;
    f[0]=-1;
    for (int i=1;i<=tot;i++)
        {
        int p=a[i].y;
        if (maxn==0)
            {
            f[1]=a[i].y;
            maxn=1;
            continue;
            }
        int l,r;
        l=0;
        r=maxn;
        while (l<r)
            {
            int mid=(l+r+1)/2;
            if (f[mid]<a[i].y) l=mid;
            else r=mid-1;
            }
        if (l==maxn)
            {
            maxn++;
            f[maxn]=a[i].y;
            }
        else f[l+1]=min(f[l+1],a[i].y);
        }
    return maxn;
}

int main()
{
    scanf ("%d %d %d %d",&x1,&Y1,&x2,&y2);
    scanf ("%d",&n);
    for (int i=1;i<=n;i++)
        scanf ("%d %d",&node[i].x,&node[i].y);

    double ans=0;
    if (x1==x2)
        {
        for (int i=1;i<=n;i++)
            if (node[i].x==x1 && node[i].y>min(Y1,y2) && node[i].y<max(Y1,y2)) ans=10*pi-20;
        ans=ans+(double)(max(Y1,y2)-min(Y1,y2))*100;
        printf ("%.15lf\n",ans);
        return 0;
        }
    if (Y1==y2)
        {
        for (int i=1;i<=n;i++)
            if (node[i].y==Y1 && node[i].x>min(x1,x2) && node[i].x<max(x1,x2)) ans=10*pi-20;
        ans=ans+(double)(max(x1,x2)-min(x1,x2))*100;
        printf ("%.15lf\n",ans);
        return 0;
        }

    sort(node+1,node+1+n,cmp);

    if (x1>x2)
        {
        int tmp;
        tmp=x1;
        x1=x2;
        x2=tmp;

        tmp=Y1;
        Y1=y2;
        y2=tmp;
        }

     tot=0;
    if (Y1<y2)
        for (int i=1;i<=n;i++)
            if (node[i].x>=x1 && node[i].x<=x2 && node[i].y>=Y1 && node[i].y<=y2)
                {
                tot++;
                a[tot]=node[i];
                }
    if (Y1>y2)
        for (int i=n;i>=1;i--)
            if (node[i].x>=x1 && node[i].x<=x2 && node[i].y>=y2 && node[i].y<=Y1)
                {
                tot++;
                a[tot]=node[i];
                }

    int anss=0;
    anss=work();
    if (x2-x1!=anss-1 && max(Y1,y2)-min(Y1,y2)!=anss-1)
        ans=(double)(x2-x1+max(Y1,y2)-min(Y1,y2))*100+anss*(pi*10/2.0-20);
    else ans=(double)(x2-x1+max(Y1,y2)-min(Y1,y2))*100+anss*(pi*10/2.0-20)+pi*10/2.0;

    printf ("%.15lf",ans);
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

ll N;
vector<ll> Graph[101010];

ll dp[101010][2];

ll dfs(ll n, ll par, ll color) {
  if (dp[n][color] != -1) {
    return dp[n][color];
  }

  if ((Graph[n].size() == 1 && Graph[n][0] == par) || Graph[n].size() == 0) {
    return dp[n][color] = 1;
  }

  ll res = 1;
  for (auto e : Graph[n]) {
    if (e != par) {
      ll sum = 0;
      sum += dfs(e, n, 0);
      sum %= MOD;
      if (color == 0) {
        sum += dfs(e, n, 1);
        sum %= MOD;
      }
      res *= sum;
      res %= MOD;
    }
  }
  return dp[n][color] = res;
}

int main() {
  cin >> N;
  rep(i, 0, N - 1) {
    ll x, y;
    cin >> x >> y;
    Graph[x].push_back(y);
    Graph[y].push_back(x);
  }

  rep(i, 0, 101010) {
    rep(j, 0, 2) { dp[i][j] = -1; }
  }

  cout << (dfs(1, 0, 0) + dfs(1, 0, 1)) % MOD;
}


Measured memory_bytes: 17572
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  struct Dice{
    Int m;
    vector<double> v,r;
    Dice(Int m):m(m),v(m),r(m){}
  };
  
  auto calc=
    [&](Dice d)->double{
      double sum=0,dom=0;
      for(Int i=0;i<d.m;i++){
        sum+=d.v[i]*d.r[i];
        dom+=d.r[i];
      }
      return sum/dom;      
    };
  
  Int t;
  cin>>t;
  vector<Dice> ds;
  for(Int i=0;i<t;i++){
    Int n,m;
    cin>>n>>m;
    ds.emplace_back(m);
    for(Int j=0;j<m;j++)
      cin>>ds[i].v[j]>>ds[i].r[j];   
  }

  Int p,q;
  cin>>p>>q;
  Dice dd(q);
  for(Int j=0;j<q;j++)
    cin>>dd.v[j]>>dd.r[j];

  const double EPS=0.0000001;
  double res=calc(dd);
  for(Int i=0;i<t;i++){
    if(res+EPS<calc(ds[i])){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}



Measured memory_bytes: 3264
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N; 
	cin >> N;
	vector<int>A(N);
	vector<int>B;
	int sum = 0;
	for (int i = 0;i<N;++i) {
		cin >> A[i];
		sum += A[i];
		if (0 != A[i]%10) {
			B.push_back(A[i]);
		}
	}
	sort(B.begin(),B.end());
	if (0 != sum%10) {
		cout <<sum <<endl;
		return 0;
	}
	if (0 == B.size()) {
		cout << 0 <<endl;
	}
	else {
		cout << sum - B[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1e18;

int N,K;
string s;

signed main() {
    IOS();
    cin>>N>>K>>s;
    int k=K;
    s=s+'?';
    vint zero(100010,0);
    int ans=0,now=1;
    rep(i,0,N){
        if(s[i]=='0'&&s[i+1]=='1'){
            zero[now]=i+1;
            now++;
            k--;
        }
        if(s[i]=='1'){
            chmax(ans,i+1-zero[max(now-1-K,0ll)]);
        }else{
            chmax(ans,i+1-zero[max(now-K,0ll)]);
        }
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1280
function Main(input) {
	var str = input;
	var ans = 0;
	var m =100;
	const n = str.split('\n');
	var x  =Number(n[0]);
	for (var i = 1; i <10**15; i++){
		m += Math.floor(m*0.01);
		if(m >=x){
			ans = i;
			break;
		}
	}
 console.log(ans);
 }
 
//*おまじない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29544
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <functional>

using namespace std;

const int dx[] = { 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int A[10];
int dp[10001];
int rd[10001];
int m;

int f(int n) {
    if(n < 0) return -1e9;
    if(n == 0) return 0;
    if(dp[n] != -1) return dp[n];
    int mx = -1e9;
    for(int j = m - 1; j >= 0; --j)
        if(mx < f(n - dx[A[j] - 1]) + 1) {
            mx = f(n - dx[A[j] - 1]) + 1;
            rd[n] = A[j];
            
        }

    return dp[n] = mx;
}

int main() {
    int n; cin >> n >> m;
    for(int i = 0; i < m; ++i)
        cin >> A[i];
    sort(A, A + m);
    
    memset(dp, -1, sizeof dp);
    
    f(n);
    while(n > 0) {
        cout << rd[n];
        n -= dx[rd[n] - 1];
    }
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
    while(1){
        int n,x;
        cin >> n >> x;
        if(n==0 && x==0)break;
        int count=0;
        for(int i=1;i<=n-2;i++){
            
            for(int j=i+1;j<=n-1;j++){
                
                if(i==j)continue;
                
                for(int k=j+1;k<=n;k++){
                    if(k==i || k==j)continue;
                    
                    if(i+j+k==x){
                        count++;
                        break;
                    }
                }
                
                
            }
        }
        
        cout<< count <<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3068
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

int main(int argc, char* argv[])
{
  int n, k;

  std::cin >> n >> k;
  std::map< int, int > mi;


  std::vector< int > va(n, 0);
  for (int i = 0; i < n; i++) {
    int tmp;
    std::cin >> tmp;
    if (mi.find(tmp) != mi.end()) {
      mi[tmp]++;
      //std::cout << "map " << tmp << " " << mi[tmp] << std::endl;
    } else {
      mi.insert(std::make_pair(tmp, 1));
      //std::cout << "insert " << tmp << std::endl;
    }
  }

  //std::cout << mi.size() << std::endl;
  std::vector< int > vi;
  std::map< int, int >::iterator itm;
  for (itm = mi.begin(); itm != mi.end(); itm++) {
    vi.push_back(itm->second);
  }
  std::sort(vi.begin(), vi.end());

  //std::vector< int >::iterator it;
  //for (it = vi.begin(); it != vi.end(); it++) {
  //  std::cout << "vi : " << *it << std::endl;
  //}

  int cnt = 0;
  for (int i = 0; i < (int)vi.size() - k; i++) {
    //std::cout << i << " " << (int)vi.size() - k << std::endl;
    cnt += vi[i];
  }
  std::cout << cnt << std::endl;
  
  return 0;
}


Measured memory_bytes: 11516
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var t = Reads();
            var m = Read();
            var ans = new long[m];
            for (int i = 0; i < m; i++)
            {
                ans[i] = t.Sum();
            }
            for (int i = 0; i < m; i++)
            {
                var px = Reads();
                var p = px[0];
                var x = px[1];
                ans[i] += (x - t[p - 1]);
            }
            foreach (var item in ans)
            {
                Console.WriteLine(item);
            }
            

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i <= min(b, a+k-1); ++i) cout << i << endl;
  for (int i = max(b-k+1, a+k); i <= b; ++i) cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
int main() {
	int N;
	double x;
	string u;
	cin >> N;
	double sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> x;
		cin >> u;
		if (u[0] == 'J') {
			if (u[1] == 'P') {
				if (u[2] == 'Y') {
					sum += x;
				}
			}
		}
		else {
			sum += 380000 * x;
		}

	}
	cout  << setprecision(16) << sum << endl;


	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
using ld = long double;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x);

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> P(N);
    REP(i,N){
        int a,b;
        cin >> a >> b;
        P[i] = MP(b,a);
    }
    sort(P.begin(),P.end());
    bool isOK = true;
    ll time = 0;
    REP(i,N){
        time += P[i].second;
        if(time > P[i].first) isOK = false;
    }
    
    Yes(isOK);
}

Measured memory_bytes: 1792