akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

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

//階乗,factで初期化
vector<ll> tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

//nCk 繰り返し高速
ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll n,k;
  cin >> n >> k;
  ll tmp=0;
  double ans=0;
  for(ll i=n;i;i--) {
    while(i*mpow(2,tmp)<k) {
      tmp++;
    }
    ans+=1.0/mpow(2,tmp);
  }
  ans/=n;
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 78336
#include<stdio.h>

struct Dice
{
	int mae;
	int ue;
	int migi;
	int hidari;
	int sita;
	int usiro;
};

struct Dice ROLL_E(struct Dice dice)
{
	
	int a = dice.ue;
	dice.ue = dice.hidari;
	dice.hidari = dice.sita;
	dice.sita = dice.migi;
	dice.migi = a;
	
	return dice;
}

struct Dice ROLL_N(struct Dice dice)
{
	int a = dice.ue;
	dice.ue = dice.mae;
	dice.mae = dice.sita;
	dice.sita = dice.usiro;
	dice.usiro = a;
	
	return dice;
}
struct Dice ROLL_S(struct Dice dice)
{
	int a = dice.ue;
	dice.ue = dice.usiro;
	dice.usiro = dice.sita;
	dice.sita = dice.mae;
	dice.mae = a;
	
	return dice;
}
struct Dice ROLL_W(struct Dice dice)
{
	int a = dice.ue;
	dice.ue = dice.migi;
	dice.migi = dice.sita;
	dice.sita =dice. hidari;
	dice.hidari = a;
	
	return dice;
}

struct Dice ROLL_TOP(struct Dice dice,int top)
{
	if(top == dice.mae){
		dice =  ROLL_N(dice);
	}else if(top == dice.migi){
		dice =  ROLL_W(dice);
	}else if(top == dice.hidari){
		dice =  ROLL_E(dice);
	}else if(top == dice.usiro){
		dice =  ROLL_S(dice);
	}else if(top == dice.sita){
		dice =  ROLL_W(dice);
		dice =  ROLL_W(dice);
	}
	return dice;
}

struct Dice ROLL_FRONT(struct Dice dice,int front)
{
	dice = ROLL_TOP(dice,front);
	dice = ROLL_S(dice);
	return dice;
}

struct Dice ROLL(struct Dice dice,int front,int top)
{
	dice = ROLL_FRONT(dice,front);
	dice = ROLL_TOP(dice,top);
	return dice;
}

struct Dice scan()
{
	struct Dice dice;
	
	scanf("%d",&dice.ue);
	scanf("%d",&dice.mae);
	scanf("%d",&dice.migi);
	scanf("%d",&dice.hidari);
	scanf("%d",&dice.usiro);
	scanf("%d",&dice.sita);
	
	return dice;
}

int COMPARE (struct Dice dice_a,struct Dice dice_b)
{
	if(dice_a.ue != dice_b.ue)return 0;
	if(dice_a.mae != dice_b.mae)return 0;
	if(dice_a.migi != dice_b.migi)return 0;
	if(dice_a.hidari != dice_b.hidari)return 0;
	if(dice_a.usiro != dice_b.usiro)return 0;
	if(dice_a.sita != dice_b.sita)return 0;
	return 1;
}

