akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const int MOD=998244353;
int main(){
    int h,n;
    cin>>h>>n;
    vector<int> a(n),b(n),dp(h+1e5,1e9);
    rep(i,n) cin>>a[i]>>b[i];
    dp[0]=0;
    rep(i,h+1){
        rep(j,n){
            if(i+a[j]>=h){
                dp[h]=min(dp[h],dp[i]+b[j]);
                continue;
            }
            dp[i+a[j]]=min(dp[i]+b[j],dp[i+a[j]]);
        }
    }
    cout<<dp[h]<<endl;
    return 0;
}

Measured memory_bytes: 3764
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


S = sys.stdin.readline().rstrip()

O = []
E = []

for i, s in enumerate(S, 1):
    if i % 2 == 0:
        E.append(s)
    else:
        O.append(s)

if "R" not in E:
    if "L" not in O:
        print("Yes")
        exit()

print("No")



Measured memory_bytes: 66156
n,m=map(int,input().split())
ans=0
if n==1 and m==1:
    ans=1
elif n==1 or m==1:
    ans=max(n,m)-2
elif n==2 or m==2:
    ans=0
elif n>=3 and m>=3:
    ans=(n-2)*(m-2)
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int N;
  cin >> N;
  int a[100010];
  for (auto i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int cnt[100010];
  fill(cnt, cnt+100010, 0);
  int ans = 0;
  for (auto i = 0; i < N; ++i) {
    if (a[i] > N) {
      ans++;
    } else {
      cnt[a[i]]++;
    }
  }
  for (auto i = 1; i <= N; ++i) {
    if (cnt[i] >= i) {
      ans += cnt[i] - i;
    } else {
      ans += cnt[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int D,N;
	int i,j,k;
	int dp[201][201];
	int T[201],A[201],B[201],C[201];
	
	cin>>D>>N;
	
	for(i=1;i<=D;i++){
		cin>>T[i];
	}
	
	for(i=1;i<=N;i++){
		cin>>A[i]>>B[i]>>C[i];
	}
	
	for(i=1;i<=D;i++){
		for(j=1;j<=N;j++){
			dp[i][j]=-1;
		}
	}
	
	
	for(i=1;i<=N;i++){
		if(A[i]<=T[1]&&T[1]<=B[i]){
			dp[1][i]=0;
		}
	}
	
	/*for(i=1;i<=D;i++){
		for(j=1;j<=N;j++){
			cout<<dp[i][j];
		}
		cout<<endl;
	}*/
	
	int sum=0;
	for(i=1;i<D;i++){
		for(j=1;j<=N;j++){
			if(dp[i][j]!=-1){
				for(k=1;k<=N;k++){
					if(A[k]<=T[i+1]&&T[i+1]<=B[k]){
						sum=abs(C[j]-C[k]);
						dp[i+1][k]=max(dp[i+1][k],dp[i][j]+sum);
					}					
				}
			}
		}
	}
	
/*	for(i=1;i<=D;i++){
		for(j=1;j<=N;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	int MAX=-1;
	for(i=1;i<=N;i++){
		MAX=max(MAX,dp[D][i]);
	}
	cout<<MAX<<endl;
	
	
	return 0;
}
						
			
			


Measured memory_bytes: 3252
n = gets.to_i
ary = []
n.times do
  ary << gets.to_i
end
if (ary.sum)%10 != 0
  puts ary.sum
else
  ary.sort!
  for i in 0..n-1
    if ary[i]%10 != 0
      puts ary.sum-ary[i]
      exit
    end
  end
  puts 0
end

Measured memory_bytes: 14392
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cassert>
#include<cstring>
#define llong long long
using namespace std;

const int N = 2e4;
const int P = 998244353;
const llong INV2 = 499122177;
llong fact[N+3],finv[N+3];

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}
llong mulinv(llong x) {return quickpow(x,P-2);}
llong comb(llong x,llong y) {return x<0||y<0||x<y ? 0ll : fact[x]*finv[y]%P*finv[x-y]%P;}

int n,a,b;
char s[N+3],t[N+3];
llong dp[2][N+3];

int main()
{
	fact[0] = 1ll; for(int i=1; i<=N; i++) fact[i] = fact[i-1]*i%P;
	finv[N] = quickpow(fact[N],P-2); for(int i=N-1; i>=0; i--) finv[i] = finv[i+1]*(i+1)%P;
	scanf("%s%s",s+1,t+1); n = strlen(s+1);
	for(int i=1; i<=n; i++)
	{
		if(s[i]=='1' && t[i]=='1') {a++;}
		else if(s[i]^t[i]) {b++;}
	}
	b>>=1;
	int cur = 0,prv = 1;
	dp[0][0] = 1ll;
	for(int j=1; j<=b; j++)
	{
		cur^=1; prv^=1;
		dp[cur][0] = dp[prv][0]*j*j%P;
		for(int i=1; i<=a; i++)
		{
			dp[cur][i] = (dp[prv][i]*j*j+dp[cur][i-1]*i*j)%P;
//			printf("dp[%d][%d]=%lld\n",i,j,dp[cur][i]);
		}
	}
	llong ans = 0ll;
	for(int k=0; k<=a; k++)
	{
		ans = (ans+dp[cur][k]*comb(a,k)%P*fact[a-k]%P*fact[a-k]%P*comb(a+b,a-k))%P;
//		printf("k%d ans%lld\n",k,ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 768
n,k=map(int,input().split())
ans=0
for i in range(n):
  hoge=i+1
  if(k<=hoge):
    ans+=1
  else:
    flag=1
    kaisu=0
    while flag==1:
      kaisu+=1
      hoge=hoge*2
      if(k<=hoge):
        flag=0    
    ans+=((1/2)**kaisu)
print(ans/n)

Measured memory_bytes: 3060
import collections
import bisect
n,m = map(int,input().split())
p = [[int(j) for j in input().split()] for i in range(m)]
a = collections.defaultdict(list)
for x,y in sorted(p):
  a[x] += [y]
for x,y in p:
  z = bisect.bisect(a[x],y)
  print("%06d%06d"%(x,z))


Measured memory_bytes: 41012
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>
#include<set>

using namespace std;
#define int long  long int
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; }

signed main()
{
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'R')
		{
			if (i % 2 == 1)
			{
				cout << "No";
				return 0;
			}
		}

		if (S[i] == 'L')
		{
			if (i % 2 == 0)
			{
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; ++i)
#define RANGE(i, x, n) for(ll i = x; i < n; ++i)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

void accelerate()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

const int MAXN = 210;
const ll mod = 1e9+7;
ll X, N;
ll dp[MAXN][100005];
vector<ll> S;

ll quickpow(ll x, ll n)
{
    ll ans = 1;
    while(n) {
        if(n&1) {
            ans *= x;
            ans %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return ans;
}

int main()
{
    accelerate();
    cin >> N >> X;
    S.resize(N);
    REP(i, N) {
        cin >> S[i];
    }
    sort(S.begin(), S.end(), greater<ll>());

    REP(i, N) {
        if(i == 0) {
            dp[i][X%S[0]] = 1ll;
            dp[i][X] += (N-1)%mod;
        }else {
            REP(cur, X+1) {
                dp[i][cur%S[i]] += dp[i-1][cur]%mod;
                dp[i][cur%S[i]] %= mod;
                dp[i][cur] += dp[i-1][cur]*(N-i-1ll)%mod;
                dp[i][cur] %= mod;
            }
        }
    }

    /*cout << endl;
    REP(i, N) {
        cout << i << ":\t";
        REP(cur, X+1) {
            if(dp[i][cur] != 0)
            cout << cur << ":" << dp[i][cur] << "\t";
        }
        cout << endl;
    }*/

    ll ans = 0;
    REP(rm, X+1) {
        ans += rm*dp[N-1][rm]%mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 157184
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n;
  vector<int> p,q;
  int seq[10];
  cin >> n;
  p.resize(n);
  q.resize(n);
  
  for(ii=0;ii<n;ii++){
    cin >> p[ii] ;
    seq[ii] = ii+1;
  }
  for(ii=0;ii<n;ii++){
    cin >> q[ii];
  }

    
  //for(ii=0;ii<n;ii++){
  //    cout << p[ii] << "\t" ;
  //}
  //cout << endl;
  int pdist,qdist;
  bool flg;
  int cnt = 1;
  pdist = 0;
  qdist = 0;
  do{
    // check p;
    flg = true;

    //for(ii=0;ii<n;ii++){
    //  cout << seq[ii] << "\t" ;
    //}
    
    //cout << endl;
    for(ii=0;ii<n;ii++){
      if(p[ii] != seq[ii]){
        //cout << "false" << p[ii] << "\t" << q[ii] << endl;
        flg = false;
      }
    }
    if(flg){
      //cout << "pdist true" << endl;
      pdist = cnt;
    }

    // check q;
    flg = true;
    for(ii=0;ii<n;ii++){
      if(q[ii] != seq[ii]){
        flg = false;
      }
    }
    if(flg){
      qdist = cnt;
    }
    cnt++;
  }while(next_permutation(seq,seq+n));

  cout << abs(pdist - qdist) << endl;
  return 0;
}


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

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
using ll = long long;
using ull = unsigned long long;

int main() {
    FAST;

    ll n;
    cin >> n;

    ll sum = 0;
    for(int i = 1; i <= n; ++i){
        if(i % 3 == 0 && i % 5 == 0){
        }else if(i % 5 == 0){
        }else if(i % 3 == 0){
        }else{
            sum += i;
        }
    }

    println(sum);
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int ans=0;
	cin>>s;
	int size=s.size();
	for(int i=0;i<size-1;i++){
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

//ll bit[200010];
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t = max(t, bit[i]);
		i -= i & -i;
	}
	return t;
}

void update(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] = max(x, bit[i]);
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

/*ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 3004; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}*/

ll N, M;

void solve() {
	cin >> N >> M;
	if (N == M) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            double[] v = new double[n];
            for(int i = 0; i < n; i++)
            {
                v[i] = float.Parse(s[i]);
            }
            Array.Sort(v);

            double bunbo = Math.Pow(2.0,(n - 1));
            double res = v[0]/bunbo;
            for (int i = 1; i<n; i++)
            {
                res += v[i] / bunbo;
                bunbo /= 2.0;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11348
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m;
l(i,0,n)
{
    cin>>a;
 d=d+a;
 if(d<=m)
 {
     c++;
 }
}
cout<<c;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
	ll n;
	cin >> n;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (n == i * j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int a[1010];
bool check=false;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0) check=true;
	}
	if(!check) cout<<"APPROVED";
	else cout<<"DENIED";
}

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

template<class T> inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
    int N; cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < N; ++j) {
            cin >> A[i][j];
        }
    }
    const int INF = 1e9;
    vector<vector<int>> dp((1 << N) + 1, vector<int>(51, INF));
    dp[0][0] = 0;
    for(int mask = 0; mask < (1 << N); ++mask) {
        int last = __builtin_popcount(mask);
        vector<pair<int, int>> id;
        int itr = last;
        for(int i = 0; i < N; ++i) {
            if(!(mask & 1 << i)) {
                id.emplace_back(i, itr++);
            }
        }
        for(int s = 0; s <= 50; ++s) {
            if(dp[mask][s] == INF) continue;
            for(auto &p : id) {
                int i, j; tie(i, j) = p;
                int ns = A[abs(i - last) % 2][i];
                int d = abs(j - last);
                if(ns >= s) {
                    chmin(dp[mask | (1 << i)][ns], dp[mask][s] + d);
                }
            }
        }
    }
    int ans = INF;
    for(int s = 0; s <= 50; ++s) {
        chmin(ans, dp[(1 << N) - 1][s]);
    }
    cout << (ans == INF ? -1 : ans) << '\n';
    return 0;
}


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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
typedef long long LL;
typedef vector<LL> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template<typename T>
void chmin(T& s,T t){
    s=min(s,t);
}
template<typename T>
void chmax(T& s,T t){
    s=max(s,t);
}

const LL INF=1145141919;
int main(){
    int N,T;
    cin>>N>>T;
    V A(N);
    for(auto &it:A)cin>>it;
    V bottoms(N);
    LL sa=0;
    bottoms[0]=A[0];
    FOR(i,1,N){
        bottoms[i]=min(bottoms[i-1],A[i]);
        chmax(sa,A[i]-bottoms[i]);
    }
    V dp(2,0);
    REP(i,N){
        V nxt=dp;
        if(A[i]-bottoms[i]==sa){
            nxt[0]++;
        }
        if(A[i]==bottoms[i]){
            nxt[0]=min(dp[0],dp[1]);
            nxt[1]=min(dp[0],dp[1])+1;
        }
        swap(dp,nxt);
        //cout<<dp[0]<<" "<<dp[1]<<endl;
    }
    cout<<min(dp[0],dp[1])<<fin;
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll fexp(ll x, ll y) {
    ll ans = 1;
    while (y > 0) {
        if (y & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return ans;
}

int main() {
//    int n, k;
//    cin >> n >> k;
    int k;
    cin >> k;
    int n = 3;
    vector<ll> f(k + 1);
    for (int i = k; i >= 1; --i) {
        f[i] = fexp(k / i, n);
        for (int j = i * 2; j <= k; j += i)
            f[i] -= f[j];
        f[i] = (f[i] % MOD + MOD) % MOD;
    }
    ll ans = 0;
    for (int i = 1; i <= k; ++i)
        ans = (ans + f[i] * i) % MOD;
    cout << ans;
}

Measured memory_bytes: 3636
N = int(input())
seats = [""] * N

# 準備
print(0)
seats[0] = input()
if seats[0] == "Vacant":
    exit()
print(N - 1)
seats[N - 1] = input()
if seats[N - 1] == "Vacant":
    exit()

l = 0
r = N - 1
while True:
    m = (l + r) // 2
    print(m)

    s = input()
    if s == "Vacant":
        exit()
    seats[m] = s

    if (seats[l] == seats[m]) & ((m - l) % 2 == 1):
        r = m
    elif (seats[l] != seats[m]) & ((m-l) % 2 == 0):
        r = m
    else:
        l = m





Measured memory_bytes: 4424
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 10000
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vector<bool>Isprime(MAX+1,true);
    vector<int>Prime(MAX+1,0); //Primearray
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(Isprime[i]){
            for(int j = 2;i*j<MAX;j++)
                Isprime[i*j] = false;//?´???°??????Primearray???????´??????????????????°?????¨???false???
            Prime[Primecounter] = i;
            Primecounter++;
        }
    }
    int m,a,b;
    while (cin>>m>>a>>b){
        if(!(m+a+b))break;
        double dif=(double)a/(double)b;
        pii ans; int maxi=-INF;
        rep(i,Prime.size()){
            if(Prime[i]*Prime[i]>m)break;
            for(int j=i;j<Prime.size();j++){
                int big=(Prime[j]);
                int mini=Prime[i];
                if(b*mini-big*a<0)continue;
                if(big*mini>m)continue;
                if(maxi<big*mini){
                    maxi=big*mini;
                    ans=pii(mini,big);
                }
            }
        }
        cout<<ans.first<<" "<<ans.second<<endl;
    }
}

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


int main()
{
	int x,y,z;

	cin >>x;
	cin >>y;
	cin >>z;

	if(x<y && y<z)
		cout <<"Yes"<<endl;
	else
		cout <<"No"<<endl;

	//while(1);

	return 0;
}

Measured memory_bytes: 1156
function Main(input) {
	tmp = input.split(" ");
	var n = parseInt(tmp[0]);
	var k = parseInt(tmp[1]);
	var a = 0;
	var b = 1;
	var r = 0;
	while(a==0){
		if(b+(k-1) <= n){
			r++;
			b++;
		}else{
			a = 1;
		}
	}
	console.log(r);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

#define int long long

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

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

    int sum = 0;
    for (auto i : a) sum += i;

    map<int, int> cnt; // value => cnt
    for (auto i : a) cnt[i] += 1;

    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int b, c; cin >> b >> c;
        int diff = c-b;
        sum += diff*cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 10028
/*
Dear ToM,
Congratulations on your graduation!
You did a great job!
     ☆ﾟ*＠*ﾟ☆
　　(＠*｡☆｡*＠
　 /☆｡*＠ﾟ*☆
▲/／｡＠｡*☆＠*
　▼―ｰ｡*＠ﾟ*☆
*/

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main(){
  ll r, b, w, g;
  cin >> r >> b >> w >> g;
  cout << r + b + w + g << endl;

	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

ll digitSum(ll n) {
    ll sum = 0;
    while (n) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    if (n % digitSum(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// {{{ by unolight
#pragma region
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&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...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
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 UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion
// }}}

void main() {
    int n;
    R(n);
    int cnt=0;
    REP(i,n) {
        int a,b;
        R(a,b);
        if ( a==b ) cnt++;
        else cnt=0;
        if ( cnt==3 ) {
            W("Yes");
            return;
        }
    }    
    W("No");
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 3824
#include <stdio.h>
#include <stdlib.h>

#define VMAX 10000

void CountingSort(unsigned short *, unsigned short *, int);

int main(){
  unsigned short *A, *B;
  int n, i;

  scanf("%d",&n);

  A = malloc(sizeof(short)*(n+1));
  B = malloc(sizeof(short)*(n+1));

  /* your code */
  for(i = 1; i <= n; i++) {
    scanf("%hu",&A[i]);
  }
  
  CountingSort(A, B, n);

  for(i = 1; i <= n; i++) {
    if(i != 1) printf(" ");
    printf("%u",B[i]);
  }
  printf("\n");


  free(A);
  free(B);
  return 0;
}

void CountingSort(unsigned short *A, unsigned short *B, int n)
{
  int C[VMAX+1];
  int i;

  for(i = 0; i <= VMAX; i++) {
    C[i] = 0;
  }

  for(i = 1; i <= n; i++) {
    C[A[i]]++;
  }

  for(i = 1; i <= VMAX; i++) {
    C[i] = C[i] + C[i-1];
  }

  for(i = n; i >= 1; i--) {
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}



Measured memory_bytes: 9112
#include<stdio.h>
int main()
{
	char a[6];
	while(~scanf("%s",a))
	{
	 int i,j,l;
	 for(l=0,i=0;i<=3;i++)
	  {
	  	if(a[i]==0)
	  	continue;
	  	for(j=i+1;j<=3;j++)
	  	  {
	  	  	if(a[i]==a[j])
	  	  	    a[j]=0;
	  	  }
	  	l=l+1;
	  }
	  if(l==2)
	  printf("Yes\n");
	  else
	  printf("No\n");
    }
	  return 0;
}

Measured memory_bytes: 128
import math

k = int(input())
s = 0

def gcd3(a, b, c):
    d = math.gcd(a, b)
    e = math.gcd(d, c)
    return e


for a in range(1, k+1):
    for b in range(a, k+1):
        for c in range(b, k+1):
            d = gcd3(a, b, c)
            if a == b and b == c:
                s += d
            elif a == b or b == c:
                s += d * 3
            else:
                s += d * 6

print(s)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
 
int main(){
  int a,b;
cin>>a>>b;
  if(b==1) cout<<0<<endl;
  else{a-=b;
  cout<<a<<endl;}
}


Measured memory_bytes: 3600
#include <iostream>
#include <array>

void swap(int &x, int &y);

int main()
{
    std::array<int, 2> input;
    std::cin >> input.at(0) >> input.at(1);

    while(input.at(0) != input.at(1)) {
        if (input.at(0) < input.at(1)) {//??§????????????????????????
            swap(input.at(0), input.at(1));
        }
        input.at(0) -=input.at(1);//?????????
    }

    std::cout << input.at(0) << std::endl;

    return 0;
}

void swap(int &x, int &y)
{
    int temp = x;
    x = y;
    y = temp;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll dp[1001][1001],h,w,k; bool vis[1001][1001]; string s[1001];
ll dfs(ll x, ll y)
{
	if(x<0 || y<0 || x>=h || y>=w)
	return 0;
	if(vis[x][y]==true)
	return dp[x][y];
	vis[x][y]=true;
	if(s[x][y]=='#')
	return dp[x][y]=0;
	if((x==1 && y==0) || (x==0 && y==1))
	return dp[x][y]=1;
	k = ( dfs(x-1,y)%mod + dfs(x,y-1)%mod ) % mod;
//	cout<<x<<" "<<y<<" "<<k<<'\n';
	return dp[x][y]=k;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,n;
    	cin>>h>>w;
    	rep(i,0,h)
    	cin>>s[i];
		rep(i,0,h)
		{
			rep(j,0,w)
			{
				vis[i][j]=false;
				dp[i][j]=0;
			}
		}
		cout<<dfs(h-1,w-1);
    } 
	return 0;
}

Measured memory_bytes: 10240
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**6+2
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

r1,c1,r2,c2=map(int,input().split())

print((cmb(r2+c2+2,c2+1,mod)+cmb(r1+c1,r1,mod)-cmb(r1+c2+1,c2+1,mod)-cmb(r2+c1+1,c1,mod))%mod)

Measured memory_bytes: 132780
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;

vector<int> ind[26];

int rsq(vector<int>& V, int s, int t, int k = 1, int l = 0, int r = 524287) {
	if (t < l || r < s)return 0;
	if (s <= l && r <= t)return V[k];
	
	int lv = rsq(V, s, t, k * 2, l, (l + r) / 2);
	int rv = rsq(V, s, t, k * 2 + 1, (l + r) / 2 + 1, r);
	return lv + rv;
}

void add(vector<int>& V, int x, int y) {
	x += 524288;
	V[x] += y;
	while (x > 1) {
		x /= 2;
		V[x] = V[x * 2] + V[x * 2 + 1];
	}
	return;
}

int gets(vector<int>& V, int x) {
	return V[x + 524288];
}

int main() {
	for (int i = 0;i < 26;i++)ind[i] = vector<int>(1048576, 0);
	int N, Q;
	string S;
	cin >> N;
	cin >> S;
	cin >> Q;

	for (int i = 0;i < N;i++) {
		add(ind[S[i] - 'a'], i, 1);
	}

	int x, l, r, p, s;
	char c;

	for (int i = 0;i < Q;i++) {
		cin >> p;
		s = 0;
		if (p == 1) {
			cin >> x >> c;
			x--;
			if (S[x] != c) {
				add(ind[S[x] - 'a'], x, -1);
				add(ind[c - 'a'], x, 1);
				S[x] = c;
			}
		}
		else {
			cin >> l >> r;
			s = 0;
			l--;r--;
			for (int j = 0;j < 26;j++) {
				if (rsq(ind[j], l, r) > 0) {
					s++;
				}
			}
			cout << s << endl;
		}
	}
}

Measured memory_bytes: 109572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 N; cin >> N;
    vector<ll> T(N), A(N);
    for(int i=0; i<N; i++){
        cin >> T[i] >> A[i];
    }

    ll t = 1LL, a = 1LL;
    for(int i=0; i<N; i++){

        if(t <= T[i] && a <= A[i]){
            t = T[i]; a = A[i];
        }
        else{
            ll k = max((t-1)/T[i] + 1, (a-1)/A[i] + 1);
            t = T[i] * k;
            a = A[i] * k;
        }
        
    }

    cout << t+a << endl;

}


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

#define ll long long int

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast_io std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define trace3(x,y,z) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;
#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(),(v).end()

using namespace std;
///////////////////////////////////////////////////////

const int M = 1e9+7;

int n;
string s1,s2;
int ans = 0;

int main()
{
	fast_io;

	cin>>n>>s1>>s2;

	int i = 0;


	if(s1[0] == s2[0]){
		ans = 3;
		i++;
	}
	else{
		ans = 6;
		i+=2;
	}

	while(i<n){
		if(s1[i] == s2[i]){
			if(s1[i-1] == s2[i-1]){
				ans = (1LL*ans*2)%M;
			}
			i+=1;
		}
		else{
			if(s1[i-1] == s2[i-1]){
				ans = (1LL*ans*2)%M;
			}
			else{
				ans = (1LL*ans*3)%M;
			}
			i+=2;
		}
	}

	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import time
start = time.time()
n = int(input())
dp = [0]*n
cnt = 0
L = []
flag = True
for i in range(n):
  T = []
  N = list(map(int,input().split()))
  for j in range(n-1):
    T.append((i+1,N[j]))
  L.append(T)
while dp != [n-1]*n:
  B = [0]*n
  act = 0
  for i in range(n):
    if B[i] == 0:
      B[i] = 1
      if dp[i] != n-1:
        miru = L[i][dp[i]][1]-1
        if dp[miru] == n-1:
          flag = False
          dp = [n-1]*n
        else:
          if B[miru] != 1:
            if L[miru][dp[miru]][1] == i+1:
              dp[i] += 1
              dp[miru] += 1
              B[miru] = 1
              if act == 0:
                act = 1
  if act == 0:
    dp = [n-1]*n
    flag = False
  cnt += 1
  ela = time.time()-start
  if ela > 1.7:
    dp = [n-1]*n
if flag == False:
  print(-1)
else:
  if ela < 1.7:
    print(cnt)
  else:
    print(n*(n-1)//2)

Measured memory_bytes: 122612
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    bool found=false;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            found=true;
            break;
        }
    }
    if(found)
    {
        cout<<"OK"<<endl;
    }
    else
    {
        cout<<"NG"<<endl;
    }
    
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, a[200005], l[200005], r[200005];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  rep(i, 0, n) cin >> a[i];
  l[0] = a[0];
  rep(i, 1, n) l[i] = max(l[i-1], a[i]);
  r[n-1] = a[n-1];
  eper(i, n-2, 0) r[i] = max(r[i+1], a[i]);
  rep(i, 0, n) {
    cout << max((i-1 >= 0 ? l[i-1] : 0), (i+1 < n ? r[i+1] : 0)) << endl;
  }
  return 0;
}




Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if((a < c && c < b) || (b < c && c < a)) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

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

   VI H(N);
   REP(i, N)
      cin >> H[i];

   vector<bool> good(N, true);

   for (int j = 0; j < M; ++j) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      if (H[u] == H[v])
         good[u] = good[v] = false;
      else if (H[u] > H[v])
         good[v] = false;
      else
         good[u] = false;
   }

   int res = count(good.begin(), good.end(), true);
   cout << res << '\n';

   return 0;
}


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

using namespace std;

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

class UnionFind {
private:
  vector<int> a;
public:
  UnionFind(int n) {rep (i, n) a.push_back(i);}
  int find(int x) {return a[x] == x ? x : (a[x] = find(a[x]));}
  bool equal(int x, int y) {return find(x) == find(y);}
  void unite(int x, int y) {a[find(y)] = find(x);}
};

int parent[100000], m[100000];

int main() {
  while (true) {
    int n, q;
    cin >> n >> q;
    if (n == 0 && q == 0) break;
    rep (i, n - 1) {
      cin >> parent[i + 1];
      --parent[i + 1];
    }
    UnionFind uf(n);
    vector<pair<int, int> > query;
    rep (i, q) {
      string s;
      int v;
      cin >> s >> v;
      --v;
      if (s == "M") query.push_back(make_pair(0, v));
      else query.push_back(make_pair(1, v));
    }
    reverse(query.begin(), query.end());
    rep (i, n) m[i] = 0;
    m[0] = 1;
    rep (i, q) if (query[i].first == 0) ++m[query[i].second];
    rep (i, n) if (m[i] == 0) {
      uf.unite(parent[i], i);
    }
    long long res = 0;
    rep (i, q) {
      if (query[i].first == 0) {
	--m[query[i].second];
	if (m[query[i].second] == 0) uf.unite(parent[query[i].second], query[i].second);
      } else {
	res += uf.find(query[i].second) + 1;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3444
import sys
import math
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
ans = 1
for i in range(1, int(math.sqrt(m)) + 2):
    if m % i == 0:
        if m // i >= n and i >= n:
            ans = max(ans, i, m // i)
        elif m // i >= n:
            ans = max(ans, i)
        elif i >= n:
            ans = max(ans, m // i)
print(ans)


Measured memory_bytes: 3064
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include "bits/stdc++.h"

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

struct node {
  int x;

  node()
  {
    x = 0;
  }
  
  node(int _x):x(_x){}

  void combine(node& other)
  {
    x = max(x,other.x);
  }

  void combine(node& a, node& b)
  {
    *this = a;
    combine(b);
  }
};

int right_half[32];
struct segtree
{
  int tree_n = 0;
  vector<node> t;

  segtree(int n = -1)
  {
    if (n >= 0)
      init(n);
  }

  void init(int n)
  {
    tree_n = n;
    t.assign(2*tree_n,node());
  }

  void build(vector<node> v)
  {
    int n = (int)v.size();
    init(n);
    assert(n <= tree_n);

    for (int i = 0; i < n; i++)
      t[tree_n+i] = v[i];

    for (int i = n-1; i > 0; i--)
      t[i].combine(t[2*i],t[2*i+1]);
  }

  node query(int a, int b)
  {
    assert(0 <= a && a <= b && b <= tree_n);
    node ans;

    int r_size = 0;
    for (a += tree_n, b += tree_n; a < b; a /= 2, b /= 2)
    {
      if (a&1)
        ans.combine(t[a++]);
      if (b&1)
        right_half[r_size++] = --b;
    }
    for (int i = r_size-1; i >= 0; i--)
      ans.combine(t[right_half[i]]);

    return ans;
  }

  node query_single(int a)
  {
    assert(a >= 0 && a < tree_n);
    return t[tree_n+a];
  }

  void join_up(int pos)
  {
    while (pos > 1)
    {
      pos /= 2;
      t[pos].combine(t[2*pos],t[2*pos+1]);
    }
  }

  void update(int index, node& a)
  {
    assert(index >= 0 && index < tree_n);
    int pos = tree_n+index;
    t[pos] = a;
    join_up(pos);
  }
};

void solve()
{
  int n,k;
  cin >> n >> k;
  vi a(n);
  vecin(n,a);
  segtree T(6e5+7);

  for (int i = 0; i < n; i++)
  {
    int x = T.query(max(a[i]-k,0),a[i]+k+1).x;
    node t(x+1);
    T.update(a[i],t);
  }

  cout << T.query(0,3e5+6).x << endl;
}

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

  ll t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }
}



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

long long int x,y;
int ans;

int main(){
    while(cin>>x>>y){
        ans = 0;
        for(long long int i=x; i<=y; i*=2){
            ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
n = int(input())

def f(s):
    prev = ''
    ct = 0
    for i in s:
        if i == prev:
            ct += 1
            prev = ''
        else:
            prev = i
    return ct
        

if len(set(s)) == 1:
    print(len(s) *n//2)
elif s[0]!=s[-1]:
    print(f(s) * n)
else:
    ans = f(s) + (f(s*2) - f(s)) * (n-1)
    print(ans)
    
    


Measured memory_bytes: 3064
function main(input) {
    const [N, Y] = input.split(' ').map(n => parseInt(n, 10));
    let result = '-1 -1 -1';

    for(let a = 0; a <= N; a++ ) {
        for(let b = 0; b <= N; b++) {
            if( a + b > N ) continue;
            const sum = a * 10000 + b * 5000 + (N - a - b) * 1000;
            if( sum === Y ) {
                result = `${a} ${b} ${N - a - b}`;
                break;
            }

        }
    }
    console.log(result);
}

main( require('fs').readFileSync('/dev/stdin', 'utf8') );

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

using ll =long long;

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

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

int main()
{
ll N;
  cin>>N;
if(N==22){cout<<"Christmas Eve Eve Eve"<<endl;}
  if(N==23){cout<<"Christmas Eve Eve"<<endl;}
  if(N==24){cout<<"Christmas Eve"<<endl;}
  if(N==25){cout<<"Christmas"<<endl;}
}



Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))

L = sorted(L, reverse=True)
cnt=0
for i in range(len(L)-2):
    a = L[i]
    for j in range(i+1,len(L)-1):
        b = L[j]
        if a==b:
            continue
        for k in range(j+1, len(L)):
            c=L[k]
            if b==c:
                continue
            if a < b+c:
                cnt+=1
print(cnt)
            

Measured memory_bytes: 9224