int JUDGE(struct Dice dice[100],int n)
{
	int i,j,front,top,point = 0;
	
	for(i=0;i<n-1;i++){
		front = dice[i].mae;
		top = dice[i].ue;
		for(j=1;j<=n-i;j++){
			dice[i+j] = ROLL(dice[i+j],front,top);
			point += COMPARE(dice[i],dice[i+j]);
		}
	}
	return point;
} 
int main()
{
	int i,n,judge;
	struct Dice dice[100];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		dice[i] = scan();
	}
	
	judge = JUDGE(dice,n);
	
	if(judge == 0)printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    int n, c;
    cin >> n >> c;
    vector<vector<int>>st(c,vector<int>(200200));
    rep(i, 0, n){
        int p, q, r;
        cin >> p >> q >> r;
        p*=2;
        q*=2;
        r--;
        st[r][p-1]++;
        st[r][q+1]--;
    }
    rep(i, 0, c){
        rep(j, 1, 200200){
            st[i][j] += st[i][j-1];
        }
    }
    rep(i, 0, c)rep(j, 1, 200200)if(st[i][j]>1)st[i][j]=1;
    int ans = -1;
    rep(j, 0, 200200){
        int temp = 0;
        rep(i, 0, c){
            temp += st[i][j];
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 27528
import numpy as np
from itertools import combinations 
INF = int(1e9)*15
def main():
    n, k = map(int, input().split()) 
    a = np.array(input().split(), np.int32)
    c = np.array([int(i) for i in range(1, n)])
    ans = INF
    for comb in combinations(c, k-1):
        s = set(comb)
        mx = a[0]
        cost = 0
        for i in range(n):
            if i in s:
                if a[i] > mx:
                    mx = a[i]
                    continue
                else:
                    mx += 1
                    cost += mx-a[i] 
                    continue
            mx = max(mx, a[i])
        ans = min(cost, ans)
    print(ans)
if __name__ == '__main__':
    main()


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

using namespace std;

#define mod 1000000007LL
#define pi 3.141592653589793238462643383279;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pic pair<char,long long >

void scan(vector<int> & v)
{
    for(int i=0;i<v.size();i++)
        scanf("%d",&v[i]);
}

void print(vector<int> & v)
{
    for(int i=0;i<v.size();i++)
        printf("%d ",v[i]);
}
void fun()
{
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    ll ans=1;
    ll sum=v[0];
    //int temp=1;
    for(ll i=1;i<n;i++)
    {
        //sum+=v[i];
        if(2*sum>=v[i])
        {
            ans++;
        }
        else
        {
            ans=1;
        }
        sum+=v[i];
    }
    cout<<ans<<endl;
}
int main()
{
    bool test=0;
    if(test==1)
    {
        freopen("input_file_name.txt","r",stdin);
        freopen("output_file_name.txt","w",stdout);
    }
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
        //cout<<"Case #"<<i<<": ";
        fun();
        //cout<<endl;
    }
    //int acc;cin>>acc;
    return 0;
}



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

int main(void)
{
    int i;
    ll x,n=100.0;
    cin >> x;
    
    for(i=0;n<x;i++){
        n*=1.01;
    }
    

    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int x, y; cin >> x >> y;
	int a[7] = { 1,3,5,7,8,10,12 };
	int b[4] = { 4,6,9,11 };
	bool ans = false;
	rep(i, 7) {
		if (x == a[i]) {
			rep(j, 7) {
				if (y == a[j]) {
					cout << "Yes" << "\n";
					return 0;
				}
			}
		}
	}
	rep(i, 4) {
		if(x==b[i]){
			rep(j, 4) {
				if (y == b[j]) {
					cout << "Yes" << "\n";
					return 0;
				}
			}
		}
	}
	if (x == y)cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
import itertools
num = int(input())
xlist = []
ylist = []
plist = []
for i in range(0,num):
  list = input().split(" ")
  xlist.append(int(list[0]))
  ylist.append(int(list[1]))

for t in itertools.permutations(range(num)):
  plist.append(t)
sum = 0
for n1 in range(0,len(plist)):
  S = 0
  sx = xlist[plist[n1][0]]
  sy = ylist[plist[n1][0]]
  for n2 in range(1,num):
    l = ((sx-xlist[plist[n1][n2]])**(2)+(sy-ylist[plist[n1][n2]])**(2))**(1/2)
    S += l
  sum += S
print(sum/len(plist))

Measured memory_bytes: 8052
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<random>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1e9;
typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 500+10
    string S;
    bool Q[30];
int main(){
    cin>>S;
    for(auto x:S){
        Q[int(x-'a')]=true;
    }
    REP(i,26){
        if(!Q[i]){
            cout<<(char)(i+'a');
            break;
        }
        if(i==25)cout<<"None";
    }
    //cout<<ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    if((B/K)-(A/K) > 0) cout << "OK" << endl;
    else if(B%K ==0 || A%K==0){
    cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    for (int i=0;i<i+1;i++) {
        string t;
        cin >> t;
        if ( t == "" ) {
            break;
        } else if ( i!=0 ) {
            cout << " ";
        }
        int l = t.length();
        for (int j=0;j<l;j++) {
            char c = t.at(j);
            if ( c >= 'A' && c <= 'Z' ) {
                char big = c + 0x20;
                cout << big;
            } else if ( c >= 'a' && c <= 'z' ) {
                char small = c - 0x20;
                cout << small;
            } else {
                cout << c;
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3164
N = int(input())
A = list(map(int, input().split()))

# add = [None] * (N+1)
# sub = [None] * (N+1)

from collections import defaultdict
add = defaultdict(int)
sub = defaultdict(int)

ans = 0
for i in range(N):
    ans += add[i+1 - A[i]] 
    ans += sub[i+1 + A[i]] 
    add[i+1 + A[i]] += 1
    sub[i+1 - A[i]] += 1

print(ans)


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

using namespace std;

int main()
{
	int n,l;
	cin>>n>>l;
	int s[205];
	int min;
	if(l>=0)
	min=l;
	else
		min=-l;
	int sum=0;
	int cnt;
	for(int i =0;i<n;i++)
	{
		int j;
		s[i]=l+(i+1)-1;
		sum+=s[i];
		if(s[i]<0)
			j=-s[i];
		else
			j=s[i];
		if(j<min)
			{min=j;
				cnt=i;}
	}
	sum-=s[cnt];
	cout<<sum<<endl;
	return 0;
}
			

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    string S;
    cin >> S;
    int N=S.size();
    bool x=false;
    for (int j=N-1; j>0; j--) {
        if (j%2==0) {
            for (int i=0; i<j/2; i++) {
                if(S.at(i)==S.at(i+j/2)) {
                    //cout << i << endl;
                    //cout << i+j/2 << endl;
                    //cout << S.at(i) << " " << S.at(i+j/2) << endl;
                    x=true;
                }
                else {
                    x=false;
                    break;
                }
            }
        }
        else continue;
        if (x) {
            cout << j << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0, p = 1;
    while(p < n)
    {
        p = p+m-1; //cout << p <<  " ";
        ans++;
    }
    cout << ans;

}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

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

	vector<int> cost(n);
	cost[0] = 0;
	cost[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++)
	{
		cost[i] = min(cost[i - 2] + abs(h[i] - h[i - 2]), cost[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << cost[n - 1] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define SIZE 262144
class BIT
{
public:
	int bit[SIZE + 1];
	void add(int a, int b)
	{
		a++;
		for (;;)
		{
			bit[a] += b;
			a += a&-a;
			if (a > SIZE)return;
		}
	}
	int get(int a)
	{
		a++;
		int ret = 0;
		for (;;)
		{
			ret += bit[a];
			a -= a&-a;
			if (a == 0)return ret;
		}
	}
};
BIT bi;
ll rui[SIZE];
int main()
{
	int num, gen;
	scanf("%d%d", &num, &gen);
	ll ans = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		z -= gen;
		rui[i + 1] = rui[i] + z;
	}
	vector<ll>zat;
	for (int i = 0; i <= num; i++)zat.push_back(rui[i]);
	sort(zat.begin(), zat.end());
	for (int i = 0; i <= num; i++)rui[i] = lower_bound(zat.begin(), zat.end(), rui[i]) - zat.begin();
	for (int i = 0; i <= num; i++)ans += bi.get(rui[i]), bi.add(rui[i], 1);
	printf("%lld\n", ans);
}

Measured memory_bytes: 4336
import collections 
n,k = map(int, raw_input().split(' '))

cc=  collections.Counter()
for ii in range(1, n+1):
	cc[ii % k] +=1

r = 0
for ii in cc:
	if 2*(k - ii) % k == 0:
		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 
		#* cc[(k - ii) % k] 
print r

Measured memory_bytes: 90816
#include <iostream>
#include <vector>
#include <math.h>
#include <string>

using namespace std;

int main(){
    int x;
    cin >> x;
    if(x == 3 || x == 5  || x == 7){
        cout << "YES" <<endl;
    }else{
        cout << "NO" << endl;

    }
    return 0;
}

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

int main(){
    int n, k;
    string s;
    cin >> n >> s >> k;

    for (int i = 0; i < n; ++i){
        if (s[i]==s[k-1] ){
            cout << s[k-1];
        }else{
            cout << "*";
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	char a;
	while(cin>>a)
	{
		if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
		{
			cout<<"vowel"<<endl;
		}
		else
			cout<<"consonant"<<endl;
	}
}


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

def main():
    r,c,k = map(int, input().split())
    rcv = [ [0]*c for _ in range(r) ]

    for _ in range(k):
        ri,ci,vi = map(int, input().split())
        rcv[ri-1][ci-1] = vi

    # dp[0] = [ [0]*c for _ in range(r) ]
    # dp1 = [ [0]*c for _ in range(r) ]
    # dp2 = [ [0]*c for _ in range(r) ]
    # dp[3] = [ [0]*c for _ in range(r) ]
    dp = [ [ [0]*c  for _ in range(r) ] for _ in range(4) ]


    dp[1][0][0] = rcv[0][0]
    for i in range(r):
        for j in range(c):
            if i+1 < r:
                dp[0][i+1][j] = max(dp[0][i][j], dp[1][i][j], dp[2][i][j], dp[3][i][j], dp[0][i+1][j])
                if rcv[i+1][j] > 0:
                    dp[1][i+1][j] = max(dp[1][i+1][j],  max(dp[0][i][j], dp[1][i][j], dp[2][i][j], dp[3][i][j])+rcv[i+1][j])

            if j+1 < c:
                dp[0][i][j+1] = max(dp[0][i][j], dp[0][i][j+1])
                dp[1][i][j+1] = max(dp[1][i][j], dp[1][i][j+1])
                dp[2][i][j+1] = max(dp[2][i][j], dp[2][i][j+1])
                dp[3][i][j+1] = max(dp[3][i][j], dp[3][i][j+1])
                if rcv[i][j+1] > 0:
                    dp[1][i][j+1] = max(dp[1][i][j+1], dp[0][i][j]+rcv[i][j+1])
                    dp[2][i][j+1] = max(dp[2][i][j+1], dp[1][i][j]+rcv[i][j+1])
                    dp[3][i][j+1] = max(dp[3][i][j+1], dp[2][i][j]+rcv[i][j+1])

    ans = max(dp[0][r-1][c-1], dp[1][r-1][c-1], dp[2][r-1][c-1], dp[3][r-1][c-1])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 429252
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

struct edge{
    int to, number;
    edge(int t, int n) : to(t),number(n){}
};

int N;
vector<edge> E[100001];
int color[100001];
bool seen[100001];
int color_max;

void dfs(int sv, int se){
    int c = 1; seen[sv] = true;
    for(auto& e : E[sv]){
        if(seen[e.to]) continue;
        if(c == color[se]) c++;
        color[e.number] = c; color_max = max(color_max, c);
        c++;
        dfs(e.to, e.number);
    }
}

int main(){
    cin >> N;
    color_max = 0; fill(seen, seen+N, false);
    int first;
    rep(i, N-1){
        int a, b; cin >> a >> b;
        E[a].push_back(edge(b, i));
        E[b].push_back(edge(a, i));
        if (i == 0) first = a;
    }
    color[0] = -1; dfs(first, 0);
    cout << color_max << endl;
    rep(i, N-1) cout << color[i] << endl;
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n; cin >> n;
    double ans;
    if(n%2==0) ans = (n/2)/(double)n;
    else ans=(n/2+1)/(double)n;
    printf("%.8f",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define lc (x << 1)
#define rc (x << 1 | 1)
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();

	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;
const int mo = 1000000007;

int n;
LL A, B;
LL s[N];

struct Segment_Tree {
	int sum[N << 2];
	int tag[N << 2];

	Segment_Tree() {
		memset(sum, 0, sizeof sum);
		memset(tag, 0, sizeof tag);
	}

	void upd(int x) {sum[x] = (sum[lc] + sum[rc]) % mo;}

	void make_tag(int x) {
		sum[x] = 0;
		tag[x] = 1;
	}

	void push_down(int x) {
		if (tag[x]) {
			make_tag(lc);
			make_tag(rc);
			tag[x] = 0;
		}
	}

	void reset() {make_tag(1);}

	void set(int x, int l, int r, int pos, int val) {
		if (l == r) {sum[x] = val; return;}
		push_down(x);
		int m = (l + r) >> 1;
		if (pos <= m) set(lc, l, m, pos, val);
		else set(rc, m + 1, r, pos, val);
		upd(x);
	}

	LL getsum(int x, int l, int r, int s, int t) {
		if (s <= l && r <= t) return sum[x];
		push_down(x);
		int m = (l + r) >> 1, ans = 0;
		if (s <= m) (ans += getsum(lc, l, m, s, t)) %= mo;
		if (m < t) (ans += getsum(rc, m + 1, r, s, t)) %= mo;
		return ans;
	}
} T1, T2;

int main() {
	read(n), read(A), read(B);
	for (int i = 1; i <= n; i++) read(s[i]);
	T1.set(1, 0, n, 0, 1);
	T2.set(1, 0, n, 0, 1);
	s[0] = -INF;
	int flagA0, flagB0;
	int la = 0, lb = 0;
	for (int i = 1; i <= n; i++) {
		flagA0 = flagB0 = 0;
		if (s[i] - s[i - 1] < A) flagA0 = 1;
		if (s[i] - s[i - 1] < B) flagB0 = 1;
		while (la + 1 <= i && s[i] - s[la + 1] >= A) la++;
		while (lb + 1 <= i && s[i] - s[lb + 1] >= B) lb++;
		int tmpA = T2.getsum(1, 0, n, 0, la);
		int tmpB = T1.getsum(1, 0, n, 0, lb);
		if (flagA0) T1.reset();
		if (flagB0) T2.reset();
		T1.set(1, 0, n, i - 1, tmpA);
		T2.set(1, 0, n, i - 1, tmpB);
	}
	int ans = (T1.getsum(1, 0, n, 0, n) + T2.getsum(1, 0, n, 0, n)) % mo;
	printf("%d\n", (ans + mo) % mo);
	return 0;
}

Measured memory_bytes: 7424
N=int(input())

divisor_set=set()
for i in range(1,int(N**0.5)+1):
  if N%i==0:
    divisor_set.add(i)
    divisor_set.add(N//i)
#print(divisor_set)

def f(x,y):
  return max(len(str(x)),len(str(y)))

min_answer=float("inf")
for d in divisor_set:
  d1=d
  d2=N//d
  min_answer=min(min_answer,f(d1,d2))
  
print(min_answer)

Measured memory_bytes: 3188
/*
ID: varunra2
LANG: C++
TASK: numways
*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

#define EPS 1e-9
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()

typedef pair<int, int> PII;
typedef vector<int> VI;

const double pi = acos(-1.0);
typedef long int int32;
typedef long long int int64;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef unsigned long int uint32;
typedef unsigned long long int uint64;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;

#define watch(x) cerr << (#x) << " is " << (x) << endl
#define printvii(v)                                    \
  cerr << (#v) << "=";                                 \
  for_each(v.begin(), v.end(), [](PII i) -> void {     \
    cerr << "(" << i.first << "," << i.second << "),"; \
  });                                                  \
  cerr << endl;
#define printvi(v)                                                       \
  cerr << (#v) << "=";                                                   \
  for_each(v.begin(), v.end(), [](int i) -> void { cerr << i << ","; }); \
  cerr << endl;

int main(int argc, char const *argv[]) {
int n;
  cin >> n;
  cout << n*n*n << endl;
}


Measured memory_bytes: 256
n = int(input())
taro = 0
hana = 0
for _ in range(n):
	taro_c, hana_c = input().split()
	if taro_c > hana_c:
		taro += 3
	elif hana_c > taro_c:
		hana += 3
	else:
		taro += 1
		hana += 1

print(taro, hana)

Measured memory_bytes: 7604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll N;
    cin>>N;
    ll x;
    bool flg=true;
    rep(i,0,N){
        cin>>x;
        if(x%2==0){
            if(x%3==0||x%5==0){}
            else{flg=false;break;}
        }
    }

    cout << (flg ? "APPROVED" : "DENIED");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] S = scanner.next().toCharArray();
    int[] a = new int[N + 1];
    int[] b = new int[N + 1];
    for (int i = 1; i <= N; i++) {
      a[i] = a[i - 1];
      if (S[i - 1] == 'W') a[i]++;
    }
    for (int i = N - 1; i >= 0; i--) {
      b[i] = b[i + 1];
      if (S[i] == 'E') b[i]++;
    }
    int min = N;
    for (int i = 1; i <= N; i++) {
      min = Math.min(min, a[i - 1] + b[i]);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 30892
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

parseint(x) = parse(int, x)
function readint()
  moji = readline(stdin)
  moji = split(moji)
  return map(parseint,moji)
end

const NMax = 50
const MMax = 100

struct Edge
  y::int
  cost ::int
  time ::int
end

mutable struct Graph{T}
  nodes::Vector{Vector{T}} 
  degree::Vector{int}
  n::int
  m::int
end

function Graph(N,T)
  Nodes = Vector{Vector{T}}(undef,N)
  for i in 1:N
    Nodes[i] = Vector{T}(undef,0)
  end
  degree = zeros(int,N)
  n = N
  m = 0
  return Graph{T}(Nodes, degree, n,m)

end

struct State
  iti::int
  kane::int
  time::int
end

isless(a::State,b::State) = a.time < b.time

mutable struct PriorityQueue{T}
  tree::Vector{T}
  Nmax::int
  n::int
  priority::Function
end

function PriorityQueue(isless,T)
  tree = Vector{T}(undef,0)
  return PriorityQueue{T}(tree, 0, 0, isless)
end

function push(P::PriorityQueue{T}, a::T) where T
  if P.Nmax == P.n
    P.Nmax += 1
    P.n += 1
    append!(P.tree,[a])
  else
    P.n+=1
    P.tree[P.n] = a
  end
  
  p = P.n
  while p > 1
    up = p÷2
    if P.priority(P.tree[p], P.tree[up]) 
      P.tree[p], P.tree[up] = P.tree[up],P.tree[p]
    end
    p = up
  end
      
end
  
function pop(P::PriorityQueue{T}) where T
  preturn = P.tree[1]
  P.tree[1] = P.tree[P.n]
  P.n -= 1 
  nmax = P.n
  p = 1
  
  while 2p <= nmax
    
    # argmin [p, 2p, 2p+1]
    m = p
    for down in 2p:2p+1
      down > nmax && break
      P.priority(P.tree[down], P.tree[m]) && (m = down)
    end
    
    m == p && break
    
    P.tree[p], P.tree[m] = P.tree[m], P.tree[p]
    p = m
        
  end
  return preturn

end

#import 
is_empty(P::PriorityQueue{T}) where T = P.n == 0

function main()
  N, M, S = readint()
  
  G =Graph(N,Edge)

  Amax = 0
  for i in 1:M
    U,V,A,B = readint()
    append!(G.nodes[U],[Edge(V,A,B)])
    append!(G.nodes[V],[Edge(U,A,B)])
    G.degree[U]+=1
    G.degree[V]+=1
    Amax < A && (Amax = A)
  end

  for i in 1:N
    C,D = readint()
    G.degree[i] += 1
    append!(G.nodes[i], [Edge(i,-C,D)])
  end

  d = Array{int,2}(undef,N,N*Amax+1)
  d .= typemax(int)
  if S > Amax * N 
    S = Amax * N
  end
  d[1, S+1] = 0

  checked = Vector{Bool}(undef,N)
  checked .= false

  Q = PriorityQueue(isless, State)
  push(Q, State(1,S,0))

  jS = S
  jp = 1
  checked[1]=true
  dd = Vector{int}(undef, N)

  while ! is_empty(Q)
    q = pop(Q)
    p, kane, time = q.iti, q.kane, q.time
    
    d[p,kane+1] < time && continue
  
    if !checked[p] # = false
      checked[p] = true
      dd[p] = time
    end

    for E in G.nodes[p]
      kane - E.cost < 0 && continue

      newkane = min(Amax*N, kane-E.cost)
      newtime = E.time + time 

      if d[E.y, newkane+1] > newtime
        d[E.y, newkane+1] = newtime   
        push(Q, State(E.y, newkane, newtime))
      end
    end
    #println(q, p)    
  end
  for i in 2:N
    println(dd[i])
  end
  #println(G)
end

main()

Measured memory_bytes: 235008
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    cout<<min(n,k)*x+max(0LL,n-k)*y;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
// Invariant: basis is in rref form from bottom to top.
template <typename T>
bool add(T x, vector<T>& basis, bool a) {
	int siz = basis.size();
	for (int i = siz - 1; i >= 0; --i) {
		x = min(x, x ^ basis[i]);
	}
	if (!x) return false;
	if (a) basis.insert(lower_bound(basis.begin(), basis.end(), x), x);
	return true;
}
char S[205];
int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int n;
		scanf("%d", &n);
		vector<ll> A(n);
		for (int i = 0; i < n; ++i) scanf("%lld", &A[i]);
		scanf("%s", S);
		vector<ll> B;
		bool win1 = false;
		for (int i = n - 1; i >= 0; --i) {
			if (S[i] == '1') {
				if (add(A[i], B, false)) {
					win1 = true;
					break;
				}
			} else {
				add(A[i], B, true);
			}
		}
		printf(win1 ? "1\n" : "0\n");
	}
}


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

int main()
{
    ll N; cin >> N;
    ll ans = 0;
    rep(i,N) {
        ll tmp = i+1;
        if (tmp % 2 == 0) continue;
        //cout << tmp << endl;
        ll num = 0;
        rep(j,N) {
            if (tmp % (j+1) == 0) {
                //cout << "j+1= " << j+1 << endl;
                num++;
            }
        }
        if (num == 8) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  string s;
  cin>>n>>s;
  int i=0;
  int j=n-1;
  int ans=0;
  while(i!=j){
    while(s[i]=='R' && i!=j){
      i++;
    }
    while(s[j]=='W' && i!=j){
      j--;
    }
    if(i!=j){
      swap(s[i],s[j]);
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

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

  if(x<y) {
    swap(x,y);
    swap(a,b);
  }

  int ans = 0;
  if(a+b>c*2){
    ans+=y*c*2;
    x-=y;
    if(a>c*2){
      ans+=x*c*2;
    }
    else
    {
      ans+=x*a;
    }
  }
  else{
    ans+=x*a+y*b;
  }
   cout << ans << endl; 
  
}

Measured memory_bytes: 256
import sys
from collections import Counter

h, w = map(int, input().split())
a_list = [input() for i in range(h)]
a_list.insert(0, '#' * w)
a_list.insert(len(a_list), '#' * w)

for i in range(len(a_list)):
    print('#' + a_list[i] + '#')



Measured memory_bytes: 3316
N, K = map(int, input().split())
H = [0] * N
for i in range(N):
  H[i] = int(input())
H.sort()
delta = H[-1] - H[0]
for i in range(N - K + 1):
  delta = min(H[i + K - 1] - H[i], delta)
print(delta)

Measured memory_bytes: 7472
# coding: utf-8
N = int(input())
lst = [input() for i in range(N)]
for i in range(N-1):
    n = lst[i]
    m = lst[i+1] 
    if lst[i+1] in lst[:i+1] or n[-1] != m[0]:
        print('No')
        exit()
print('Yes')

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



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

    string s;
    cin >> s;

    int c=1;

    rep(i,n-1){
        if(s[i]!=s[i+1]){
            c++;
        }
    }

    cout << c << endl;
return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N],B[N];
    rep(i,N) cin >> A[i] >> B[i];
    int S[N],T[N];
    rep(i,N) {
        S[i]=A[i]-B[i];
    }
    rep(i,N) {
        T[i]=A[i]+B[i]; 
    }
    int ma=-INF,mi=INF;
    rep(i,N) {
        chmax(ma,S[i]);
        chmin(mi,S[i]);
    }
    int ans1=ma-mi;
    ma=-INF; mi=INF;
    rep(i,N) {
        chmax(ma,T[i]);
        chmin(mi,T[i]);
    }
    int ans2=ma-mi;
    cout << max(ans1,ans2) << endl;
}


Measured memory_bytes: 9892
#include <cstdio>
using namespace std;
typedef long long ll;
ll x, ans;
int main() {
  scanf("%ld", &x);
  int a = x%11;
  if(a > 6) ans += 2;
  else if(a > 0) ++ans;
  ans += x/11*2;
  printf("%ld\n", ans);
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll; typedef pair<ll, pi> plp;
typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 3e2 + 10, MAX_M = 3e2 + 10;

int N, M, Nr[MAX_N][MAX_M], Ix[MAX_N][MAX_M];
vector<int> maxList[MAX_M];
bool Chk[MAX_M];
int Cnt[MAX_M];
int main() {
	cin >> N >> M;
	for(int i=1; i<=N; i++) for(int j=1; j<=M; j++) {
		int x; scanf("%d", &x);
		Nr[i][x] = M+1-j;
	}
	for(int i=1; i<=N; i++) for(int j=1; j<=M; j++) Ix[i][Nr[i][j]] = j;

	int ans = -1;
	for(int l=0, r=N; l<=r; ) {
		int m = (l+r) >> 1;
		for(int i=1; i<=M; i++) maxList[i].clear(), Chk[i] = false;
		for(int i=1; i<=N; i++) maxList[Ix[i][M]].push_back(i);
		queue<int> Q; for(int i=1; i<=M; i++) if(SZ(maxList[i]) > m) Q.push(i), Chk[i] = true;
		int cnt = 0;
		while(!Q.empty()) {
			int v = Q.front(); Q.pop();
			cnt++;
			for(int x : maxList[v]) {
				int val = Nr[x][v];
				for(int k=val-1; k>=1; k--) if(Chk[Ix[x][k]] == false) {
					maxList[Ix[x][k]].push_back(x);
					if(SZ(maxList[Ix[x][k]]) > m) {
						Q.push(Ix[x][k]);
						Chk[Ix[x][k]] = true;
					}
					break;
				}
			}
			maxList[v].clear();
		}
		if(cnt == M) l = m+1; else ans = m, r = m-1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))

using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

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

    while(n--){
        string in, res; cin >> in;
        res = in.at(0);

        for(int i = 3; i < in.size(); i += 3){
            string cur = in.substr(i, 1);

            if(~res.find(cur)) continue;
            switch(in.at(i - 2)){
                case '-':
                    res = res + cur;
                    break;
                case '<':
                    res = cur + res;
                    break;
            }
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int d,n;cin>>d>>n;

    if(d == 0) cout << (n == 100 ? 101:n) << endl;
    else if(d == 1) cout << (n == 100 ? 101:n) << "00" << endl;
    else cout <<  (n == 100 ? 101:n) << "0000" << endl;
  
    return 0;
    
}


Measured memory_bytes: 256
n=int(input())
ori=input()
max=0
for i in range(n-1):
    former=ori[:i+1]
    latter=ori[i+1:n]
    common=0
    for j in range(26):
        if chr(j+97) in former and chr(j+97) in latter:
            common+=1
        if max<=common:
            max=common
    
print(max)

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

#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fir first
#define sec second
#define sz size()
ll n,m,k;
VI v;
VI sum;
ll dp[405][405];
ll fun(ll l,ll r)
    {   if(dp[l][r]!=-1)
            return dp[l][r];
        if(l==r)
            return dp[l][r]=0;
        ll mini=10000000000000000;
        lf(i,l,r-1)
        {   ll smt=sum[r]-sum[l-1];
            mini=min(mini,smt+fun(l,i)+fun(i+1,r));
        }
        return dp[l][r]=mini;
    }
int main() 
{   cin>>n;
    v=VI(n+1);
    lf(i,1,n)
        cin>>v[i];
    sum=VI(n+1,0);
    lf(i,1,n)
        sum[i]=sum[i-1]+v[i];
    // lf(i,0,n)
    //     cout<<sum[i]<<" ";
    // cout<<endl;
    memset(dp,-1,sizeof(dp));
    cout<<fun(1,n)<<endl;
}

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

long long n,a,b;

bool ok(long long mid, vector<long long> h){
  long long cnt=0;
  for(int i=0;i<n;i++){
    h.at(i)-=b*mid;
    h.at(i)=max(0ll, h.at(i));
    cnt+=h.at(i)/(a-b);
    cnt+=(h.at(i)%(a-b)>0);
  }
  return cnt<=mid;
}

int main(){
  cin >> n >> a >> b;
  vector<long long> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  long long r=1e9, l=0;
  while(abs(r-l)>1){
    long long mid=(r+l)/2;
    if(ok(mid, h)){
      r=mid;
    }else{
      l=mid;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
vector<pair<char,int>> compress(const string &s){
    vector<pair<char,int>> ret;
    char c=s[0];
    int cnt=1;
    rep(i,1,s.size()){
        if(c==s[i])++cnt;
        else{
            ret.push_back({c,cnt});
            c=s[i];
            cnt=1;
        }
    }
    ret.push_back({c,cnt});
    return ret;
}
int main(){
    string s;
    ll k;
    cin >> s >> k;
    auto cmp=compress(s);
    if(cmp.size()==1){
        cout << (k*s.size())/2 << endl;
    }else if(s[0]==s[s.size()-1]){
        ll a=(cmp[0].second+cmp[cmp.size()-1].second)/2-cmp[0].second/2-cmp[cmp.size()-1].second/2;
        for(const auto &p:cmp){
            a+=p.second/2;
        }
        ll b=0;
        for(const auto &p:cmp){
            b+=p.second/2;
        }
        cout << (k-1)*a+b << endl;
    }else{
        ll a=0;
        for(const auto &p:cmp){
            a+=p.second/2;
        }
        cout << k*a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long max = (long) Math.ceil(Math.sqrt(n));
        for (long i = max; i >= 1; i--) {
            if (n % i == 0) {
                long x = n / i;
                System.out.println((i - 1) + (x - 1));
                return;
            }
        }
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

/*#define int ll*/
signed main(){
    string s;
    cin>>s;
    int n=s.size();
    string x="ABC";
    
    ll dp[100010][4]={};
    for(int i=n;i>=0;i--){
        for(int j=3;j>=0;j--){
            if(i==n){
                dp[i][j]=(j==3?1:0);
            }else{
                dp[i][j]=dp[i+1][j]*(s[i]=='?'?3ll:1ll);
                if(j<3&&(s[i]=='?'||s[i]==x[j])){
                    dp[i][j]+=dp[i+1][j+1];
                }
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[0][0]<<endl;
    return 0;
}

Measured memory_bytes: 3584
begin
    loop do
        a = (1..3).map { gets.chomp.split("") }
        winner = nil
        a.each {|r| winner = r[0] if r.uniq.size == 1 && r[0] != ?+}
        a.transpose.each {|r| winner = r[0] if r.uniq.size == 1 && r[0] != ?+}
        r = (0..2).map{|i| a[i][i]}
        winner = r[0] if r.uniq.size == 1 && r[0] != ?+
        r = (0..2).map{|i| a[2-i][i]}
        winner = r[0] if r.uniq.size == 1 && r[0] != ?+
        puts winner ? winner : 'NA'
    end
rescue
end

Measured memory_bytes: 8932